Skip to content

Commit e356c04

Browse files
authored
Merge pull request #39 from com-pas/create-scd-with-header
Create scd with header and import ICD
2 parents 0ade614 + 452ca41 commit e356c04

File tree

137 files changed

+10168
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+10168
-13
lines changed

pom.xml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,57 @@
3030
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
3131
</properties>
3232

33+
<dependencyManagement>
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.projectlombok</groupId>
37+
<artifactId>lombok</artifactId>
38+
<version>1.18.20</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.junit.jupiter</groupId>
42+
<artifactId>junit-jupiter-api</artifactId>
43+
<version>5.7.2</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.junit.jupiter</groupId>
47+
<artifactId>junit-jupiter-engine</artifactId>
48+
<version>5.7.2</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.lfenergy.compas.core</groupId>
52+
<artifactId>scl2007b4</artifactId>
53+
<version>0.2.1</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>ch.qos.logback</groupId>
57+
<artifactId>logback-classic</artifactId>
58+
<version>1.2.6</version>
59+
</dependency>
60+
<!--<dependency>
61+
<groupId>org.slf4j</groupId>
62+
<artifactId>slf4j-log4j12</artifactId>
63+
<version>1.7.32</version>
64+
<scope>test</scope>
65+
</dependency>-->
66+
</dependencies>
67+
</dependencyManagement>
3368
<dependencies>
3469
<dependency>
3570
<groupId>org.lfenergy.compas.core</groupId>
3671
<artifactId>scl2007b4</artifactId>
37-
<version>0.2.1</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>ch.qos.logback</groupId>
75+
<artifactId>logback-classic</artifactId>
3876
</dependency>
3977
</dependencies>
4078
<modules>
4179
<module>sct-commons</module>
4280
<module>sct-coverage</module>
81+
<module>sct-data</module>
82+
<module>sct-data-pg</module>
83+
<module>sct-service</module>
4384
</modules>
4485

4586
<build>
@@ -55,6 +96,11 @@
5596
<artifactId>jacoco-maven-plugin</artifactId>
5697
<version>0.8.6</version>
5798
</plugin>
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-surefire-plugin</artifactId>
102+
<version>2.22.2</version>
103+
</plugin>
58104
</plugins>
59105
</pluginManagement>
60106

sct-commons/pom.xml

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,23 @@
1616
<groupId>org.lfenergy.compas</groupId>
1717
<artifactId>sct-commons</artifactId>
1818
<version>local-SNAPSHOT</version>
19+
<name>SCT-COMMONS</name>
20+
1921

2022
<properties>
2123
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
2224
</properties>
2325

2426
<dependencies>
2527
<dependency>
26-
<groupId>org.springframework</groupId>
27-
<artifactId>spring-context</artifactId>
28-
<version>5.3.3</version>
28+
<groupId>commons-io</groupId>
29+
<artifactId>commons-io</artifactId>
30+
<version>2.11.0</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.apache.commons</groupId>
34+
<artifactId>commons-lang3</artifactId>
35+
<version>3.11</version>
2936
</dependency>
3037
<dependency>
3138
<groupId>jakarta.xml.bind</groupId>
@@ -38,21 +45,19 @@
3845
<version>2.3.3</version>
3946
<scope>runtime</scope>
4047
</dependency>
41-
<dependency>
42-
<groupId>org.springframework</groupId>
43-
<artifactId>spring-oxm</artifactId>
44-
<version>5.3.2</version>
45-
</dependency>
4648
<dependency>
4749
<groupId>org.projectlombok</groupId>
4850
<artifactId>lombok</artifactId>
49-
<version>1.18.16</version>
5051
<optional>true</optional>
5152
</dependency>
5253
<dependency>
5354
<groupId>org.junit.jupiter</groupId>
5455
<artifactId>junit-jupiter-api</artifactId>
55-
<version>5.7.0</version>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.junit.jupiter</groupId>
60+
<artifactId>junit-jupiter-engine</artifactId>
5661
<scope>test</scope>
5762
</dependency>
5863
<dependency>
@@ -67,6 +72,12 @@
6772
<version>3.6.28</version>
6873
<scope>test</scope>
6974
</dependency>
75+
<dependency>
76+
<groupId>org.mockito</groupId>
77+
<artifactId>mockito-inline</artifactId>
78+
<version>4.0.0</version>
79+
<scope>test</scope>
80+
</dependency>
7081
<dependency>
7182
<groupId>org.mockito</groupId>
7283
<artifactId>mockito-junit-jupiter</artifactId>
@@ -86,6 +97,45 @@
8697
</dependencies>
8798
<build>
8899
<plugins>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-compiler-plugin</artifactId>
103+
<configuration>
104+
<source>11</source>
105+
<target>11</target>
106+
</configuration>
107+
</plugin>
108+
109+
<plugin>
110+
<groupId>org.apache.maven.plugins</groupId>
111+
<artifactId>maven-surefire-plugin</artifactId>
112+
</plugin>
113+
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-dependency-plugin</artifactId>
117+
<executions>
118+
<execution>
119+
<id>unpack</id>
120+
<phase>initialize</phase>
121+
<goals>
122+
<goal>unpack</goal>
123+
</goals>
124+
125+
<configuration>
126+
<artifactItems>
127+
<artifactItem>
128+
<groupId>org.lfenergy.compas.xsd</groupId>
129+
<artifactId>compas-scl-xsd</artifactId>
130+
<version>0.0.4</version>
131+
</artifactItem>
132+
</artifactItems>
133+
<outputDirectory>${project.build.directory}</outputDirectory>
134+
</configuration>
135+
</execution>
136+
</executions>
137+
</plugin>
138+
89139
<plugin>
90140
<groupId>org.jacoco</groupId>
91141
<artifactId>jacoco-maven-plugin</artifactId>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-FileCopyrightText: 2021 RTE FRANCE
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.sct.commons;
6+
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.lfenergy.compas.core.commons.exception.CompasErrorCode;
9+
import org.lfenergy.compas.core.commons.exception.CompasException;
10+
11+
import javax.xml.bind.JAXBException;
12+
import javax.xml.bind.Marshaller;
13+
import javax.xml.bind.Unmarshaller;
14+
import javax.xml.transform.Result;
15+
import javax.xml.transform.stream.StreamResult;
16+
import javax.xml.transform.stream.StreamSource;
17+
import java.io.*;
18+
19+
@Slf4j
20+
public class MarshallerWrapper {
21+
private final Unmarshaller unmarshaller;
22+
private final Marshaller marshaller;
23+
24+
protected MarshallerWrapper(Unmarshaller unmarshaller, Marshaller marshaller) {
25+
this.unmarshaller = unmarshaller;
26+
this.marshaller = marshaller;
27+
}
28+
29+
public static SclMarshallerBuilder builder(){
30+
return new SclMarshallerBuilder();
31+
}
32+
33+
public <T> String marshall(final T obj) {
34+
try {
35+
StringWriter sw = new StringWriter();
36+
Result result = new StreamResult(sw);
37+
marshaller.marshal(obj, result);
38+
39+
return sw.toString();
40+
} catch (JAXBException exp) {
41+
String message = String.format("Error marshalling the Class: %s", exp);
42+
log.error(message);
43+
throw new CompasException(CompasErrorCode.MARSHAL_ERROR_CODE, message);
44+
}
45+
}
46+
47+
public <T> T unmarshall(final byte[] xml, Class<T> cls) {
48+
ByteArrayInputStream input = new ByteArrayInputStream(xml);
49+
return unmarshall(input, cls);
50+
}
51+
52+
public <T> T unmarshall(final InputStream xml, Class<T> cls) {
53+
try {
54+
Object result = unmarshaller.unmarshal(new StreamSource(xml));
55+
if (!result.getClass().isAssignableFrom(cls)) {
56+
throw new CompasException(CompasErrorCode.UNMARSHAL_ERROR_CODE,
57+
"Error unmarshalling to the Class. Invalid class");
58+
}
59+
return cls.cast(result);
60+
} catch (JAXBException exp) {
61+
String message = String.format("Error unmarshalling to the Class: %s", exp.getLocalizedMessage());
62+
log.error(message);
63+
throw new CompasException(CompasErrorCode.UNMARSHAL_ERROR_CODE, message);
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)