From 873aefed488c0a528db93e9243df8496d4d35970 Mon Sep 17 00:00:00 2001 From: preetamnpr <128618622+preetamnpr@users.noreply.github.com> Date: Tue, 14 May 2024 18:21:44 +0200 Subject: [PATCH 1/2] DT-798 added minimum shipper request fields --- .../booking/checks/BookingChecks.java | 73 +++++++++++++------ .../messages/booking-api-2.0.0-dg.json | 4 + .../booking-api-2.0.0-reefer-temp-change.json | 4 + .../messages/booking-api-2.0.0-reefer.json | 3 + .../booking-api-2.0.0-regular-2re1c.json | 4 + .../booking-api-2.0.0-regular-2re2c.json | 4 + .../booking-api-2.0.0-regular-cho-dest.json | 4 + .../booking-api-2.0.0-regular-cho-orig.json | 4 + ...pi-2.0.0-regular-non-operating-reefer.json | 4 + ...oking-api-2.0.0-regular-shipper-owned.json | 4 + .../messages/booking-api-2.0.0-regular.json | 4 + 11 files changed, 90 insertions(+), 22 deletions(-) diff --git a/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java b/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java index 34f917d9..12b6a421 100644 --- a/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java +++ b/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonPointer; import com.fasterxml.jackson.databind.JsonNode; +import lombok.NonNull; import lombok.experimental.UtilityClass; import org.dcsa.conformance.core.check.*; import org.dcsa.conformance.core.traffic.HttpMessageType; @@ -306,31 +307,17 @@ private static Consumer allDg(Consumer { var issues = new LinkedHashSet(); - var shipmentLocations = body.path("shipmentLocations"); var receiptTypeAtOrigin = body.path("receiptTypeAtOrigin").asText(""); - var polNode = - StreamSupport.stream(shipmentLocations.spliterator(), false) - .filter(o -> o.path("locationTypeCode").asText("").equals("POL") - || o.path("locationTypeCode").asText("").equals("PRE") ) - .findFirst() - .orElse(null); - var podNode = - StreamSupport.stream(shipmentLocations.spliterator(), false) - .filter(o -> o.path("locationTypeCode").asText("").equals("POD") - || o.path("locationTypeCode").asText("").equals("PDE") ) - .findFirst() - .orElse(null); - - var ielNode = - StreamSupport.stream(shipmentLocations.spliterator(), false) - .filter(o -> o.path("locationTypeCode").asText("").equals("IEL")) - .findFirst() - .orElse(null); - - if (podNode == null || podNode.isEmpty() ) { + var polNode = getShipmenLocationTypeCode(body,"POL"); + var preNode = getShipmenLocationTypeCode(body,"PRE"); + var pdeNode = getShipmenLocationTypeCode(body,"PDE"); + var podNode = getShipmenLocationTypeCode(body,"POD"); + var ielNode = getShipmenLocationTypeCode(body,"IEL"); + + if ((pdeNode == null || pdeNode.isEmpty()) && (podNode == null || podNode.isEmpty()) ) { issues.add("Port of Discharge/Place of Delivery value must be provided"); } - if (polNode == null || polNode.isEmpty()) { + if ((preNode == null || preNode.isEmpty()) && (polNode == null || polNode.isEmpty())) { issues.add("Port of Load/Place of Receipt values must be provided"); } if(!"SD".equals(receiptTypeAtOrigin) && ielNode != null) { @@ -339,6 +326,47 @@ private static Consumer allDg(Consumer { + var issues = new LinkedHashSet(); + var vesselName = body.has("vessel") ? body.path("vessel").path("name").asText(""): ""; + var carrierExportVoyageNumber = body.path("carrierExportVoyageNumber").asText(""); + var carrierServiceCode = body.path("carrierServiceCode").asText(""); + var carrierServiceName = body.path("carrierServiceName").asText(""); + var expectedDepartureDate = body.path("expectedDepartureDate").asText(""); + + var polNode = getShipmenLocationTypeCode(body,"POL"); + var preNode = getShipmenLocationTypeCode(body,"PRE"); + var pdeNode = getShipmenLocationTypeCode(body,"PDE"); + var podNode = getShipmenLocationTypeCode(body,"POD"); + + String providedArrivalStartDate = body.path("expectedArrivalAtPlaceOfDeliveryStartDate").asText(""); + String providedArrivalEndDate = body.path("expectedArrivalAtPlaceOfDeliveryEndDate").asText(""); + + var isPodAbsent = (pdeNode == null || pdeNode.isEmpty()) && (podNode == null || podNode.isEmpty()); + var isPolAbsent = (preNode == null || preNode.isEmpty()) && (polNode == null || polNode.isEmpty()); + + var poldServiceCodeAbsent = (isPolAbsent && isPodAbsent && vesselName.isEmpty() && carrierExportVoyageNumber.isEmpty()) + || (isPolAbsent && isPodAbsent && carrierServiceCode.isEmpty() && carrierExportVoyageNumber.isEmpty()) + || (isPolAbsent && isPodAbsent && carrierServiceName.isEmpty() && carrierExportVoyageNumber.isEmpty()); + + var poldExpectedDepartureDateAbsent = isPolAbsent && isPodAbsent && expectedDepartureDate.isEmpty() ; + + var poldArrivalStartEndDateAbsent = isPolAbsent && isPodAbsent && providedArrivalStartDate.isEmpty() && providedArrivalEndDate.isEmpty(); + + if ( poldServiceCodeAbsent || poldExpectedDepartureDateAbsent || poldArrivalStartEndDateAbsent ) { + issues.add("The minimum options to provide shipper's requested fields are missing."); + } + return issues; + }); + private static JsonNode getShipmenLocationTypeCode(JsonNode body, @NonNull String locationTypeCode) { + var shipmentLocations = body.path("shipmentLocations"); + return StreamSupport.stream(shipmentLocations.spliterator(), false) + .filter(o -> o.path("locationTypeCode").asText("").equals(locationTypeCode)) + .findFirst() + .orElse(null); + } private static final JsonContentCheck REQUESTED_CHANGES_PRESENCE = JsonAttribute.customValidator( "Requested changes must be present for the selected Booking Status ", @@ -546,6 +574,7 @@ private static void generateScenarioRelatedChecks(List checks, VALIDATE_SHIPMENT_CUTOFF_TIME_CODE, VALIDATE_ALLOWED_SHIPMENT_CUTOFF_CODE, COUNTRY_CODE_VALIDATIONS, + VALIDATE_SHIPPER_MINIMUM_REQUEST_FIELDS, JsonAttribute.atLeastOneOf( JsonPointer.compile("/expectedDepartureDate"), JsonPointer.compile("/expectedArrivalAtPlaceOfDeliveryStartDate"), diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-dg.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-dg.json index b67eca6b..03630053 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-dg.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-dg.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": true, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "22GP", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer-temp-change.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer-temp-change.json index dc6c5331..fbc35f61 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer-temp-change.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer-temp-change.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": false, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "42R0", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer.json index d64b3368..1b8f5c07 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-reefer.json @@ -12,6 +12,9 @@ "isImportLicenseRequired": true, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "42R0", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re1c.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re1c.json index 6f33af15..5232030f 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re1c.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re1c.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": true, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "22GP", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re2c.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re2c.json index 3ddfcc9d..475c7007 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re2c.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-2re2c.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": true, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "22GP", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-dest.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-dest.json index dfb53204..fa3df44e 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-dest.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-dest.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": true, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "22GP", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-orig.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-orig.json index de01b110..4f8a5b59 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-orig.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-cho-orig.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": false, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "22GP", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-non-operating-reefer.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-non-operating-reefer.json index b10fe708..74bf0c42 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-non-operating-reefer.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-non-operating-reefer.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": false, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "42R0", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-shipper-owned.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-shipper-owned.json index 68af2a3f..7d0db9fb 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-shipper-owned.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular-shipper-owned.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": false, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "45G1", diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular.json index d550ad68..5b513118 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-regular.json @@ -12,6 +12,10 @@ "isImportLicenseRequired": true, "communicationChannelCode": "AO", "isEquipmentSubstitutionAllowed": true, + "carrierServiceCode": "TA1", + "vessel": { + "name": "King of the Seas" + }, "requestedEquipments": [ { "ISOEquipmentCode": "22GP", From b2d3dc1655bb0c5547aee4e9a0b3318488702919 Mon Sep 17 00:00:00 2001 From: preetamnpr <128618622+preetamnpr@users.noreply.github.com> Date: Wed, 22 May 2024 15:19:24 +0200 Subject: [PATCH 2/2] DT-798 addressed review comment. --- .../conformance/standards/booking/checks/BookingChecks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java b/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java index 12b6a421..47594eb5 100644 --- a/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java +++ b/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java @@ -330,7 +330,7 @@ private static Consumer allDg(Consumer { var issues = new LinkedHashSet(); - var vesselName = body.has("vessel") ? body.path("vessel").path("name").asText(""): ""; + var vesselName = body.path("vessel").path("name").asText(""); var carrierExportVoyageNumber = body.path("carrierExportVoyageNumber").asText(""); var carrierServiceCode = body.path("carrierServiceCode").asText(""); var carrierServiceName = body.path("carrierServiceName").asText("");