mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-06 15:18:49 +00:00
AbstractEfaProvider: handle missing currency in <itdSingleTicket>
This commit is contained in:
parent
64defb58ad
commit
295cbdc3c8
1 changed files with 30 additions and 27 deletions
|
@ -2405,36 +2405,39 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
|||
if (XmlPullUtil.test(pp, "itdSingleTicket")) {
|
||||
final String net = XmlPullUtil.optAttr(pp, "net", null);
|
||||
if (net != null) {
|
||||
final Currency currency = parseCurrency(XmlPullUtil.attr(pp, "currency"));
|
||||
final String fareAdult = XmlPullUtil.optAttr(pp, "fareAdult", null);
|
||||
final String fareChild = XmlPullUtil.optAttr(pp, "fareChild", null);
|
||||
final String unitName = XmlPullUtil.optAttr(pp, "unitName", null);
|
||||
final String unitsAdult = XmlPullUtil.optAttr(pp, "unitsAdult", null);
|
||||
final String unitsChild = XmlPullUtil.optAttr(pp, "unitsChild", null);
|
||||
final String levelAdult = XmlPullUtil.optAttr(pp, "levelAdult", null);
|
||||
final String levelChild = XmlPullUtil.optAttr(pp, "levelChild", null);
|
||||
if (fareAdult != null)
|
||||
fares.add(new Fare(net.toUpperCase(), Type.ADULT, currency,
|
||||
Float.parseFloat(fareAdult) * fareCorrectionFactor,
|
||||
levelAdult != null ? null : unitName,
|
||||
levelAdult != null ? levelAdult : unitsAdult));
|
||||
if (fareChild != null)
|
||||
fares.add(new Fare(net.toUpperCase(), Type.CHILD, currency,
|
||||
Float.parseFloat(fareChild) * fareCorrectionFactor,
|
||||
levelChild != null ? null : unitName,
|
||||
levelChild != null ? levelChild : unitsChild));
|
||||
final String currencyStr = Strings.emptyToNull(XmlPullUtil.optAttr(pp, "currency", null));
|
||||
if (currencyStr != null) {
|
||||
final Currency currency = parseCurrency(currencyStr);
|
||||
final String fareAdult = XmlPullUtil.optAttr(pp, "fareAdult", null);
|
||||
final String fareChild = XmlPullUtil.optAttr(pp, "fareChild", null);
|
||||
final String unitName = XmlPullUtil.optAttr(pp, "unitName", null);
|
||||
final String unitsAdult = XmlPullUtil.optAttr(pp, "unitsAdult", null);
|
||||
final String unitsChild = XmlPullUtil.optAttr(pp, "unitsChild", null);
|
||||
final String levelAdult = XmlPullUtil.optAttr(pp, "levelAdult", null);
|
||||
final String levelChild = XmlPullUtil.optAttr(pp, "levelChild", null);
|
||||
if (fareAdult != null)
|
||||
fares.add(new Fare(net.toUpperCase(), Type.ADULT, currency,
|
||||
Float.parseFloat(fareAdult) * fareCorrectionFactor,
|
||||
levelAdult != null ? null : unitName,
|
||||
levelAdult != null ? levelAdult : unitsAdult));
|
||||
if (fareChild != null)
|
||||
fares.add(new Fare(net.toUpperCase(), Type.CHILD, currency,
|
||||
Float.parseFloat(fareChild) * fareCorrectionFactor,
|
||||
levelChild != null ? null : unitName,
|
||||
levelChild != null ? levelChild : unitsChild));
|
||||
|
||||
if (XmlPullUtil.optEnter(pp, "itdSingleTicket")) {
|
||||
if (XmlPullUtil.optEnter(pp, "itdGenericTicketList")) {
|
||||
while (XmlPullUtil.test(pp, "itdGenericTicketGroup")) {
|
||||
final Fare fare = processItdGenericTicketGroup(pp, net.toUpperCase(),
|
||||
currency);
|
||||
if (fare != null)
|
||||
fares.add(fare);
|
||||
if (XmlPullUtil.optEnter(pp, "itdSingleTicket")) {
|
||||
if (XmlPullUtil.optEnter(pp, "itdGenericTicketList")) {
|
||||
while (XmlPullUtil.test(pp, "itdGenericTicketGroup")) {
|
||||
final Fare fare = processItdGenericTicketGroup(pp, net.toUpperCase(),
|
||||
currency);
|
||||
if (fare != null)
|
||||
fares.add(fare);
|
||||
}
|
||||
XmlPullUtil.skipExit(pp, "itdGenericTicketList");
|
||||
}
|
||||
XmlPullUtil.skipExit(pp, "itdGenericTicketList");
|
||||
XmlPullUtil.skipExit(pp, "itdSingleTicket");
|
||||
}
|
||||
XmlPullUtil.skipExit(pp, "itdSingleTicket");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue