Skip to content

Commit 340bcb7

Browse files
authored
Merge pull request #214 from com-pas/develop
Merge develop into main for New Release
2 parents 17a46a5 + fcc433a commit 340bcb7

35 files changed

+1926
-622
lines changed

.github/workflows/sonarcloud-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
distribution: 'zulu'
2121
java-version: '17'
2222
- name: Cache SonarCloud packages
23-
uses: actions/cache@v1
23+
uses: actions/cache@v3
2424
with:
2525
path: ~/.sonar/cache
2626
key: ${{ runner.os }}-sonar
2727
restore-keys: ${{ runner.os }}-sonar
2828
- name: Cache Maven packages
29-
uses: actions/cache@v1
29+
uses: actions/cache@v3
3030
with:
3131
path: ~/.m2
3232
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}

pom.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<plugin>
137137
<groupId>org.apache.maven.plugins</groupId>
138138
<artifactId>maven-compiler-plugin</artifactId>
139-
<version>3.8.1</version>
139+
<version>3.10.1</version>
140140
<configuration>
141141
<source>${java.version}</source>
142142
<target>${java.version}</target>
@@ -189,10 +189,6 @@
189189
</pluginManagement>
190190

191191
<plugins>
192-
<plugin>
193-
<groupId>org.apache.maven.plugins</groupId>
194-
<artifactId>maven-compiler-plugin</artifactId>
195-
</plugin>
196192
<plugin>
197193
<groupId>org.jacoco</groupId>
198194
<artifactId>jacoco-maven-plugin</artifactId>

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/FCDAInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public TFCDA getFCDA(){
9494
}
9595

9696
if(doName != null && doName.isDefined()){
97-
tfcda.setDaName(doName.toString());
97+
tfcda.setDoName(doName.toString());
9898
}
9999

100100
if(daName != null && daName.isDefined()){

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ExtRefService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static SclReport updateAllExtRefIedNames(SCL scd) {
5353
.filter(LN0Adapter::hasInputs)
5454
.map(LN0Adapter::getInputsAdapter)
5555
.map(inputsAdapter -> inputsAdapter.updateAllExtRefIedNames(icdSystemVersionToIed))
56-
.flatMap(List::stream).collect(Collectors.toList());
56+
.flatMap(List::stream).toList();
5757

5858
return new SclReport(sclRootAdapter, extRefErrors);
5959
}
@@ -79,7 +79,7 @@ private static List<SclReportItem> checkIedCompasIcdHeaderAttributes(SclRootAdap
7979
return null;
8080
}
8181
).filter(Objects::nonNull)
82-
.collect(Collectors.toList());
82+
.toList();
8383
}
8484

8585
private static List<SclReportItem> checkIedUnityOfIcdSystemVersionUuid(SclRootAdapter sclRootAdapter) {
@@ -97,7 +97,7 @@ private static List<SclReportItem> checkIedUnityOfIcdSystemVersionUuid(SclRootAd
9797
.collect(Collectors.joining(", ")),
9898
"/IED/Private/compas:ICDHeader[@ICDSystemVersionUUID] must be unique" +
9999
" but the same ICDSystemVersionUUID was found on several IED."))
100-
.collect(Collectors.toList());
100+
.toList();
101101
}
102102

103103
public static SclReport createDataSetAndControlBlocks(SCL scd) {
@@ -127,7 +127,7 @@ private static SclReport createDataSetAndControlBlocks(SclRootAdapter sclRootAda
127127
List<SclReportItem> sclReportItems = lDeviceAdapters
128128
.map(LDeviceAdapter::createDataSetAndControlBlocks)
129129
.flatMap(List::stream)
130-
.collect(Collectors.toList());
130+
.toList();
131131
return new SclReport(sclRootAdapter, sclReportItems);
132132
}
133133
}

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/PrivateService.java

Lines changed: 115 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
import org.lfenergy.compas.sct.commons.util.PrivateEnum;
1111

1212
import javax.xml.bind.JAXBElement;
13-
import java.util.ArrayList;
14-
import java.util.Collections;
15-
import java.util.List;
16-
import java.util.Optional;
13+
import java.util.*;
1714
import java.util.function.Predicate;
18-
import java.util.stream.Collectors;
15+
import java.util.stream.Stream;
16+
17+
import static java.util.stream.Collectors.toList;
18+
import static org.lfenergy.compas.sct.commons.util.CommonConstants.*;
19+
import static org.lfenergy.compas.sct.commons.util.PrivateEnum.COMPAS_ICDHEADER;
1920

2021
/**
2122
* A representation of the <em><b>{@link PrivateService PrivateService}</b></em>.
@@ -57,7 +58,7 @@ public static <T> List<T> extractCompasPrivates(List<TPrivate> tPrivates, Class<
5758
.map(TAnyContentFromOtherNamespace::getContent).flatMap(List::stream)
5859
.filter(JAXBElement.class::isInstance).map(JAXBElement.class::cast)
5960
.filter(Predicate.not(JAXBElement::isNil))
60-
.map(JAXBElement::getValue).collect(Collectors.toList());
61+
.map(JAXBElement::getValue).collect(toList());
6162

6263
List<T> result = new ArrayList<>();
6364
for (Object compasElement : compasElements) {
@@ -239,13 +240,121 @@ private static TPrivate createPrivate(JAXBElement<?> jaxbElement) {
239240
}
240241

241242

243+
/**
244+
* Sorts in map of ICD_SYSTEM_VERSION_UUID and related Private coupled with all corresponding STD for all given STD
245+
*
246+
* @param stds list of STD to short
247+
* @return map of ICD_SYSTEM_VERSION_UUID attribute in IED/Private:COMPAS-ICDHeader and related Private coupled with
248+
* all corresponding STD
249+
*/
250+
public static Map<String, PrivateLinkedToSTDs> createMapICDSystemVersionUuidAndSTDFile(Set<SCL> stds) {
251+
Map<String, PrivateLinkedToSTDs> stringSCLMap = new HashMap<>();
252+
stds.forEach(std -> std.getIED().forEach(ied -> ied.getPrivate().forEach(tp ->
253+
PrivateService.extractCompasICDHeader(tp).map(TCompasICDHeader::getICDSystemVersionUUID).ifPresent(icdSysVer -> {
254+
PrivateLinkedToSTDs privateLinkedToSTDs = stringSCLMap.get(icdSysVer);
255+
List<SCL> list = privateLinkedToSTDs != null ? privateLinkedToSTDs.stdList() : new ArrayList<>();
256+
list.add(std);
257+
stringSCLMap.put(icdSysVer, new PrivateLinkedToSTDs(tp, list));
258+
})
259+
)));
260+
return stringSCLMap;
261+
}
242262

243263

264+
public record PrivateLinkedToSTDs (TPrivate tPrivate, List<SCL> stdList) {
265+
}
244266

245267

268+
/**
269+
* Checks SCD and STD compatibilities by checking if there is at least one ICD_SYSTEM_VERSION_UUID in
270+
* Substation/../LNode/Private COMPAS-ICDHeader of SCL not present in IED/Private COMPAS-ICDHeader of STD
271+
*
272+
* @param mapICDSystemVersionUuidAndSTDFile map of ICD_SYSTEM_VERSION_UUID and list of corresponding STD
273+
* @throws ScdException throws when there are several STD files corresponding to <em>ICD_SYSTEM_VERSION_UUID</em>
274+
* from Substation/../LNode/Private COMPAS-ICDHeader of SCL
275+
*/
276+
public static void checkSTDCorrespondanceWithLNodeCompasICDHeader(Map<String, PrivateLinkedToSTDs> mapICDSystemVersionUuidAndSTDFile) throws ScdException {
277+
mapICDSystemVersionUuidAndSTDFile.values().stream()
278+
.filter(privateLinkedToSTDs -> privateLinkedToSTDs.stdList().size() != 1)
279+
.findFirst()
280+
.ifPresent(pToStd -> {
281+
throw new ScdException("There are several STD files corresponding to " + stdCheckFormatExceptionMessage(pToStd.tPrivate()));
282+
});
283+
}
246284

285+
/**
286+
* Creates formatted message including data's of Private for Exception
287+
*
288+
* @param key Private causing exception
289+
* @return formatted message
290+
* @throws ScdException throws when parameter not present in Private
291+
*/
292+
public static String stdCheckFormatExceptionMessage(TPrivate key) throws ScdException {
293+
Optional<TCompasICDHeader> optionalCompasICDHeader = PrivateService.extractCompasICDHeader(key);
294+
return HEADER_ID + " = " + optionalCompasICDHeader.map(TCompasICDHeader::getHeaderId).orElse(null) + " " +
295+
HEADER_VERSION + " = " + optionalCompasICDHeader.map(TCompasICDHeader::getHeaderVersion).orElse(null) + " " +
296+
HEADER_REVISION + " = " + optionalCompasICDHeader.map(TCompasICDHeader::getHeaderRevision).orElse(null) +
297+
" and " + ICD_SYSTEM_VERSION_UUID + " = " + optionalCompasICDHeader.map(TCompasICDHeader::getICDSystemVersionUUID).orElse(null);
298+
}
247299

248300

301+
/**
302+
* Creates map of IEDName and related Private for all Privates COMPAS-ICDHeader in /Substation of SCL
303+
*
304+
* @param scdRootAdapter SCL file in which Private should be found
305+
* @return map of Private and its IEDName parameter
306+
*/
307+
public static Stream<TPrivate> createMapIEDNameAndPrivate(SclRootAdapter scdRootAdapter) {
308+
return scdRootAdapter.getCurrentElem().getSubstation().get(0).getVoltageLevel().stream()
309+
.map(TVoltageLevel::getBay).flatMap(Collection::stream)
310+
.map(TBay::getFunction).flatMap(Collection::stream)
311+
.map(TFunction::getLNode).flatMap(Collection::stream)
312+
.map(TLNode::getPrivate).flatMap(Collection::stream)
313+
.filter(tPrivate ->
314+
tPrivate.getType().equals(COMPAS_ICDHEADER.getPrivateType())
315+
&& PrivateService.extractCompasICDHeader(tPrivate).isPresent()
316+
&& PrivateService.extractCompasICDHeader(tPrivate).get().getIEDName() != null);
317+
}
318+
319+
320+
/**
321+
* Compares if two Private:COMPAS-ICDHeader have all attributes equal except IEDNane, BayLabel and IEDinstance
322+
*
323+
* @param iedPrivate Private of IED from STD to compare
324+
* @param scdPrivate Private of LNode fro SCD to compare
325+
* @return <em>Boolean</em> value of check result
326+
* @throws ScdException throws when Private is not COMPAS_ICDHEADER one
327+
*/
328+
public static boolean comparePrivateCompasICDHeaders(TPrivate iedPrivate, TPrivate scdPrivate) throws ScdException {
329+
TCompasICDHeader iedCompasICDHeader = PrivateService.extractCompasICDHeader(iedPrivate)
330+
.orElseThrow(() -> new ScdException(COMPAS_ICDHEADER + "not found in IED Private "));
331+
TCompasICDHeader scdCompasICDHeader = PrivateService.extractCompasICDHeader(scdPrivate)
332+
.orElseThrow(() -> new ScdException(COMPAS_ICDHEADER + "not found in LNode Private "));
333+
return Objects.equals(iedCompasICDHeader.getIEDType(), scdCompasICDHeader.getIEDType())
334+
&& Objects.equals(iedCompasICDHeader.getICDSystemVersionUUID(), scdCompasICDHeader.getICDSystemVersionUUID())
335+
&& Objects.equals(iedCompasICDHeader.getVendorName(), scdCompasICDHeader.getVendorName())
336+
&& Objects.equals(iedCompasICDHeader.getIEDredundancy(), scdCompasICDHeader.getIEDredundancy())
337+
&& Objects.equals(iedCompasICDHeader.getIEDmodel(), scdCompasICDHeader.getIEDmodel())
338+
&& Objects.equals(iedCompasICDHeader.getHwRev(), scdCompasICDHeader.getHwRev())
339+
&& Objects.equals(iedCompasICDHeader.getSwRev(), scdCompasICDHeader.getSwRev())
340+
&& Objects.equals(iedCompasICDHeader.getHeaderId(), scdCompasICDHeader.getHeaderId())
341+
&& Objects.equals(iedCompasICDHeader.getHeaderRevision(), scdCompasICDHeader.getHeaderRevision())
342+
&& Objects.equals(iedCompasICDHeader.getHeaderVersion(), scdCompasICDHeader.getHeaderVersion());
343+
}
344+
345+
/**
346+
* Copy Private COMPAS_ICDHEADER from LNode of SCD into Private COMPAS_ICDHEADER from IED of STD
347+
*
348+
* @param stdPrivate Private of IED from STD in which to copy new data
349+
* @param lNodePrivate Private of IED from STD from which new data are taken
350+
* @throws ScdException throws when Private is not COMPAS_ICDHEADER one
351+
*/
352+
public static void copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate(TPrivate stdPrivate, TPrivate lNodePrivate) throws ScdException {
353+
TCompasICDHeader lNodeCompasICDHeader = extractCompasICDHeader(lNodePrivate)
354+
.orElseThrow(() -> new ScdException(COMPAS_ICDHEADER + " not found in LNode Private "));
355+
stdPrivate.getContent().clear();
356+
stdPrivate.getContent().add(objectFactory.createICDHeader(lNodeCompasICDHeader));
357+
}
249358

250359

251360
}

0 commit comments

Comments
 (0)