summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-13 17:48:04 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-13 17:48:04 +0200
commit4204b79b6fd1f783ac8c5282ea46d50b88cd0355 (patch)
treed96492a7b1958f9822cd994c86d0b0a9f3c6c59f /src/main/java
parentcomplete test for v3 fcb elements (diff)
downloadUIC-barcode-4204b79b6fd1f783ac8c5282ea46d50b88cd0355.tar
UIC-barcode-4204b79b6fd1f783ac8c5282ea46d50b88cd0355.tar.gz
UIC-barcode-4204b79b6fd1f783ac8c5282ea46d50b88cd0355.tar.bz2
UIC-barcode-4204b79b6fd1f783ac8c5282ea46d50b88cd0355.tar.lz
UIC-barcode-4204b79b6fd1f783ac8c5282ea46d50b88cd0355.tar.xz
UIC-barcode-4204b79b6fd1f783ac8c5282ea46d50b88cd0355.tar.zst
UIC-barcode-4204b79b6fd1f783ac8c5282ea46d50b88cd0355.zip
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/asn/omv1/LineType.java14
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java20
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/Asn2ApiDecoder.java3
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java36
4 files changed, 61 insertions, 12 deletions
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LineType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LineType.java
index 290f0e6..eb9249a 100644
--- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LineType.java
+++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LineType.java
@@ -127,8 +127,11 @@ public class LineType extends Object {
}
public byte[] getBinaryZoneId() {
-
- return binaryZoneId.toByteArray();
+ if (binaryZoneId != null) {
+ 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/utils/Api2OpenAsnEncoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
index 835a324..6cf1673 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
@@ -352,7 +352,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
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));
+
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -564,6 +567,9 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
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));
asnData.setReferenceNum(UicEncoderUtils.getNum(document.getReference()));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -983,6 +989,8 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
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));
asnData.setTicketReferenceNum(UicEncoderUtils.getNum(document.getTicketReference()));
asnData.setTicketReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getTicketReference()));
@@ -1366,6 +1374,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder {
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));
+
+
asnData.setReferenceNum(Asn1BigInteger.toAsn1(UicEncoderUtils.getNum(document.getReference())));
asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
@@ -2110,6 +2122,12 @@ public class Api2OpenAsnEncoder 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/Asn2ApiDecoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/Asn2ApiDecoder.java
index e751f48..79acf75 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/Asn2ApiDecoder.java
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/Asn2ApiDecoder.java
@@ -2,12 +2,13 @@ package org.uic.barcode.ticket.api.utils;
import java.io.IOException;
+import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
public interface Asn2ApiDecoder {
- public IUicRailTicket decodeFromAsn (byte[] data) throws IOException;
+ public IUicRailTicket decodeFromAsn (byte[] data) throws IOException, EncodingFormatException;
}
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 5f5ce4d..4cccb18 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
@@ -8,6 +8,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import org.uic.barcode.ticket.EncodingFormatException;
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;
@@ -132,8 +133,9 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
* @param asnUicRailTicketData the asn uic rail ticket data
* @return the decoded uic rail ticket
* @throws IOException Signals that an I/O exception has occurred.
+ * @throws EncodingFormatException
*/
- public IUicRailTicket decodeFromAsn (UicRailTicketData asnUicRailTicketData) throws IOException{
+ public IUicRailTicket decodeFromAsn (UicRailTicketData asnUicRailTicketData) throws IOException, EncodingFormatException{
IUicRailTicket uicRailTicket = factory.createUicRailTicket();
@@ -149,8 +151,9 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
* @param data byte array of the asn.1 encoded FCB data
* @return the decoded uic rail ticket
* @throws IOException Signals that an I/O exception has occurred.
+ * @throws EncodingFormatException
*/
- public IUicRailTicket decodeFromAsn (byte[] data) throws IOException{
+ public IUicRailTicket decodeFromAsn (byte[] data) throws IOException, EncodingFormatException{
UicRailTicketData asnUicRailTicketData = UicRailTicketData.decode(data);
@@ -171,8 +174,9 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
*
* @param uicRailTicket the uic rail ticket
* @param asnUicRailTicketData the asn uic rail ticket data
+ * @throws EncodingFormatException
*/
- protected void populateFromAsn1Model(IUicRailTicket uicRailTicket, UicRailTicketData asnUicRailTicketData) {
+ protected void populateFromAsn1Model(IUicRailTicket uicRailTicket, UicRailTicketData asnUicRailTicketData) throws EncodingFormatException {
if (asnUicRailTicketData.getExtension()!= null && !asnUicRailTicketData.getExtension().isEmpty()) {
for (ExtensionData asnExtension : asnUicRailTicketData.getExtension()){
@@ -215,8 +219,9 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
* @param asnTransportDocuments the asn transport documents
* @param uicRailTicket the uic rail ticket
* @param issuingDate the issuing date
+ * @throws EncodingFormatException
*/
- protected void populateTravelDocuments(List<DocumentData> asnTransportDocuments,IUicRailTicket uicRailTicket, Date issuingDate) {
+ protected void populateTravelDocuments(List<DocumentData> asnTransportDocuments,IUicRailTicket uicRailTicket, Date issuingDate) throws EncodingFormatException {
for ( DocumentData asnDocument : asnTransportDocuments){
@@ -1658,12 +1663,15 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
* @param asnDocument the asn document
* @param issuingDate the issuing date
* @return the i fip ticket
+ * @throws EncodingFormatException
*/
- protected IFipTicket convertFipTicket(FIPTicketData asnDocument , Date issuingDate) {
+ protected IFipTicket convertFipTicket(FIPTicketData asnDocument , Date issuingDate) throws EncodingFormatException {
if (asnDocument == null) return null;
IFipTicket document = factory.createFipTicket();
+
+
if(asnDocument.getClassCode()!=null){
document.setClassCode(ITravelClassType.valueOf(asnDocument.getClassCode().name()));
}
@@ -1671,7 +1679,16 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
document.setValidFrom(asnDocument.getValidFromDate(issuingDate));
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
-
+ 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);
+ }
+ }
document.setProductId(UicEncoderUtils.mapToString(asnDocument.getProductIdNum(),asnDocument.getProductIdIA5()));
document.setProductOwner(UicEncoderUtils.mapToString(asnDocument.getProductOwnerNum(),asnDocument.getProductOwnerIA5()));
@@ -2200,6 +2217,13 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder {
issuingDetail.setPointOfSale(convertGeoCoordinate(asnIssuingDetail.getPointOfSale()));
}
+
+ issuingDetail.setCurrency(asnIssuingDetail.getCurrency());
+
+ if (asnIssuingDetail.getCurrencyFract() != null) {
+ issuingDetail.setCurrencyFraction(asnIssuingDetail.getCurrencyFract().intValue());
+ }
+
}