summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-14 15:09:45 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-14 15:09:45 +0200
commit8770b99fdb6f47dea7b1f598633407e67b22572f (patch)
tree5d1fc48cf597cb12cfb125192fe8c4ff9765c95b /src/main
parentunit test for fcb version 1 including all elements (diff)
downloadUIC-barcode-8770b99fdb6f47dea7b1f598633407e67b22572f.tar
UIC-barcode-8770b99fdb6f47dea7b1f598633407e67b22572f.tar.gz
UIC-barcode-8770b99fdb6f47dea7b1f598633407e67b22572f.tar.bz2
UIC-barcode-8770b99fdb6f47dea7b1f598633407e67b22572f.tar.lz
UIC-barcode-8770b99fdb6f47dea7b1f598633407e67b22572f.tar.xz
UIC-barcode-8770b99fdb6f47dea7b1f598633407e67b22572f.tar.zst
UIC-barcode-8770b99fdb6f47dea7b1f598633407e67b22572f.zip
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java38
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/asn/omv2/LineType.java14
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java1
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java239
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java217
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java234
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/NumListWrapper.java55
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java36
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java118
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/UicEncoderUtils.java36
10 files changed, 642 insertions, 346 deletions
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java b/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java
index 3bfcbf5..7dbd131 100644
--- a/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java
+++ b/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java
@@ -122,44 +122,6 @@ public class DynamicFrame extends Object{
return UperEncoder.decode(bytes, DynamicFrame.class);
}
- /**
- * Sign level 2 data without a specific security provider.
- *
- * @param key the key
- * @throws Exception the exception
- */
- public void signLevel2(PrivateKey key) throws Exception {
-
- //find the algorithm name for the signature OID
- String algo = AlgorithmNameResolver.getSignatureAlgorithmName(this.getLevel2SignedData().getLevel1Data().level2SigningAlg);
- Signature sig = Signature.getInstance(algo);
- sig.initSign(key);
- byte[] data = level2SignedData.encode();
- sig.update(data);
- byte[] signature = sig.sign();
- this.level2Signature = new OctetString(signature);
-
- }
-
- /**
- * Sign level 2 data.
- *
- * @param key the key
- * @param prov the security Provider
- * @throws Exception the exception
- */
- public void signLevel2(PrivateKey key, Provider prov) throws Exception {
-
- //find the algorithm name for the signature OID
- String algo = AlgorithmNameResolver.getSignatureAlgorithmName(this.getLevel2SignedData().getLevel1Data().level2SigningAlg);
- Signature sig = Signature.getInstance(algo,prov);
- sig.initSign(key);
- byte[] data = level2SignedData.encode();
- sig.update(data);
- this.level2Signature = new OctetString(sig.sign());
-
- }
-
/**
* Adds the dynamic content and encodes it. (API level)
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LineType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LineType.java
index fff4499..ffe19a3 100644
--- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LineType.java
+++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LineType.java
@@ -127,8 +127,11 @@ public class LineType extends Object {
}
public byte[] getBinaryZoneId() {
-
- return binaryZoneId.toByteArray();
+ if (binaryZoneId != null && binaryZoneId.size() > 0) {
+ return binaryZoneId.toByteArray();
+ } else {
+ return null;
+ }
}
public void setCarrierNum(Long carrierNum) {
@@ -177,8 +180,11 @@ public class LineType extends Object {
}
public void setBinaryZoneId(byte[] binaryZoneId) {
-
- this.binaryZoneId = new OctetString(binaryZoneId);
+ if (binaryZoneId != null && binaryZoneId.length > 0) {
+ this.binaryZoneId = new OctetString(binaryZoneId);
+ } else {
+ this.binaryZoneId = null;
+ }
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java
index 30a7dfc..2522355 100644
--- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java
+++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java
@@ -314,6 +314,7 @@ public class TravelerType extends Object {
public Date getDateOfBirth() {
if (this.yearOfBirth == null) return null;
+ if (this.monthOfBirth == null) return null;
if (this.dayOfBirth == null) return null;
Calendar cal = Calendar.getInstance();
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 6cf1673..d8934d9 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
@@ -350,12 +350,13 @@ public class Api2OpenAsnEncoder 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.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
-
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
+
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -363,8 +364,9 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
}
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
@@ -378,7 +380,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
if (document.getServiceBrand()!= null) {
- asnData.setServiceBrand(UicEncoderUtils.getRestrictedInt(document.getServiceBrand().getServiceBrand(),1,9999));
+ asnData.setServiceBrand(UicEncoderUtils.getRestrictedInt(document.getServiceBrand().getServiceBrand(),1,32000));
asnData.setServiceBrandAbrUTF8(document.getServiceBrand().getServiceBrandAbbreviation());
asnData.setServiceBrandNameUTF8(document.getServiceBrand().getServiceBrandDescription());
@@ -465,9 +467,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setCoach(UicEncoderUtils.getIA5(places.getCoach()));
asnData.setPlaceDescription(places.getPlaceDescription());
asnData.setPlaceString(UicEncoderUtils.getIA5(places.getPlaceString()));
- asnData.setPlaceNum(SequenceOfPlaceNum.getSequence(UicEncoderUtils.getNumList(places.getPlaces())));
- asnData.setPlaceIA5(UicEncoderUtils.getIA5NonNumList(places.getPlaces()));
+ NumListWrapper w = new NumListWrapper(places.getPlaces(),1,254);
+ asnData.setPlaceNum(SequenceOfPlaceNum.getSequence(w.getNumList()));
+ asnData.setPlaceIA5(w.getStringList());
+
return asnData;
}
@@ -565,20 +569,22 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
ReservationData asnData = new ReservationData();
asnDocument.getTicket().setReservation(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
- 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()));
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
if (document.getStationCodeTable() != IStationCodeTable.stationUICReservation && document.getStationCodeTable() != null){
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
@@ -640,7 +646,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
}
if (document.getServiceBrand()!= null) {
- asnData.setServiceBrand(UicEncoderUtils.getRestrictedInt(document.getServiceBrand().getServiceBrand(),1,9999));
+ asnData.setServiceBrand(UicEncoderUtils.getRestrictedInt(document.getServiceBrand().getServiceBrand(),1,32000));
asnData.setServiceBrandAbrUTF8(document.getServiceBrand().getServiceBrandAbbreviation());
asnData.setServiceBrandNameUTF8(document.getServiceBrand().getServiceBrandDescription());
@@ -708,12 +714,12 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
IncludedOpenTicketType asnData = new IncludedOpenTicketType();
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
-
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
-
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
@@ -722,12 +728,13 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
}
- asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setIncludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
-
- asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,9999)));
- asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,9999)));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setIncludedCarriersIA5(w.getStringList());
+ asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
+ asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
+
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
if (document.getValidFromUTCoffset() != null) {
@@ -871,12 +878,13 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnDocument.setTicket(asnTicket);
asnTicket.setOpenTicket(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
- asnData.setProductIdNum(UicEncoderUtils.getNum(document.getProductId()));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5NonNum(document.getProductId()));
-
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -896,8 +904,9 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setFromStationNameUTF8(document.getFromStationName());
asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -986,12 +995,13 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
CountermarkData asnData = new CountermarkData();
asnDocument.getTicket().setCounterMark(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
-
- asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
-
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
+
asnData.setTicketReferenceNum(UicEncoderUtils.getNum(document.getTicketReference()));
asnData.setTicketReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getTicketReference()));
@@ -1043,9 +1053,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setFromStationNameUTF8(document.getFromStationName());
asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
-
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
+
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -1127,9 +1138,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
asnData.setBorder(false);
}
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
-
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
+
asnData.setRoute(encodeViaStationCollection(document.getRoute()));
if (document.getRouteId() > 0){
@@ -1371,12 +1383,12 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
ParkingGroundData asnData = new ParkingGroundData();
asnDocument.getTicket().setParkingGround(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
-
- asnData.setProductIdNum(UicEncoderUtils.getRestrictedNum(document.getProductId(),0,65535));
- asnData.setProductIdIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductId(),0,65535));
-
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1549,11 +1561,12 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
VoucherData asnData = new VoucherData();
asnDocument.getTicket().setVoucher(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()));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1589,23 +1602,26 @@ public class Api2OpenAsnEncoder 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()));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
asnData.setInfoText(document.getInfoText());
- asnData.setExtension(encodeExtension(document.getExtension()));
+ asnData.setExtension(encodeExtension(document.getExtension()));
- asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setIncludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
-
- asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getExcludedCarriers())));
- asnData.setExcludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getExcludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setIncludedCarriersIA5(w.getStringList());
+
+ w = new NumListWrapper(document.getExcludedCarriers(),1,32000);
+ asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setExcludedCarriersIA5(w.getStringList());
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
@@ -1736,18 +1752,20 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
FIPTicketData asnData = new FIPTicketData();
asnDocument.getTicket().setFipTicket(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()));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
-
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
+
asnData.setClassCode(convertTravelClass(document.getClassCode()));
asnData.setIncludesSupplements(document.isIncludesSupplements());
@@ -1782,11 +1800,12 @@ public class Api2OpenAsnEncoder 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()));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,32000);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1991,27 +2010,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
for (ITicketLink ticket : linkedTickets){
- TicketLinkType asnTicket = new TicketLinkType();
-
- asnTicket.setIssuerName(ticket.getIssuer());
-
- asnTicket.setIssuerPNR(ticket.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()));
-
- if (ticket.getTicketType() != ITicketType.openTicket && ticket.getTicketType() != null){
- asnTicket.setTicketType(TicketType.valueOf(ticket.getTicketType().name()));
- }
-
- if (ticket.getLinkMode() != ILinkMode.issuedTogether && ticket.getLinkMode() != null){
- asnTicket.setLinkMode(LinkMode.valueOf(ticket.getLinkMode().name()));
+ TicketLinkType asnTicket = convert(ticket);
+ if (asnTicket!= null) {
+ asnList.add(asnTicket);
}
-
- asnList.add(asnTicket);
}
if (asnList.isEmpty()) return null;
@@ -2019,6 +2021,35 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
return asnList;
}
+ private TicketLinkType convert(ITicketLink document) throws EncodingFormatException {
+
+ if (document == null) return null;
+
+ TicketLinkType asnData = new TicketLinkType();
+
+ asnData.setIssuerName(document.getIssuer());
+
+ asnData.setIssuerPNR(document.getIssuerPNR());
+
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+
+ asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
+ asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
+
+ if (document.getTicketType() != ITicketType.openTicket && document.getTicketType() != null){
+ asnData.setTicketType(TicketType.valueOf(document.getTicketType().name()));
+ }
+
+ if (document.getLinkMode() != ILinkMode.issuedTogether && document.getLinkMode() != null){
+ asnData.setLinkMode(LinkMode.valueOf(document.getLinkMode().name()));
+ }
+
+ return asnData;
+ }
+
+
/**
* Encode travelers.
*
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
index 00c0ce3..3468ec6 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
@@ -68,9 +68,11 @@ import org.uic.barcode.ticket.api.asn.omv2.SequenceOfRegisteredLuggageType;
import org.uic.barcode.ticket.api.asn.omv2.SequenceOfServiceBrands;
import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTariffType;
import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTimeRangeType;
import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTransportTypes;
import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerId;
import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv2.SequenceOfValidityPeriodType;
import org.uic.barcode.ticket.api.asn.omv2.SequenceOfViaStationType;
import org.uic.barcode.ticket.api.asn.omv2.SeriesDetailType;
import org.uic.barcode.ticket.api.asn.omv2.ServiceType;
@@ -92,11 +94,13 @@ import org.uic.barcode.ticket.api.asn.omv2.VatDetailType;
import org.uic.barcode.ticket.api.asn.omv2.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv2.VoucherData;
import org.uic.barcode.ticket.api.asn.omv2.ZoneType;
+import org.uic.barcode.ticket.api.asn.omv2.CompartmentPositionType;
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;
@@ -343,9 +347,13 @@ public class Api2OpenAsnEncoderV2 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()));
-
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
+
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -353,9 +361,11 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
}
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
+ asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setCompartmentDetails(encodeCompartmentDetails(document.getCompartmentDetails()));
@@ -394,7 +404,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setLoadingDeck(LoadingDeckType.valueOf(document.getLoadingDeck().name()));
}
- asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),0,999));
+ asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getLoadingListEntry(),0,999));
asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),0,6));
asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),0,9));
@@ -455,8 +465,10 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setCoach(UicEncoderUtils.getIA5(places.getCoach()));
asnData.setPlaceDescription(places.getPlaceDescription());
asnData.setPlaceString(UicEncoderUtils.getIA5(places.getPlaceString()));
- asnData.setPlaceNum(SequenceOfPlaceNum.getSequence(UicEncoderUtils.getNumList(places.getPlaces())));
- asnData.setPlaceIA5(UicEncoderUtils.getIA5NonNumList(places.getPlaces()));
+
+ NumListWrapper w = new NumListWrapper(places.getPlaces(),1,254);
+ asnData.setPlaceNum(SequenceOfPlaceNum.getSequence(w.getNumList()));
+ asnData.setPlaceIA5(w.getStringList());
return asnData;
}
@@ -483,9 +495,23 @@ public class Api2OpenAsnEncoderV2 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.
*
@@ -539,8 +565,12 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
ReservationData asnData = new ReservationData();
asnDocument.getTicket().setReservation(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getNum(document.getProductOwner()));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5NonNum(document.getProductOwner()));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -548,8 +578,9 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
if (document.getStationCodeTable() != IStationCodeTable.stationUICReservation && document.getStationCodeTable() != null){
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
@@ -599,6 +630,9 @@ public class Api2OpenAsnEncoderV2 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()));
@@ -689,12 +723,14 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
}
- asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setIncludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setIncludedCarriersIA5(w.getStringList());
- asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,9999)));
- asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,9999)));
+ asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
+ asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
+
asnData.setExcludedTransportTypes(SequenceOfTransportTypes.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedTransportTypes(),0,31)));
asnData.setIncludedTransportTypes(SequenceOfTransportTypes.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedTransportTypes(),0,31)));
@@ -716,6 +752,11 @@ public class Api2OpenAsnEncoderV2 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()));
}
@@ -862,8 +903,9 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setFromStationNameUTF8(document.getFromStationName());
asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -890,6 +932,11 @@ public class Api2OpenAsnEncoderV2 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()));
}
@@ -911,9 +958,12 @@ public class Api2OpenAsnEncoderV2 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);
}
@@ -950,6 +1000,8 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
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.setTicketReferenceNum(UicEncoderUtils.getNum(document.getTicketReference()));
asnData.setTicketReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getTicketReference()));
@@ -1002,8 +1054,9 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setFromStationNameUTF8(document.getFromStationName());
asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -1017,12 +1070,12 @@ public class Api2OpenAsnEncoderV2 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);
}
@@ -1087,14 +1140,19 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setBorder(false);
}
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
-
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
+
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;
}
@@ -1198,7 +1256,11 @@ public class Api2OpenAsnEncoderV2 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()));
+ if (asnData.getEdges() == null) {
+ asnData.setEdges(new SequenceOfDeltaCoordinates());
+ }
+ asnData.getEdges().add(delta);
}
}
@@ -1328,6 +1390,10 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
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.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1479,7 +1545,7 @@ public class Api2OpenAsnEncoderV2 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;
}
/**
@@ -1509,6 +1575,7 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
asnData.setInfoText(document.getInfoText());
+ asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setValidity(document.getValidFrom(), document.getValidUntil());
@@ -1552,11 +1619,13 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
- asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setIncludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
-
- asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getExcludedCarriers())));
- asnData.setExcludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getExcludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setIncludedCarriersIA5(w.getStringList());
+
+ w = new NumListWrapper(document.getExcludedCarriers(),1,32000);
+ asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setExcludedCarriersIA5(w.getStringList());
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
@@ -1636,7 +1705,10 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
TimeRangeType asnRange = new TimeRangeType();
asnRange.setFromTime(new Long(range.getFromTime()));
asnRange.setUntilTime(new Long(range.getUntilTime()));
-
+
+ if (asnData.getExcludedTimeRange() == null) {
+ asnData.setExcludedTimeRange(new SequenceOfTimeRangeType());
+ }
asnData.getExcludedTimeRange().add(asnRange);
}
}
@@ -1655,7 +1727,9 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
}
}
-
+ if (asnData.getValidityPeriod() == null) {
+ asnData.setValidityPeriod(new SequenceOfValidityPeriodType());
+ }
asnData.getValidityPeriod().add(asnRange);
}
}
@@ -1690,14 +1764,17 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
-
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
+
if (document.getClassCode() != null) {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
if (!document.isIncludesSupplements()){
asnData.setIncludesSupplements(false);
+ } else {
+ asnData.setIncludesSupplements(true);
}
asnData.setNumberOfTravelDays(UicEncoderUtils.getRestrictedInt(document.getNumberOfTravelDates(), 1, 8));
@@ -1937,27 +2014,10 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
for (ITicketLink ticket : linkedTickets){
- TicketLinkType asnTicket = new TicketLinkType();
-
- asnTicket.setIssuerName(ticket.getIssuer());
-
- asnTicket.setIssuerPNR(ticket.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()));
-
- if (ticket.getTicketType() != ITicketType.openTicket && ticket.getTicketType() != null){
- asnTicket.setTicketType(TicketType.valueOf(ticket.getTicketType().name()));
- }
-
- if (ticket.getLinkMode() != ILinkMode.issuedTogether && ticket.getLinkMode() != null){
- asnTicket.setLinkMode(LinkMode.valueOf(ticket.getLinkMode().name()));
+ TicketLinkType asnTicket = convert(ticket);
+ if (asnTicket != null) {
+ asnList.add(asnTicket);
}
-
- asnList.add(asnTicket);
}
if (asnList.isEmpty()) return null;
@@ -1965,6 +2025,35 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
return asnList;
}
+ private TicketLinkType convert(ITicketLink document) throws EncodingFormatException {
+
+ if (document == null) return null;
+
+ TicketLinkType asnData = new TicketLinkType();
+
+ asnData.setIssuerName(document.getIssuer());
+
+ asnData.setIssuerPNR(document.getIssuerPNR());
+
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,65535);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+
+ asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
+ asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
+
+ if (document.getTicketType() != ITicketType.openTicket && document.getTicketType() != null){
+ asnData.setTicketType(TicketType.valueOf(document.getTicketType().name()));
+ }
+
+ if (document.getLinkMode() != ILinkMode.issuedTogether && document.getLinkMode() != null){
+ asnData.setLinkMode(LinkMode.valueOf(document.getLinkMode().name()));
+ }
+
+ return asnData;
+ }
+
+
/**
* Encode travelers.
*
@@ -2065,6 +2154,12 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnData.setPointOfSale(encodeGeoCoordinate(data.getPointOfSale()));
}
+ asnData.setCurrency(data.getCurrency());
+
+ if (data.getCurrencyFraction() != null) {
+ asnData.setCurrencyFract(data.getCurrencyFraction().longValue());
+ }
+
return asnData;
}
@@ -2157,6 +2252,8 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder {
asnCustomerCard.setIncludedServices(SequenceOfUnrestrictedLong.getSequence(UicEncoderUtils.getUnRestrictedIntList(document.getIncludedServices())));
asnCustomerCard.setValidity(document.getValidFrom(), document.getValidUntil());
+
+ asnCustomerCard.setExtension(encodeExtension(document.getExtension()));
return asnDocument;
}
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 fd9995f..e3a6430 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
@@ -351,11 +351,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setTrainIA5(UicEncoderUtils.getIA5NonNum(document.getTrain()));
asnData.setTrainNum(UicEncoderUtils.getNum(document.getTrain()));
- 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));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -364,8 +365,9 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
}
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
@@ -467,8 +469,10 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setCoach(UicEncoderUtils.getIA5(places.getCoach()));
asnData.setPlaceDescription(places.getPlaceDescription());
asnData.setPlaceString(UicEncoderUtils.getIA5(places.getPlaceString()));
- asnData.setPlaceNum(SequenceOfPlaceNum.getSequence(UicEncoderUtils.getNumList(places.getPlaces())));
- asnData.setPlaceIA5(UicEncoderUtils.getIA5NonNumList(places.getPlaces()));
+
+ NumListWrapper w = new NumListWrapper(places.getPlaces(),1,254);
+ asnData.setPlaceNum(SequenceOfPlaceNum.getSequence(w.getNumList()));
+ asnData.setPlaceIA5(w.getStringList());
return asnData;
}
@@ -565,20 +569,22 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
ReservationData asnData = new ReservationData();
asnDocument.getTicket().setReservation(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
- 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()));
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
if (document.getStationCodeTable() != IStationCodeTable.stationUICReservation && document.getStationCodeTable() != null){
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
@@ -708,12 +714,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
IncludedOpenTicketType asnData = new IncludedOpenTicketType();
- 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));
-
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
@@ -722,11 +728,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setStationCodeTable(CodeTableType.valueOf(document.getStationCodeTable().name()));
}
- asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setIncludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setIncludedCarriersIA5(w.getStringList());
- asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,9999)));
- asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,9999)));
+ asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
+ asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
asnData.setExcludedTransportTypes(SequenceOfTransportTypes.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedTransportTypes(),0,31)));
asnData.setIncludedTransportTypes(SequenceOfTransportTypes.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedTransportTypes(),0,31)));
@@ -877,12 +884,13 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnDocument.setTicket(asnTicket);
asnTicket.setOpenTicket(asnData);
- asnData.setProductOwnerNum(UicEncoderUtils.getRestrictedNum(document.getProductOwner(),1,32000));
- asnData.setProductOwnerIA5(UicEncoderUtils.getIA5RestrictedNonNum(document.getProductOwner(),1,32000));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
- 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()));
@@ -902,8 +910,9 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setFromStationNameUTF8(document.getFromStationName());
asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -995,12 +1004,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
CountermarkData asnData = new CountermarkData();
asnDocument.getTicket().setCounterMark(asnData);
- 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));
-
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setTicketReferenceNum(UicEncoderUtils.getNum(document.getTicketReference()));
asnData.setTicketReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getTicketReference()));
@@ -1054,8 +1063,9 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setFromStationNameUTF8(document.getFromStationName());
asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -1138,9 +1148,10 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setBorder(false);
}
- asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
-
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarriersIA5(w.getStringList());
+
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -1384,11 +1395,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
ParkingGroundData asnData = new ParkingGroundData();
asnDocument.getTicket().setParkingGround(asnData);
- 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));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1560,11 +1572,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
VoucherData asnData = new VoucherData();
asnDocument.getTicket().setVoucher(asnData);
- 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));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1602,11 +1615,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
PassData asnData = new PassData();
asnDocument.getTicket().setPass(asnData);
- 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));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -1614,11 +1628,13 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
- asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setIncludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
-
- asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getExcludedCarriers())));
- asnData.setExcludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getExcludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setIncludedCarriersIA5(w.getStringList());
+
+ w = new NumListWrapper(document.getExcludedCarriers(),1,32000);
+ asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setExcludedCarriersIA5(w.getStringList());
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
@@ -1692,11 +1708,13 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
}
}
- asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getIncludedCarriers())));
- asnData.setIncludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getIncludedCarriers()));
+ NumListWrapper w = new NumListWrapper(document.getIncludedCarriers(),1,32000);
+ asnData.setIncludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setIncludedCarriersIA5(w.getStringList());
- asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getExcludedCarriers())));
- asnData.setExcludedCarriersIA5(UicEncoderUtils.getIA5NonNumList(document.getExcludedCarriers()));
+ w = new NumListWrapper(document.getExcludedCarriers(),1,32000);
+ asnData.setExcludedCarriersNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setExcludedCarriersIA5(w.getStringList());
asnData.setExcludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getExcludedServiceBrands(),1,32000)));
asnData.setIncludedServiceBrands(SequenceOfServiceBrands.getSequence(UicEncoderUtils.encodeRestrictedIntegerCollection(document.getIncludedServiceBrands(),1,32000)));
@@ -1782,18 +1800,20 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
FIPTicketData asnData = new FIPTicketData();
asnDocument.getTicket().setFipTicket(asnData);
- 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));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
- asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
- asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
-
+ NumListWrapper w = new NumListWrapper(document.getCarriers(),1,32000);
+ asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(w.getNumList()));
+ asnData.setCarrierIA5(w.getStringList());
+
if (document.getClassCode() != null) {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
@@ -1829,11 +1849,12 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
StationPassageData asnData = new StationPassageData();
asnDocument.getTicket().setStationPassage(asnData);
- 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));
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,32000);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+ wn = new NumWrapper(document.getProductId(),0,65535);
+ asnData.setProductIdNum(wn.getNumber());
+ asnData.setProductIdIA5(wn.getString());
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -2038,27 +2059,11 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
for (ITicketLink document : linkedTickets){
- TicketLinkType asnData = new TicketLinkType();
+ TicketLinkType asnData = convert(document);
- asnData.setIssuerName(document.getIssuer());
-
- asnData.setIssuerPNR(document.getIssuerPNR());
-
- 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 (document.getTicketType() != ITicketType.openTicket && document.getTicketType() != null){
- asnData.setTicketType(TicketType.valueOf(document.getTicketType().name()));
- }
-
- if (document.getLinkMode() != ILinkMode.issuedTogether && document.getLinkMode() != null){
- asnData.setLinkMode(LinkMode.valueOf(document.getLinkMode().name()));
+ if (asnData != null) {
+ asnList.add(asnData);
}
-
- asnList.add(asnData);
}
if (asnList.isEmpty()) return null;
@@ -2066,6 +2071,35 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder {
return asnList;
}
+ private TicketLinkType convert(ITicketLink document) throws EncodingFormatException {
+
+ if (document == null) return null;
+
+ TicketLinkType asnData = new TicketLinkType();
+
+ asnData.setIssuerName(document.getIssuer());
+
+ asnData.setIssuerPNR(document.getIssuerPNR());
+
+ NumWrapper wn = new NumWrapper(document.getProductOwner(),1,65535);
+ asnData.setProductOwnerNum(wn.getNumber());
+ asnData.setProductOwnerIA5(wn.getString());
+
+ asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
+ asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
+
+ if (document.getTicketType() != ITicketType.openTicket && document.getTicketType() != null){
+ asnData.setTicketType(TicketType.valueOf(document.getTicketType().name()));
+ }
+
+ if (document.getLinkMode() != ILinkMode.issuedTogether && document.getLinkMode() != null){
+ asnData.setLinkMode(LinkMode.valueOf(document.getLinkMode().name()));
+ }
+
+ return asnData;
+ }
+
+
/**
* Encode travelers.
*
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/NumListWrapper.java b/src/main/java/org/uic/barcode/ticket/api/utils/NumListWrapper.java
new file mode 100644
index 0000000..4d48a81
--- /dev/null
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/NumListWrapper.java
@@ -0,0 +1,55 @@
+package org.uic.barcode.ticket.api.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.EncodingFormatException;
+
+public class NumListWrapper {
+
+ private SequenceOfStringIA5 stringList = null;
+ private List<Long> numList = null;
+
+ public NumListWrapper(Collection<String> list, int min, int max) throws EncodingFormatException {
+
+
+ if (list== null || list.isEmpty()) {
+ return;
+ }
+
+ for (String text : list){
+ String ia5 = UicEncoderUtils.getIA5RestrictedNonNum (text,min,max);
+ if (ia5 != null && ia5.length() > 0) {
+ if (stringList == null) {
+ stringList = new SequenceOfStringIA5();
+ }
+ stringList.add(ia5);
+ } else {
+ Long l = UicEncoderUtils.getRestrictedNum (text,min,max);
+ if (l != null) {
+ if (numList == null) {
+ numList = new ArrayList<Long>();
+ }
+ numList.add(l);
+ }
+ }
+
+ }
+ return;
+
+ }
+
+ public SequenceOfStringIA5 getStringList() {
+ return stringList;
+ }
+
+ public List<Long> getNumList() {
+ return numList;
+ }
+
+
+
+
+}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java b/src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java
new file mode 100644
index 0000000..2adcdf2
--- /dev/null
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/NumWrapper.java
@@ -0,0 +1,36 @@
+package org.uic.barcode.ticket.api.utils;
+
+import org.uic.barcode.ticket.EncodingFormatException;
+
+public class NumWrapper {
+
+ private String ia5string = null;
+ private Long number = null;
+
+ public NumWrapper(String string, int min, int max) throws EncodingFormatException {
+
+
+ if (string == null || string.isEmpty()) {
+ return;
+ }
+
+ ia5string = UicEncoderUtils.getIA5RestrictedNonNum (string,min,max);
+ if (ia5string == null || ia5string.length() == 0) {
+ number = UicEncoderUtils.getRestrictedNum (string,min,max);
+ }
+ if (ia5string != null && ia5string.length() == 0) {
+ ia5string = null;
+ }
+ return;
+
+ }
+
+ public String getString() {
+ return ia5string;
+ }
+
+ public Long getNumber() {
+ return number;
+ }
+
+}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
index 1f8e25b..70017aa 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
@@ -5,6 +5,7 @@ package org.uic.barcode.ticket.api.utils;
import java.io.IOException;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import org.uic.barcode.ticket.api.asn.omv2.BerthDetailData;
@@ -51,6 +52,7 @@ import org.uic.barcode.ticket.api.asn.omv2.VatDetailType;
import org.uic.barcode.ticket.api.asn.omv2.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv2.VoucherData;
import org.uic.barcode.ticket.api.asn.omv2.ZoneType;
+import org.uic.barcode.ticket.api.asn.omv2.ServiceType;
import org.uic.barcode.ticket.api.impl.SimpleUicTicketObjectFactory;
import org.uic.barcode.ticket.api.spec.IBerth;
import org.uic.barcode.ticket.api.spec.IBerthTypeType;
@@ -94,6 +96,7 @@ import org.uic.barcode.ticket.api.spec.IRoofRackType;
import org.uic.barcode.ticket.api.spec.IRouteSection;
import org.uic.barcode.ticket.api.spec.ISeriesDataDetails;
import org.uic.barcode.ticket.api.spec.IServiceBrand;
+import org.uic.barcode.ticket.api.spec.IServiceType;
import org.uic.barcode.ticket.api.spec.IStationCodeTable;
import org.uic.barcode.ticket.api.spec.IStationPassage;
import org.uic.barcode.ticket.api.spec.ITariff;
@@ -438,6 +441,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setArrivalUTCoffset(asnDocument.getDepartureUTCOffset());
}
+ if (asnDocument.getService() != null) {
+ document.setService(convert(asnDocument.getService()));
+ }
+
if(asnDocument.getClassCode()!=null){
document.setClassCode(ITravelClassType.valueOf(asnDocument.getClassCode().name()));
}
@@ -457,6 +464,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
if (asnDocument.getPlaces()!=null) {
document.setPlaces(convertPlaces(asnDocument.getPlaces()));
}
+
+ if (asnDocument.getAdditionalPlaces()!=null) {
+ document.setAdditionalPlaces(convertPlaces(asnDocument.getAdditionalPlaces()));
+ }
if (asnDocument.getBicyclePlaces()!=null) {
document.setBicyclePlaces(convertPlaces(asnDocument.getBicyclePlaces()));
@@ -518,7 +529,20 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
return document;
}
-
+ private IServiceType convert(ServiceType service) {
+
+ if (service == null) {
+ return null;
+ } else if (service.equals(ServiceType.seat)) {
+ return IServiceType.seat;
+ } else if (service.equals(ServiceType.couchette)) {
+ return IServiceType.couchette;
+ } else if (service.equals(ServiceType.berth)) {
+ return IServiceType.berth;
+ }
+
+ return null;
+ }
@@ -703,7 +727,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
details.setCompartmentTypeDescr(asnDetails.getCompartmentTypeDescr());
details.setSpecialAllocationDescr(asnDetails.getSpecialAllocationDescr());
- details.setPosition(ICompartmentPositionType.valueOf(asnDetails.getPosition().name()));
+ if (asnDetails.getPosition() != null) {
+ details.setPosition(ICompartmentPositionType.valueOf(asnDetails.getPosition().name()));
+ }
return details;
}
@@ -799,6 +825,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setReference(UicEncoderUtils.mapToString(asnDocument.getReferenceNum(),asnDocument.getReferenceIA5()));
document.setTicketReference(UicEncoderUtils.mapToString(asnDocument.getTicketReferenceNum(),asnDocument.getTicketReferenceIA5()));
+ if (asnDocument.getStationCodeTable()!=null){
+ document.setStationCodeTable(IStationCodeTable.valueOf(asnDocument.getStationCodeTable().name()));
+ }
+
document.setFromStation(UicEncoderUtils.mapToString(asnDocument.getFromStationNum(),asnDocument.getFromStationIA5()));
document.setToStation(UicEncoderUtils.mapToString(asnDocument.getToStationNum(),asnDocument.getToStationIA5()));
@@ -812,6 +842,29 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
}
}
+ if (asnDocument.getCarriersNum()!=null && !asnDocument.getCarriersNum().isEmpty()){
+ for(Long carrier :asnDocument.getCarriersNum()){
+ document.addIncludedCarrier(carrier.toString());
+ }
+ }
+ if (asnDocument.getCarriersIA5()!=null && !asnDocument.getCarriersIA5().isEmpty()){
+ for(String carrier :asnDocument.getCarriersIA5()){
+ document.addIncludedCarrier(carrier);
+ }
+ }
+
+ if (asnDocument.getIncludedServiceBrands()!=null && !asnDocument.getIncludedServiceBrands().isEmpty()){
+ for(Long number :asnDocument.getIncludedServiceBrands()){
+ document.addIncludedServiceBrand(number.intValue());
+ }
+ }
+
+ if (asnDocument.getExcludedServiceBrands()!=null && !asnDocument.getExcludedServiceBrands().isEmpty()){
+ for(Long number :asnDocument.getExcludedServiceBrands()){
+ document.addExcludedServiceBrand(number.intValue());
+ }
+ }
+
document.setReturnDescription(convertReturnDescription(asnDocument.getReturnDescription(), issuingDate));
@@ -934,6 +987,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setClassCode(ITravelClassType.valueOf(asnDocument.getClassCode().name()));
}
+ if (asnDocument.getServiceLevel()!=null && asnDocument.getServiceLevel().length() != 0) {
+ document.setServiceLevel(asnDocument.getServiceLevel());
+ }
+
document.setValidFrom(asnDocument.getValidFromDate(issuingDate));
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
@@ -1074,6 +1131,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setClassCode(classCode);
}
+ if (asnDocument.getServiceLevel() != null && asnDocument.getServiceLevel().length() > 0) {
+ document.setServiceLevel(asnDocument.getServiceLevel());
+ }
+
document.setValidFrom(asnDocument.getValidFromDate(issuingDate));
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
@@ -1201,9 +1262,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setProductName(asnDocument.getProductName());
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
- if (asnDocument.getStationNameUTF8()!= null && asnDocument.getStationNameUTF8().isEmpty() ) {
+ if (asnDocument.getStationNameUTF8()!= null && !asnDocument.getStationNameUTF8().isEmpty() ) {
for (String name : asnDocument.getStationNameUTF8()) {
- document.addStation(name);
+ document.addStationName(name);
}
}
@@ -1364,11 +1425,16 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
via.addRouteStation(convertViaStation(routeVia));
}
}
+
if (asnDocument.getAlternativeRoutes()!= null && !asnDocument.getAlternativeRoutes().isEmpty()) {
for ( ViaStationType routeVia: asnDocument.getAlternativeRoutes()) {
- via.addRouteStation(convertViaStation(routeVia));
+ via.getAlternativeRoutes().add(convertViaStation(routeVia));
}
}
+
+ if (asnDocument.getSeriesId() != null) {
+ via.setSeriesId(asnDocument.getSeriesId().intValue());
+ }
return via;
@@ -1409,7 +1475,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
IZone zone = factory.createZone();
- zone.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ if (asnDocument.getBinaryZoneId() != null && asnDocument.getBinaryZoneId().length > 0) {
+ zone.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ }
zone.setCarrier(UicEncoderUtils.mapToString(asnDocument.getCarrierNum(),asnDocument.getCarrierIA5()));
if (asnDocument.getCity() != null) {
@@ -1423,6 +1491,13 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
zone.setNUTScode(asnDocument.getNutsCode());
+ if (asnDocument.getZoneId() != null && !asnDocument.getZoneId().isEmpty()) {
+ Iterator<Long> it = asnDocument.getZoneId().iterator();
+ while (it.hasNext()) {
+ zone.addZoneId(it.next().intValue());
+ }
+ }
+
return zone;
}
@@ -1440,8 +1515,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
IGeoCoordinate firstEdge = convertGeoCoordinate(asnPolygone.getFirstEdge());
+
if (firstEdge == null) return null;
-
+ polygone.addEdge(firstEdge);
+
if (asnPolygone.getEdges()!=null && !asnPolygone.getEdges().isEmpty()) {
for (DeltaCoordinates asnEdge :asnPolygone.getEdges()){
@@ -1470,7 +1547,10 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
ILine line = factory.createLine();
- line.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ if (asnDocument.getBinaryZoneId() != null && asnDocument.getBinaryZoneId().length > 0) {
+ line.setBinaryZoneId(asnDocument.getBinaryZoneId());
+ }
+
line.setCarrier(UicEncoderUtils.mapToString(asnDocument.getCarrierNum(),asnDocument.getCarrierIA5()));
if (asnDocument.getCity()!=null) {
line.setCity(asnDocument.getCity().intValue());
@@ -1621,6 +1701,17 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
document.setReference(UicEncoderUtils.mapToString(asnDocument.getReferenceNum(),asnDocument.getReferenceIA5()));
+ if (asnDocument.getCarrierNum()!=null && !asnDocument.getCarrierNum().isEmpty()){
+ for(Long carrier :asnDocument.getCarrierNum()){
+ document.addCarrier(carrier.toString());
+ }
+ }
+ if (asnDocument.getCarrierIA5()!=null && !asnDocument.getCarrierIA5().isEmpty()){
+ for(String carrier :asnDocument.getCarrierIA5()){
+ document.addCarrier(carrier);
+ }
+ }
+
if (asnDocument.getActivatedDay() != null && !asnDocument.getActivatedDay().isEmpty()) {
document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
}
@@ -1673,6 +1764,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
if (asnDocument.getNumberOfDaysOfTravel() != null) {
document.setNumberOfDaysOfTravel(asnDocument.getNumberOfDaysOfTravel().intValue());
}
+ if (asnDocument.getNumberOfValidityDays() != null) {
+ document.setNumberOfValidityDays(asnDocument.getNumberOfValidityDays().intValue());
+ }
if (asnDocument.getNumberOfPossibleTrips() != null) {
document.setNumberOfPossibleTrips(asnDocument.getNumberOfPossibleTrips().intValue());
}
@@ -1884,6 +1978,9 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
card.addIncludedService(new Integer(service.intValue()));
}
}
+
+ card.setExtension(convertExtension(asnDocument.getExtension()));
+
return card;
}
@@ -2138,6 +2235,11 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder {
issuingDetail.setPointOfSale(convertGeoCoordinate(asnIssuingDetail.getPointOfSale()));
}
+ issuingDetail.setCurrency(asnIssuingDetail.getCurrency());
+
+ if (asnIssuingDetail.getCurrencyFract() != null) {
+ issuingDetail.setCurrencyFraction(asnIssuingDetail.getCurrencyFract().intValue());
+ }
}
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 f5eb15c..261b7ac 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
@@ -217,7 +217,7 @@ public class UicEncoderUtils {
}
/**
- * Gets the num list.
+ * Gets the list of all numeric strings.
*
* @param list the list
* @return the num list
@@ -244,9 +244,10 @@ public class UicEncoderUtils {
return numList;
}
+
/**
- * Gets the i a5 non num list.
+ * Gets the IA5 string list of all elements that are not nmeric.
*
* @param list the list
* @return the i a5 non num list
@@ -274,8 +275,7 @@ public class UicEncoderUtils {
return ia5List;
}
-
-
+
/**
* Gets the i a5.
@@ -443,34 +443,6 @@ public class UicEncoderUtils {
return list;
}
- /**
- * Gets the restricted int list.
- *
- * @param intList the int list
- * @param min the min
- * @param max the max
- * @return the restricted int list
- * @throws EncodingFormatException the encoding format exception
- */
- public static List<Integer> getRestrictedIntList( Collection<Integer> intList, int min, int max) throws EncodingFormatException {
- if (intList == null || intList.isEmpty()) return null;
-
- ArrayList<Integer> list = new ArrayList<Integer>();
-
- for (Integer i : intList){
- if (i != 0){
-
- if (i < min || i > max){
- throw new EncodingFormatException("Integer value exceeds boundaries");
- }
-
- list.add(i);
- }
- }
-
- if (list.isEmpty()) return null;
- return list;
- }
/**
* Encode restricted integer collection.