diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2022-04-13 17:57:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-13 17:57:16 +0200 |
commit | 7a5f15e2b958dca771b83594669401be2b84f2b6 (patch) | |
tree | d96492a7b1958f9822cd994c86d0b0a9f3c6c59f /src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java | |
parent | Merge pull request #45 from UnionInternationalCheminsdeFer/1.3.1 (diff) | |
parent | unit test for fcb version 1 including all elements (diff) | |
download | UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.gz UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.bz2 UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.lz UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.xz UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.zst UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java | 112 |
1 files changed, 89 insertions, 23 deletions
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 f4b9569..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 @@ -18,6 +18,7 @@ import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType; import org.uic.barcode.ticket.api.asn.omv1.CodeTableType;
import org.uic.barcode.ticket.api.asn.omv1.CompartmentDetailsType;
import org.uic.barcode.ticket.api.asn.omv1.CompartmentGenderType;
+import org.uic.barcode.ticket.api.asn.omv1.CompartmentPositionType;
import org.uic.barcode.ticket.api.asn.omv1.ConfirmationTypeType;
import org.uic.barcode.ticket.api.asn.omv1.ControlData;
import org.uic.barcode.ticket.api.asn.omv1.CountermarkData;
@@ -91,11 +92,14 @@ import org.uic.barcode.ticket.api.asn.omv1.VatDetailType; import org.uic.barcode.ticket.api.asn.omv1.ViaStationType;
import org.uic.barcode.ticket.api.asn.omv1.VoucherData;
import org.uic.barcode.ticket.api.asn.omv1.ZoneType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfValidityPeriodType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTimeRangeType;
import org.uic.barcode.ticket.api.spec.IBerth;
import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
import org.uic.barcode.ticket.api.spec.ICardReference;
import org.uic.barcode.ticket.api.spec.ICompartmentDetails;
import org.uic.barcode.ticket.api.spec.ICompartmentGenderType;
+import org.uic.barcode.ticket.api.spec.ICompartmentPositionType;
import org.uic.barcode.ticket.api.spec.IControlDetail;
import org.uic.barcode.ticket.api.spec.ICounterMark;
import org.uic.barcode.ticket.api.spec.ICustomerCard;
@@ -348,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()));
@@ -359,6 +366,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setCompartmentDetails(encodeCompartmentDetails(document.getCompartmentDetails()));
@@ -389,21 +397,20 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),1,5));
- asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),1,2));
- asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,5));
+ asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),0,4));
+ asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),0,2));
+ asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),0,5));
if (document.getLoadingDeck() != ILoadingDeckType.upper && document.getLoadingDeck() != null){
asnData.setLoadingDeck(LoadingDeckType.valueOf(document.getLoadingDeck().name()));
}
- asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,200));
-
- asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),1,6));
- asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),1,9));
+ asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getLoadingListEntry(),0,999));
+ asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),0,6));
+ asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),0,9));
asnData.setCoach(UicEncoderUtils.getIA5(document.getCoach()));
- asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),1,99));
+ asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),0,99));
if (document.getRoofRackType()!= IRoofRackType.norack && document.getRoofRackType() != null ) {
asnData.setRoofRackType(RoofRackType.valueOf(document.getRoofRackType().name()));
@@ -486,9 +493,25 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setSpecialAllocation(UicEncoderUtils.getRestrictedInt(compartmentDetails.getSpecialAllocation(), 1,99));
asnData.setSpecialAllocationDescr(compartmentDetails.getSpecialAllocationDescr());
+ asnData.setPosition(convert(compartmentDetails.getPosition()));
return asnData;
}
+ private CompartmentPositionType convert(ICompartmentPositionType position) {
+ if (position == null) {
+ return null;
+ } else if (position.equals(ICompartmentPositionType.lowerLevel)) {
+ return CompartmentPositionType.lowerLevel;
+ } else if (position.equals(ICompartmentPositionType.upperLevel)) {
+ return CompartmentPositionType.upperLevel;
+ } else if (position.equals(ICompartmentPositionType.unspecified)) {
+ return CompartmentPositionType.unspecified;
+ }
+ return null;
+ }
+
+
+
/**
* Encode berths.
*
@@ -544,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()));
@@ -602,6 +628,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setTypeOfSupplement(UicEncoderUtils.getRestrictedInt(document.getTypeOfSupplement(), 1, 9));
asnData.setPlaces(encodePlaces(document.getPlaces()));
+
+ if (document.getAdditionalPlaces() != null) {
+ asnData.setAdditionalPlaces(encodePlaces(document.getAdditionalPlaces()));
+ }
asnData.setBicyclePlaces(encodePlaces(document.getBicyclePlaces()));
@@ -715,6 +745,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { if (document.getClassCode() != classCode){
asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
+
+ if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ asnData.setServiceLevel(document.getServiceLevel());
+ }
+
if (document.getExternalIssuer() > 0) {
asnData.setExternalIssuerId(new Long(document.getExternalIssuer()));
}
@@ -886,6 +921,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { if (document.getClassCode() != ITravelClassType.second){
asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
+
+ if (document.getServiceLevel() != null && document.getServiceLevel().length() > 0) {
+ asnData.setServiceLevel(document.getServiceLevel());
+ }
+
if (document.getExternalIssuer()>0) {
asnData.setExtIssuerId(new Long(document.getExternalIssuer()));
}
@@ -906,10 +946,13 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { if (document.getLuggageRestriction() != null) {
asnData.setLuggage(encodeLuggage(document.getLuggageRestriction()));
}
+
+ if (document.getReturnDescription() != null) {
+ asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
+ }
if (document.isReturnIncluded()) {
asnData.setReturnIncluded(true);
- asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
} else {
asnData.setReturnIncluded(false);
}
@@ -946,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()));
@@ -1013,12 +1058,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setClassCode(convertTravelClass(document.getClassCode()));
}
-
+ if (document.getReturnDescription()!= null) {
+ asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
+ }
if (document.isReturnIncluded()) {
asnData.setReturnIncluded(true);
- if (document.getReturnDescription()!= null) {
- asnData.setReturnDescription(encodeReturnDescription(document.getReturnDescription(),issuingDate));
- }
} else {
asnData.setReturnIncluded(false);
}
@@ -1089,8 +1133,13 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setRoute(encodeViaStationCollection(document.getRoute()));
if (document.getRouteId() > 0){
- asnData.setSeriesId(new Long(document.getRouteId()));
+ asnData.setRouteId(new Long(document.getRouteId()));
}
+
+ if (document.getSeriesId() > 0) {
+ asnData.setSeriesId(new Long(document.getSeriesId()));
+ }
+
return asnData;
}
@@ -1194,7 +1243,8 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { } else {
DeltaCoordinates delta = new DeltaCoordinates();
delta.setLatitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLatitude() - edge.getLatitude()));
- delta.setLatitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLongitude() - edge.getLongitude()));
+ delta.setLongitude(Asn1BigInteger.toAsn1(asnData.getFirstEdge().getLongitude() - edge.getLongitude()));
+ asnList.add(delta);
}
}
@@ -1324,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()));
@@ -1475,7 +1529,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { details.setSeries(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getSeries(), 1, 99999));
details.setSupplyingCarrier(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getSupplyingCarrier(), 1, 9999));
details.setOfferIdentification(UicEncoderUtils.getRestrictedInt(seriesDataDetails.getOfferIdentification(), 1, 99));
- return null;
+ return details;
}
/**
@@ -1505,6 +1559,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setReferenceIA5(UicEncoderUtils.getIA5NonNum(document.getReference()));
asnData.setInfoText(document.getInfoText());
+ asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setValidity(document.getValidFrom(), document.getValidUntil());
@@ -1620,7 +1675,10 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { ValidityPeriodDetailType asnData = new ValidityPeriodDetailType();
- if (validityDetails.getTimeRanges() != null) {
+ if (validityDetails.getTimeRanges() != null && !validityDetails.getTimeRanges().isEmpty()) {
+
+ asnData.setExcludedTimeRange(new SequenceOfTimeRangeType());
+
for (ITimeRange range : validityDetails.getTimeRanges()) {
if (range.getFromTime() == range.getUntilTime()){
@@ -1635,8 +1693,11 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { }
}
- if (validityDetails.getValidityRanges() != null) {
- for (IValidityRange range : validityDetails.getValidityRanges()) {
+ if (validityDetails.getValidityRanges() != null && !validityDetails.getValidityRanges().isEmpty()) {
+
+ asnData.setValidityPeriod(new SequenceOfValidityPeriodType());
+
+ for (IValidityRange range : validityDetails.getValidityRanges()) {
ValidityPeriodType asnRange = new ValidityPeriodType();
@@ -1689,9 +1750,8 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setClassCode(convertTravelClass(document.getClassCode()));
- if (!document.isIncludesSupplements()){
- asnData.setIncludesSupplements(false);
- }
+ asnData.setIncludesSupplements(document.isIncludesSupplements());
+
asnData.setNumberOfTravelDays(UicEncoderUtils.getRestrictedInt(document.getNumberOfTravelDates(), 1, 8));
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
@@ -2062,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;
}
|