Skip to content

Commit

Permalink
DT-1832: Remove use of EPUI
Browse files Browse the repository at this point in the history
  • Loading branch information
nt-gt committed Oct 15, 2024
1 parent 9dfe137 commit 2e59847
Show file tree
Hide file tree
Showing 25 changed files with 287 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.dcsa.conformance.core.check.JsonAttribute.*;
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.genericTDContentChecks;
import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES;

import java.util.Set;
import java.util.UUID;
Expand All @@ -19,6 +20,12 @@

public class IssuanceChecks {

private static final JsonRebaseableContentCheck ISSUE_TO_CODE_LIST_PROVIDER = JsonAttribute.allIndividualMatchesMustBeValid(
"The 'codeListProvider' is valid",
mav -> mav.submitAllMatching("issueTo.identifyingCodes.*.codeListProvider"),
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES)
);

private static JsonRebaseableContentCheck hasEndorseeScenarioCheck(String standardsVersion, EblType eblType) {
return JsonAttribute.customValidator(
"[Scenario] Validate endorsee party presence is correct",
Expand Down Expand Up @@ -53,6 +60,7 @@ public static ActionCheck tdScenarioChecks(UUID matched, String standardsVersion
JsonPointer.compile("/document/isToOrder"),
eblType.isToOrder()
),
ISSUE_TO_CODE_LIST_PROVIDER,
hasEndorseeScenarioCheck(standardsVersion, eblType)
);
}
Expand Down
5 changes: 4 additions & 1 deletion ebl-surrender/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
<groupId>org.dcsa.conformance</groupId>
<artifactId>core</artifactId>
</dependency>

<dependency>
<groupId>org.dcsa.conformance</groupId>
<artifactId>ebl</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
import org.dcsa.conformance.core.check.ActionCheck;
import org.dcsa.conformance.core.check.JsonAttribute;
import org.dcsa.conformance.core.check.JsonContentCheck;
import org.dcsa.conformance.core.check.JsonRebaseableContentCheck;
import org.dcsa.conformance.core.check.KeywordDataset;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.eblsurrender.party.EblSurrenderRole;

import java.util.UUID;

import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES;

public class SurrenderChecks {
private static final KeywordDataset SURRENDER_ACTIONS_DATA_SET = KeywordDataset.staticDataset(
"ISSUE",
"ENDORSE",
"SIGN",
"SURRENDER FOR DELIVERY",
"SURRENDER FOR AMENDMENT"
"SURRENDER_FOR_DELIVERY",
"SURRENDER_FOR_AMENDMENT"
);

private static final JsonContentCheck SURRENDER_ACTION_VALIDATION = JsonAttribute.allIndividualMatchesMustBeValid(
Expand All @@ -24,14 +27,23 @@ public class SurrenderChecks {
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(SURRENDER_ACTIONS_DATA_SET)
);

private static final JsonRebaseableContentCheck SURRENDER_PARTY_CODE_LIST_PROVIDER = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate 'codeListProvider' is a known value",
(mav) -> {
mav.submitAllMatching("endorsementChain.*.actor.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("endorsementChain.*.recipient.identifyingCodes.*.codeListProvider");
},
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES)
);

public static ActionCheck surrenderRequestChecks(UUID matched, String standardVersion) {
return JsonAttribute.contentChecks(
EblSurrenderRole::isPlatform,
matched,
HttpMessageType.REQUEST,
standardVersion,
SURRENDER_ACTION_VALIDATION
SURRENDER_ACTION_VALIDATION,
SURRENDER_PARTY_CODE_LIST_PROVIDER
);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.dcsa.conformance.core.scenario.ConformanceAction;
import org.dcsa.conformance.standards.eblsurrender.party.SuppliedScenarioParameters;

import static org.dcsa.conformance.core.toolkit.JsonToolkit.OBJECT_MAPPER;

@Getter
public class SupplyScenarioParametersAction extends ConformanceAction {
private SuppliedScenarioParameters suppliedScenarioParameters = null;
Expand Down Expand Up @@ -47,12 +49,22 @@ public String getHumanReadablePrompt() {

@Override
public JsonNode getJsonForHumanReadablePrompt() {
return new SuppliedScenarioParameters(
UUID.randomUUID().toString().replace("-", "").substring(0, 20),
"XMPL",
"Example carrier party code",
"Example party code",
"Example code list")
var issueToParty = OBJECT_MAPPER.createObjectNode();
issueToParty.put("partyName", "Issue To name")
.put("eblPlatform", "WAVE");
var carrierParty = OBJECT_MAPPER.createObjectNode();
carrierParty.put("partyName", "Carrier name")
.put("eblPlatform", "WAVE");

var surrendereeParty = OBJECT_MAPPER.createObjectNode();
surrendereeParty.put("partyName", "Surrenderee name")
.put("eblPlatform", "BOLE");
return new SuppliedScenarioParameters(
UUID.randomUUID().toString().replace("-", "").substring(0, 20),
issueToParty,
carrierParty,
surrendereeParty
)
.toJson();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,20 @@ private void supplyScenarioParameters(JsonNode actionPrompt) {
String tdr = UUID.randomUUID().toString().replace("-", "").substring(0, 20);
eblStatesById.put(tdr, EblSurrenderState.AVAILABLE_FOR_SURRENDER);

var issueToParty = OBJECT_MAPPER.createObjectNode();
issueToParty.put("partyName", "Issue To name")
.put("eblPlatform", "WAVE");
var carrierParty = OBJECT_MAPPER.createObjectNode();
carrierParty.put("partyName", "Carrier name")
.put("eblPlatform", "WAVE");

var surrendereeParty = OBJECT_MAPPER.createObjectNode();
surrendereeParty.put("partyName", "Surrenderee name")
.put("eblPlatform", "BOLE");

SuppliedScenarioParameters suppliedScenarioParameters =
new SuppliedScenarioParameters(
tdr, "XMPL", "Example carrier party code", "Example party code", "Example code list");
tdr, issueToParty, carrierParty, surrendereeParty);

asyncOrchestratorPostPartyInput(
actionPrompt.required("actionId").asText(), suppliedScenarioParameters.toJson());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ private void requestSurrender(JsonNode actionPrompt) {
Map.entry("SURRENDER_REQUEST_REFERENCE_PLACEHOLDER", srr),
Map.entry("TRANSPORT_DOCUMENT_REFERENCE_PLACEHOLDER", tdr),
Map.entry("SURRENDER_REQUEST_CODE_PLACEHOLDER", src),
Map.entry("EBL_PLATFORM_PLACEHOLDER", ssp.eblPlatform()),
Map.entry("CARRIER_PARTY_CODE_PLACEHOLDER", ssp.carrierPartyCode()),
Map.entry("PARTY_CODE_PLACEHOLDER", ssp.surrenderPartyCode()),
Map.entry("CODE_LIST_NAME_PLACEHOLDER", ssp.codeListName()),
Map.entry("ISSUE_TO_PARTY", ssp.issueToParty().toString()),
Map.entry("SURRENDEREE_PARTY", ssp.surrendereeParty().toString()),
Map.entry("CARRIER_PARTY", ssp.carrierParty().toString()),
Map.entry("ACTION_DATE_TIME_PLACEHOLDER", Instant.now().toString())));

syncCounterpartPost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@
import com.fasterxml.jackson.databind.node.ObjectNode;

public record SuppliedScenarioParameters(
String transportDocumentReference, String eblPlatform, String carrierPartyCode, String surrenderPartyCode, String codeListName) {
String transportDocumentReference,
JsonNode issueToParty,
JsonNode carrierParty,
JsonNode surrendereeParty
) {
public ObjectNode toJson() {
return OBJECT_MAPPER
var r = OBJECT_MAPPER
.createObjectNode()
.put("transportDocumentReference", transportDocumentReference)
.put("eblPlatform", eblPlatform)
.put("carrierPartyCode", surrenderPartyCode)
.put("surrenderPartyCode", surrenderPartyCode)
.put("codeListName", codeListName);
.put("transportDocumentReference", transportDocumentReference);

r.set("issueToParty", issueToParty);
r.set("carrierParty", carrierParty);
r.set("surrendereeParty", surrendereeParty);
return r;
}

public static SuppliedScenarioParameters fromJson(JsonNode jsonNode) {
return new SuppliedScenarioParameters(
jsonNode.required("transportDocumentReference").asText(),
jsonNode.required("eblPlatform").asText(),
jsonNode.required("carrierPartyCode").asText(),
jsonNode.required("surrenderPartyCode").asText(),
jsonNode.required("codeListName").asText());
jsonNode.required("issueToParty"),
jsonNode.required("carrierParty"),
jsonNode.required("surrendereeParty"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,14 @@
{
"actionDateTime": "2024-06-11T13:54:00Z",
"actionCode": "ISSUE",
"actor": {
"eblPlatform": "EBL_PLATFORM_PLACEHOLDER",
"partyName": "legal name",
"identifyingCodes": [
{
"codeListProvider": "EPUI",
"partyCode": "CARRIER_PARTY_CODE_PLACEHOLDER",
"codeListName": "CODE_LIST_NAME_PLACEHOLDER"
}
],
"taxLegalReferences": [
{
"type": "PAN",
"countryCode": "IN",
"value": "AAAAA0000A"
}
]
},
"recipient": {
"eblPlatform": "EBL_PLATFORM_PLACEHOLDER",
"partyName": "legal name",
"identifyingCodes": [
{
"codeListProvider": "EPUI",
"partyCode": "PARTY_CODE_PLACEHOLDER",
"codeListName": "CODE_LIST_NAME_PLACEHOLDER"
}
]
}
"actor": ISSUE_TO_PARTY,
"recipient": SURRENDEREE_PARTY
},
{
"actionDateTime": "2024-06-12T14:54:00Z",
"actionCode": "SURRENDER FOR DELIVERY",
"actor": {
"eblPlatform": "EBL_PLATFORM_PLACEHOLDER",
"partyName": "legal name",
"identifyingCodes": [
{
"codeListProvider": "EPUI",
"partyCode": "PARTY_CODE_PLACEHOLDER",
"codeListName": "CODE_LIST_NAME_PLACEHOLDER"
}
],
"taxLegalReferences": [
{
"type": "PAN",
"countryCode": "IN",
"value": "AAAAA0000A"
}
]
},
"recipient": {
"eblPlatform": "EBL_PLATFORM_PLACEHOLDER",
"partyName": "legal name",
"identifyingCodes": [
{
"codeListProvider": "EPUI",
"partyCode": "CARRIER_PARTY_CODE_PLACEHOLDER",
"codeListName": "CODE_LIST_NAME_PLACEHOLDER"
}
],
"taxLegalReferences": [
{
"type": "PAN",
"countryCode": "IN",
"value": "AAAAA0000A"
}
]
}
"actionCode": "SURRENDER_FOR_DELIVERY",
"actor": SURRENDEREE_PARTY,
"recipient": CARRIER_PARTY
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.dcsa.conformance.standards.ebl.checks;

import static org.dcsa.conformance.core.check.JsonAttribute.concatContextPath;
import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES;
import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.MODE_OF_TRANSPORT;
import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.NATIONAL_COMMODITY_CODES;

Expand Down Expand Up @@ -212,6 +213,29 @@ public class EBLChecks {
JsonAttribute.path("numberOfOriginalsWithCharges", JsonAttribute.matchedMaximum(1))
);

private static final JsonRebaseableContentCheck DOCUMENTATION_PARTIES_CODE_LIST_PROVIDERS = JsonAttribute.allIndividualMatchesMustBeValid(
"The code in 'codeListProvider' is known",
mav -> {
mav.submitAllMatching("documentParties.shipper.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("documentParties.consignee.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("documentParties.endorsee.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("documentParties.issueTo.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("documentParties.seller.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("documentParties.buyer.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("documentParties.notifyParties.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("documentParties.other.party.identifyingCodes.*.codeListProvider");


mav.submitAllMatching("houseBillOfLadings.*.documentParties.shipper.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("houseBillOfLadings.*.documentParties.consignee.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("houseBillOfLadings.*.documentParties.notifyParty.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("houseBillOfLadings.*.documentParties.seller.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("houseBillOfLadings.*.documentParties.buyer.identifyingCodes.*.codeListProvider");
mav.submitAllMatching("houseBillOfLadings.*.documentParties.other.party.identifyingCodes.*.codeListProvider");
},
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(DOCUMENTATION_PARTY_CODE_LIST_PROVIDER_CODES)
);

private static final JsonRebaseableContentCheck NOTIFY_PARTIES_REQUIRED_IN_NEGOTIABLE_BLS = JsonAttribute.ifThen(
"The 'documentParties.notifyParties' attribute is mandatory for negotiable B/Ls",
JsonAttribute.isTrue("isToOrder"),
Expand Down Expand Up @@ -440,6 +464,7 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
JsonAttribute.mustBePresent(ISSUE_TO_PARTY),
JsonAttribute.mustBeAbsent(ISSUE_TO_PARTY)
),
DOCUMENTATION_PARTIES_CODE_LIST_PROVIDERS,
VALID_WOOD_DECLARATIONS,
NATIONAL_COMMODITY_CODE_IS_VALID,
VALID_REFERENCE_TYPES,
Expand Down Expand Up @@ -490,6 +515,7 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
JsonAttribute.isNotNull(JsonPointer.compile("/transports/onCarriageBy")),
JsonAttribute.mustBeNotNull(JsonPointer.compile("/transports/placeOfDelivery"), "'onCarriageBy' is present")
),
DOCUMENTATION_PARTIES_CODE_LIST_PROVIDERS,
VALID_WOOD_DECLARATIONS,
NATIONAL_COMMODITY_CODE_IS_VALID,
VALID_REFERENCE_TYPES,
Expand Down Expand Up @@ -557,14 +583,9 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
TLR_CC_T_COMBINATION_UNIQUE
);

public static final JsonContentCheck SIR_REQUIRED_IN_REF_STATUS = JsonAttribute.mustBePresent(SI_REF_SIR_PTR);
public static final JsonContentCheck SIR_REQUIRED_IN_NOTIFICATION = JsonAttribute.mustBePresent(SI_NOTIFICATION_SIR_PTR);
public static final JsonContentCheck TDR_REQUIRED_IN_NOTIFICATION = JsonAttribute.mustBePresent(TD_NOTIFICATION_TDR_PTR);

public static JsonContentCheck sirInRefStatusMustMatchDSP(Supplier<DynamicScenarioParameters> dspSupplier) {
return JsonAttribute.mustEqual(SI_REF_SIR_PTR, () -> dspSupplier.get().shippingInstructionsReference());
}

public static JsonContentCheck sirInNotificationMustMatchDSP(Supplier<DynamicScenarioParameters> dspSupplier) {
return JsonAttribute.mustEqual(SI_NOTIFICATION_SIR_PTR, () -> dspSupplier.get().shippingInstructionsReference());
}
Expand Down
Loading

0 comments on commit 2e59847

Please sign in to comment.