diff --git a/commons/src/main/java/org/lfenergy/compas/core/commons/MarshallerWrapper.java b/commons/src/main/java/org/lfenergy/compas/core/commons/MarshallerWrapper.java index 34789fa..16b2e67 100644 --- a/commons/src/main/java/org/lfenergy/compas/core/commons/MarshallerWrapper.java +++ b/commons/src/main/java/org/lfenergy/compas/core/commons/MarshallerWrapper.java @@ -105,11 +105,11 @@ private List getSchemaConfigs() { var schemaConfigs = new ArrayList(); try { // Search for the YAml File on the classpath. - var inputStream = Resources.getResource(yamlFilePath) + var source = Resources.getResource(yamlFilePath) .orElseThrow(() -> new CompasException(RESOURCE_NOT_FOUND_ERROR_CODE, String.format("Resource %s not found", yamlFilePath))); var objectMapper = new ObjectMapper(new YAMLFactory()); - var jsonNode = objectMapper.readTree(inputStream); + var jsonNode = objectMapper.readTree(source); var pathsNode = jsonNode.at(COMPAS_SCL_SCHEMAS_JSONPATH); if (pathsNode != null && pathsNode.getNodeType() == JsonNodeType.ARRAY) { diff --git a/pom.xml b/pom.xml index 17419b0..e88f354 100644 --- a/pom.xml +++ b/pom.xml @@ -125,6 +125,33 @@ SPDX-License-Identifier: Apache-2.0 3.2.0 + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.14.0 + + + org.jvnet.jaxb2_commons + jaxb2-namespace-prefix + 1.3 + + + + + xjc + + generate + + + + + + -extension + -Xnamespace-prefix + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManager.java b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManager.java index 6f188d6..667c168 100644 --- a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManager.java +++ b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManager.java @@ -8,7 +8,19 @@ import java.util.List; import java.util.Optional; +/** + * Abstract class that can be used to get CoMPAS Extensions and Fields from certain XML Elements in the SCL XML File. + */ public abstract class AbstractCompasExtensionsManager { + /** + * Retrieve the value from one of the CoMPAS Extension Fields. + * + * @param content The list of private elements in the SCL XML File. + * @param field The CoMPAS Extension Field to search for in the list. + * @param clazz The class to which the value is casted. + * @param The type of value the field holds. + * @return A Optional containing the value of the field or a empty value if the field can't be found or casted. + */ protected Optional getCompasValue(List content, CompasExtensionsField field, Class clazz) { if (content != null) { return getCompasElement(content, field) @@ -21,6 +33,13 @@ protected Optional getCompasValue(List content, CompasExtensionsF return Optional.empty(); } + /** + * Retrieve the element from one of the CoMPAS Extension Fields. + * + * @param content The list of private elements in the SCL XML File. + * @param field The CoMPAS Extension Field to search for in the list. + * @return A Optional containing the field or is empty if field can't be found in the list. + */ @SuppressWarnings("rawtypes") protected Optional getCompasElement(List content, CompasExtensionsField field) { if (content != null) { diff --git a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsConstants.java b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsConstants.java index 016b414..330ee97 100644 --- a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsConstants.java +++ b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsConstants.java @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 package org.lfenergy.compas.scl.extensions.commons; +/** + * Some standard constants that can be used in code to reference CoMPAS Extensions. + */ public class CompasExtensionsConstants { CompasExtensionsConstants() { throw new UnsupportedOperationException("CompasExtensionsConstants class"); @@ -10,7 +13,7 @@ public class CompasExtensionsConstants { public static final String XML_DEFAULT_NS_PREFIX = "compas"; public static final String COMPAS_EXTENSION_NS_URI = "https://www.lfenergy.org/compas/v1"; - public static final String COMPAS_SCL_EXTENSION_TYPE = "compas_scl"; + public static final String COMPAS_SCL_EXTENSION_TYPE = "compas-scl"; public static final String XML_DEFAULT_XSD_PATH = "classpath:xsd/SCL_CoMPAS.xsd"; public static final String JAXB_CONTEXT_PATH = "org.lfenergy.compas.scl.extensions.model"; } diff --git a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java index 567875e..008d97c 100644 --- a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java +++ b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java @@ -3,8 +3,17 @@ // SPDX-License-Identifier: Apache-2.0 package org.lfenergy.compas.scl.extensions.commons; +/** + * The CoMPAS Extension fields that exists. The fieldName is the name how the element is used in the XML. + */ public enum CompasExtensionsField { + /** + * The name of the SCL XML File, will be used in the search and when SCL XML File is saved to the filesystem. + */ SCL_NAME_EXTENSION("SclName"), + /** + * The type of SCL XML File it is, like IID, SCD and more. TSclFileType indicates which values are allowed. + */ SCL_FILETYPE_EXTENSION("SclFileType"); private final String fieldName; diff --git a/scl2003/pom.xml b/scl2003/pom.xml index 0e6e5bc..e78955b 100644 --- a/scl2003/pom.xml +++ b/scl2003/pom.xml @@ -96,15 +96,6 @@ SPDX-License-Identifier: Apache-2.0 org.jvnet.jaxb2.maven2 maven-jaxb2-plugin - 0.14.0 - - - xjc - - generate - - - org.lfenergy.compas.scl2003.model ${project.build.directory}/xsd/SCL2003 diff --git a/scl2003/src/main/bindings/scl2003.xjb b/scl2003/src/main/bindings/scl2003.xjb index d044a1a..e9b854a 100644 --- a/scl2003/src/main/bindings/scl2003.xjb +++ b/scl2003/src/main/bindings/scl2003.xjb @@ -6,7 +6,12 @@ SPDX-License-Identifier: Apache-2.0 --> + + + + diff --git a/scl2003/src/test/resources/scl/scl_with_compas_private.scd b/scl2003/src/test/resources/scl/scl_with_compas_private.scd index ece5725..3ef2d44 100644 --- a/scl2003/src/test/resources/scl/scl_with_compas_private.scd +++ b/scl2003/src/test/resources/scl/scl_with_compas_private.scd @@ -2,7 +2,7 @@ - + project CID diff --git a/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd b/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd index c75ef9d..dce4629 100644 --- a/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd +++ b/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd @@ -2,7 +2,7 @@ - + project
diff --git a/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd b/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd index 487a598..48e35ae 100644 --- a/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd +++ b/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd @@ -2,7 +2,7 @@ - + CID
diff --git a/scl2007b/pom.xml b/scl2007b/pom.xml index 4dd969b..88504b3 100644 --- a/scl2007b/pom.xml +++ b/scl2007b/pom.xml @@ -96,21 +96,16 @@ SPDX-License-Identifier: Apache-2.0 org.jvnet.jaxb2.maven2 maven-jaxb2-plugin - 0.14.0 - - - xjc - - generate - - - org.lfenergy.compas.scl2007b.model ${project.build.directory}/xsd/SCL2007B SCL*.xsd + ${project.basedir}/src/main/bindings + + *.xjb + diff --git a/scl2007b/src/main/bindings/scl2007b.xjb b/scl2007b/src/main/bindings/scl2007b.xjb new file mode 100644 index 0000000..e3c3030 --- /dev/null +++ b/scl2007b/src/main/bindings/scl2007b.xjb @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/scl2007b/src/test/resources/scl/scl_with_compas_private.scd b/scl2007b/src/test/resources/scl/scl_with_compas_private.scd index 3e99de1..867dbe9 100644 --- a/scl2007b/src/test/resources/scl/scl_with_compas_private.scd +++ b/scl2007b/src/test/resources/scl/scl_with_compas_private.scd @@ -2,7 +2,7 @@ - + project CID diff --git a/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd b/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd index c1addcd..7cd6c0a 100644 --- a/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd +++ b/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd @@ -2,7 +2,7 @@ - + project
diff --git a/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd b/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd index 1972cdf..d83c457 100644 --- a/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd +++ b/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd @@ -2,7 +2,7 @@ - + CID
diff --git a/scl2007b4/pom.xml b/scl2007b4/pom.xml index d09d0d7..cde42d1 100644 --- a/scl2007b4/pom.xml +++ b/scl2007b4/pom.xml @@ -96,21 +96,16 @@ SPDX-License-Identifier: Apache-2.0 org.jvnet.jaxb2.maven2 maven-jaxb2-plugin - 0.14.0 - - - xjc - - generate - - - org.lfenergy.compas.scl2007b4.model ${project.build.directory}/xsd/SCL2007B4 SCL*.xsd + ${project.basedir}/src/main/bindings + + *.xjb + diff --git a/scl2007b4/src/main/bindings/scl2007b4.xjb b/scl2007b4/src/main/bindings/scl2007b4.xjb new file mode 100644 index 0000000..56b880f --- /dev/null +++ b/scl2007b4/src/main/bindings/scl2007b4.xjb @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd index 01c8431..d10722f 100644 --- a/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd +++ b/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd @@ -2,7 +2,7 @@ - + project CID diff --git a/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd index 7558d63..6e16eec 100644 --- a/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd +++ b/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd @@ -2,7 +2,7 @@ - + project
diff --git a/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd index 58704f1..d3c10f2 100644 --- a/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd +++ b/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd @@ -2,7 +2,7 @@ - + CID