Skip to content

Commit

Permalink
Merge pull request #200 from com-pas/develop
Browse files Browse the repository at this point in the history
Upgrade to java 17
  • Loading branch information
AliouDIAITE authored Nov 24, 2022
2 parents 88291aa + e956419 commit bc57e31
Show file tree
Hide file tree
Showing 44 changed files with 41,998 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automate_javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v2
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
ref: ${{ env.target_branch }}

- name: Create custom Maven Settings.xml
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Extract tag name
id: extract_tagname
shell: bash
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
- name: Set up JDK 1.11
uses: actions/setup-java@v2.5.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- name: Create custom Maven Settings.xml
uses: whelk-io/maven-settings-xml-action@v20
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
9 changes: 5 additions & 4 deletions .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'zulu'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
Expand Down
29 changes: 8 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
</repositories>

<properties>
<java.version>17</java.version>
<compas.core.version>local-SNAPSHOT</compas.core.version>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.coverage.exclusions>sct-coverage/**</sonar.coverage.exclusions>
<aggregate.report.dir>../sct-coverage/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
Expand All @@ -40,6 +41,7 @@
<compas-scl-xsd.version>0.0.4</compas-scl-xsd.version>
<maven.plugin.javadoc>3.4.1</maven.plugin.javadoc>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<junit-version>5.9.0</junit-version>
</properties>

<dependencyManagement>
Expand All @@ -52,19 +54,19 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.8.1</version>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -131,7 +133,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -157,20 +159,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.plugin.javadoc}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand Down Expand Up @@ -219,7 +207,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.plugin.javadoc}</version>
<configuration>
<doctitle>${javadoc.title}</doctitle>
<doclint>${javadoc.lint}</doclint>
Expand Down
4 changes: 2 additions & 2 deletions sct-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void createSCD_should_delete_ControlBlocks_DataSet_and_ExtRef_src_attributes() t
// Then
LN0 ln0 = expectedSCD.streamIEDAdapters()
.findFirst()
.map(iedAdapter -> iedAdapter.getLDeviceAdapterByLdInst("lDeviceInst1").orElseThrow())
.map(iedAdapter -> iedAdapter.findLDeviceAdapterByLdInst("lDeviceInst1").orElseThrow())
.map(LDeviceAdapter::getLN0Adapter)
.map(SclElementAdapter::getCurrentElem)
.orElseThrow(() -> new RuntimeException("Test shouldn't fail here, please check your XML input file"));
Expand Down
17 changes: 12 additions & 5 deletions sct-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
<sonar.jacoco.excludes>**/scl2007b4/**/*</sonar.jacoco.excludes>
<assertJ.version>3.22.0</assertJ.version>
<opencsv.version>5.6</opencsv.version>
<mockito.version>4.9.0</mockito.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -74,19 +76,19 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.6.28</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.0.0</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.6.28</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -111,6 +113,11 @@
<version>${assertJ.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>${opencsv.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -119,8 +126,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void validateCB() throws ScdException {
public void validateDestination(SclRootAdapter sclRootAdapter) throws ScdException {
for(TControlWithIEDName.IEDName iedName : iedNames){
IEDAdapter iedAdapter =sclRootAdapter.getIEDAdapterByName(iedName.getValue());
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst(iedName.getLdInst())
LDeviceAdapter lDeviceAdapter = iedAdapter.findLDeviceAdapterByLdInst(iedName.getLdInst())
.orElseThrow(
() -> new ScdException(
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
@NoArgsConstructor
@EqualsAndHashCode
public class DataTypeName {
protected static final String DELIMITER = ".";

protected String name = ""; // dataName or DataAttributeName

private List<String> structNames = new ArrayList<>(); // [.DataName[…]] or [.DAComponentName[ ….]]
Expand Down Expand Up @@ -98,13 +100,8 @@ public boolean isDefined(){
*/
@Override
public String toString(){
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(name);
for(String sName : structNames){
stringBuilder.append('.');
stringBuilder.append(sName);
}
return stringBuilder.toString();
return name
+ (getStructNames().isEmpty() ? StringUtils.EMPTY : DELIMITER + String.join(DELIMITER, getStructNames()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.TPredefinedCDCEnum;
import org.lfenergy.compas.sct.commons.util.Utils;

/**
* A representation of the model object <em><b>DoTypeName</b></em>.
Expand All @@ -34,6 +36,7 @@ public class DoTypeName extends DataTypeName {

/**
* Constructor
*
* @param doName input
*/
public DoTypeName(String doName) {
Expand All @@ -42,6 +45,7 @@ public DoTypeName(String doName) {

/**
* Constructor
*
* @param ppDoName input
* @param sdoNames input
*/
Expand All @@ -51,24 +55,39 @@ public DoTypeName(String ppDoName, String sdoNames) {

/**
* Initializes DoTypeName
*
* @param dataName input
* @return DoTypeName object
*/
public static DoTypeName from(DoTypeName dataName){
public static DoTypeName from(DoTypeName dataName) {
DoTypeName doTypeName = new DoTypeName(dataName.toString());
if(doTypeName.isDefined()) {
if (doTypeName.isDefined()) {
doTypeName.setCdc(dataName.getCdc());
}
return doTypeName;
}

/**
* Copy DO's content
*
* @param doName DO object
*/
public void merge(DoTypeName doName) {
if(!isDefined()) return;
if(cdc == null)
if (!isDefined()) return;
if (cdc == null)
cdc = doName.getCdc();
}

/**
* Same as toString() without the instance of the DO.
* Only the DO can have an instance number (not the SDO).
* Prerequisites: A non instanced DO never ends with digits.
*
* @return Same as DataTypeName#toString(), without the digits at the end of the DO if any.
* @see DataTypeName#toString()
*/
public String toStringWithoutInst() {
return Utils.removeTrailingDigits(name)
+ (getStructNames().isEmpty() ? StringUtils.EMPTY : DELIMITER + String.join(DELIMITER, getStructNames()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

@Getter
@EqualsAndHashCode
@AllArgsConstructor
@ToString
public final class SclReportItem {
private final String xpath;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.lfenergy.compas.scl2007b4.model.TIED;
import org.lfenergy.compas.sct.commons.dto.SclReport;
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.LN0Adapter;
Expand All @@ -19,10 +20,13 @@
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@UtilityClass
public class ExtRefService {

private static final String MESSAGE_MISSING_IED_NAME_PARAMETER = "IED.name parameter is missing";

/**
* Updates iedName attribute of all ExtRefs in the Scd.
*
Expand Down Expand Up @@ -88,12 +92,42 @@ private static List<SclReportItem> checkIedUnityOfIcdSystemVersionUuid(SclRootAd
.filter(entry -> StringUtils.isNotBlank(entry.getKey()))
.filter(entry -> entry.getValue().size() > 1)
.map(entry -> SclReportItem.fatal(entry.getValue().stream()
.map(tied -> new IEDAdapter(sclRootAdapter, tied))
.map(IEDAdapter::getXPath)
.collect(Collectors.joining(", ")),
.map(tied -> new IEDAdapter(sclRootAdapter, tied))
.map(IEDAdapter::getXPath)
.collect(Collectors.joining(", ")),
"/IED/Private/compas:ICDHeader[@ICDSystemVersionUUID] must be unique" +
" but the same ICDSystemVersionUUID was found on several IED."))
.collect(Collectors.toList());
}

public static SclReport createDataSetAndControlBlocks(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
Stream<LDeviceAdapter> lDeviceAdapters = sclRootAdapter.streamIEDAdapters().flatMap(IEDAdapter::streamLDeviceAdapters);
return createDataSetAndControlBlocks(sclRootAdapter, lDeviceAdapters);
}

public static SclReport createDataSetAndControlBlocks(SCL scd, String targetIedName) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
return createDataSetAndControlBlocks(sclRootAdapter, iedAdapter.streamLDeviceAdapters());

}

public static SclReport createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst) {
if (StringUtils.isBlank(targetIedName)) {
throw new ScdException(MESSAGE_MISSING_IED_NAME_PARAMETER);
}
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst(targetLDeviceInst);
return createDataSetAndControlBlocks(sclRootAdapter, Stream.of(lDeviceAdapter));
}

private static SclReport createDataSetAndControlBlocks(SclRootAdapter sclRootAdapter, Stream<LDeviceAdapter> lDeviceAdapters) {
List<SclReportItem> sclReportItems = lDeviceAdapters
.map(LDeviceAdapter::createDataSetAndControlBlocks)
.flatMap(List::stream)
.collect(Collectors.toList());
return new SclReport(sclRootAdapter, sclReportItems);
}
}
Loading

0 comments on commit bc57e31

Please sign in to comment.