Skip to content

Commit

Permalink
DT-1367 national commodity codes
Browse files Browse the repository at this point in the history
  • Loading branch information
preetamnpr committed Aug 2, 2024
1 parent a948bd5 commit e5f57a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static org.dcsa.conformance.standards.booking.checks.BookingDataSets.NATIONAL_COMMODITY_TYPE_CODES;

@UtilityClass
public class BookingChecks {

Expand Down Expand Up @@ -88,6 +90,12 @@ public static ActionCheck requestContentChecks(UUID matched, String standardVers
}
);

private static final JsonRebaseableContentCheck NATIONAL_COMMODITY_TYPE_CODE_VALIDATION = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate that 'type' of 'nationalCommodityCodes' is a known code",
(mav) -> mav.submitAllMatching("requestedEquipments.*.commodities.*.nationalCommodityCodes.*.type"),
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(NATIONAL_COMMODITY_TYPE_CODES)
);

private static final JsonContentCheck VALIDATE_ALL_BOOKING_UN_LOCATION_CODES = JsonAttribute.allIndividualMatchesMustBeValid(
"Validate all booking UNLocationCodes",
(mav) -> {
Expand Down Expand Up @@ -353,6 +361,7 @@ private static Set<String> validateDocumentPartyFields(JsonNode documentPartyNod
mav.submitAllMatching("documentParties.carrierBookingOffice.address.countryCode");
mav.submitAllMatching("documentParties.other.*.party.address.countryCode");
mav.submitAllMatching("placeOfBLIssue.countryCode");
mav.submitAllMatching("requestedEquipments.*.commodities.*.nationalCommodityCodes.*.countryCode");
},
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(BookingDataSets.ISO_3166_ALPHA2_COUNTRY_CODES)
);
Expand Down Expand Up @@ -640,6 +649,7 @@ private static void generateScenarioRelatedChecks(List<JsonContentCheck> checks,
VALIDATE_SHIPPER_MINIMUM_REQUEST_FIELDS,
VALIDATE_DOCUMENT_PARTY,
CR_TYPE_CODES_VALIDATIONS,
NATIONAL_COMMODITY_TYPE_CODE_VALIDATION,
JsonAttribute.atLeastOneOf(
JsonPointer.compile("/expectedDepartureDate"),
JsonPointer.compile("/expectedArrivalAtPlaceOfDeliveryStartDate"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ public class BookingDataSets {

public static final KeywordDataset INCO_TERMS_VALUES = KeywordDataset.staticDataset("EXW", "FCA", "FAS", "FOB", "CFR", "CIF", "CPT", "CIP", "DAP", "DPU", "DDP");

public static final KeywordDataset NATIONAL_COMMODITY_TYPE_CODES = KeywordDataset.staticDataset( "NCM", "HTS", "Schedule B", "TARIC", "CN", "CUS" );

public static final KeywordDataset CUTOFF_DATE_TIME_CODES = KeywordDataset.staticDataset("DCO", "VCO", "FCO", "LCO", "ECP", "EFC");

public static final KeywordDataset AMF_CC_MTC_TYPE_CODES = KeywordDataset.fromVersionedCSV(BookingDataSets.class, "/standards/booking/datasets/advancemanifestfilings-v%s.csv", "Advance Manifest Filing Type Code");

public static final KeywordDataset ISO_4217_CURRENCY_CODES = KeywordDataset.fromCSV(BookingDataSets.class, "/standards/booking/datasets/currency-codes-iso-4217.csv", "CurrencyCode");

public static final KeywordDataset REFERENCE_TYPES = KeywordDataset.fromCSV(BookingDataSets.class, "/standards/booking/datasets/general-reference-types.csv", "General Reference Type Code");
Expand Down

0 comments on commit e5f57a4

Please sign in to comment.