Skip to content

Commit

Permalink
Merge pull request #23 from dcsaorg/DT-716
Browse files Browse the repository at this point in the history
DT-716 first set changes
  • Loading branch information
preetamnpr authored Dec 8, 2023
2 parents 0ab2ab4 + b4aa9c8 commit 41f00fd
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ public String getHumanReadablePrompt() {

@Override
public JsonNode getJsonForHumanReadablePrompt() {
return new CarrierScenarioParameters("Example Carrier Service", "1234567890").toJson();
return new CarrierScenarioParameters("Example Carrier Service",
"1234567",
"service Name",
"411510",
"commodity Type",
"DKCPH",
"FRPAR").toJson();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ private String generateSchemaValidVesselIMONumber() {

private void supplyScenarioParameters(JsonNode actionPrompt) {
log.info("Carrier.supplyScenarioParameters(%s)".formatted(actionPrompt.toPrettyString()));
List<String> validHsCodeAndCommodityType = generateValidCommodityTypeAndHSCodes();
CarrierScenarioParameters carrierScenarioParameters =
new CarrierScenarioParameters(
"Carrier Service %d".formatted(RANDOM.nextInt(999999)),
generateSchemaValidVesselIMONumber());
generateSchemaValidVesselIMONumber(),
"service name",
validHsCodeAndCommodityType.get(0),
validHsCodeAndCommodityType.get(1),
generateValidPolUNLocationCode(),
generateValidPodUNLocationCode());
asyncOrchestratorPostPartyInput(
OBJECT_MAPPER
.createObjectNode()
Expand All @@ -129,6 +135,26 @@ private void supplyScenarioParameters(JsonNode actionPrompt) {
}


private String generateValidPolUNLocationCode() {
List<String> validUnLocationCode = Arrays.asList("DEHAM", "BEANR", "NLRTM", "ESVLC", "ESALG", "SGSIN", "HKHKG");
return validUnLocationCode.get(RANDOM.nextInt(validUnLocationCode.size()));
}

private String generateValidPodUNLocationCode() {
List<String> validUnLocationCode = Arrays.asList("DEBRV", "CNSGH", "JPTYO", "AEAUH", "AEJEA", "AEKHL", "AEKLF");
return validUnLocationCode.get(RANDOM.nextInt(validUnLocationCode.size()));
}

private List<String> generateValidCommodityTypeAndHSCodes() {
Map<Integer, List<String>> mapHSCodesAndCommodityType = Map.of(
0,Arrays.asList("411510", "Leather"),
1,Arrays.asList("843420", "Dairy machinery"),
2,Arrays.asList("721911", "Stainless steel"),
3,Arrays.asList("730110", "Iron or steel")
);
return mapHSCodesAndCommodityType.get(RANDOM.nextInt(mapHSCodesAndCommodityType.size()));
}

private void processBookingAmendment(JsonNode actionPrompt) {
log.info("Carrier.processBookingAmendment(%s)".formatted(actionPrompt.toPrettyString()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,36 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

public record CarrierScenarioParameters(String carrierServiceName, String vesselIMONumber) {
public record CarrierScenarioParameters(String contractQuotationReference,
String carrierExportVoyageNumber,
String carrierServiceName,
String hsCodes,
String commodityType,
String polUNLocationCode,
String podUNLocationCode
) {
public ObjectNode toJson() {
return new ObjectMapper()
.createObjectNode()
.put("contractQuotationReference", contractQuotationReference())
.put("carrierExportVoyageNumber", carrierExportVoyageNumber())
.put("carrierServiceName", carrierServiceName())
.put("vesselIMONumber", vesselIMONumber());
.put("hsCodes", hsCodes() )
.put("commodityType", commodityType() )
.put("polUNLocationCode", polUNLocationCode() )
.put("podUNLocationCode", podUNLocationCode() );
}

public static CarrierScenarioParameters fromJson(JsonNode jsonNode) {
ObjectNode cspNode = (ObjectNode) jsonNode;

return new CarrierScenarioParameters(
cspNode.get("carrierServiceName").asText(), cspNode.get("vesselIMONumber").asText());
cspNode.required("contractQuotationReference").asText(),
cspNode.required("carrierExportVoyageNumber").asText(),
cspNode.required("carrierServiceName").asText(),
cspNode.required("hsCodes").asText(),
cspNode.required("commodityType").asText(),
cspNode.required("polUNLocationCode").asText(),
cspNode.required("podUNLocationCode").asText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,8 @@ private void sendBookingRequest(JsonNode actionPrompt) {
CarrierScenarioParameters carrierScenarioParameters =
CarrierScenarioParameters.fromJson(actionPrompt.get("csp"));

JsonNode jsonRequestBody =
JsonToolkit.templateFileToJsonNode(
"/standards/booking/messages/booking-api-v20-request.json",
Map.ofEntries(
Map.entry(
"CARRIER_SERVICE_NAME_PLACEHOLDER",
carrierScenarioParameters.carrierServiceName()),
Map.entry(
"VESSEL_IMO_NUMBER_PLACEHOLDER", carrierScenarioParameters.vesselIMONumber())));

JsonNode jsonRequestBody = replaceBookingPlaceHolders(actionPrompt);

asyncCounterpartPost(
"/v2/bookings",
Expand All @@ -114,6 +107,34 @@ private void sendBookingRequest(JsonNode actionPrompt) {
.formatted(carrierScenarioParameters.toJson()));
}

private JsonNode replaceBookingPlaceHolders(JsonNode actionPrompt) {

CarrierScenarioParameters carrierScenarioParameters =
CarrierScenarioParameters.fromJson(actionPrompt.get("csp"));

JsonNode jsonRequestBody =
JsonToolkit.templateFileToJsonNode(
"/standards/booking/messages/booking-api-v20-request.json",
Map.ofEntries(
Map.entry(
"CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER",
carrierScenarioParameters.contractQuotationReference()),
Map.entry(
"CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", carrierScenarioParameters.carrierExportVoyageNumber()),
Map.entry(
"CARRIER_SERVICE_NAME_PLACEHOLDER", carrierScenarioParameters.carrierServiceName()),
Map.entry(
"COMMODITY_HS_CODE", carrierScenarioParameters.hsCodes()),
Map.entry(
"COMMODITY_TYPE_PLACEHOLDER", carrierScenarioParameters.commodityType() ),
Map.entry(
"POL_UNLOCATION_CODE_PLACEHOLDER", carrierScenarioParameters.polUNLocationCode()),
Map.entry(
"POD_UNLOCATION_CODE_PLACEHOLDER", carrierScenarioParameters.podUNLocationCode()) ));

return jsonRequestBody;
}

private void sendCancelEntireBooking(JsonNode actionPrompt) {
log.info("Shipper.sendCancelEntireBooking(%s)".formatted(actionPrompt.toPrettyString()));
String cbrr = actionPrompt.get("cbrr").asText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,125 +3,67 @@
"deliveryTypeAtDestination": "CY",
"cargoMovementTypeAtOrigin": "FCL",
"cargoMovementTypeAtDestination": "FCL",
"vessel": {
"name": "King of the Seas",
"vesselIMONumber": "VESSEL_IMO_NUMBER_PLACEHOLDER"
},
"serviceContractReference": "serviceRef",
"carrierExportVoyageNumber": "2106W",
"contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"declaredValue": 3.14,
"declaredValueCurrency": "DKK",
"isPartialLoadAllowed": true,
"isExportDeclarationRequired": true,
"exportDeclarationReference": "exportDeclarationRef",
"isImportLicenseRequired": true,
"importLicenseReference": "importLicenseRef",
"expectedDepartureDate": "2052-11-15",
"expectedArrivalAtPlaceOfDeliveryStartDate": "2052-11-15",
"expectedArrivalAtPlaceOfDeliveryEndDate": "2052-11-15",
"transportDocumentTypeCode": "BOL",
"transportDocumentReference": "transportDocumentRef",
"bookingChannelReference": "bookingChannelRef",
"incoTerms": "FOB",
"isPartialLoadAllowed": false,
"isExportDeclarationRequired": false,
"isImportLicenseRequired": false,
"communicationChannelCode": "AO",
"isEquipmentSubstitutionAllowed": true,
"placeOfBLIssue": {
"locationName": "Asseco DK office",
"locationType": "ADDR",
"address": {
"name": "Asseco DK",
"street": "Kronprinsessegade",
"streetNumber": "54",
"floor": "5. sal",
"postCode": "1306",
"city": "København",
"country": "Denmark"
}
},
"requestedEquipments": [
{
"ISOEquipmentCode": "22G1",
"ISOEquipmentCode": "22GP",
"units": 1,
"isShipperOwned": false,
"commodities": [
{
"HSCodes": ["411510"],
"commodityType": "commodity type",
"HSCodes": ["COMMODITY_HS_CODE"],
"commodityType": "COMMODITY_TYPE_PLACEHOLDER",
"cargoGrossWeight": 323.32,
"cargoGrossWeightUnit": "KGM",
"cargoGrossVolume": 100.0,
"cargoGrossVolumeUnit": "MTQ",
"outerPackaging": {
"packageCode" : "1A",
"imoPackagingCode": "A1222",
"numberOfPackages": 1,
"description": "steel"

},
"exportLicenseIssueDate": "2022-11-15",
"exportLicenseExpiryDate": "2023-05-15"
"cargoGrossWeightUnit": "KGM"
}
]
}
],
"references": [
{
"type": "AAO",
"value": "ref value"
}
],
"documentParties": [
{
"party": {
"partyName": "boring party",
"partyName": "DCSA Conformance Toolkit",
"address": {
"name": "Asseco DK",
"street": "Kronprinsessegade",
"streetNumber": "54",
"floor": "5. sal",
"postCode": "1306",
"city": "København",
"country": "Denmark"
"name": "Mustermann",
"street": "Strawinskylaan",
"streetNumber": "4117",
"floor": "6",
"postCode": "1077 ZX",
"city": "Amsterdam",
"country": "Netherlands"
},
"partyContactDetails": [
{
"name": "Henrik",
"phone": "+31611444666"
}
],
"identifyingCodes": [
{
"DCSAResponsibleAgencyCode": "DCSA",
"partyCode": "reponsible fun",
"codeListName": "irreponsible fun"
}
]
},
"partyFunction": "BA",
"displayedAddress": [
"line1",
"line2"
],
"isToBeNotified": true
"isToBeNotified": false
}
],
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "NLRTM"
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL",
"eventDateTime": "2022-11-15T10:34:41.99631016+01:00"
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "USMIA"
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD",
"eventDateTime": "2022-11-15T10:34:41.99631016+01:00"
"locationTypeCode": "POD"
}
]
}

0 comments on commit 41f00fd

Please sign in to comment.