Skip to content

Commit d83efeb

Browse files
committed
feat / review deconstructing compas-flow
Signed-off-by: Samir Romdhani <[email protected]>
1 parent 66c01ca commit d83efeb

File tree

4 files changed

+10
-224
lines changed

4 files changed

+10
-224
lines changed

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@
1515
import org.lfenergy.compas.sct.commons.model.epf.TCBScopeType;
1616
import org.lfenergy.compas.sct.commons.model.epf.TChannel;
1717
import org.lfenergy.compas.sct.commons.model.epf.TChannelType;
18-
import org.lfenergy.compas.sct.commons.scl.ExtRefService;
1918
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
2019
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
2120
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
2221
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;
2322
import org.lfenergy.compas.sct.commons.util.ActiveStatus;
24-
import org.lfenergy.compas.sct.commons.util.PrivateEnum;
2523
import org.lfenergy.compas.sct.commons.util.PrivateUtils;
2624
import org.lfenergy.compas.sct.commons.util.Utils;
2725

28-
import java.math.BigInteger;
2926
import java.util.*;
30-
import java.util.stream.Collectors;
3127

3228
import static org.apache.commons.lang3.StringUtils.*;
3329
import static org.lfenergy.compas.sct.commons.util.CommonConstants.*;
@@ -325,48 +321,6 @@ public void epfPostProcessing(SCL scd) {
325321
})));
326322
}
327323

328-
private List<SclReportItem> validateIed(SclRootAdapter sclRootAdapter) {
329-
List<SclReportItem> iedErrors = new ArrayList<>(checkIedCompasIcdHeaderAttributes(sclRootAdapter));
330-
iedErrors.addAll(checkIedUnityOfIcdSystemVersionUuid(sclRootAdapter));
331-
return iedErrors;
332-
}
333-
334-
private List<SclReportItem> checkIedCompasIcdHeaderAttributes(SclRootAdapter sclRootAdapter) {
335-
return sclRootAdapter.streamIEDAdapters()
336-
.map(iedAdapter -> {
337-
Optional<TCompasICDHeader> compasPrivate = iedAdapter.getCompasICDHeader();
338-
if (compasPrivate.isEmpty()) {
339-
return iedAdapter.buildFatalReportItem(String.format("IED has no Private %s element", PrivateEnum.COMPAS_ICDHEADER.getPrivateType()));
340-
}
341-
if (isBlank(compasPrivate.get().getICDSystemVersionUUID())
342-
|| isBlank(compasPrivate.get().getIEDName())) {
343-
return iedAdapter.buildFatalReportItem(String.format("IED private %s as no icdSystemVersionUUID or iedName attribute",
344-
PrivateEnum.COMPAS_ICDHEADER.getPrivateType()));
345-
}
346-
return null;
347-
}
348-
).filter(Objects::nonNull)
349-
.toList();
350-
}
351-
352-
private List<SclReportItem> checkIedUnityOfIcdSystemVersionUuid(SclRootAdapter sclRootAdapter) {
353-
Map<String, List<TIED>> systemVersionToIedList = sclRootAdapter.getCurrentElem().getIED().stream()
354-
.collect(Collectors.groupingBy(ied -> PrivateUtils.extractCompasPrivate(ied, TCompasICDHeader.class)
355-
.map(TCompasICDHeader::getICDSystemVersionUUID)
356-
.orElse("")));
357-
358-
return systemVersionToIedList.entrySet().stream()
359-
.filter(entry -> isNotBlank(entry.getKey()))
360-
.filter(entry -> entry.getValue().size() > 1)
361-
.map(entry -> SclReportItem.error(entry.getValue().stream()
362-
.map(tied -> new IEDAdapter(sclRootAdapter, tied))
363-
.map(IEDAdapter::getXPath)
364-
.collect(Collectors.joining(", ")),
365-
"/IED/Private/compas:ICDHeader[@ICDSystemVersionUUID] must be unique" +
366-
" but the same ICDSystemVersionUUID was found on several IED."))
367-
.toList();
368-
}
369-
370324
private void updateLDEPFExtRefBinding(TExtRef extRef, TIED iedSource, TChannel setting) {
371325
extRef.setIedName(iedSource.getName());
372326
extRef.setLdInst(setting.getLDInst());
@@ -434,12 +388,6 @@ private String computeDaiValue(AbstractLNAdapter<?> lnAdapter, TExtRef extRef, S
434388
}
435389
}
436390

437-
record TopoKey(String FlowNode, BigInteger FlowNodeOrder) {
438-
}
439-
440-
record BayTopoKey(TBay bay, TopoKey topoKey) {
441-
}
442-
443391
private record DoNameAndDaName(String doName, String daName) {
444392
}
445393

sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.lfenergy.compas.sct.commons.dto.*;
1717
import org.lfenergy.compas.sct.commons.exception.ScdException;
1818
import org.lfenergy.compas.sct.commons.model.epf.*;
19-
import org.lfenergy.compas.sct.commons.scl.ExtRefService;
2019
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
2120
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;
2221
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;

sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -153,44 +153,34 @@ void updateAllSourceDataSetsAndControlBlocks_should_create_dataset_and_fcda_for_
153153
public static Stream<Arguments> provideCreateFCDA() {
154154
return Stream.of(
155155
Arguments.of(named("should include signal internal to a Bay",
156-
"test bay internal"),
157-
"IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
156+
"test bay internal"), "IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
158157
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "DoName", "daNameST", TFCEnum.ST))),
159158
Arguments.of(named("should include signal external to a Bay",
160-
"test bay external"),
161-
"IED_NAME3/LD_INST31/DS_LD_INST31_GSE",
159+
"test bay external"), "IED_NAME3/LD_INST31/DS_LD_INST31_GSE",
162160
List.of(new FCDARecord("LD_INST31", "ANCR", "1", "", "DoName", "daNameST", TFCEnum.ST))),
163161
Arguments.of(named("keep source DA with fc = ST",
164-
"test daName ST"),
165-
"IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
162+
"test daName ST"), "IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
166163
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "DoName", "daNameST", TFCEnum.ST))),
167164
Arguments.of(named("keep source DA with fc = MX",
168-
"test daName MX"),
169-
"IED_NAME2/LD_INST21/DS_LD_INST21_GMI",
165+
"test daName MX"), "IED_NAME2/LD_INST21/DS_LD_INST21_GMI",
170166
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "DoName", "daNameMX", TFCEnum.MX))),
171167
Arguments.of(named("for GOOSE, should keep only valid fcda candidates",
172-
"test ServiceType is GOOSE, no daName and DO contains ST and MX, but only ST is FCDA candidate"),
173-
"IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
168+
"test ServiceType is GOOSE, no daName and DO contains ST and MX, but only ST is FCDA candidate"), "IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
174169
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "OtherDoName", "daNameST", TFCEnum.ST))),
175170
Arguments.of(named("for SMV, should keep only valid fcda candidates",
176-
"test ServiceType is SMV, no daName and DO contains ST and MX, but only ST is FCDA candidate"),
177-
"IED_NAME2/LD_INST21/DS_LD_INST21_SVI",
171+
"test ServiceType is SMV, no daName and DO contains ST and MX, but only ST is FCDA candidate"), "IED_NAME2/LD_INST21/DS_LD_INST21_SVI",
178172
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "OtherDoName", "daNameST", TFCEnum.ST))),
179173
Arguments.of(named("for Report, should get source daName from ExtRef.desc to deduce FC ST",
180-
"test ServiceType is Report_daReportST_1"),
181-
"IED_NAME2/LD_INST21/DS_LD_INST21_DQCI",
174+
"test ServiceType is Report_daReportST_1"), "IED_NAME2/LD_INST21/DS_LD_INST21_DQCI",
182175
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "DoName", null, TFCEnum.ST))),
183176
Arguments.of(named("for Report, should get source daName from ExtRef.desc to deduce FC MX",
184-
"test ServiceType is Report_daReportMX_1"),
185-
"IED_NAME2/LD_INST21/DS_LD_INST21_CYCI",
177+
"test ServiceType is Report_daReportMX_1"), "IED_NAME2/LD_INST21/DS_LD_INST21_CYCI",
186178
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "DoName", null, TFCEnum.MX))),
187179
Arguments.of(named("should ignore instance number when checking FCDA Candidate file",
188-
"test no daName and doName with instance number"),
189-
"IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
180+
"test no daName and doName with instance number"), "IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
190181
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "DoWithInst1", "daNameST", TFCEnum.ST))),
191182
Arguments.of(named("should ignore instance number when checking FCDA Candidate file (DO with SDO)",
192-
"test no daName and doName with instance number and SDO"),
193-
"IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
183+
"test no daName and doName with instance number and SDO"), "IED_NAME2/LD_INST21/DS_LD_INST21_GSI",
194184
List.of(new FCDARecord("LD_INST21", "ANCR", "1", "", "DoWithInst2.subDo", "daNameST", TFCEnum.ST)))
195185
);
196186
}
@@ -214,26 +204,6 @@ void updateAllSourceDataSetsAndControlBlocks_when_no_valid_source_Da_found_shoul
214204
.allMatch(ln0Adapter -> !ln0Adapter.getCurrentElem().isSetDataSet());
215205
}
216206

217-
@ParameterizedTest
218-
@MethodSource("provideDoCreateFCDA")
219-
void updateAllSourceDataSetsAndControlBlocks_when_valid_source_Da_found_should_create_FCDA(String extRefDesc, String extRefIedName) {
220-
// Given
221-
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
222-
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
223-
InputsAdapter inputsAdapter = keepOnlyThisExtRef(sclRootAdapter, extRefDesc);
224-
DACOMM dacomm = DaComTestMarshallerHelper.getDACOMMFromFile("/cb_comm/Template_DA_COMM_v1.xml");
225-
// When
226-
List<SclReportItem> sclReportItems = inputsAdapter.updateAllSourceDataSetsAndControlBlocks(dacomm.getFCDAs().getFCDA());
227-
// Then
228-
assertThat(sclReportItems).isEmpty();
229-
assertThat(sclRootAdapter.streamIEDAdapters()
230-
.filter(iedAdapter -> iedAdapter.getName().equals(extRefIedName))
231-
.flatMap(IEDAdapter::streamLDeviceAdapters)
232-
.filter(LDeviceAdapter::hasLN0)
233-
.map(LDeviceAdapter::getLN0Adapter))
234-
.allMatch(ln0Adapter -> ln0Adapter.getCurrentElem().isSetDataSet());
235-
}
236-
237207
public static Stream<Arguments> provideDoNotCreateFCDA() {
238208
return Stream.of(
239209
Arguments.of(named("should not create FCDA for source Da different from MX and ST",
@@ -245,13 +215,6 @@ public static Stream<Arguments> provideDoNotCreateFCDA() {
245215
);
246216
}
247217

248-
public static Stream<Arguments> provideDoCreateFCDA() {
249-
return Stream.of(
250-
Arguments.of(named("should create FCDA", "test bay internal"), "IED_NAME2"),
251-
Arguments.of(named("should create FCDA", "test bay external"), "IED_NAME3")
252-
);
253-
}
254-
255218
@Test
256219
void updateAllSourceDataSetsAndControlBlocks_when_AccessPoint_does_not_have_dataset_creation_capability_should_report_error() {
257220
// Given

sct-commons/src/test/resources/scd-refresh-lnode/Test_Missing_ModstVal_In_LN0_when_binding.scd

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)