Skip to content

Commit

Permalink
Merge pull request #46 from com-pas/develop
Browse files Browse the repository at this point in the history
Merge Develop into Master
  • Loading branch information
Dennis Labordus authored Jul 26, 2021
2 parents e1172b1 + e1cc0b4 commit d45b64b
Show file tree
Hide file tree
Showing 20 changed files with 113 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ private List<SchemaConfig> getSchemaConfigs() {
var schemaConfigs = new ArrayList<SchemaConfig>();
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) {
Expand Down
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,33 @@ SPDX-License-Identifier: Apache-2.0
<version>3.2.0</version>
</plugin>

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-namespace-prefix</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-extension</arg>
<arg>-Xnamespace-prefix</arg>
</args>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> 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 <T> Optional<T> getCompasValue(List<Object> content, CompasExtensionsField field, Class<T> clazz) {
if (content != null) {
return getCompasElement(content, field)
Expand All @@ -21,6 +33,13 @@ protected <T> Optional<T> getCompasValue(List<Object> 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<JAXBElement> getCompasElement(List<Object> content, CompasExtensionsField field) {
if (content != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
// 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");
}

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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions scl2003/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,6 @@ SPDX-License-Identifier: Apache-2.0
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>org.lfenergy.compas.scl2003.model</generatePackage>
<schemaDirectory>${project.build.directory}/xsd/SCL2003</schemaDirectory>
Expand Down
5 changes: 5 additions & 0 deletions scl2003/src/main/bindings/scl2003.xjb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ SPDX-License-Identifier: Apache-2.0
-->
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="../../../target/xsd/SCL2003/SCL.xsd" node="/xs:schema">
<namespace:prefix name=""/>
<namespace:prefix name="compas" namespaceURI="https://www.lfenergy.org/compas/v1"/>
</jxb:bindings>
<jxb:bindings schemaLocation="../../../target/xsd/SCL2003/SCL_IED.xsd" node="/xs:schema">
<jxb:bindings node="//xs:complexType[@name='tSMVSettings']//xs:attribute[@name='smpRate']">
<jxb:property name="smpRateSetting"/>
Expand Down
2 changes: 1 addition & 1 deletion scl2003/src/test/resources/scl/scl_with_compas_private.scd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclName>project</ns2:SclName>
<ns2:SclFileType>CID</ns2:SclFileType>
</Private>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclName>project</ns2:SclName>
</Private>
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclFileType>CID</ns2:SclFileType>
</Private>
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>
Expand Down
13 changes: 4 additions & 9 deletions scl2007b/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,16 @@ SPDX-License-Identifier: Apache-2.0
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>org.lfenergy.compas.scl2007b.model</generatePackage>
<schemaDirectory>${project.build.directory}/xsd/SCL2007B</schemaDirectory>
<schemaIncludes>
<schemaInclude>SCL*.xsd</schemaInclude>
</schemaIncludes>
<bindingDirectory>${project.basedir}/src/main/bindings</bindingDirectory>
<bindingIncludes>
<include>*.xjb</include>
</bindingIncludes>
</configuration>
</plugin>
</plugins>
Expand Down
15 changes: 15 additions & 0 deletions scl2007b/src/main/bindings/scl2007b.xjb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2021 Alliander N.V.
SPDX-License-Identifier: Apache-2.0
-->
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="../../../target/xsd/SCL2007B/SCL.xsd" node="/xs:schema">
<namespace:prefix name=""/>
<namespace:prefix name="compas" namespaceURI="https://www.lfenergy.org/compas/v1"/>
</jxb:bindings>
</jxb:bindings>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1" version="2007" revision="B">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclName>project</ns2:SclName>
<ns2:SclFileType>CID</ns2:SclFileType>
</Private>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1" version="2007" revision="B">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclName>project</ns2:SclName>
</Private>
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1" version="2007" revision="B">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclFileType>CID</ns2:SclFileType>
</Private>
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>
Expand Down
13 changes: 4 additions & 9 deletions scl2007b4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,16 @@ SPDX-License-Identifier: Apache-2.0
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>org.lfenergy.compas.scl2007b4.model</generatePackage>
<schemaDirectory>${project.build.directory}/xsd/SCL2007B4</schemaDirectory>
<schemaIncludes>
<schemaInclude>SCL*.xsd</schemaInclude>
</schemaIncludes>
<bindingDirectory>${project.basedir}/src/main/bindings</bindingDirectory>
<bindingIncludes>
<include>*.xjb</include>
</bindingIncludes>
</configuration>
</plugin>
</plugins>
Expand Down
15 changes: 15 additions & 0 deletions scl2007b4/src/main/bindings/scl2007b4.xjb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2021 Alliander N.V.
SPDX-License-Identifier: Apache-2.0
-->
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="../../../target/xsd/SCL2007B4/SCL.xsd" node="/xs:schema">
<namespace:prefix name=""/>
<namespace:prefix name="compas" namespaceURI="https://www.lfenergy.org/compas/v1"/>
</jxb:bindings>
</jxb:bindings>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1" version="2007" revision="B" release="4">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclName>project</ns2:SclName>
<ns2:SclFileType>CID</ns2:SclFileType>
</Private>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1" version="2007" revision="B" release="4">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclName>project</ns2:SclName>
</Private>
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- -->
<!-- SPDX-License-Identifier: Apache-2.0 -->
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1" version="2007" revision="B" release="4">
<Private type="compas_scl">
<Private type="compas-scl">
<ns2:SclFileType>CID</ns2:SclFileType>
</Private>
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>
Expand Down

0 comments on commit d45b64b

Please sign in to comment.