Skip to content

Commit

Permalink
LDEPF Post processing - reviews
Browse files Browse the repository at this point in the history
Signed-off-by: Samir Romdhani <[email protected]>
  • Loading branch information
samirromdhani committed Aug 23, 2024
1 parent 25548c7 commit 5712365
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,38 +330,35 @@ public List<SclReportItem> manageBindingForLDEPF(SCL scd, EPF epf) {
public void epfPostProcessing(SCL scd) {
iedService.getFilteredIeds(scd, ied -> !ied.getName().contains("TEST"))
.forEach(tied -> ldeviceService.findLdevice(tied, tlDevice -> LDEVICE_LDEPF.equals(tlDevice.getInst()))
.ifPresent(tlDevice -> {
List<TDOI> tdoiList = tlDevice.getLN0().getDOI()
.stream().filter(tdoi -> tdoi.getName().startsWith("InRef"))
.toList();
for (TDOI tdoi: tdoiList){
DoLinkedToDaFilter doLinkedToSetSrcRef = new DoLinkedToDaFilter(tdoi.getName(), List.of(), SETSRCREF_DA_NAME, List.of());
Optional<TDAI> setSrcRefDAI = lnEditor.getDOAndDAInstances(tlDevice.getLN0(), doLinkedToSetSrcRef);
DoLinkedToDaFilter doLinkedPurPose = new DoLinkedToDaFilter(tdoi.getName(), List.of(), PURPOSE_DA_NAME, List.of());
Optional<TDAI> purPoseDAI = lnEditor.getDOAndDAInstances(tlDevice.getLN0(), doLinkedPurPose);

boolean isSetSrcRefExistAndEmpty = setSrcRefDAI.isPresent()
&& (!setSrcRefDAI.get().isSetVal()
|| (setSrcRefDAI.get().isSetVal()
&& setSrcRefDAI.get().getVal().getFirst().getValue().isEmpty()));
boolean isPurposeExistAndMatchChannel = purPoseDAI.isPresent()
&& purPoseDAI.get().isSetVal()
&& (purPoseDAI.get().getVal().getFirst().getValue().startsWith("DYN_LDEPF_DIGITAL CHANNEL")
|| purPoseDAI.get().getVal().getFirst().getValue().startsWith("DYN_LDEPF_ANALOG CHANNEL"));
if(isSetSrcRefExistAndEmpty && isPurposeExistAndMatchChannel) {

DoLinkedToDa doLinkedToDa = new DoLinkedToDa();
DataObject dataObject = new DataObject();
dataObject.setDoName(tdoi.getName());
doLinkedToDa.setDataObject(dataObject);
DataAttribute dataAttribute = new DataAttribute();
dataAttribute.setDaName(SETSRCREF_DA_NAME);
dataAttribute.setDaiValues(List.of(new DaVal(null, tied.getName()+tlDevice.getInst()+"/LPHD0.Proxy")));
doLinkedToDa.setDataAttribute(dataAttribute);
lnEditor.updateOrCreateDOAndDAInstances(tlDevice.getLN0(), doLinkedToDa);
}
}
}));
.ifPresent(tlDevice -> tlDevice.getLN0().getDOI()
.stream().filter(tdoi -> tdoi.getName().startsWith(INREF_PREFIX))
.forEach(tdoi -> {
DoLinkedToDaFilter doLinkedToSetSrcRef = new DoLinkedToDaFilter(tdoi.getName(), List.of(), SETSRCREF_DA_NAME, List.of());
Optional<TDAI> setSrcRefDAI = lnEditor.getDOAndDAInstances(tlDevice.getLN0(), doLinkedToSetSrcRef);
DoLinkedToDaFilter doLinkedPurPose = new DoLinkedToDaFilter(tdoi.getName(), List.of(), PURPOSE_DA_NAME, List.of());
Optional<TDAI> purPoseDAI = lnEditor.getDOAndDAInstances(tlDevice.getLN0(), doLinkedPurPose);

boolean isSetSrcRefExistAndEmpty = setSrcRefDAI.isPresent()
&& (!setSrcRefDAI.get().isSetVal()
|| (setSrcRefDAI.get().isSetVal()
&& setSrcRefDAI.get().getVal().getFirst().getValue().isEmpty()));
boolean isPurposeExistAndMatchChannel = purPoseDAI.isPresent()
&& purPoseDAI.get().isSetVal()
&& (purPoseDAI.get().getVal().getFirst().getValue().startsWith("DYN_LDEPF_DIGITAL CHANNEL")
|| purPoseDAI.get().getVal().getFirst().getValue().startsWith("DYN_LDEPF_ANALOG CHANNEL"));
if(isSetSrcRefExistAndEmpty && isPurposeExistAndMatchChannel) {

DoLinkedToDa doLinkedToDa = new DoLinkedToDa();
DataObject dataObject = new DataObject();
dataObject.setDoName(tdoi.getName());
doLinkedToDa.setDataObject(dataObject);
DataAttribute dataAttribute = new DataAttribute();
dataAttribute.setDaName(SETSRCREF_DA_NAME);
dataAttribute.setDaiValues(List.of(new DaVal(null, tied.getName()+tlDevice.getInst()+"/LPHD0.Proxy")));
doLinkedToDa.setDataAttribute(dataAttribute);
lnEditor.updateOrCreateDOAndDAInstances(tlDevice.getLN0(), doLinkedToDa);
}
})));
}

private List<SclReportItem> validateIed(SclRootAdapter sclRootAdapter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.lfenergy.compas.sct.commons.util.CommonConstants.BEHAVIOUR_DO_NAME;
import static org.lfenergy.compas.sct.commons.util.CommonConstants.STVAL_DA_NAME;
import static org.lfenergy.compas.sct.commons.util.CommonConstants.*;

/**
* A representation of the model object
Expand Down Expand Up @@ -73,8 +72,6 @@ public class LN0Adapter extends AbstractLNAdapter<LN0> {

public static final DoTypeName BEHAVIOUR_DO_TYPE_NAME = new DoTypeName(BEHAVIOUR_DO_NAME);
public static final DaTypeName BEHAVIOUR_DA_TYPE_NAME = getDaTypeNameForBeh();
private static final String DAI_NAME_PURPOSE = "purpose";
private static final String INREF_PREFIX = "InRef";

/**
* Constructor
Expand Down Expand Up @@ -234,8 +231,8 @@ public List<SclReportItem> updateDoInRef() {
return getDOIAdapters().stream()
.filter(doiAdapter -> doiAdapter.getCurrentElem().isSetName()
&& doiAdapter.getCurrentElem().getName().startsWith(INREF_PREFIX)
&& doiAdapter.findDataAdapterByName(DAI_NAME_PURPOSE).isPresent())
.map(doiAdapter -> doiAdapter.getDataAdapterByName(DAI_NAME_PURPOSE).getCurrentElem().getVal().stream()
&& doiAdapter.findDataAdapterByName(PURPOSE_DA_NAME).isPresent())
.map(doiAdapter -> doiAdapter.getDataAdapterByName(PURPOSE_DA_NAME).getCurrentElem().getVal().stream()
.findFirst()
.map(tVal -> doiAdapter.updateDaiFromExtRef(getBoundExtRefsByDesc(tVal.getValue())))
.orElse(List.of(SclReportItem.warning(getXPath(), "The DOI %s can't be bound with an ExtRef".formatted(getXPath()))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class CommonConstants {
public static final String PURPOSE_DA_NAME = "purpose";
public static final String Q_DA_NAME = "q";
public static final String IED_TEST_NAME = "IEDTEST";
public static final String INREF_PREFIX = "InRef";

/**
* Private Controlller, should not be instanced
Expand Down

0 comments on commit 5712365

Please sign in to comment.