Skip to content

Commit

Permalink
feat(404-rsr-1004): Add constraints to update compas flow bindings
Browse files Browse the repository at this point in the history
- modification of ExtRefEditorService and add a test
- modification of ExtRefEditor interface to return List with updateIedNameBasedOnLnode()

Signed-off-by: JAFFRE Guillaume <guillaume.jaffre@rte-france.com>
  • Loading branch information
GuillaumeJAFFRE committed Jul 3, 2024
1 parent 84ef6bd commit 4d3455b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static List<TIED> getIedSources(SclRootAdapter sclRootAdapter, TCompasBa
*/
private List<ExtRefInfo.ExtRefWithBayReference> getExtRefWithBayReferenceInLDEPF(TDataTypeTemplates dataTypeTemplates, TIED tied, final TLDevice tlDevice, final List<SclReportItem> sclReportItems) {
List<ExtRefInfo.ExtRefWithBayReference> extRefBayReferenceList = new ArrayList<>();
String lDevicePath = "SCL/IED[@name=\""+ tied.getName() + "\"]/AccessPoint/Server/LDevice[@inst=\"" + tlDevice.getInst() + "\"]";
String lDevicePath = "SCL/IED[@name=\"" + tied.getName() + "\"]/AccessPoint/Server/LDevice[@inst=\"" + tlDevice.getInst() + "\"]";
Optional<TCompasBay> tCompasBay = PrivateUtils.extractCompasPrivate(tied, TCompasBay.class);
if (tCompasBay.isEmpty()) {
sclReportItems.add(SclReportItem.error(lDevicePath, "The IED has no Private Bay"));
Expand Down Expand Up @@ -405,8 +405,7 @@ private List<SclReportItem> updateLDEPFDos(LDeviceAdapter lDeviceAdapter, TExtRe
private Optional<SclReportItem> updateVal(AbstractLNAdapter<?> lnAdapter, String doName, String daName, TExtRef extRef, TChannel setting) {
String value = switch (daName) {
case DU_DA_NAME -> setting.getChannelShortLabel();
case SETVAL_DA_NAME ->
LN_PREFIX_B.equals(lnAdapter.getPrefix()) || LN_PREFIX_A.equals(lnAdapter.getPrefix()) ? setting.getChannelLevModQ().value() : setting.getChannelLevMod().value();
case SETVAL_DA_NAME -> LN_PREFIX_B.equals(lnAdapter.getPrefix()) || LN_PREFIX_A.equals(lnAdapter.getPrefix()) ? setting.getChannelLevModQ().value() : setting.getChannelLevMod().value();
case STVAL_DA_NAME -> ActiveStatus.ON.getValue();
case SETSRCREF_DA_NAME -> computeDaiValue(lnAdapter, extRef, setting.getDAName());
default -> null;
Expand Down Expand Up @@ -492,7 +491,7 @@ public List<SclReportItem> updateIedNameBasedOnLnode(SCL scl) {
.filter(tlNode -> {
TCompasICDHeader tCompasICDHeader = PrivateUtils.extractCompasPrivate(tlNode, TCompasICDHeader.class)
.orElseThrow(() -> new ScdException(("The substation LNode with following attributes : IedName:%s / LdInst:%s / LnClass:%s / LnInst:%s " +
"does not contain the needed private (COMPAS - ICDHeader)")
"does not contain the needed (COMPAS - ICDHeader) private")
.formatted(tlNode.getIedName(), tlNode.getLdInst(), tlNode.getLnClass().getFirst(), tlNode.getLnInst())));
return Objects.equals(tCompasFlow.getFlowSourceIEDType(), tCompasICDHeader.getIEDType())
&& Objects.equals(tCompasFlow.getFlowIEDSystemVersioninstance(), tCompasICDHeader.getIEDSystemVersioninstance())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package org.lfenergy.compas.sct.commons;

import jakarta.xml.bind.Marshaller;
import org.assertj.core.api.Assertions;
import org.assertj.core.groups.Tuple;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -21,11 +20,9 @@
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;
import org.lfenergy.compas.sct.commons.util.PrivateUtils;

import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
Expand Down Expand Up @@ -937,10 +934,10 @@ void updateIedNameBasedOnLnode_when_several_ied_match_compasFlow_should_return_a
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_based_on_lnode_several_ied_matching.xml");
// When
List<SclReportItem> result = extRefEditorService.updateIedNameBasedOnLnode(scd);
List<SclReportItem> result = extRefEditorService.updateIedNameBasedOnLnode(scd);
// Then
assertThat(result)
.extracting(SclReportItem::isError,SclReportItem::message)
.extracting(SclReportItem::isError, SclReportItem::message)
.containsExactly(Tuple.tuple(true,
"Several LNode@IedName ('IED_NAME2', 'IED_NAME3') are found in the bay 'BAY_1' for the following compas-flow attributes " +
": @FlowSourceIEDType 'SCU' @FlowSourceIEDredundancy 'A' @FlowIEDSystemVersioninstance '1'"));
Expand Down

0 comments on commit 4d3455b

Please sign in to comment.