Skip to content

Commit

Permalink
feat(#351): RSR-894 Update Compasflow and extref prebindings
Browse files Browse the repository at this point in the history
Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>
  • Loading branch information
massifben committed Dec 12, 2023
1 parent 9cce141 commit fa90163
Show file tree
Hide file tree
Showing 9 changed files with 700 additions and 440 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<sonar.coverage.exclusions>sct-coverage/**</sonar.coverage.exclusions>
<aggregate.report.dir>../sct-coverage/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
<compas-core.version>0.17.0</compas-core.version>
<compas-core.version>0.18.0</compas-core.version>
<compas-scl-xsd.version>0.0.4</compas-scl-xsd.version>
<maven.plugin.javadoc>3.4.1</maven.plugin.javadoc>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,9 @@ public interface ExtRefEditor {
*/
List<SclReportItem> manageBindingForLDEPF(SCL scd, EPF epf);

/**
* Update compas:Flow.ExtRefiedName and ExtRef.iedName, based on Substation LNode iedName
*/
void updateIedNameBasedOnLnode(SCL scd);

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.lfenergy.compas.sct.commons.ExtRefService.filterDuplicatedExtRefs;
import static org.lfenergy.compas.sct.commons.ExtRefEditorService.filterDuplicatedExtRefs;

/**
* A representation of the model object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.lfenergy.compas.scl2007b4.model.*;
import org.lfenergy.compas.sct.commons.ExtRefEditorService;
import org.lfenergy.compas.sct.commons.ExtRefService;
import org.lfenergy.compas.sct.commons.dto.DataAttributeRef;
import org.lfenergy.compas.sct.commons.dto.FcdaForDataSetsCreation;
Expand Down Expand Up @@ -94,6 +95,7 @@ protected String elementXPath() {
* @return list of encountered errors
*/
public List<SclReportItem> updateAllExtRefIedNames(Map<String, IEDAdapter> icdSystemVersionToIed) {
ExtRefService extRefService = new ExtRefService();
Optional<String> optionalLDeviceStatus = getLDeviceAdapter().getLDeviceStatus();
if (optionalLDeviceStatus.isEmpty()) {
return List.of(getLDeviceAdapter().buildFatalReportItem(MESSAGE_LDEVICE_STATUS_UNDEFINED));
Expand All @@ -107,7 +109,7 @@ public List<SclReportItem> updateAllExtRefIedNames(Map<String, IEDAdapter> icdSy
.flatMap(Optional::stream)
.toList();
case OFF -> {
getExtRefs().forEach(this::clearBinding);
getExtRefs().forEach(extRefService::clearBinding);
yield Collections.emptyList();
}
};
Expand All @@ -123,19 +125,20 @@ public List<SclReportItem> updateAllExtRefIedNames(Map<String, IEDAdapter> icdSy
* @return Error if ExtRef could not be updated
*/
private Optional<SclReportItem> updateExtRefIedName(TExtRef extRef, IEDAdapter sourceIed) {
ExtRefService extRefService = new ExtRefService();
List<TCompasFlow> matchingCompasFlows = getMatchingCompasFlows(extRef);
if (!singleMatch(matchingCompasFlows)) {
return fatalReportItem(extRef,
matchingCompasFlows.isEmpty() ? MESSAGE_NO_MATCHING_COMPAS_FLOW : MESSAGE_TOO_MANY_MATCHING_COMPAS_FLOWS);
}
TCompasFlow compasFlow = matchingCompasFlows.get(0);
if (compasFlow.getFlowStatus() == TCompasFlowStatus.INACTIVE) {
clearBinding(extRef);
extRefService.clearBinding(extRef);
return Optional.empty();
}
Optional<SclReportItem> sourceValidationError = validateExtRefSource(extRef, sourceIed);
if (sourceValidationError.isPresent()) {
clearBinding(extRef);
extRefService.clearBinding(extRef);
return sourceValidationError;
}
String sourceIedName = PrivateUtils.extractCompasPrivate(sourceIed.getCurrentElem(), TCompasICDHeader.class)
Expand Down Expand Up @@ -192,22 +195,6 @@ private boolean singleMatch(List<TCompasFlow> matchingCompasFlows) {
return matchingCompasFlows.size() == 1;
}

private void clearBinding(TExtRef extRef) {
extRef.setIedName(null);
extRef.setLdInst(null);
extRef.setPrefix(null);
extRef.setLnInst(null);
extRef.setDoName(null);
extRef.setDaName(null);
extRef.setServiceType(null);
extRef.setSrcLDInst(null);
extRef.setSrcPrefix(null);
extRef.setSrcLNInst(null);
extRef.setSrcCBName(null);
extRef.unsetLnClass();
extRef.unsetSrcLNClass();
}

private Optional<SclReportItem> warningReportItem(TExtRef extRef, String message) {
return Optional.of(SclReportItem.warning(extRefXPath(extRef.getDesc()), message));
}
Expand All @@ -228,8 +215,9 @@ private String extRefXPath(String extRefDesc) {
* @return list of matching CompasFlows
*/
private List<TCompasFlow> getMatchingCompasFlows(TExtRef extRef) {
ExtRefService extRefService = new ExtRefService();
return PrivateUtils.extractCompasPrivates(currentElem, TCompasFlow.class)
.filter(compasFlow -> isMatchingExtRef(compasFlow, extRef))
.filter(compasFlow -> extRefService.matchesCompasFlow(extRef, compasFlow))
.toList();
}

Expand Down Expand Up @@ -429,7 +417,7 @@ private SclRootAdapter getSclRootAdapter() {
* @return list ExtRefs without duplication
*/
public List<TExtRef> filterDuplicatedExtRefs() {
return ExtRefService.filterDuplicatedExtRefs(getExtRefs());
return ExtRefEditorService.filterDuplicatedExtRefs(getExtRefs());
}

}
Loading

0 comments on commit fa90163

Please sign in to comment.