summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/impl/SimpleIncludedOpenTicket.java35
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/impl/SimpleIssuingDetail.java24
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/spec/IIncludedOpenTicket.java5
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/spec/IIssuingDetail.java7
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java76
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java198
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java104
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java145
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java45
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java1141
10 files changed, 1663 insertions, 117 deletions
diff --git a/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIncludedOpenTicket.java b/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIncludedOpenTicket.java
index 765b992..3dcf641 100644
--- a/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIncludedOpenTicket.java
+++ b/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIncludedOpenTicket.java
@@ -81,10 +81,18 @@ public class SimpleIncludedOpenTicket implements IIncludedOpenTicket {
/** The info text. */
- protected String infoText;
+ protected String infoText;
/** The extension. */
- protected IExtension extension;
+ protected IExtension extension;
+
+ protected String serviceLevel;
+
+ /** The included service brands. */
+ protected Collection<Integer>includedTransportTypes = new LinkedHashSet<Integer>();
+
+ /** The excluded service brands. */
+ protected Collection<Integer>excludedTransportTypes = new LinkedHashSet<Integer>();
/* (nicht-Javadoc)
* @see org.uic.ticket.api.spec.IIncludedOpenTicket#getDepartureDate()
@@ -435,28 +443,35 @@ public class SimpleIncludedOpenTicket implements IIncludedOpenTicket {
this.validUntil = date;
}
+
@Override
public Collection<Integer> getExcludedTransportTypes() {
- // TODO Auto-generated method stub
- return null;
+ return excludedTransportTypes;
}
@Override
public void addExcludedTransportType(Integer excludedTransportType) {
- // TODO Auto-generated method stub
-
+ excludedTransportTypes.add(excludedTransportType);
}
@Override
public Collection<Integer> getIncludedTransportTypes() {
- // TODO Auto-generated method stub
- return null;
+ return includedTransportTypes;
}
@Override
public void addInludedTransportType(Integer includedTransportType) {
- // TODO Auto-generated method stub
-
+ includedTransportTypes.add(includedTransportType);
+ }
+
+ @Override
+ public String getServiceLevel() {
+ return serviceLevel;
+ }
+
+ @Override
+ public void setServiceLevel(String serviceLevel) {
+ this.serviceLevel = serviceLevel;
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIssuingDetail.java b/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIssuingDetail.java
index 34a1ef2..dad50c2 100644
--- a/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIssuingDetail.java
+++ b/src/main/java/org/uic/barcode/ticket/api/impl/SimpleIssuingDetail.java
@@ -51,6 +51,10 @@ public class SimpleIssuingDetail implements IIssuingDetail{
/** The secure paper ticket. */
protected boolean securePaperTicket;
+
+ protected String currency;
+
+ protected Integer currencyFraction;
/* (nicht-Javadoc)
* @see org.uic.ticket.api.IIssuingDetail#getIssuer()
@@ -224,6 +228,26 @@ public class SimpleIssuingDetail implements IIssuingDetail{
public void setSecurePaperTicket(boolean securePaperTicket) {
this.securePaperTicket = securePaperTicket;
}
+
+ @Override
+ public String getCurrency() {
+ return currency;
+ }
+
+ @Override
+ public void setCurrency(String currency) {
+ this.currency = currency;
+ }
+
+ @Override
+ public Integer getCurrencyFraction() {
+ return currencyFraction;
+ }
+
+ @Override
+ public void setCurrencyFraction(Integer fraction) {
+ this.currencyFraction = fraction;
+ }
diff --git a/src/main/java/org/uic/barcode/ticket/api/spec/IIncludedOpenTicket.java b/src/main/java/org/uic/barcode/ticket/api/spec/IIncludedOpenTicket.java
index f64d374..24645f1 100644
--- a/src/main/java/org/uic/barcode/ticket/api/spec/IIncludedOpenTicket.java
+++ b/src/main/java/org/uic/barcode/ticket/api/spec/IIncludedOpenTicket.java
@@ -429,5 +429,10 @@ public interface IIncludedOpenTicket {
* @param validUntilDateTime the new validUntil date time
*/
public void setValidUntilUTCoffset(Long validUntilUTCoffset) ;
+
+
+ public String getServiceLevel();
+
+ public void setServiceLevel(String serviceLevel);
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/spec/IIssuingDetail.java b/src/main/java/org/uic/barcode/ticket/api/spec/IIssuingDetail.java
index ecaf9c7..d09b226 100644
--- a/src/main/java/org/uic/barcode/ticket/api/spec/IIssuingDetail.java
+++ b/src/main/java/org/uic/barcode/ticket/api/spec/IIssuingDetail.java
@@ -185,5 +185,12 @@ public interface IIssuingDetail {
public boolean isSecurePaperTicket();
public void setSecurePaperTicket(boolean securePaperTicket);
+
+ public String getCurrency();
+ public void setCurrency(String currency);
+
+ public Integer getCurrencyFraction();
+ public void setCurrencyFraction(Integer fraction);
+
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
index 633f2d7..835a324 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
@@ -18,6 +18,7 @@ import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
import org.uic.barcode.ticket.api.asn.omv1.CodeTableType;
import org.uic.barcode.ticket.api.asn.omv1.CompartmentDetailsType;
import org.uic.barcode.ticket.api.asn.omv1.CompartmentGenderType;
+import org.uic.barcode.ticket.api.asn.omv1.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv1.ConfirmationTypeType;
import org.uic.barcode.ticket.api.asn.omv1.ControlData;
import org.uic.barcode.ticket.api.asn.omv1.CountermarkData;
@@ -91,11 +92,14 @@ import org.uic.barcode.ticket.api.asn.omv1.VatDetailType;
import org.uic.barcode.ticket.api.asn.omv1.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv1.VoucherData;
import org.uic.barcode.ticket.api.asn.omv1.ZoneType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfValidityPeriodType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTimeRangeType;
import org.uic.barcode.ticket.api.spec.IBerth;
import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
import org.uic.barcode.ticket.api.spec.ICardReference;
import org.uic.barcode.ticket.api.spec.ICompartmentDetails;
import org.uic.barcode.ticket.api.spec.ICompartmentGenderType;
+import org.uic.barcode.ticket.api.spec.ICompartmentPositionType;
import org.uic.barcode.ticket.api.spec.IControlDetail;
import org.uic.barcode.ticket.api.spec.ICounterMark;
import org.uic.barcode.ticket.api.spec.ICustomerCard;
@@ -486,9 +490,25 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setSpecialAllocation(UicEncoderUtils.getRestrictedInt(compartmentDetails.getSpecialAllocation(), 1,99));
asnData.setSpecialAllocationDescr(compartmentDetails.getSpecialAllocationDescr());
+ asnData.setPosition(convert(compartmentDetails.getPosition()));
return asnData;
}
+ private CompartmentPositionType convert(ICompartmentPositionType position) {
+ if (position == null) {
+ return null;
+ } else if (position.equals(ICompartmentPositionType.lowerLevel)) {
+ return CompartmentPositionType.lowerLevel;
+ } else if (position.equals(ICompartmentPositionType.upperLevel)) {
+ return CompartmentPositionType.upperLevel;
+ } else if (position.equals(ICompartmentPositionType.unspecified)) {
+ return CompartmentPositionType.unspecified;
+ }
+ return null;
+ }
+
+
+
/**
* Encode berths.
*
@@ -602,6 +622,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setTypeOfSupplement(UicEncoderUtils.getRestrictedInt(document.getTypeOfSupplement(), 1, 9));
asnData.setPlaces(encodePlaces(document.getPlaces()));
+
+ if (document.getAdditionalPlaces() != null) {
+ asnData.setAdditionalPlaces(encodePlaces(document.getAdditionalPlaces()));
+ }
asnData.setBicyclePlaces(encodePlaces(document.getBicyclePlaces()));
@@ -715,6 +739,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
if (document.getClassCode() != classCode){
asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
+
+ if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ asnData.setServiceLevel(document.getServiceLevel());
+ }
+
if (document.getExternalIssuer() > 0) {
asnData.setExternalIssuerId(new Long(document.getExternalIssuer()));
}
@@ -886,6 +915,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
if (document.getClassCode() != ITravelClassType.second){
asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
+
+ if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ asnData.setServiceLevel(document.getServiceLevel());
+ }
+
if (document.getExternalIssuer()>0) {
asnData.setExtIssuerId(new Long(document.getExternalIssuer()));
}
@@ -906,10 +940,13 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
if (document.getLuggageRestriction() != null) {
asnData.setLuggage(encodeLuggage(document.getLuggageRestriction()));
}
+
+ if (document.getReturnDescription() != null) {
+ asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
+ }
if (document.isReturnIncluded()) {
asnData.setReturnIncluded(true);
- asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
} else {
asnData.setReturnIncluded(false);
}
@@ -1013,12 +1050,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
-
+ if (document.getReturnDescription()!= null) {
+ asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
+ }
if (document.isReturnIncluded()) {
asnData.setReturnIncluded(true);
- if (document.getReturnDescription()!= null) {
- asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
- }
} else {
asnData.setReturnIncluded(false);
}
@@ -1089,8 +1125,13 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setRoute(encodeViaStationCollection(document.getRoute()));
if (document.getRouteId() > 0){
- asnData.setSeriesId(new Long(document.getRouteId()));
+ asnData.setRouteId(new Long(document.getRouteId()));
+ }
+
+ if (document.getSeriesId() > 0) {
+ asnData.setSeriesId(new Long(document.getSeriesId()));
}
+
return asnData;
}
@@ -1194,7 +1235,8 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
} else {
DeltaCoordinates delta = new DeltaCoordinates();
delta.setLatitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLatitude() - edge.getLatitude()));
- delta.setLatitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLongitude() - edge.getLongitude()));
+ delta.setLongitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLongitude() - edge.getLongitude()));
+ asnList.add(delta);
}
}
@@ -1475,7 +1517,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
details.setSeries(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getSeries(), 1, 99999));
details.setSupplyingCarrier(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getSupplyingCarrier(), 1, 9999));
details.setOfferIdentification(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getOfferIdentification(), 1, 99));
- return null;
+ return details;
}
/**
@@ -1505,6 +1547,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
asnData.setInfoText(document.getInfoText());
+ asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setValidity(document.getValidFrom(), document.getValidUntil());
@@ -1620,7 +1663,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
ValidityPeriodDetailType asnData = new ValidityPeriodDetailType();
- if (validityDetails.getTimeRanges() != null) {
+ if (validityDetails.getTimeRanges() != null && !validityDetails.getTimeRanges().isEmpty()) {
+
+ asnData.setExcludedTimeRange(new SequenceOfTimeRangeType());
+
for (ITimeRange range : validityDetails.getTimeRanges()) {
if (range.getFromTime() == range.getUntilTime()){
@@ -1635,8 +1681,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
}
}
- if (validityDetails.getValidityRanges() != null) {
- for (IValidityRange range : validityDetails.getValidityRanges()) {
+ if (validityDetails.getValidityRanges() != null && !validityDetails.getValidityRanges().isEmpty()) {
+
+ asnData.setValidityPeriod(new SequenceOfValidityPeriodType());
+
+ for (IValidityRange range : validityDetails.getValidityRanges()) {
ValidityPeriodType asnRange = new ValidityPeriodType();
@@ -1689,9 +1738,8 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setClassCode(convertTravelClass(document.getClassCode()));
- if (!document.isIncludesSupplements()){
- asnData.setIncludesSupplements(false);
- }
+ asnData.setIncludesSupplements(document.isIncludesSupplements());
+
asnData.setNumberOfTravelDays(UicEncoderUtils.getRestrictedInt(document.getNumberOfTravelDates(), 1, 8));
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java
index c586da0..fd9995f 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java
@@ -11,6 +11,7 @@ import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv3.BerthDetailData;
import org.uic.barcode.ticket.api.asn.omv3.BerthTypeType;
import org.uic.barcode.ticket.api.asn.omv3.BoardingOrArrivalType;
@@ -69,9 +70,11 @@ import org.uic.barcode.ticket.api.asn.omv3.SequenceOfRegisteredLuggageType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfServiceBrands;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTariffType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTimeRangeType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTransportTypes;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTravelerId;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv3.SequenceOfValidityPeriodType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfViaStationType;
import org.uic.barcode.ticket.api.asn.omv3.SeriesDetailType;
import org.uic.barcode.ticket.api.asn.omv3.ServiceType;
@@ -99,6 +102,7 @@ import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
import org.uic.barcode.ticket.api.spec.ICardReference;
import org.uic.barcode.ticket.api.spec.ICompartmentDetails;
import org.uic.barcode.ticket.api.spec.ICompartmentGenderType;
+import org.uic.barcode.ticket.api.spec.ICompartmentPositionType;
import org.uic.barcode.ticket.api.spec.IControlDetail;
import org.uic.barcode.ticket.api.spec.ICounterMark;
import org.uic.barcode.ticket.api.spec.ICustomerCard;
@@ -347,8 +351,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setTrainIA5(UicEncoderUtils.getIA5NonNum(document.getTrain()));
asnData.setTrainNum(UicEncoderUtils.getNum(document.getTrain()));
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -488,9 +495,23 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setSpecialAllocation(UicEncoderUtils.getRestrictedInt(compartmentDetails.getSpecialAllocation(), 1,99));
asnData.setSpecialAllocationDescr(compartmentDetails.getSpecialAllocationDescr());
+ asnData.setPosition(convert(compartmentDetails.getPosition()));
return asnData;
}
+ private CompartmentPositionType convert(ICompartmentPositionType position) {
+ if (position == null) {
+ return null;
+ } else if (position.equals(ICompartmentPositionType.lowerLevel)) {
+ return CompartmentPositionType.lowerLevel;
+ } else if (position.equals(ICompartmentPositionType.upperLevel)) {
+ return CompartmentPositionType.upperLevel;
+ } else if (position.equals(ICompartmentPositionType.unspecified)) {
+ return CompartmentPositionType.unspecified;
+ }
+ return null;
+ }
+
/**
* Encode berths.
*
@@ -544,8 +565,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
ReservationData asnData = new ReservationData();
asnDocument.getTicket().setReservation(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -604,6 +628,10 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setTypeOfSupplement(UicEncoderUtils.getRestrictedInt(document.getTypeOfSupplement(), 1, 9));
asnData.setPlaces(encodePlaces(document.getPlaces()));
+
+ if (document.getAdditionalPlaces() != null) {
+ asnData.setAdditionalPlaces(encodePlaces(document.getAdditionalPlaces()));
+ }
asnData.setBicyclePlaces(encodePlaces(document.getBicyclePlaces()));
@@ -680,11 +708,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
IncludedOpenTicketType asnData = new IncludedOpenTicketType();
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setInfoText(document.getInfoText());
@@ -721,6 +749,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
if (document.getClassCode() != classCode && document.getClassCode() != null){
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
+
+ if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ asnData.setServiceLevel(document.getServiceLevel());
+ }
+
if (document.getExternalIssuer() > 0) {
asnData.setExternalIssuerId(new Long(document.getExternalIssuer()));
}
@@ -732,6 +765,8 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
if (document.getValidRegionList()!= null && document.getValidRegionList().size() > 0) {
asnData.setValidRegion(encodeRegionCollection(document.getValidRegionList(), issuingDate));
}
+
+
return asnData;
}
@@ -842,11 +877,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnDocument.setTicket(asnTicket);
asnTicket.setOpenTicket(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -895,6 +930,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
if (document.getClassCode() != ITravelClassType.second && document.getClassCode() != null){
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
+
+ if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ asnData.setServiceLevel(document.getServiceLevel());
+ }
+
if (document.getExternalIssuer()>0) {
asnData.setExtIssuerId(new Long(document.getExternalIssuer()));
}
@@ -916,9 +956,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setLuggage(encodeLuggage(document.getLuggageRestriction()));
}
+ if (document.getReturnDescription() != null) {
+ asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
+ }
+
if (document.isReturnIncluded()) {
asnData.setReturnIncluded(true);
- asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
} else {
asnData.setReturnIncluded(false);
}
@@ -952,8 +995,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
CountermarkData asnData = new CountermarkData();
asnDocument.getTicket().setCounterMark(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setTicketReferenceNum(UicEncoderUtils.getNum(document.getTicketReference()));
@@ -1023,12 +1069,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
-
+ if (document.getReturnDescription()!= null) {
+ asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
+ }
if (document.isReturnIncluded()) {
asnData.setReturnIncluded(true);
- if (document.getReturnDescription()!= null) {
- asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
- }
} else {
asnData.setReturnIncluded(false);
}
@@ -1102,8 +1147,13 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setRoute(encodeViaStationCollection(document.getRoute()));
if (document.getRouteId() > 0){
- asnData.setSeriesId(new Long(document.getRouteId()));
+ asnData.setRouteId(new Long(document.getRouteId()));
+ }
+
+ if (document.getSeriesId() > 0) {
+ asnData.setSeriesId(new Long(document.getSeriesId()));
}
+
return asnData;
}
@@ -1207,7 +1257,8 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
} else {
DeltaCoordinates delta = new DeltaCoordinates();
delta.setLatitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLatitude() - edge.getLatitude()));
- delta.setLatitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLongitude() - edge.getLongitude()));
+ delta.setLongitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLongitude() - edge.getLongitude()));
+ asnList.add(delta);
}
}
@@ -1333,8 +1384,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
ParkingGroundData asnData = new ParkingGroundData();
asnDocument.getTicket().setParkingGround(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1449,8 +1503,8 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
TariffType asnTariff = new TariffType();
- asnTariff.setAgeAbove(UicEncoderUtils.getRestrictedInt(tariff.getAgeAbove(),2,120));
- asnTariff.setAgeBelow(UicEncoderUtils.getRestrictedInt(tariff.getAgeBelow(),1,40));
+ asnTariff.setAgeAbove(UicEncoderUtils.getRestrictedInt(tariff.getAgeAbove(),2,128));
+ asnTariff.setAgeBelow(UicEncoderUtils.getRestrictedInt(tariff.getAgeBelow(),1,64));
asnTariff.setNumberOfPassengers(UicEncoderUtils.getRestrictedIntWithDefault(tariff.getNumberOfPassengers(),1,200,1));
@@ -1485,9 +1539,9 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
private SeriesDetailType encodeSeriesDataDetails( ISeriesDataDetails seriesDataDetails) throws EncodingFormatException {
SeriesDetailType details = new SeriesDetailType();
details.setSeries(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getSeries(), 1, 99999));
- details.setSupplyingCarrier(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getSupplyingCarrier(), 1, 9999));
+ details.setSupplyingCarrier(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getSupplyingCarrier(), 1, 32000));
details.setOfferIdentification(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getOfferIdentification(), 1, 99));
- return null;
+ return details;
}
/**
@@ -1506,16 +1560,17 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
VoucherData asnData = new VoucherData();
asnDocument.getTicket().setVoucher(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
asnData.setInfoText(document.getInfoText());
+ asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setValidity(document.getValidFrom(), document.getValidUntil());
@@ -1547,11 +1602,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
PassData asnData = new PassData();
asnDocument.getTicket().setPass(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
-
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1587,8 +1642,8 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
- asnData.setNumberOfDaysOfTravel(UicEncoderUtils.getRestrictedInt(document.getNumberOfDaysOfTravel(), 1, 93));
- asnData.setNumberOfPossibleTrips(UicEncoderUtils.getRestrictedInt(document.getNumberOfPossibleTrips(), 1, 30));
+ asnData.setNumberOfDaysOfTravel(UicEncoderUtils.getRestrictedInt(document.getNumberOfDaysOfTravel(), 1, 250));
+ asnData.setNumberOfPossibleTrips(UicEncoderUtils.getRestrictedInt(document.getNumberOfPossibleTrips(), 1, 250));
asnData.setNumberOfValidityDays(UicEncoderUtils.getRestrictedInt(document.getNumberOfValidityDays(), 1, 370));
asnData.setPassDescription(document.getPassDescription());
if (document.getPassType() > 0 ){
@@ -1667,7 +1722,9 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
ValidityPeriodDetailType asnData = new ValidityPeriodDetailType();
- if (validityDetails.getTimeRanges() != null) {
+ if (validityDetails.getTimeRanges() != null && !validityDetails.getTimeRanges().isEmpty()) {
+ asnData.setExcludedTimeRange(new SequenceOfTimeRangeType());
+
for (ITimeRange range : validityDetails.getTimeRanges()) {
if (range.getFromTime() == range.getUntilTime()){
@@ -1682,7 +1739,10 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
}
}
- if (validityDetails.getValidityRanges() != null) {
+ if (validityDetails.getValidityRanges() != null && !validityDetails.getValidityRanges().isEmpty()) {
+
+ asnData.setValidityPeriod(new SequenceOfValidityPeriodType());
+
for (IValidityRange range : validityDetails.getValidityRanges()) {
ValidityPeriodType asnRange = new ValidityPeriodType();
@@ -1722,11 +1782,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
FIPTicketData asnData = new FIPTicketData();
asnDocument.getTicket().setFipTicket(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1737,9 +1797,9 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
if (document.getClassCode() != null) {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
- if (!document.isIncludesSupplements()){
- asnData.setIncludesSupplements(false);
- }
+
+ asnData.setIncludesSupplements(document.isIncludesSupplements());
+
asnData.setNumberOfTravelDays(UicEncoderUtils.getRestrictedInt(document.getNumberOfTravelDates(), 1, 8));
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
@@ -1769,11 +1829,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
StationPassageData asnData = new StationPassageData();
asnDocument.getTicket().setStationPassage(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
-
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+
+ asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
+ asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1976,29 +2036,29 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
SequenceOfTicketLinkType asnList = new SequenceOfTicketLinkType();
- for (ITicketLink ticket : linkedTickets){
+ for (ITicketLink document : linkedTickets){
- TicketLinkType asnTicket = new TicketLinkType();
+ TicketLinkType asnData = new TicketLinkType();
- asnTicket.setIssuerName(ticket.getIssuer());
+ asnData.setIssuerName(document.getIssuer());
- asnTicket.setIssuerPNR(ticket.getIssuerPNR());
+ asnData.setIssuerPNR(document.getIssuerPNR());
- asnTicket.setProductOwnerNum(UicEncoderUtils.getNum(ticket.getProductOwner()));
- asnTicket.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(ticket.getProductOwner()));
-
- asnTicket.setReferenceNum(UicEncoderUtils.getNum(ticket.getReference()));
- asnTicket.setReferenceIA5(UicEncoderUtils.getIA5NonNum(ticket.getReference()));
+ asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
+ asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+
+ asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
+ asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
- if (ticket.getTicketType() != ITicketType.openTicket && ticket.getTicketType() != null){
- asnTicket.setTicketType(TicketType.valueOf(ticket.getTicketType().name()));
+ if (document.getTicketType() != ITicketType.openTicket && document.getTicketType() != null){
+ asnData.setTicketType(TicketType.valueOf(document.getTicketType().name()));
}
- if (ticket.getLinkMode() != ILinkMode.issuedTogether && ticket.getLinkMode() != null){
- asnTicket.setLinkMode(LinkMode.valueOf(ticket.getLinkMode().name()));
+ if (document.getLinkMode() != ILinkMode.issuedTogether && document.getLinkMode() != null){
+ asnData.setLinkMode(LinkMode.valueOf(document.getLinkMode().name()));
}
- asnList.add(asnTicket);
+ asnList.add(asnData);
}
if (asnList.isEmpty()) return null;
@@ -2106,6 +2166,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setPointOfSale(encodeGeoCoordinate(data.getPointOfSale()));
}
+ asnData.setCurrency(data.getCurrency());
+
+ if (data.getCurrencyFraction() != null) {
+ asnData.setCurrencyFract(data.getCurrencyFraction().longValue());
+ }
+
return asnData;
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
index f62e1f9..5f5ce4d 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
@@ -5,12 +5,14 @@ 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.omv1.BerthDetailData;
import org.uic.barcode.ticket.api.asn.omv1.CarCarriageReservationData;
import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
import org.uic.barcode.ticket.api.asn.omv1.CompartmentDetailsType;
+import org.uic.barcode.ticket.api.asn.omv1.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv1.ControlData;
import org.uic.barcode.ticket.api.asn.omv1.CountermarkData;
import org.uic.barcode.ticket.api.asn.omv1.CustomerCardData;
@@ -51,6 +53,7 @@ import org.uic.barcode.ticket.api.asn.omv1.VatDetailType;
import org.uic.barcode.ticket.api.asn.omv1.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv1.VoucherData;
import org.uic.barcode.ticket.api.asn.omv1.ZoneType;
+import org.uic.barcode.ticket.api.asn.omv1.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 +97,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;
@@ -436,6 +440,10 @@ public class OpenAsn2ApiDecoder 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()));
}
@@ -455,6 +463,10 @@ public class OpenAsn2ApiDecoder 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()));
@@ -517,6 +529,20 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
}
+ 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;
+ }
@@ -701,11 +727,24 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
details.setCompartmentTypeDescr(asnDetails.getCompartmentTypeDescr());
details.setSpecialAllocationDescr(asnDetails.getSpecialAllocationDescr());
- details.setPosition(ICompartmentPositionType.valueOf(asnDetails.getPosition().name()));
+ details.setPosition(convert(asnDetails.getPosition()));
return details;
}
+ private ICompartmentPositionType convert(CompartmentPositionType position) {
+ if (position == null) {
+ return null;
+ } else if (position.equals(CompartmentPositionType.lowerLevel)) {
+ return ICompartmentPositionType.lowerLevel;
+ } else if (position.equals(CompartmentPositionType.upperLevel)) {
+ return ICompartmentPositionType.upperLevel;
+ } else if (position.equals(CompartmentPositionType.unspecified)) {
+ return ICompartmentPositionType.unspecified;
+ }
+ return null;
+ }
+
/**
* Convert places.
*
@@ -796,7 +835,10 @@ public class OpenAsn2ApiDecoder 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()));
@@ -811,7 +853,6 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
}
document.setReturnDescription(convertReturnDescription(asnDocument.getReturnDescription(), issuingDate));
-
if(asnDocument.getReturnIncluded()!=null){
document.setReturnIncluded(asnDocument.getReturnIncluded());
@@ -819,7 +860,29 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
document.setReturnIncluded(false);
}
-
+
+ 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.setGroupName(asnDocument.getGroupName());
@@ -932,6 +995,10 @@ public class OpenAsn2ApiDecoder 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));
@@ -1058,6 +1125,10 @@ public class OpenAsn2ApiDecoder 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));
@@ -1173,9 +1244,9 @@ public class OpenAsn2ApiDecoder 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);
}
}
@@ -1338,9 +1409,13 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
}
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;
@@ -1395,6 +1470,13 @@ public class OpenAsn2ApiDecoder 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;
}
@@ -1413,6 +1495,8 @@ public class OpenAsn2ApiDecoder 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()){
@@ -1645,6 +1729,9 @@ public class OpenAsn2ApiDecoder 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());
}
@@ -1856,6 +1943,9 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
card.addIncludedService(new Integer(service.intValue()));
}
}
+
+ card.setExtension(convertExtension(asnDocument.getExtension()));
+
return card;
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java
index b656d3c..a9cc0d3 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java
@@ -5,8 +5,10 @@ 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.omv3.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv3.BerthDetailData;
import org.uic.barcode.ticket.api.asn.omv3.CarCarriageReservationData;
import org.uic.barcode.ticket.api.asn.omv3.CardReferenceType;
@@ -36,6 +38,7 @@ import org.uic.barcode.ticket.api.asn.omv3.ReservationData;
import org.uic.barcode.ticket.api.asn.omv3.ReturnRouteDescriptionType;
import org.uic.barcode.ticket.api.asn.omv3.RouteSectionType;
import org.uic.barcode.ticket.api.asn.omv3.SeriesDetailType;
+import org.uic.barcode.ticket.api.asn.omv3.ServiceType;
import org.uic.barcode.ticket.api.asn.omv3.StationPassageData;
import org.uic.barcode.ticket.api.asn.omv3.TariffType;
import org.uic.barcode.ticket.api.asn.omv3.TicketLinkType;
@@ -96,6 +99,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;
@@ -441,6 +445,10 @@ public class OpenAsn2ApiDecoderV3 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()));
}
@@ -460,6 +468,11 @@ public class OpenAsn2ApiDecoderV3 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()));
@@ -522,12 +535,20 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
}
-
-
-
-
-
-
+ 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;
+ }
/**
* Convert car carriage.
@@ -706,11 +727,24 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
details.setCompartmentTypeDescr(asnDetails.getCompartmentTypeDescr());
details.setSpecialAllocationDescr(asnDetails.getSpecialAllocationDescr());
- details.setPosition(ICompartmentPositionType.valueOf(asnDetails.getPosition().name()));
+ details.setPosition(convert(asnDetails.getPosition()));
return details;
}
+ private ICompartmentPositionType convert(CompartmentPositionType position) {
+ if (position == null) {
+ return null;
+ } else if (position.equals(CompartmentPositionType.lowerLevel)) {
+ return ICompartmentPositionType.lowerLevel;
+ } else if (position.equals(CompartmentPositionType.upperLevel)) {
+ return ICompartmentPositionType.upperLevel;
+ } else if (position.equals(CompartmentPositionType.unspecified)) {
+ return ICompartmentPositionType.unspecified;
+ }
+ return null;
+ }
+
/**
* Convert places.
*
@@ -802,6 +836,9 @@ public class OpenAsn2ApiDecoderV3 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()));
@@ -825,6 +862,28 @@ public class OpenAsn2ApiDecoderV3 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.setGroupName(asnDocument.getGroupName());
@@ -937,6 +996,10 @@ public class OpenAsn2ApiDecoderV3 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));
@@ -954,12 +1017,6 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
document.setReference(UicEncoderUtils.mapToString(asnDocument.getReferenceNum(),asnDocument.getReferenceIA5()));
- if (asnDocument.getExcludedServiceBrands()!=null && !asnDocument.getExcludedServiceBrands().isEmpty()){
- for(Long number :asnDocument.getExcludedServiceBrands()){
- document.addExcludedServiceBrand(number.intValue());
- }
- }
-
if (asnDocument.getCarriersNum()!=null && !asnDocument.getCarriersNum().isEmpty()){
for(Long carrier :asnDocument.getCarriersNum()){
document.addIncludedCarrier(carrier.toString());
@@ -978,6 +1035,12 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
}
}
+ if (asnDocument.getExcludedServiceBrands()!=null && !asnDocument.getExcludedServiceBrands().isEmpty()){
+ for(Long number :asnDocument.getExcludedServiceBrands()){
+ document.addExcludedServiceBrand(number.intValue());
+ }
+ }
+
if (asnDocument.getIncludedTransportTypes()!=null && !asnDocument.getIncludedTransportTypes().isEmpty()){
for(Long number :asnDocument.getIncludedTransportTypes()){
document.addInludedTransportType(number.intValue());
@@ -1012,6 +1075,8 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
}
}
+ document.setReturnDescription(convertReturnDescription(asnDocument.getReturnDescription(), issuingDate));
+
if (asnDocument.getIssuerAutorizationId() != null) {
document.setAuthorizationCode(asnDocument.getIssuerAutorizationId().intValue());
}
@@ -1077,6 +1142,10 @@ public class OpenAsn2ApiDecoderV3 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));
@@ -1149,6 +1218,8 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
if (asnDocument.getExternalIssuerId()!=null){
document.setExternalIssuer(asnDocument.getExternalIssuerId().intValue());
}
+
+
return document;
}
@@ -1204,9 +1275,9 @@ public class OpenAsn2ApiDecoderV3 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);
}
}
@@ -1381,10 +1452,13 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
}
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;
}
@@ -1438,6 +1512,14 @@ public class OpenAsn2ApiDecoderV3 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;
}
@@ -1456,6 +1538,8 @@ public class OpenAsn2ApiDecoderV3 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()){
@@ -1630,17 +1714,26 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
document.setValidFrom(asnDocument.getValidFromDate(issuingDate));
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
-
-
document.setProductId(UicEncoderUtils.mapToString(asnDocument.getProductIdNum(),asnDocument.getProductIdIA5()));
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));
}
- if(asnDocument.getIncludesSupplements()!=null) {
+ if(asnDocument.getIncludesSupplements()!= null) {
document.setIncludesSupplements(asnDocument.getIncludesSupplements());
}
if(asnDocument.getNumberOfTravelDays()!=null){
@@ -1688,6 +1781,9 @@ public class OpenAsn2ApiDecoderV3 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());
}
@@ -1958,6 +2054,9 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
card.addIncludedService(new Integer(service.intValue()));
}
}
+
+ card.setExtension(convertExtension(asnDocument.getExtension()));
+
return card;
}
@@ -2212,6 +2311,12 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder {
issuingDetail.setPointOfSale(convertGeoCoordinate(asnIssuingDetail.getPointOfSale()));
}
+ issuingDetail.setCurrency(asnIssuingDetail.getCurrency());
+
+ if (asnIssuingDetail.getCurrencyFract() != null) {
+ issuingDetail.setCurrencyFraction(asnIssuingDetail.getCurrencyFract().intValue());
+ }
+
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java b/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java
index 73f96f1..f5eb15c 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java
@@ -329,6 +329,49 @@ public class UicEncoderUtils {
}
}
+
+ public static Long getRestrictedNum(String text, int min, int max) {
+
+ if (text == null || text.length() == 0) {
+ return null;
+ }
+
+ Long i;
+ try {
+ i = Long.parseLong(text);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ if (i < min || i > max) {
+ return null;
+ }
+ return i;
+
+ }
+
+ public static String getIA5RestrictedNonNum(String text, int min, int max) throws EncodingFormatException {
+ if (text == null || text.length() == 0) {
+ return null;
+ }
+
+ for (int i = 0; i < text.length(); i++){
+ int index = text.charAt(i);
+ if (index < 0 || index > 127) {
+ throw new EncodingFormatException("Wrong Characters in IA5 String encoding");
+ }
+ }
+
+ try {
+ long l = Long.parseLong(text);
+ if (l < min || l > max) {
+ return text;
+ } else {
+ return null;
+ }
+ } catch (NumberFormatException e) {
+ return text;
+ }
+ }
/**
* Gets the restricted int.
@@ -511,4 +554,6 @@ public class UicEncoderUtils {
}
+
+
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java
new file mode 100644
index 0000000..0b426f2
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java
@@ -0,0 +1,1141 @@
+package org.uic.barcode.ticket.api.test;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.ConfirmationTypeType;
+import org.uic.barcode.ticket.api.spec.IBerth;
+import org.uic.barcode.ticket.api.spec.IBerthTypeType;
+import org.uic.barcode.ticket.api.spec.IBoardingOrArrivalType;
+import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
+import org.uic.barcode.ticket.api.spec.ICardReference;
+import org.uic.barcode.ticket.api.spec.ICompartmentGenderType;
+import org.uic.barcode.ticket.api.spec.ICompartmentPositionType;
+import org.uic.barcode.ticket.api.spec.ICounterMark;
+import org.uic.barcode.ticket.api.spec.ICustomerCard;
+import org.uic.barcode.ticket.api.spec.ICustomerStatusDescription;
+import org.uic.barcode.ticket.api.spec.IDelayConfirmation;
+import org.uic.barcode.ticket.api.spec.IDocumentData;
+import org.uic.barcode.ticket.api.spec.IDocumentExtension;
+import org.uic.barcode.ticket.api.spec.IExtension;
+import org.uic.barcode.ticket.api.spec.IFipTicket;
+import org.uic.barcode.ticket.api.spec.IGenderType;
+import org.uic.barcode.ticket.api.spec.IGeoCoordinateSystemType;
+import org.uic.barcode.ticket.api.spec.IGeoUnitType;
+import org.uic.barcode.ticket.api.spec.IHemisphereLatitudeType;
+import org.uic.barcode.ticket.api.spec.IHemisphereLongitudeType;
+import org.uic.barcode.ticket.api.spec.IIncludedOpenTicket;
+import org.uic.barcode.ticket.api.spec.ILine;
+import org.uic.barcode.ticket.api.spec.ILinkMode;
+import org.uic.barcode.ticket.api.spec.ILoadingDeckType;
+import org.uic.barcode.ticket.api.spec.IOpenTicket;
+import org.uic.barcode.ticket.api.spec.IParkingGround;
+import org.uic.barcode.ticket.api.spec.IPass;
+import org.uic.barcode.ticket.api.spec.IPassengerType;
+import org.uic.barcode.ticket.api.spec.IPolygone;
+import org.uic.barcode.ticket.api.spec.IPriceTypeType;
+import org.uic.barcode.ticket.api.spec.IRegionalValidity;
+import org.uic.barcode.ticket.api.spec.IRegisteredLuggage;
+import org.uic.barcode.ticket.api.spec.IReservation;
+import org.uic.barcode.ticket.api.spec.IRoofRackType;
+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;
+import org.uic.barcode.ticket.api.spec.ITicketLink;
+import org.uic.barcode.ticket.api.spec.ITicketType;
+import org.uic.barcode.ticket.api.spec.ITimeRange;
+import org.uic.barcode.ticket.api.spec.ITrainLink;
+import org.uic.barcode.ticket.api.spec.ITravelClassType;
+import org.uic.barcode.ticket.api.spec.ITraveler;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.spec.IValidityRange;
+import org.uic.barcode.ticket.api.spec.IVatDetail;
+import org.uic.barcode.ticket.api.spec.IViaStation;
+import org.uic.barcode.ticket.api.spec.IVoucher;
+import org.uic.barcode.ticket.api.spec.IZone;
+import org.uic.barcode.ticket.api.test.testtickets.AllElementsTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class CarCarriageTestV1.
+ *
+ *
+ *
+ */
+public class AllElementsTestV3 {
+
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testDelayConfirmation() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+
+ defaulttimeZone = TimeZone.getDefault();
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ IUicRailTicket ticketDecoded = null;
+ try {
+ String hex = AllElementsTestTicketV3.getEncodingHex();
+ byte[] content = UperEncoder.bytesFromHexString(hex);
+ ticketDecoded = decoder.decodeFromAsn(content);
+ } catch (IOException e) {
+ assert(false);
+ }
+
+
+
+
+ byte[] encoded = null;
+ try {
+ encoded = encoder.encode(ticketDecoded);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ }
+
+ //decode ticket again
+ IUicRailTicket ticketDecoded2 = null;
+ try {
+ ticketDecoded2 = decoder.decodeFromAsn(encoded);
+ } catch (IOException e) {
+ assert(false);
+ }
+
+ assert (ticketDecoded2 != null);
+
+ //validate content
+ validateTicketContent(ticketDecoded2);
+
+
+
+
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+
+
+
+
+ private void validateTicketContent(IUicRailTicket ticket) {
+ assert (ticket != null);
+
+ assert(ticket.getControlDetails() != null);
+ assert(ticket.getControlDetails().isAgeCheckRequired() == false);
+ assert(ticket.getControlDetails().isIdentificationByPassportId() == false);
+ assert(ticket.getControlDetails().isIdentificationByIdCard() == false);
+ assert(ticket.getControlDetails().isOnlineValidationRequired() == false);
+ assert(ticket.getControlDetails().getIdentificationItem() == 12);
+ assert(ticket.getControlDetails().isPassportValidationRequired() == false);
+ assert(ticket.getControlDetails().getRandomDetailedValidationRequired() == 50);
+ assert(ticket.getControlDetails().getExtension() != null);
+ assert(ticket.getControlDetails().isReductionCardCheckRequired() == false);
+ assert(ticket.getControlDetails().getInfoText().equals("control"));
+ assert(ticket.getControlDetails().getIdentificationByCardReference() != null);
+
+ assert(ticket.getControlDetails().getIdentificationByCardReference().size() == 1);
+ ICardReference cr = ticket.getControlDetails().getIdentificationByCardReference().iterator().next();
+ assert(cr != null);
+ assert(cr.getCardId().equals("5678"));
+ assert(cr.getCardIssuer().equals("1234"));
+ assert(cr.getCardName().equals("testcard"));
+ assert(cr.getCardType() == 123);
+ assert(cr.getLeadingCardId().equals("3456"));
+ assert(cr.getTrailingCardId().equals("100"));
+
+
+ assert(ticket.getControlDetails().getLinkedTickets() != null);
+
+ ITicketLink tl = ticket.getControlDetails().getLinkedTickets().iterator().next();
+
+ assert(tl.getIssuer().equals("XYZ"));
+ assert(tl.getIssuerPNR().equals("LDWDUR45"));
+ assert(tl.getProductOwner().equals("IEFHU"));
+ assert(tl.getLinkMode().equals(ILinkMode.issuedTogether));
+ assert(tl.getReference().equals("KDJET"));
+ assert(tl.getTicketType().equals(ITicketType.openTicket));
+
+ assert(ticket.getExtensions() != null);
+ assert(ticket.getExtensions().size() == 2);
+ Iterator<IExtension> it = ticket.getExtensions().iterator();
+ IExtension e0 = it.next();
+ IExtension e1 = it.next();
+ assert(e0.getId().equals("1"));
+ assert(UperEncoder.hexStringFromBytes(e0.getBinarydata()).equals("82DA"));
+ assert(e1.getId().equals("2"));
+ assert(UperEncoder.hexStringFromBytes(e1.getBinarydata()).equals("83DA"));
+
+
+ assert(ticket.getIssuerDetails() != null);
+
+ assert(ticket.getIssuerDetails().isActivated() == true);
+ assert(ticket.getIssuerDetails().getCurrency().equals("SRF"));
+ assert(ticket.getIssuerDetails().getCurrencyFraction() == 3L);
+ assert(ticket.getIssuerDetails().getExtension() != null);
+ assert(ticket.getIssuerDetails().getIssuedOnLine() == 12);
+ assert(ticket.getIssuerDetails().getIssuedOnTrain().equals("123"));
+ assert(ticket.getIssuerDetails().getIssuerName().equals("name"));
+ assert(ticket.getIssuerDetails().getIssuer().equals("1"));
+ assert(ticket.getIssuerDetails().getIssuerPNR().equals("issuerTestPNR"));
+ assert(ticket.getIssuerDetails().getIssuingDate() != null);
+ assert(ticket.getIssuerDetails().isSecurePaperTicket() == false);
+ assert(ticket.getIssuerDetails().getSecurityProvider().equals("1"));
+ assert(ticket.getIssuerDetails().isSpecimen() == true);
+ assert(ticket.getIssuerDetails().getPointOfSale() != null);
+ assert(ticket.getIssuerDetails().getPointOfSale().getUnit().equals(IGeoUnitType.microDegree));
+ assert(ticket.getIssuerDetails().getPointOfSale().getSystem().equals(IGeoCoordinateSystemType.wgs84));
+ assert(ticket.getIssuerDetails().getPointOfSale().getAccuracy().equals(IGeoUnitType.microDegree));
+ assert(ticket.getIssuerDetails().getPointOfSale().getHemisphereLatitude().equals(IHemisphereLatitudeType.east));
+ assert(ticket.getIssuerDetails().getPointOfSale().getHemisphereLongitude().equals(IHemisphereLongitudeType.north));
+ assert(ticket.getIssuerDetails().getPointOfSale().getLatitude() == 269);
+ assert(ticket.getIssuerDetails().getPointOfSale().getLongitude() == 105);
+
+ assert(ticket.getDocumentData() != null);
+ assert(!ticket.getDocumentData().isEmpty());
+
+ Iterator<IDocumentData> i2 = ticket.getDocumentData().iterator();
+
+ int numberOfDocuments = 0;
+ while (i2.hasNext()) {
+ numberOfDocuments++;
+ IDocumentData d1 = i2.next();
+ if (d1 instanceof IReservation) {
+ validate((IReservation) d1);
+ } else if (d1 instanceof ICarCarriageReservation) {
+ validate((ICarCarriageReservation) d1);
+ } else if (d1 instanceof IPass) {
+ validate((IPass) d1);
+ } else if (d1 instanceof IOpenTicket) {
+ validate((IOpenTicket) d1);
+ } else if (d1 instanceof ICounterMark) {
+ validate((ICounterMark) d1);
+ } else if (d1 instanceof IStationPassage) {
+ validate((IStationPassage) d1);
+ } else if (d1 instanceof ICustomerCard) {
+ validate((ICustomerCard) d1);
+ } else if (d1 instanceof IDelayConfirmation) {
+ validate((IDelayConfirmation) d1);
+ } else if (d1 instanceof IParkingGround) {
+ validate((IParkingGround) d1);
+ } else if (d1 instanceof IFipTicket) {
+ validate((IFipTicket) d1);
+ } else if (d1 instanceof IVoucher) {
+ validate((IVoucher) d1);
+ } else if (d1 instanceof IDocumentExtension) {
+ assert(((IDocumentExtension) d1).getId() != null);
+ }
+ }
+ assert(numberOfDocuments == 11);
+
+
+ assert(ticket.getTravelerDetails() != null);
+ assert(ticket.getTravelerDetails().getGroupName().equals("myGroup"));
+ assert(ticket.getTravelerDetails().getPreferredLanguage().equals("EN"));
+ assert(ticket.getTravelerDetails().getTravelers() != null);
+ assert(ticket.getTravelerDetails().getTravelers().size() == 1);
+
+ ITraveler tr = ticket.getTravelerDetails().getTravelers().iterator().next();
+
+ assert(tr.getIDCardCountry() == 103);
+ assert(tr.getPassportCountry() == 102);
+ assert(tr.getCountryOfResidence() == 101);
+ assert(tr.getCustomerId().equals("DZE5gT"));
+ assert(tr.getDateOfBirth() != null);
+ assert(tr.getFirstName().equals("John"));
+ assert(tr.getGender().equals(IGenderType.male));
+ assert(tr.getIdCard().equals("12345"));
+ assert(tr.getLastName().equals("Dow"));
+ assert(tr.getPassengerType().equals(IPassengerType.senior));
+ assert(tr.isPassengerWithReducedMobility() == false);
+ assert(tr.getPassportId().equals("JDTS"));
+ assert(tr.getSecondName().equals("Little"));
+ assert(tr.getTitle().equals("PhD"));
+ assert(tr.isTicketHolder() == true);
+ assert(tr.getStatusCollection() != null);
+ assert(tr.getStatusCollection().size() == 1);
+ ICustomerStatusDescription csd = tr.getStatusCollection().iterator().next();
+ assert(csd.getStatus() == 1);
+ assert(csd.getDescription().equals("senior"));
+
+ }
+
+
+ private void validate(ICounterMark t) {
+
+ assert(t != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals( "23456"));
+ assert(t.getProductId().equals( "123456"));
+ assert(t.getTicketReference().equals( "810123456789"));
+ assert(t.getNumberOfCountermark() == 12L);
+ assert(t.getTotalOfCountermarks() == 24L);
+ assert(t.getGroupName().equals( "groupName"));
+ assert(t.isReturnIncluded() == false);
+
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getFromStation().equals("8100001"));
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ assert(t.getValidRegionDesc().equals("From A to B via C"));
+
+ assert(t.getValidRegionList() != null);
+ assert(t.getValidRegionList().size() == 1);
+
+
+ assert(t.getReturnDescription() != null);
+ assert(t.getReturnDescription().getFromStation().equals("8100001"));
+ assert(t.getReturnDescription().getToStation().equals( "8100002"));
+ assert(t.getReturnDescription().getFromStationName().equals( "A-STATION"));
+ assert(t.getReturnDescription().getToStationName().equals( "B-STATION"));
+ assert(t.getReturnDescription().getValidRegionDesc().equals( "return"));
+ assert(t.getReturnDescription().getValidRegionList() != null);
+ assert(t.getReturnDescription().getValidRegionList().size() == 1);
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+
+ assert(t.getClassCode().equals(ITravelClassType.first));
+
+ assert(t.getIncludedCarriers() != null);
+ assert(t.getIncludedCarriers().size() == 2);
+ assert(t.getIncludedCarriers().contains("1080"));
+ assert(t.getIncludedCarriers().contains("1181"));
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ assert (t.getInfoText().equals("counterMark"));
+
+ assert(t.getExtension() != null);
+
+
+ }
+
+ private void validate(IDelayConfirmation t) {
+ assert(t != null);
+
+ assert(t.getTrain().equals("100"));
+ assert(t.getArrivalDate() != null);
+ assert(t.getReference().equals("ABDJ12345"));
+ assert(t.getStation().equals("DJE"));
+ assert(t.getDelay() == 31);
+ assert(t.isTrainCancelled() == false);
+ assert(t.getConfirmationType() == ConfirmationTypeType.travelerDelayConfirmation.ordinal());
+ assert(t.getLinkedTickets() != null);
+ assert(t.getLinkedTickets().size() == 1);
+ ITicketLink tl = t.getLinkedTickets().iterator().next();
+ assert(tl.getReference().equals("KDJET"));
+ assert(tl.getIssuer().equals( "XYZ"));
+ assert(tl.getIssuerPNR().equals( "LDWDUR45"));
+ assert(tl.getProductOwner().equals( "IEFHU"));
+ assert(tl.getTicketType().equals(ITicketType.openTicket));
+ assert(tl.getLinkMode().equals( ILinkMode.issuedTogether));
+
+ assert(t.getInfoText().equals( "delay confirmation"));
+ assert(t.getExtension() != null);
+
+ }
+
+ private void validate(ICustomerCard c) {
+ assert(c != null);
+ assert (c.getExtension() != null);
+ assert (c.getCustomer() != null);
+ assert (c.getCustomer() != null);
+
+ assert (c.getCardId().equals("2345"));
+ assert (c.getValidFrom() != null);
+ assert (c.getValidUntil() != null);
+ assert (c.getClassCode().equals(ITravelClassType.second));
+ assert (c.getCardType() == 15);
+ assert (c.getCardTypeDescr().equals( "RAILPLUS"));
+ assert (c.getCustomerStatus() == 1);
+ assert (c.getCustomerStatusDescr().equals( "gold"));
+ assert (c.getIncludedServices() != null);
+ assert (c.getIncludedServices().size() == 2);
+ Iterator<Integer> i3 = c.getIncludedServices().iterator();
+ assert(i3.next() == 1);
+ assert(i3.next() == 2);
+
+ }
+
+ private void validate(IVoucher v) {
+ assert(v != null);
+ assert (v.getExtension() != null);
+
+ assert(v.getReference().equals("810123456789"));
+ assert(v.getProductOwner().equals("COFFEEMACHINE"));
+ assert(v.getProductId().equals("123456"));
+
+ assert(v.getValidFrom() != null);
+ assert(v.getValidUntil() != null);
+ assert(v.getAmount() == 500);
+ assert(v.getType() == 123);
+ assert(v.getInfoText().equals("coffee voucher"));
+
+ }
+
+ private void validate(IStationPassage t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("123456"));
+
+ assert(t.getProductName().equals("passage"));
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(t.getStations() != null);
+ assert(t.getStations().size() == 2);
+ assert(t.getStations().contains("8200001"));
+ assert(t.getStations().contains("AMS"));
+ assert(t.getStationNames() != null);
+ assert(t.getStationNames().size() == 1);
+ assert(t.getStationNames().iterator().next().equals("Amsterdam"));
+ assert(t.getAreaCodes() != null);
+ assert(t.getAreaCodes().size() == 2);
+ assert(t.getAreaCodes().contains("AMS"));
+ assert(t.getAreaCodes().contains("8200001"));
+ assert(t.getAreaNames() != null);
+ assert(t.getAreaNames().size() == 1);
+ assert(t.getAreaNames().contains("Amsterdam"));
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+ assert(t.getNumberOfdaysAllowed() == 5);
+
+ }
+
+ private void validate(IParkingGround t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("123456"));
+
+
+ assert(t.getParkingGroundId().equals( "IA5"));
+ assert(t.getFromParkingDate() != null);
+ assert(t.getToParkingDate() != null);
+
+
+ assert(t.getAccessCode().equals( "4ga"));
+ assert(t.getLocation().equals( "Parking Frankfurt Main West"));
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(t.getStation().equals( "8000001"));
+ assert(t.getSpecialInformation().equals( "outdoor parking"));
+ assert(t.getEntryTrack().equals( "left"));
+ assert(t.getNumberPlate().equals( "AA-DE-12345"));
+ assert(t.getPrice() == 500);
+ assert(t.getVatDetails() != null);
+ assert(t.getVatDetails().size() == 1);
+
+
+ }
+
+ private void validate(IFipTicket t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("123456"));
+
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+ assert(t.getActivatedDays() != null);
+ assert(t.getActivatedDays().size() == 4);
+ Iterator<Date> i5 = t.getActivatedDays().iterator();
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+
+
+
+ assert(t.getCarriers()!= null);
+ assert(t.getCarriers().size() == 2);
+ assert(t.getCarriers().contains("1080"));
+ assert(t.getCarriers().contains("1181"));
+
+
+ assert(t.getNumberOfTravelDates() == 8);
+ assert(t.isIncludesSupplements() == true);
+ assert(t.getClassCode().equals(ITravelClassType.first));
+
+ }
+
+ private void validate(IOpenTicket t) {
+
+ assert (t != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals( "23456"));
+ assert(t.getProductId().equals( "123456"));
+ assert(t.getExternalIssuer() == 12);
+ assert(t.getAuthorizationCode() == 13);
+ assert(t.isReturnIncluded() == false);
+
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getFromStation().equals("8100001"));
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ assert(t.getValidRegionDesc().equals("From A to B via C"));
+
+ assert (t.getValidRegionList() != null);
+ assert(t.getValidRegionList().size() == 5);
+ Iterator<IRegionalValidity> irv = t.getValidRegionList().iterator();
+ int checks = 0;
+ while (irv.hasNext()) {
+ IRegionalValidity v = irv.next();
+ if (v instanceof IZone) {
+ validateRegion((IZone) v);
+ checks++;
+ } else if (v instanceof IViaStation) {
+ validateRegion((IViaStation) v);
+ checks++;
+ } else if (v instanceof ITrainLink) {
+ validateRegion((ITrainLink) v);
+ checks++;
+ } else if (v instanceof IPolygone) {
+ validateRegion((IPolygone) v);
+ checks++;
+ } else if (v instanceof ILine) {
+ validateRegion((ILine) v);
+ checks++;
+ }
+ }
+ assert(checks == 5);
+
+ assert(t.getReturnDescription() != null);
+
+ assert(t.getReturnDescription().getFromStation().equals("8100001"));
+ assert(t.getReturnDescription().getToStation().equals( "8100002"));
+ assert(t.getReturnDescription().getFromStationName().equals( "A-STATION"));
+ assert(t.getReturnDescription().getToStationName().equals( "B-STATION"));
+ assert(t.getReturnDescription().getValidRegionDesc().equals( "return"));
+ assert(t.getReturnDescription().getValidRegionList() != null);
+ assert(t.getReturnDescription().getValidRegionList().size() == 1);
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+
+ assert(t.getActivatedDays() != null);
+ assert(t.getActivatedDays().size() == 2);
+
+ assert(t.getClassCode().equals(ITravelClassType.first));
+ assert(t.getServiceLevel().equals("A"));
+
+ assert(t.getIncludedCarriers() != null);
+ assert(t.getIncludedCarriers().size() == 2);
+ assert(t.getIncludedCarriers().contains("1080"));
+ assert(t.getIncludedCarriers().contains("1181"));
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ assert(t.getTariffs() != null);
+ assert(t.getTariffs().size() == 1);
+
+ assert (t.getPrice() == 12345);
+ assert (t.getVatDetails() != null);
+ assert (t.getVatDetails().size() == 1);
+
+ assert (t.getInfoText().equals("openTicketInfo"));
+
+ assert (t.getIncludedAddOns() != null);
+ assert (t.getIncludedAddOns().size() == 1);
+ validate(t.getIncludedAddOns().iterator().next());
+
+ assert(t.getLuggageRestriction() != null);
+
+ assert(t.getIncludedTransportTypes() != null);
+ assert(t.getIncludedTransportTypes().size() == 2);
+ assert(t.getIncludedTransportTypes().contains(10));
+ assert(t.getIncludedTransportTypes().contains(11));
+
+
+ assert(t.getExcludedTransportTypes() != null);
+ assert(t.getExcludedTransportTypes().size() == 2);
+ assert(t.getExcludedTransportTypes().contains(10));
+ assert(t.getExcludedTransportTypes().contains(18));
+
+
+
+ assert(t.getExtension() != null);
+
+ }
+
+ private void validateRegion(ITrainLink t) {
+
+ assert (t != null);
+
+ assert(t.getTrain().equals("12345"));
+ assert(t.getDepartureDateTime() != null);
+ assert(t.getFromStation().equals("8100001"));
+
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ }
+
+ private void validateRegion(IPolygone p) {
+
+ assert(p.getEdges() != null);
+ assert(p.getEdges().size() == 3);
+
+ }
+
+ private void validateRegion(IZone z) {
+
+ assert(z != null);
+
+ assert(z.getCarrier().equals("1080"));
+ assert(z.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(z.getEntryStation().equals( "1234"));
+ assert(z.getTerminatingStation().equals( "2345"));
+ assert(z.getCity() == 123456);
+ assert(z.getZoneIds() != null);
+ assert(z.getZoneIds().size() == 2);
+ Iterator<Integer> iz = z.getZoneIds().iterator();
+ assert(iz.next() == 100);
+ assert(iz.next() == 200);
+
+ assert(UperEncoder.hexStringFromBytes(z.getBinaryZoneId()).equals("82DA"));
+ assert(z.getNUTScode().equals("DE4711"));
+
+ }
+
+ private void validateRegion(ILine z) {
+
+
+ assert(z.getCarrier().equals("1080"));
+ assert(z.getStationCodeTable().equals(IStationCodeTable.stationERA));
+
+ assert(z.getEntryStation().equals( "1234"));
+
+ assert(z.getTerminatingStation().equals( "2345"));
+ assert(z.getCity() == 123456);
+ assert(z.getLineIds() != null);
+ assert(z.getLineIds().size() == 2);
+ Iterator<Integer> iz = z.getLineIds().iterator();
+ assert(iz.next() == 100);
+ assert(iz.next() == 200);
+
+
+ }
+
+ private void validateRegion(IViaStation t) {
+
+ assert( t != null);
+
+ assert(t.getRoute() != null);
+
+ assert(t.getRoute().size() == 4);
+
+ Iterator<IViaStation> iv = t.getRoute().iterator();
+ IViaStation v1 = iv.next();
+ IViaStation v2 = iv.next();
+ IViaStation v3 = iv.next();
+ IViaStation v4 = iv.next();
+
+ assert(v1.getStation().equals("123455"));
+ assert(v1.isBorder() == false);
+
+ assert(v2.getStation().equals("123456"));
+ assert(v2.isBorder() == false);
+
+ assert(v3.getAlternativeRoutes() != null);
+ assert(v3.getAlternativeRoutes().size() == 2);
+ Iterator<IViaStation> ari = v3.getAlternativeRoutes().iterator();
+ IViaStation ar1 = ari.next();
+ IViaStation ar2 = ari.next();
+ assert(ar1.getRoute().size() == 2);
+ assert(ar1.getRoute().iterator().next().getStation().equals("23455"));
+ assert(ar2.getRoute() != null);
+ assert(ar2.getRoute().size() == 2);
+ assert(ar2.getRoute().iterator().next().getStation().equals("3455"));
+
+ assert(v4.getStation().equals("123457"));
+
+ assert(t.isBorder() == false);
+
+ assert(t.getSeriesId() == 999);
+ assert(t.getRouteId() == 21);
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ }
+
+ private void validate(IIncludedOpenTicket d1) {
+
+ assert(d1.getProductOwner().equals("23456"));
+ assert(d1.getProductId().equals("123456"));
+ assert(d1.getExternalIssuer() == 12);
+ assert(d1.getAuthorizationCode() == 13);
+ assert(d1.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(d1.getValidRegionList() != null);
+ assert(d1.getValidRegionList().size() == 1);
+ assert(d1.getValidFrom() != null);
+ assert(d1.getValidUntil() != null);
+ assert(d1.getClassCode().equals(ITravelClassType.second));
+ assert(d1.getServiceLevel().equals("A"));
+
+ assert(d1.getIncludedCarriers() != null);
+ assert(d1.getIncludedCarriers().size() == 2);
+ assert(d1.getIncludedCarriers().contains("1080"));
+ assert(d1.getIncludedCarriers().contains("1181"));
+
+ assert(d1.getIncludedServiceBrands() != null);
+ assert(d1.getIncludedServiceBrands().size() == 2);
+ assert(d1.getIncludedServiceBrands().contains(108));
+ assert(d1.getIncludedServiceBrands().contains(118));
+
+
+ assert(d1.getExcludedServiceBrands() != null);
+ assert(d1.getExcludedServiceBrands().size() == 2);
+ assert(d1.getExcludedServiceBrands().contains(108));
+ assert(d1.getExcludedServiceBrands().contains(118));
+
+
+ assert(d1.getTariffs() != null);
+ assert(d1.getTariffs().size() == 1);
+
+ assert(d1.getInfoText().equals("included ticket"));
+
+ assert(d1.getIncludedTransportTypes() != null);
+ assert(d1.getIncludedTransportTypes().size() == 2);
+ assert(d1.getIncludedTransportTypes().contains(10));
+ assert(d1.getIncludedTransportTypes().contains(11));
+
+
+ assert(d1.getExcludedTransportTypes() != null);
+ assert(d1.getExcludedTransportTypes().size() == 2);
+ assert(d1.getExcludedTransportTypes().contains(10));
+ assert(d1.getExcludedTransportTypes().contains(18));
+
+ assert(d1.getExtension() != null);
+
+
+
+ }
+
+ private void validate(IPass p) {
+
+
+ assert(p.getReference().equals("810123456789"));
+ assert(p.getProductOwner().equals( "23456"));
+ assert(p.getProductId().equals( "123456"));
+ assert(p.getPassType() == 2);
+ assert(p.getPassDescription().equals( "Eurail FlexPass"));
+ assert(p.getClassCode().equals(ITravelClassType.first));
+ assert(p.getValidFrom() != null);
+ assert(p.getValidUntil() != null);
+ assert(p.getValidityDetails() != null);
+
+ assert(p.getValidityDetails() != null);
+ assert(p.getValidityDetails().getValidityRanges().size() == 1);
+ IValidityRange vr = p.getValidityDetails().getValidityRanges().iterator().next();
+ assert(vr.getFromDate() != null);
+ assert(vr.getUntilDate() != null);
+
+ assert(p.getValidityDetails().getTimeRanges() != null);
+ ITimeRange tr = p.getValidityDetails().getTimeRanges().iterator().next();
+ assert(tr.getFromTime() == 6);
+ assert(tr.getUntilTime() == 9);
+
+ assert(p.getNumberOfValidityDays() == 5);
+ assert(p.getTrainValidity() != null);
+
+ assert(p.getTrainValidity().getFromDate() != null);
+ assert(p.getTrainValidity().getUntilDate() != null);
+ assert(p.getTrainValidity().getIncludedCarriers() != null);
+ assert(p.getTrainValidity().getIncludedCarriers().size() == 2);
+ Iterator<String> i3 = p.getTrainValidity().getIncludedCarriers().iterator();
+ assert(i3.next().equals("1234"));
+ assert(i3.next().equals("5678"));
+
+ assert(p.getTrainValidity().getBoardingOrArrival().equals(IBoardingOrArrivalType.boarding));
+
+ assert(p.getNumberOfPossibleTrips() == 3);
+ assert(p.getNumberOfDaysOfTravel() == 10);
+ assert(p.getActivatedDays() != null);
+ assert(p.getActivatedDays().size() == 2);
+
+
+ assert(p.getCountries() != null);
+ assert(p.getCountries().size() == 2);
+ Iterator<Integer> i6 = p.getCountries().iterator();
+ assert(i6.next() == 10);
+ assert(i6.next() == 20);
+
+ assert(p.getIncludedCarriers() != null);
+ assert(p.getIncludedCarriers().size() == 2);
+ assert(p.getIncludedCarriers().contains("1080"));
+ assert(p.getIncludedCarriers().contains("1181"));
+
+ assert(p.getIncludedServiceBrands() != null);
+ assert(p.getIncludedServiceBrands().size() == 2);
+ assert(p.getIncludedServiceBrands().contains(108));
+ assert(p.getIncludedServiceBrands().contains(118));
+
+
+ assert(p.getExcludedServiceBrands() != null);
+ assert(p.getExcludedServiceBrands().size() == 2);
+ assert(p.getExcludedServiceBrands().contains(108));
+ assert(p.getExcludedServiceBrands().contains(118));
+
+
+
+ assert(p.getExcludedCarriers() != null);
+ assert(p.getExcludedCarriers().size() == 2);
+ assert(p.getExcludedCarriers().contains("1080"));
+ assert(p.getExcludedCarriers().contains("1181"));
+
+
+
+
+
+ assert(p.getValidRegionList() != null);
+ assert(p.getValidRegionList().size() == 1);
+ assert(p.getTariffs() != null);
+ assert(p.getTariffs().size() == 1);
+ assert(p.getPrice() == 10000);
+ assert(p.getVatDetails() != null);
+ assert(p.getVatDetails().size() == 1);
+ assert(p.getInfoText().equals("pass info"));
+ assert (p.getExtension() != null);
+
+
+ }
+
+ private void validate(IReservation r) {
+
+ assert(r.getTrain().equals("12345"));
+ assert(r.getDepartureDate() != null);
+ assert(r.getReference().equals("810123456789"));
+ assert(r.getProductOwner().equals("23456"));
+
+ assert(r.getProductId().equals("123456"));
+ assert(r.getServiceBrand().getServiceBrand() == 12);
+ assert(r.getServiceBrand().getServiceBrandAbbreviation().equals("TGV"));
+ assert(r.getServiceBrand().getServiceBrandDescription().equals("Lyria"));
+ assert(r.getService().equals(IServiceType.couchette));
+
+ assert(r.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(r.getFromStation().equals("8100001"));
+ assert(r.getToStation().equals( "8100002"));
+ assert(r.getFromStationName().equals( "A-STATION"));
+ assert(r.getToStationName().equals( "B-STATION"));
+ assert(r.getDepartureDate() != null);
+ assert(r.getArrivalDate() != null);
+ assert(r.getCarriers()!= null);
+ assert(r.getCarriers().size() == 2);
+ Iterator<String> i8 = r.getCarriers().iterator();
+ assert(i8.next().equals("1080"));
+ assert(i8.next().equals("1181"));
+
+
+ assert(r.getClassCode().equals(ITravelClassType.first));
+ assert(r.getServiceLevel().equals("A"));
+
+ assert(r.getPlaces() != null);
+ assert(r.getPlaces().getCoach().equals("31A"));
+ assert(r.getPlaces().getPlaceString().equals("31-47"));
+ assert(r.getPlaces().getPlaceDescription().equals("Window"));
+ assert(r.getPlaces().getPlaces() != null);
+ assert(r.getPlaces().getPlaces().size() == 4);
+ Iterator<String> is = r.getPlaces().getPlaces().iterator();
+ assert(is.next().equals("31"));
+ assert(is.next().equals("32"));
+
+
+ assert(r.getAdditionalPlaces() != null);
+ assert(r.getBicyclePlaces() != null);
+
+
+ assert(r.getCompartmentDetails() != null);
+ assert(r.getCompartmentDetails().getCoachType() == 1);
+ assert(r.getCompartmentDetails().getCompartmentType() == 99);
+ assert(r.getCompartmentDetails().getSpecialAllocation() == 50);
+ assert(r.getCompartmentDetails().getCoachTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getCompartmentTypeDescr().equals( "xwz"));
+ assert(r.getCompartmentDetails().getSpecialAllocationDescr().equals( "xwz"));
+ assert(r.getCompartmentDetails().getPosition().equals(ICompartmentPositionType.upperLevel));
+
+ assert(r.getNumberOfOverbooked() == 200);
+ assert(r.getBerths() != null);
+ assert(r.getBerths().size() == 1);
+ IBerth b = r.getBerths().iterator().next();
+
+ assert(b.getType().equals(IBerthTypeType.single));
+ assert(b.getGender().equals(ICompartmentGenderType.female));
+ assert(b.getNumberOfBerths() == 999);
+
+
+ assert(r.getTariffs() != null);
+ assert(r.getTariffs().size() == 1);
+ ITariff t = r.getTariffs().iterator().next();
+ assert(t.getNumberOfPassengers() == 1);
+
+
+ assert(t.getPassengerType().equals(IPassengerType.senior) );
+ assert(t.getAgeBelow() == 64);
+ assert(t.getAgeAbove() == 60);
+ assert(t.getTravelerIds() != null);
+ assert(t.getTravelerIds().size() == 1);
+ assert(t.getTravelerIds().iterator().next() == 1);
+
+ assert(t.isRestrictedToCountryOfResidence() == false);
+ assert(t.getRestrictedToRouteSection() != null);
+ assert(t.getRestrictedToRouteSection().getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getRestrictedToRouteSection().getFromStation().equals( "123"));
+ assert(t.getRestrictedToRouteSection().getToStation().equals( "234"));
+ assert(t.getRestrictedToRouteSection().getFromStationName().equals( "A"));
+ assert(t.getRestrictedToRouteSection().getToStationName().equals( "B"));
+
+ assert(t.getSeriesDataDetails() != null);
+ assert(t.getSeriesDataDetails().getSupplyingCarrier() == 12345);
+ assert(t.getSeriesDataDetails().getOfferIdentification() == 99);
+ assert(t.getSeriesDataDetails().getSeries() == 23456);
+
+
+ assert(t.getTariffId().equals( "72"));
+ assert(t.getTariffDescription().equals( "Leasure Fare"));
+ assert(t.getReductionCards() != null);
+ assert(t.getReductionCards().size() == 1);
+ ICardReference rc = t.getReductionCards().iterator().next();
+
+ assert(rc.getCardIssuer().equals( "1234"));
+ assert(rc.getCardId().equals( "5678"));
+ assert(rc.getCardName().equals( "testcard"));
+ assert(rc.getCardType() == 123);
+ assert(rc.getLeadingCardId().equals("3456"));
+ assert(rc.getTrailingCardId().equals("100"));
+
+
+ assert(r.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(r.getPrice() == 12345);
+ assert(r.getVatDetails() != null);
+ IVatDetail v = r.getVatDetails().iterator().next();
+ assert(r.getVatDetails().size() == 1);
+ assert(v.getCountry() == 80);
+ assert(v.getPercentage() == 70);
+ assert(v.getAmount() == 10);
+ assert(v.getVatId().equals("IUDGTE"));
+
+ assert(r.getTypeOfSupplement() == 9);
+ assert(r.getNumberOfSupplements() == 2);
+ assert(r.getLuggageRestriction() != null);
+
+ assert(r.getLuggageRestriction().getMaxHandLuggagePieces() == 2);
+ assert(r.getLuggageRestriction().getMaxNonHandLuggagePieces() == 1);
+ assert(r.getLuggageRestriction().getRegisteredLuggage() != null);
+ assert(r.getLuggageRestriction().getRegisteredLuggage().size() == 2);
+
+
+ Iterator<IRegisteredLuggage> il = r.getLuggageRestriction().getRegisteredLuggage().iterator();
+ IRegisteredLuggage rl1 = null;
+ IRegisteredLuggage rl2 = null;
+ while (il.hasNext()) {
+ IRegisteredLuggage l = il.next();
+ if (l.getRegistrationId().equals("IODHUV")) {
+ rl1 = l;
+ } else {
+ rl2 = l;
+ }
+ }
+ assert(rl1.getRegistrationId().equals("IODHUV"));
+ assert(rl1.getMaxWeight() == 20);
+ assert(rl1.getMaxSize() == 100);
+ assert(rl2.getRegistrationId().equals("XXDHUV"));
+ assert(rl2.getMaxWeight() == 21);
+ assert(rl2.getMaxSize() == 101);
+ assert(r.getInfoText().equals("reservation"));
+ assert(r.getExtension() != null);
+
+ }
+
+
+ private void validate(ICarCarriageReservation r) {
+
+
+ assert(r.getToken() != null);
+ assert(UperEncoder.hexStringFromBytes(r.getToken().getToken()).equals("82DA"));
+ assert(r.getToken().getTokenProvider().equals("VDV"));
+ assert(r.getToken().getTokenSpecification().equals("TEST"));
+
+
+ assert(r.getTrain().equals("123"));
+ assert(r.getReference().equals("810123456789"));
+ assert(r.getProductOwner().equals("23456"));
+ assert(r.getProductId().equals("123456"));
+ assert(r.getServiceBrand().getServiceBrand() == 100);
+ assert(r.getServiceBrand().getServiceBrandAbbreviation().equals("AZ"));
+ assert(r.getServiceBrand().getServiceBrandDescription().equals("special train"));
+
+ assert(r.getBeginLoading() != null);
+ assert(r.getEndLoading() != null);
+
+ assert(r.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(r.getFromStation().equals("8100001"));
+ assert(r.getToStation().equals( "8100002"));
+ assert(r.getFromStationName().equals( "A-STATION"));
+ assert(r.getToStationName().equals( "B-STATION"));
+
+ assert(r.getCoach().equals("21"));
+ assert(r.getPlace().equals("41"));
+ assert(r.getCompartmentDetails() != null);
+
+ assert(r.getCompartmentDetails().getCoachType() == 1L);
+ assert(r.getCompartmentDetails().getCompartmentType() == 99L);
+ assert(r.getCompartmentDetails().getSpecialAllocation() == 50L);
+ assert(r.getCompartmentDetails().getCoachTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getCompartmentTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getSpecialAllocationDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getPosition().equals(ICompartmentPositionType.upperLevel));
+
+ assert(r.getNumberPlate().equals( "AD-DE-123"));
+ assert(r.getTrailerPlate().equals( "DX-AB-123"));
+ assert(r.getCarCategory() == 3L);
+ assert(r.getBoatCategory() == 5L);
+ assert(r.isTextileRoof() == false);
+ assert(r.getRoofRackType().equals(IRoofRackType.bicycleRack));
+ assert(r.getRoofRackHeight() == 20L);
+ assert(r.getAttachedBoats() == 2L);
+ assert(r.getAttachedBicycles() == 1L);
+ assert(r.getAttachedSurfboards() == 2L);
+ assert(r.getLoadingListEntry() == 421L);
+ assert(r.getLoadingDeck().equals(ILoadingDeckType.upper));
+
+ assert(r.getCarriers()!= null);
+ assert(r.getCarriers().size() == 2);
+ Iterator<String> i9 = r.getCarriers().iterator();
+ assert(i9.next().equals("1080"));
+ assert(i9.next().equals("1181"));
+
+ assert(r.getTariff() != null);
+ assert(r.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(r.getPrice() == 12345L);
+
+ assert(r.getVatDetails() != null);
+
+ assert(r.getInfoText().equals("car carriage"));
+ assert(r.getExtension() != null);
+
+ }
+
+ public static int getIndexOfDifference(String s1, String s2) {
+
+ if (s1 == null || s2 == null) return -1;
+
+ char[] ca1 = null;
+ char[] ca2 = null;
+
+ if (s1.length() > s2.length()) {
+ ca1 = s1.toCharArray();
+ ca2 = s2.toCharArray();
+ } else {
+ ca1 = s2.toCharArray();
+ ca2 = s1.toCharArray();
+ }
+
+ int i = 0;
+ for (char c : ca2) {
+ if (c != ca1[i]) return i;
+ i++;
+ }
+ return 0;
+ }
+
+
+
+}