summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java')
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java118
1 files changed, 110 insertions, 8 deletions
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
index 1f8e25b..70017aa 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
@@ -5,6 +5,7 @@ package org.uic.barcode.ticket.api.utils;
import java.io.IOException;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import org.uic.barcode.ticket.api.asn.omv2.BerthDetailData;
@@ -51,6 +52,7 @@ import org.uic.barcode.ticket.api.asn.omv2.VatDetailType;
import org.uic.barcode.ticket.api.asn.omv2.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv2.VoucherData;
import org.uic.barcode.ticket.api.asn.omv2.ZoneType;
+import org.uic.barcode.ticket.api.asn.omv2.ServiceType;
import org.uic.barcode.ticket.api.impl.SimpleUicTicketObjectFactory;
import org.uic.barcode.ticket.api.spec.IBerth;
import org.uic.barcode.ticket.api.spec.IBerthTypeType;
@@ -94,6 +96,7 @@ import org.uic.barcode.ticket.api.spec.IRoofRackType;
import org.uic.barcode.ticket.api.spec.IRouteSection;
import org.uic.barcode.ticket.api.spec.ISeriesDataDetails;
import org.uic.barcode.ticket.api.spec.IServiceBrand;
+import org.uic.barcode.ticket.api.spec.IServiceType;
import org.uic.barcode.ticket.api.spec.IStationCodeTable;
import org.uic.barcode.ticket.api.spec.IStationPassage;
import org.uic.barcode.ticket.api.spec.ITariff;
@@ -438,6 +441,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setArrivalUTCoffset(asnDocument.getDepartureUTCOffset());
}
+ if (asnDocument.getService() != null) {
+ document.setService(convert(asnDocument.getService()));
+ }
+
if(asnDocument.getClassCode()!=null){
document.setClassCode(ITravelClassType.valueOf(asnDocument.getClassCode().name()));
}
@@ -457,6 +464,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
if (asnDocument.getPlaces()!=null) {
document.setPlaces(convertPlaces(asnDocument.getPlaces()));
}
+
+ if (asnDocument.getAdditionalPlaces()!=null) {
+ document.setAdditionalPlaces(convertPlaces(asnDocument.getAdditionalPlaces()));
+ }
if (asnDocument.getBicyclePlaces()!=null) {
document.setBicyclePlaces(convertPlaces(asnDocument.getBicyclePlaces()));
@@ -518,7 +529,20 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
return document;
}
-
+ private IServiceType convert(ServiceType service) {
+
+ if (service == null) {
+ return null;
+ } else if (service.equals(ServiceType.seat)) {
+ return IServiceType.seat;
+ } else if (service.equals(ServiceType.couchette)) {
+ return IServiceType.couchette;
+ } else if (service.equals(ServiceType.berth)) {
+ return IServiceType.berth;
+ }
+
+ return null;
+ }
@@ -703,7 +727,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
details.setCompartmentTypeDescr(asnDetails.getCompartmentTypeDescr());
details.setSpecialAllocationDescr(asnDetails.getSpecialAllocationDescr());
- details.setPosition(ICompartmentPositionType.valueOf(asnDetails.getPosition().name()));
+ if (asnDetails.getPosition() != null) {
+ details.setPosition(ICompartmentPositionType.valueOf(asnDetails.getPosition().name()));
+ }
return details;
}
@@ -799,6 +825,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setReference(UicEncoderUtils.mapToString(asnDocument.getReferenceNum(),asnDocument.getReferenceIA5()));
document.setTicketReference(UicEncoderUtils.mapToString(asnDocument.getTicketReferenceNum(),asnDocument.getTicketReferenceIA5()));
+ if (asnDocument.getStationCodeTable()!=null){
+ document.setStationCodeTable(IStationCodeTable.valueOf(asnDocument.getStationCodeTable().name()));
+ }
+
document.setFromStation(UicEncoderUtils.mapToString(asnDocument.getFromStationNum(),asnDocument.getFromStationIA5()));
document.setToStation(UicEncoderUtils.mapToString(asnDocument.getToStationNum(),asnDocument.getToStationIA5()));
@@ -812,6 +842,29 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
}
}
+ if (asnDocument.getCarriersNum()!=null && !asnDocument.getCarriersNum().isEmpty()){
+ for(Long carrier :asnDocument.getCarriersNum()){
+ document.addIncludedCarrier(carrier.toString());
+ }
+ }
+ if (asnDocument.getCarriersIA5()!=null && !asnDocument.getCarriersIA5().isEmpty()){
+ for(String carrier :asnDocument.getCarriersIA5()){
+ document.addIncludedCarrier(carrier);
+ }
+ }
+
+ if (asnDocument.getIncludedServiceBrands()!=null && !asnDocument.getIncludedServiceBrands().isEmpty()){
+ for(Long number :asnDocument.getIncludedServiceBrands()){
+ document.addIncludedServiceBrand(number.intValue());
+ }
+ }
+
+ if (asnDocument.getExcludedServiceBrands()!=null && !asnDocument.getExcludedServiceBrands().isEmpty()){
+ for(Long number :asnDocument.getExcludedServiceBrands()){
+ document.addExcludedServiceBrand(number.intValue());
+ }
+ }
+
document.setReturnDescription(convertReturnDescription(asnDocument.getReturnDescription(), issuingDate));
@@ -934,6 +987,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setClassCode(ITravelClassType.valueOf(asnDocument.getClassCode().name()));
}
+ if (asnDocument.getServiceLevel()!=null && asnDocument.getServiceLevel().length() != 0) {
+ document.setServiceLevel(asnDocument.getServiceLevel());
+ }
+
document.setValidFrom(asnDocument.getValidFromDate(issuingDate));
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
@@ -1074,6 +1131,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setClassCode(classCode);
}
+ if (asnDocument.getServiceLevel() != null && asnDocument.getServiceLevel().length() > 0) {
+ document.setServiceLevel(asnDocument.getServiceLevel());
+ }
+
document.setValidFrom(asnDocument.getValidFromDate(issuingDate));
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
@@ -1201,9 +1262,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setProductName(asnDocument.getProductName());
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
- if (asnDocument.getStationNameUTF8()!= null && asnDocument.getStationNameUTF8().isEmpty() ) {
+ if (asnDocument.getStationNameUTF8()!= null && !asnDocument.getStationNameUTF8().isEmpty() ) {
for (String name : asnDocument.getStationNameUTF8()) {
- document.addStation(name);
+ document.addStationName(name);
}
}
@@ -1364,11 +1425,16 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
via.addRouteStation(convertViaStation(routeVia));
}
}
+
if (asnDocument.getAlternativeRoutes()!= null && !asnDocument.getAlternativeRoutes().isEmpty()) {
for ( ViaStationType routeVia: asnDocument.getAlternativeRoutes()) {
- via.addRouteStation(convertViaStation(routeVia));
+ via.getAlternativeRoutes().add(convertViaStation(routeVia));
}
}
+
+ if (asnDocument.getSeriesId() != null) {
+ via.setSeriesId(asnDocument.getSeriesId().intValue());
+ }
return via;
@@ -1409,7 +1475,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
IZone zone = factory.createZone();
- zone.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ if (asnDocument.getBinaryZoneId() != null && asnDocument.getBinaryZoneId().length > 0) {
+ zone.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ }
zone.setCarrier(UicEncoderUtils.mapToString(asnDocument.getCarrierNum(),asnDocument.getCarrierIA5()));
if (asnDocument.getCity() != null) {
@@ -1423,6 +1491,13 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
zone.setNUTScode(asnDocument.getNutsCode());
+ if (asnDocument.getZoneId() != null && !asnDocument.getZoneId().isEmpty()) {
+ Iterator<Long> it = asnDocument.getZoneId().iterator();
+ while (it.hasNext()) {
+ zone.addZoneId(it.next().intValue());
+ }
+ }
+
return zone;
}
@@ -1440,8 +1515,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
IGeoCoordinate firstEdge = convertGeoCoordinate(asnPolygone.getFirstEdge());
+
if (firstEdge == null) return null;
-
+ polygone.addEdge(firstEdge);
+
if (asnPolygone.getEdges()!=null && !asnPolygone.getEdges().isEmpty()) {
for (DeltaCoordinates asnEdge :asnPolygone.getEdges()){
@@ -1470,7 +1547,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
ILine line = factory.createLine();
- line.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ if (asnDocument.getBinaryZoneId() != null && asnDocument.getBinaryZoneId().length > 0) {
+ line.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ }
+
line.setCarrier(UicEncoderUtils.mapToString(asnDocument.getCarrierNum(),asnDocument.getCarrierIA5()));
if (asnDocument.getCity()!=null) {
line.setCity(asnDocument.getCity().intValue());
@@ -1621,6 +1701,17 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
document.setReference(UicEncoderUtils.mapToString(asnDocument.getReferenceNum(),asnDocument.getReferenceIA5()));
+ if (asnDocument.getCarrierNum()!=null && !asnDocument.getCarrierNum().isEmpty()){
+ for(Long carrier :asnDocument.getCarrierNum()){
+ document.addCarrier(carrier.toString());
+ }
+ }
+ if (asnDocument.getCarrierIA5()!=null && !asnDocument.getCarrierIA5().isEmpty()){
+ for(String carrier :asnDocument.getCarrierIA5()){
+ document.addCarrier(carrier);
+ }
+ }
+
if (asnDocument.getActivatedDay() != null && !asnDocument.getActivatedDay().isEmpty()) {
document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
}
@@ -1673,6 +1764,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
if (asnDocument.getNumberOfDaysOfTravel() != null) {
document.setNumberOfDaysOfTravel(asnDocument.getNumberOfDaysOfTravel().intValue());
}
+ if (asnDocument.getNumberOfValidityDays() != null) {
+ document.setNumberOfValidityDays(asnDocument.getNumberOfValidityDays().intValue());
+ }
if (asnDocument.getNumberOfPossibleTrips() != null) {
document.setNumberOfPossibleTrips(asnDocument.getNumberOfPossibleTrips().intValue());
}
@@ -1884,6 +1978,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
card.addIncludedService(new Integer(service.intValue()));
}
}
+
+ card.setExtension(convertExtension(asnDocument.getExtension()));
+
return card;
}
@@ -2138,6 +2235,11 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
issuingDetail.setPointOfSale(convertGeoCoordinate(asnIssuingDetail.getPointOfSale()));
}
+ issuingDetail.setCurrency(asnIssuingDetail.getCurrency());
+
+ if (asnIssuingDetail.getCurrencyFract() != null) {
+ issuingDetail.setCurrencyFraction(asnIssuingDetail.getCurrencyFract().intValue());
+ }
}