Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.2.36 #472

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<DoLinkedToDa> getAllSDOLinkedToDa(TDataTypeTemplates dtt, TDOType td
List<DoLinkedToDa> result = new ArrayList<>();
// DA -> BDA -> BDA..
sdoOrDAService.getDAs(tdoType).forEach(tda -> {
DoLinkedToDa doLinkedToDa = DoLinkedToDa.copyFrom(doLinkedToDaTemplate);
DoLinkedToDa doLinkedToDa = doLinkedToDaTemplate.deepCopy();
doLinkedToDa.dataAttribute().setDaName(tda.getName());
if (tda.isSetFc()) {
doLinkedToDa.dataAttribute().setFc(tda.getFc());
Expand All @@ -57,7 +57,7 @@ public List<DoLinkedToDa> getAllSDOLinkedToDa(TDataTypeTemplates dtt, TDOType td
if (tsdo.isSetType()) {
findDoType(dtt, tdoType1 -> tdoType1.getId().equals(tsdo.getType()))
.ifPresent(nextDoType -> {
DoLinkedToDa newDoLinkedToDa = DoLinkedToDa.copyFrom(doLinkedToDaTemplate);
DoLinkedToDa newDoLinkedToDa = doLinkedToDaTemplate.deepCopy();
newDoLinkedToDa.dataObject().getSdoNames().add(tsdo.getName());
if (nextDoType.isSetCdc()) {
newDoLinkedToDa.dataObject().setCdc(nextDoType.getCdc());
Expand All @@ -73,7 +73,7 @@ private Stream<DoLinkedToDa> getDaLinkedToBDA(TDataTypeTemplates dtt, TDAType td
// BDA -> BDA -> BDA..
return bdaService.getBDAs(tdaType1)
.flatMap(tbda -> {
DoLinkedToDa newDoLinkedToDa = DoLinkedToDa.copyFrom(doLinkedToDaTemplate);
DoLinkedToDa newDoLinkedToDa = doLinkedToDaTemplate.deepCopy();
newDoLinkedToDa.dataAttribute().getBdaNames().add(tbda.getName());

// STRUCT type (BType=STRUCT) refer to complex BDA object, otherwise it is kind of DA object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,15 @@ public void updateOrCreateDOAndDAInstances(TAnyLN tAnyLN, DoLinkedToDa doLinkedT
});
}

public void completeFromDAInstance(TIED tied, String ldInst, TAnyLN anyLN, DoLinkedToDa doLinkedToDa) {
@Override
public DoLinkedToDa getDoLinkedToDaCompletedFromDAI(TIED tied, String ldInst, TAnyLN anyLN, DoLinkedToDa doLinkedToDa) {
DoLinkedToDa result = doLinkedToDa.deepCopy();
getDOAndDAInstances(anyLN, doLinkedToDa.toFilter())
.ifPresent(tdai -> {
if (tdai.isSetVal()) {
doLinkedToDa.dataAttribute().addDaVal(tdai.getVal());
result.dataAttribute().addDaVal(tdai.getVal());
}
if (doLinkedToDa.dataAttribute().getFc() == TFCEnum.SG || doLinkedToDa.dataAttribute().getFc() == TFCEnum.SE) {
if (result.dataAttribute().getFc() == TFCEnum.SG || result.dataAttribute().getFc() == TFCEnum.SE) {
if (hasSettingGroup(tdai)) {
boolean isIedHasConfSG = tied.isSetAccessPoint() &&
tied.getAccessPoint().stream()
Expand All @@ -163,15 +165,16 @@ public void completeFromDAInstance(TIED tied, String ldInst, TAnyLN anyLN, DoLin
&& tAccessPoint.getServices() != null
&& tAccessPoint.getServices().getSettingGroups() != null
&& tAccessPoint.getServices().getSettingGroups().getConfSG() != null);
doLinkedToDa.dataAttribute().setValImport((!tdai.isSetValImport() || tdai.isValImport()) && isIedHasConfSG);
result.dataAttribute().setValImport((!tdai.isSetValImport() || tdai.isValImport()) && isIedHasConfSG);
} else {
log.warn(String.format("Inconsistency in the SCD file - DAI= %s with fc= %s must have a sGroup attribute", tdai.getName(), doLinkedToDa.dataAttribute().getFc()));
doLinkedToDa.dataAttribute().setValImport(false);
log.warn("Inconsistency in the SCD file - DAI= {} with fc= {} must have a sGroup attribute", tdai.getName(), result.dataAttribute().getFc());
result.dataAttribute().setValImport(false);
}
} else if (tdai.isSetValImport()) {
doLinkedToDa.dataAttribute().setValImport(tdai.isValImport());
result.dataAttribute().setValImport(tdai.isValImport());
}
});
return result;
}

public boolean matchesLn(TAnyLN tAnyLN, String lnClass, String lnInst, String lnPrefix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.lfenergy.compas.scl2007b4.model.TAnyLN;
import org.lfenergy.compas.scl2007b4.model.TDAI;
import org.lfenergy.compas.scl2007b4.model.TIED;
import org.lfenergy.compas.sct.commons.domain.DoLinkedToDa;
import org.lfenergy.compas.sct.commons.domain.DoLinkedToDaFilter;
import org.lfenergy.compas.sct.commons.util.ActiveStatus;
Expand All @@ -22,4 +23,5 @@ public interface LnEditor {

void updateOrCreateDOAndDAInstances(TAnyLN tAnyLN, DoLinkedToDa doLinkedToDa);

DoLinkedToDa getDoLinkedToDaCompletedFromDAI(TIED tied, String ldInst, TAnyLN anyLN, DoLinkedToDa doLinkedToDa);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Getter
@Setter
Expand All @@ -26,19 +27,24 @@ public class DataAttribute {
private List<String> bdaNames = new ArrayList<>();
private List<DaVal> daiValues = new ArrayList<>();

public static DataAttribute copyFrom(DataAttribute dataAttribute) {
DataAttribute dataAttribute1 = new DataAttribute();
dataAttribute1.setDaName(dataAttribute.getDaName());
dataAttribute1.setFc(dataAttribute.getFc());
dataAttribute1.setBType(dataAttribute.getBType());
dataAttribute1.setType(dataAttribute.getType());
dataAttribute1.getBdaNames().addAll(dataAttribute.getBdaNames());
dataAttribute1.setValImport(dataAttribute.isValImport());
return dataAttribute1;
public DataAttribute deepCopy() {
DataAttribute dataAttribute = new DataAttribute();
dataAttribute.setDaName(getDaName());
dataAttribute.setType(getType());
dataAttribute.setBType(getBType());
dataAttribute.setFc(getFc());
dataAttribute.setValImport(isValImport());
dataAttribute.getBdaNames().addAll(getBdaNames());
dataAttribute.getDaiValues().addAll(getDaiValues());
return dataAttribute;
}

public void addDaVal(List<TVal> vals) {
vals.forEach(tVal -> daiValues.add(new DaVal(tVal.isSetSGroup() ? tVal.getSGroup() : null, tVal.getValue())));
vals.forEach(tVal -> {
Long settingGroup = tVal.isSetSGroup() ? tVal.getSGroup() : null;
daiValues.removeIf(daVal -> Objects.equals(daVal.settingGroup(), settingGroup));
daiValues.add(new DaVal(settingGroup, tVal.getValue()));
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public DataObject(String doName, TPredefinedCDCEnum cdc, List<String> sdoNames)
this.sdoNames.addAll(sdoNames);
}

public static DataObject copyFrom(DataObject dataObject) {
return new DataObject(dataObject.getDoName(), dataObject.getCdc(), dataObject.getSdoNames());
public DataObject deepCopy() {
return new DataObject(getDoName(), getCdc(), getSdoNames());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

public record DoLinkedToDa(DataObject dataObject, DataAttribute dataAttribute) {

public static DoLinkedToDa copyFrom(DoLinkedToDa doLinkedToDa) {
public DoLinkedToDa deepCopy() {
return new DoLinkedToDa(
DataObject.copyFrom(doLinkedToDa.dataObject()),
DataAttribute.copyFrom(doLinkedToDa.dataAttribute()));
dataObject().deepCopy(),
dataAttribute().deepCopy());
}

public String getDoRef() {
Expand Down
Loading
Loading