From 3d26bedcb65da9485a7af7dd9a9809a254816434 Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Thu, 5 Dec 2024 14:43:21 +0100 Subject: [PATCH] Added support for CII D22B XML Schema validation --- README.md | 1 + phive-rules-cii/pom.xml | 5 +++ .../com/helger/phive/cii/CIIValidation.java | 42 ++++++++++++++++++- .../com/helger/phive/cii/mock/CTestFiles.java | 9 +++- pom.xml | 2 +- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fada09e5..c822b58b 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,7 @@ I hope that with the introduction of PINT, the versioning problem will be solved * Added Peppol PINT JP Self Billing 1.0.1 release * Deprecated Simplerinvoicing Invoice 2.0.3.8, Simplerinvoicing 2.0 G-Account extension 1.0.8 and NLCIUS-CII 1.0.3.7 * Added Simplerinvoicing Invoice 2.0.3.10, Simplerinvoicing 2.0 G-Account extension 1.0.10 and NLCIUS-CII 1.0.3.9 + * Added support for CII D22B XML Schema validation * v3.2.1 - 2024-10-09 * Added support for EN 16931 rules v1.3.13 format and deprecated v1.3.11 * v3.2.0 - 2024-09-16 diff --git a/phive-rules-cii/pom.xml b/phive-rules-cii/pom.xml index 694ad5aa..59873550 100644 --- a/phive-rules-cii/pom.xml +++ b/phive-rules-cii/pom.xml @@ -59,6 +59,11 @@ ph-cii-d16b ${ph-cii.version} + + com.helger.cii + ph-cii-d22b + ${ph-cii.version} + com.helger.phive.rules phive-rules-api diff --git a/phive-rules-cii/src/main/java/com/helger/phive/cii/CIIValidation.java b/phive-rules-cii/src/main/java/com/helger/phive/cii/CIIValidation.java index feaf6096..aa924104 100644 --- a/phive-rules-cii/src/main/java/com/helger/phive/cii/CIIValidation.java +++ b/phive-rules-cii/src/main/java/com/helger/phive/cii/CIIValidation.java @@ -20,6 +20,7 @@ import javax.annotation.concurrent.Immutable; import com.helger.cii.d16b.CCIID16B; +import com.helger.cii.d22b.CCIID22B; import com.helger.commons.ValueEnforcer; import com.helger.diver.api.coord.DVRCoordinate; import com.helger.phive.api.executorset.IValidationExecutorSetRegistry; @@ -38,20 +39,38 @@ public final class CIIValidation { public static final String GROUP_ID = "un.unece.uncefact"; public static final String VERSION_D16B = "D16B"; + public static final String VERSION_D22B = "D22B"; public static final DVRCoordinate VID_CII_D16B_CROSSINDUSTRYINVOICE = PhiveRulesHelper.createCoordinate (GROUP_ID, "crossindustryinvoice", VERSION_D16B); + public static final DVRCoordinate VID_CII_D22B_CROSSINDUSTRYINVOICE = PhiveRulesHelper.createCoordinate (GROUP_ID, + "crossindustryinvoice", + VERSION_D22B); private CIIValidation () {} + /** + * Register all supported CII validation execution sets to the provided + * registry. + * + * @param aRegistry + * The registry to add the artefacts to. May not be null. + * @since 3.2.2 + */ + public static void initCII (@Nonnull final IValidationExecutorSetRegistry aRegistry) + { + initCIID16B (aRegistry); + initCIID22B (aRegistry); + } + /** * Register all standard CII D16B validation execution sets to the provided * registry. * * @param aRegistry - * The registry to add the artefacts. May not be null. + * The registry to add the artefacts to. May not be null. */ public static void initCIID16B (@Nonnull final IValidationExecutorSetRegistry aRegistry) { @@ -65,4 +84,25 @@ public static void initCIID16B (@Nonnull final IValidationExecutorSetRegistry null. + * @since 3.2.2 + */ + public static void initCIID22B (@Nonnull final IValidationExecutorSetRegistry aRegistry) + { + ValueEnforcer.notNull (aRegistry, "Registry"); + + final boolean bNotDeprecated = false; + + // No Schematrons here + aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (VID_CII_D22B_CROSSINDUSTRYINVOICE, + "CII CrossIndustryInvoice " + VERSION_D22B, + PhiveRulesHelper.createSimpleStatus (bNotDeprecated), + ValidationExecutorXSD.create (CCIID22B.getXSDResource ()))); + } } diff --git a/phive-rules-cii/src/test/java/com/helger/phive/cii/mock/CTestFiles.java b/phive-rules-cii/src/test/java/com/helger/phive/cii/mock/CTestFiles.java index 9eef6c84..fc120ec2 100644 --- a/phive-rules-cii/src/test/java/com/helger/phive/cii/mock/CTestFiles.java +++ b/phive-rules-cii/src/test/java/com/helger/phive/cii/mock/CTestFiles.java @@ -40,7 +40,7 @@ public final class CTestFiles public static final ValidationExecutorSetRegistry VES_REGISTRY = new ValidationExecutorSetRegistry <> (); static { - CIIValidation.initCIID16B (VES_REGISTRY); + CIIValidation.initCII (VES_REGISTRY); } private CTestFiles () @@ -51,7 +51,8 @@ private CTestFiles () public static ICommonsList getAllTestFiles () { final ICommonsList ret = new CommonsArrayList <> (); - for (final DVRCoordinate aESID : new DVRCoordinate [] { CIIValidation.VID_CII_D16B_CROSSINDUSTRYINVOICE }) + for (final DVRCoordinate aESID : new DVRCoordinate [] { CIIValidation.VID_CII_D16B_CROSSINDUSTRYINVOICE, + CIIValidation.VID_CII_D22B_CROSSINDUSTRYINVOICE }) for (final IReadableResource aRes : getAllMatchingTestFiles (aESID)) { assertTrue ("Not existing test file: " + aRes.getPath (), aRes.exists ()); @@ -70,6 +71,10 @@ public static ICommonsList getAllMatchingTestFiles { return new CommonsArrayList <> (CIITestFiles.D16B_FILES, ClassPathResource::new); } + if (aVESID.equals (CIIValidation.VID_CII_D22B_CROSSINDUSTRYINVOICE)) + { + return new CommonsArrayList <> (CIITestFiles.D22B_FILES, ClassPathResource::new); + } throw new IllegalArgumentException ("Invalid VESID: " + aVESID); } diff --git a/pom.xml b/pom.xml index db5b2530..e8502411 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ jaxb-maven-plugin 4.0.8 9.6.0 - 3.0.2 + 3.1.0 7.1.0 2.0.2 4.0.3