Skip to content

Commit d45b64b

Browse files
author
Dennis Labordus
authored
Merge pull request #46 from com-pas/develop
Merge Develop into Master
2 parents e1172b1 + e1cc0b4 commit d45b64b

File tree

20 files changed

+113
-39
lines changed

20 files changed

+113
-39
lines changed

commons/src/main/java/org/lfenergy/compas/core/commons/MarshallerWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ private List<SchemaConfig> getSchemaConfigs() {
105105
var schemaConfigs = new ArrayList<SchemaConfig>();
106106
try {
107107
// Search for the YAml File on the classpath.
108-
var inputStream = Resources.getResource(yamlFilePath)
108+
var source = Resources.getResource(yamlFilePath)
109109
.orElseThrow(() -> new CompasException(RESOURCE_NOT_FOUND_ERROR_CODE,
110110
String.format("Resource %s not found", yamlFilePath)));
111111
var objectMapper = new ObjectMapper(new YAMLFactory());
112-
var jsonNode = objectMapper.readTree(inputStream);
112+
var jsonNode = objectMapper.readTree(source);
113113

114114
var pathsNode = jsonNode.at(COMPAS_SCL_SCHEMAS_JSONPATH);
115115
if (pathsNode != null && pathsNode.getNodeType() == JsonNodeType.ARRAY) {

pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,33 @@ SPDX-License-Identifier: Apache-2.0
125125
<version>3.2.0</version>
126126
</plugin>
127127

128+
<plugin>
129+
<groupId>org.jvnet.jaxb2.maven2</groupId>
130+
<artifactId>maven-jaxb2-plugin</artifactId>
131+
<version>0.14.0</version>
132+
<dependencies>
133+
<dependency>
134+
<groupId>org.jvnet.jaxb2_commons</groupId>
135+
<artifactId>jaxb2-namespace-prefix</artifactId>
136+
<version>1.3</version>
137+
</dependency>
138+
</dependencies>
139+
<executions>
140+
<execution>
141+
<id>xjc</id>
142+
<goals>
143+
<goal>generate</goal>
144+
</goals>
145+
</execution>
146+
</executions>
147+
<configuration>
148+
<args>
149+
<arg>-extension</arg>
150+
<arg>-Xnamespace-prefix</arg>
151+
</args>
152+
</configuration>
153+
</plugin>
154+
128155
<plugin>
129156
<groupId>org.apache.maven.plugins</groupId>
130157
<artifactId>maven-compiler-plugin</artifactId>

scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@
88
import java.util.List;
99
import java.util.Optional;
1010

11+
/**
12+
* Abstract class that can be used to get CoMPAS Extensions and Fields from certain XML Elements in the SCL XML File.
13+
*/
1114
public abstract class AbstractCompasExtensionsManager {
15+
/**
16+
* Retrieve the value from one of the CoMPAS Extension Fields.
17+
*
18+
* @param content The list of private elements in the SCL XML File.
19+
* @param field The CoMPAS Extension Field to search for in the list.
20+
* @param clazz The class to which the value is casted.
21+
* @param <T> The type of value the field holds.
22+
* @return A Optional containing the value of the field or a empty value if the field can't be found or casted.
23+
*/
1224
protected <T> Optional<T> getCompasValue(List<Object> content, CompasExtensionsField field, Class<T> clazz) {
1325
if (content != null) {
1426
return getCompasElement(content, field)
@@ -21,6 +33,13 @@ protected <T> Optional<T> getCompasValue(List<Object> content, CompasExtensionsF
2133
return Optional.empty();
2234
}
2335

36+
/**
37+
* Retrieve the element from one of the CoMPAS Extension Fields.
38+
*
39+
* @param content The list of private elements in the SCL XML File.
40+
* @param field The CoMPAS Extension Field to search for in the list.
41+
* @return A Optional containing the field or is empty if field can't be found in the list.
42+
*/
2443
@SuppressWarnings("rawtypes")
2544
protected Optional<JAXBElement> getCompasElement(List<Object> content, CompasExtensionsField field) {
2645
if (content != null) {

scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsConstants.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
// SPDX-License-Identifier: Apache-2.0
44
package org.lfenergy.compas.scl.extensions.commons;
55

6+
/**
7+
* Some standard constants that can be used in code to reference CoMPAS Extensions.
8+
*/
69
public class CompasExtensionsConstants {
710
CompasExtensionsConstants() {
811
throw new UnsupportedOperationException("CompasExtensionsConstants class");
912
}
1013

1114
public static final String XML_DEFAULT_NS_PREFIX = "compas";
1215
public static final String COMPAS_EXTENSION_NS_URI = "https://www.lfenergy.org/compas/v1";
13-
public static final String COMPAS_SCL_EXTENSION_TYPE = "compas_scl";
16+
public static final String COMPAS_SCL_EXTENSION_TYPE = "compas-scl";
1417
public static final String XML_DEFAULT_XSD_PATH = "classpath:xsd/SCL_CoMPAS.xsd";
1518
public static final String JAXB_CONTEXT_PATH = "org.lfenergy.compas.scl.extensions.model";
1619
}

scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
// SPDX-License-Identifier: Apache-2.0
44
package org.lfenergy.compas.scl.extensions.commons;
55

6+
/**
7+
* The CoMPAS Extension fields that exists. The fieldName is the name how the element is used in the XML.
8+
*/
69
public enum CompasExtensionsField {
10+
/**
11+
* The name of the SCL XML File, will be used in the search and when SCL XML File is saved to the filesystem.
12+
*/
713
SCL_NAME_EXTENSION("SclName"),
14+
/**
15+
* The type of SCL XML File it is, like IID, SCD and more. TSclFileType indicates which values are allowed.
16+
*/
817
SCL_FILETYPE_EXTENSION("SclFileType");
918

1019
private final String fieldName;

scl2003/pom.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,6 @@ SPDX-License-Identifier: Apache-2.0
9696
<plugin>
9797
<groupId>org.jvnet.jaxb2.maven2</groupId>
9898
<artifactId>maven-jaxb2-plugin</artifactId>
99-
<version>0.14.0</version>
100-
<executions>
101-
<execution>
102-
<id>xjc</id>
103-
<goals>
104-
<goal>generate</goal>
105-
</goals>
106-
</execution>
107-
</executions>
10899
<configuration>
109100
<generatePackage>org.lfenergy.compas.scl2003.model</generatePackage>
110101
<schemaDirectory>${project.build.directory}/xsd/SCL2003</schemaDirectory>

scl2003/src/main/bindings/scl2003.xjb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ SPDX-License-Identifier: Apache-2.0
66
-->
77
<jxb:bindings version="1.0"
88
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
9+
xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
910
xmlns:xs="http://www.w3.org/2001/XMLSchema">
11+
<jxb:bindings schemaLocation="../../../target/xsd/SCL2003/SCL.xsd" node="/xs:schema">
12+
<namespace:prefix name=""/>
13+
<namespace:prefix name="compas" namespaceURI="https://www.lfenergy.org/compas/v1"/>
14+
</jxb:bindings>
1015
<jxb:bindings schemaLocation="../../../target/xsd/SCL2003/SCL_IED.xsd" node="/xs:schema">
1116
<jxb:bindings node="//xs:complexType[@name='tSMVSettings']//xs:attribute[@name='smpRate']">
1217
<jxb:property name="smpRateSetting"/>

scl2003/src/test/resources/scl/scl_with_compas_private.scd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- -->
33
<!-- SPDX-License-Identifier: Apache-2.0 -->
44
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1">
5-
<Private type="compas_scl">
5+
<Private type="compas-scl">
66
<ns2:SclName>project</ns2:SclName>
77
<ns2:SclFileType>CID</ns2:SclFileType>
88
</Private>

scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- -->
33
<!-- SPDX-License-Identifier: Apache-2.0 -->
44
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1">
5-
<Private type="compas_scl">
5+
<Private type="compas-scl">
66
<ns2:SclName>project</ns2:SclName>
77
</Private>
88
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>

scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- -->
33
<!-- SPDX-License-Identifier: Apache-2.0 -->
44
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/v1">
5-
<Private type="compas_scl">
5+
<Private type="compas-scl">
66
<ns2:SclFileType>CID</ns2:SclFileType>
77
</Private>
88
<Header id="370e5d89-df3a-4d9b-a651-3dc5cb28bee1" version="1.0.0"/>

0 commit comments

Comments
 (0)