diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java index 538c93e65..24dfb79f8 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java @@ -330,38 +330,35 @@ public List 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 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 setSrcRefDAI = lnEditor.getDOAndDAInstances(tlDevice.getLN0(), doLinkedToSetSrcRef); - DoLinkedToDaFilter doLinkedPurPose = new DoLinkedToDaFilter(tdoi.getName(), List.of(), PURPOSE_DA_NAME, List.of()); - Optional 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")) + .forEach(tdoi -> { + DoLinkedToDaFilter doLinkedToSetSrcRef = new DoLinkedToDaFilter(tdoi.getName(), List.of(), SETSRCREF_DA_NAME, List.of()); + Optional setSrcRefDAI = lnEditor.getDOAndDAInstances(tlDevice.getLN0(), doLinkedToSetSrcRef); + DoLinkedToDaFilter doLinkedPurPose = new DoLinkedToDaFilter(tdoi.getName(), List.of(), PURPOSE_DA_NAME, List.of()); + Optional 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 validateIed(SclRootAdapter sclRootAdapter) {