Skip to content
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 @@ -16,6 +16,7 @@
import org.lfenergy.compas.sct.commons.dto.HeaderDTO;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.ControlService;
import org.lfenergy.compas.sct.commons.scl.ExtRefService;
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
Expand All @@ -33,12 +34,12 @@ class SclAutomationServiceIntegrationTest {
private SclAutomationService sclAutomationService;
private static final IedService iedService = new IedService();
private static final LnService lnService = new LnService();
private static final ExtRefReaderService extRefReaderService = new ExtRefReaderService();
private static final ExtRefService extRefService = new ExtRefService();
private static final DataTypeTemplateReader dataTypeTemplatesService = new DataTypeTemplatesService() ;
private static final LdeviceService ldeviceService = new LdeviceService(lnService);
private static final SclEditor sclEditor = new SclService(iedService, ldeviceService, lnService, extRefReaderService, dataTypeTemplatesService) ;
private static final SclEditor sclEditor = new SclService(iedService, ldeviceService, lnService, extRefService, dataTypeTemplatesService);
private static final SubstationEditor substationEditor = new SubstationService(new VoltageLevelService());
private static final ControlBlockEditor controlBlockEditor = new ControlBlockEditorService(new ControlService(), new LdeviceService(new LnService()), new ConnectedAPService(), new SubNetworkService());
private static final ControlBlockEditor controlBlockEditor = new ControlBlockEditorService(new ControlService(), new LdeviceService(new LnService()), new ConnectedAPService(), new SubNetworkService(), extRefService);

private HeaderDTO headerDTO;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.lfenergy.compas.sct.commons.model.cbcom.*;
import org.lfenergy.compas.sct.commons.model.da_comm.DACOMM;
import org.lfenergy.compas.sct.commons.scl.ControlService;
import org.lfenergy.compas.sct.commons.scl.ExtRefService;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter;
import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class ControlBlockEditorService implements ControlBlockEditor {
private final LdeviceService ldeviceService;
private final ConnectedAPService connectedAPService;
private final SubNetworkService subNetworkService;
private final ExtRefService extRefService;

@Override
public List<SclReportItem> analyzeDataGroups(SCL scd) {
Expand Down Expand Up @@ -169,8 +171,7 @@ private List<Long> findExcludedMacAddresses(SCL scl, TIED ied, TCBType tcbType)
List<TIED> iedWithExtRefFromCurrentCB = scl.getIED().stream()
.filter(tied -> !tied.getName().equals(ied.getName()))
.filter(tied -> ldeviceService.getLdevices(tied)
.filter(lDevice -> lDevice.getLN0().isSetInputs())
.flatMap(tlDevice -> tlDevice.getLN0().getInputs().getExtRef().stream())
.flatMap(extRefService::getExtRefs)
.anyMatch(tExtRef -> ied.getName().equals(tExtRef.getIedName()))
)
.toList();
Expand All @@ -189,8 +190,7 @@ private List<Long> findExcludedMacAddresses(SCL scl, TIED ied, TCBType tcbType)

private Stream<Long> getExtRefAddress(SCL scl, TIED tied) {
return ldeviceService.getLdevices(tied)
.filter(lDevice -> lDevice.getLN0().isSetInputs())
.flatMap(tlDevice -> tlDevice.getLN0().getInputs().getExtRef().stream())
.flatMap(extRefService::getExtRefs)
.filter(TExtRef::isSetSrcCBName)
.map(tExtRef -> new CbKey(tExtRef.getIedName(), tExtRef.getLdInst(), tExtRef.getSrcCBName()))
.flatMap(cbKey -> scl.getCommunication().getSubNetwork().stream()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.lfenergy.compas.sct.commons.domain.DataRef;
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.ExtRefService;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.com.CommunicationAdapter;
import org.lfenergy.compas.sct.commons.scl.com.ConnectedAPAdapter;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class SclService implements SclEditor {
private final IedService iedService;
private final LdeviceService ldeviceService;
private final LnService lnService;
private final ExtRefReaderService extRefReaderService;
private final ExtRefService extRefService;
private final DataTypeTemplateReader dataTypeTemplateService;

@Getter
Expand Down Expand Up @@ -216,7 +217,7 @@ public List<SclReportItem> manageMonitoringLns(SCL scd) {
iedService.getFilteredIeds(scd, ied -> !ied.getName().contains(IED_TEST_NAME))
.forEach(tied -> {
Map<TServiceType, List<IedSource>> serviceTypeToIedSource = ldeviceService.getLdevices(tied)
.flatMap(tlDevice -> extRefReaderService.getExtRefs(tlDevice.getLN0()))
.flatMap(extRefService::getExtRefs)
.filter(tExtRef -> tExtRef.isSetServiceType() && tExtRef.isSetSrcCBName() && (tExtRef.getServiceType().equals(TServiceType.GOOSE) || tExtRef.getServiceType().equals(TServiceType.SMV)))
.collect(Collectors.groupingBy(tExtRef -> new IedSource(tExtRef.getIedName(), tExtRef.getSrcCBName(), tExtRef.getSrcLDInst(), tExtRef.getServiceType())))
.keySet()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.scl2007b4.model.TLNodeType;
import org.lfenergy.compas.sct.commons.DataSetService;
import org.lfenergy.compas.sct.commons.ExtRefReaderService;
import org.lfenergy.compas.sct.commons.LnodeTypeService;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter;
Expand Down Expand Up @@ -71,10 +70,11 @@ public class LNodeDTO {

/**
* Constructor
* @param inst input
* @param lnClass input
*
* @param inst input
* @param lnClass input
* @param lnPrefix input
* @param lnType input
* @param lnType input
*/
public LNodeDTO(String inst, String lnClass, String lnPrefix, String lnType) {
this.inst = inst;
Expand All @@ -85,48 +85,49 @@ public LNodeDTO(String inst, String lnClass, String lnPrefix, String lnType) {

/**
* Initialize LN
*
* @param nodeAdapter input
* @param options input
* @param options input
* @param <T> LNode type (LLN0 or other LN's)
* @return LNodeDTO object
* @param <T> LNode type (LLN0 or other LN's)
*/
public static <T extends TAnyLN> LNodeDTO from(AbstractLNAdapter<T> nodeAdapter, LogicalNodeOptions options) {
log.info(Utils.entering());
LNodeDTO lNodeDTO = new LNodeDTO();
if(nodeAdapter == null) return lNodeDTO;
if (nodeAdapter == null) return lNodeDTO;

lNodeDTO.nodeType = nodeAdapter.getLnType();
lNodeDTO.nodeClass = nodeAdapter.getLNClass();
if(!nodeAdapter.getPrefix().isBlank()){
if (!nodeAdapter.getPrefix().isBlank()) {
lNodeDTO.prefix = nodeAdapter.getPrefix();
}
lNodeDTO.inst = nodeAdapter.getLNInst();
if(options == null) {
if (options == null) {
log.info(Utils.leaving());
return lNodeDTO;
}

if(options.isWithExtRef()) {
List<TExtRef> extRefList = nodeAdapter.getExtRefs(null);
if (options.isWithExtRef()) {
List<TExtRef> extRefList = nodeAdapter.getExtRefs(null);
LDeviceAdapter lDeviceAdapter = nodeAdapter.getParentAdapter();
String holderIedName = lDeviceAdapter.getParentAdapter().getName();
String holderLDInst = lDeviceAdapter.getInst();
lNodeDTO.extRefs.addAll(
extRefList.stream()
.map(tExtRef ->
ExtRefInfo.from(tExtRef,holderIedName,holderLDInst,lNodeDTO.nodeClass,
lNodeDTO.inst,lNodeDTO.prefix
))
.collect(Collectors.toList())
ExtRefInfo.from(tExtRef, holderIedName, holderLDInst, lNodeDTO.nodeClass,
lNodeDTO.inst, lNodeDTO.prefix
))
.toList()
);
}

if(options.isWithDatSet()) {
if (options.isWithDatSet()) {
DataSetService dataSetService = new DataSetService();
lNodeDTO.datSets = dataSetService.getDataSets(nodeAdapter.getCurrentElem()).map(DataSetInfo::new).collect(Collectors.toSet());
}

if(options.isWithDataAttributeRef()) {
if (options.isWithDataAttributeRef()) {
DataTypeTemplateAdapter dttAdapter = nodeAdapter.getDataTypeTemplateAdapter();
LNodeTypeAdapter lNodeTypeAdapter = dttAdapter.getLNodeTypeAdapterById(nodeAdapter.getLnType())
.orElseThrow(
Expand All @@ -138,15 +139,15 @@ public static <T extends TAnyLN> LNodeDTO from(AbstractLNAdapter<T> nodeAdapter,
)
);
DataAttributeRef filter = DataAttributeRef.builder()
.lnInst(nodeAdapter.getLNInst())
.lnClass(nodeAdapter.getLNClass())
.prefix(nodeAdapter.getPrefix())
.lnType(nodeAdapter.getLnType()).build();
.lnInst(nodeAdapter.getLNInst())
.lnClass(nodeAdapter.getLNClass())
.prefix(nodeAdapter.getPrefix())
.lnType(nodeAdapter.getLnType()).build();
List<DataAttributeRef> dataAttributeRefList = lNodeTypeAdapter.getDataAttributeRefs(filter);
lNodeDTO.addAllDataAttributeRef(dataAttributeRefList);
}

if(options.isWithCB()) {
if (options.isWithCB()) {
//TODO
}
log.info(Utils.leaving());
Expand All @@ -162,9 +163,11 @@ public static LNodeDTO from(TAnyLN tAnyLN, LogicalNodeOptions options, String ie
String lnType = tAnyLN.getLnType();
LNodeDTO lNodeDTO = new LNodeDTO(inst, lnClass, prefix, lnType);
if (options.isWithExtRef()) {
List<ExtRefInfo> extRefInfos = new ExtRefReaderService().getExtRefs(tAnyLN)
.map(extRef -> ExtRefInfo.from(extRef, iedName, ldInst, lnClass, inst, prefix))
.toList();
List<ExtRefInfo> extRefInfos = tAnyLN.isSetInputs() ?
tAnyLN.getInputs().getExtRef().stream()
.map(extRef -> ExtRefInfo.from(extRef, iedName, ldInst, lnClass, inst, prefix))
.toList()
: List.of();
lNodeDTO.addAllExtRefInfo(extRefInfos);
}
if (options.isWithDatSet()) {
Expand Down Expand Up @@ -195,45 +198,50 @@ public static LNodeDTO from(TAnyLN tAnyLN, LogicalNodeOptions options, String ie

/**
* Sets LNode Inst value
*
* @param inst input
*/
public void setInst(String inst){
public void setInst(String inst) {
this.inst = inst;
}

/**
* Sets LNode Class value
*
* @param lnClass input
*/
public void setNodeClass(String lnClass){
public void setNodeClass(String lnClass) {
this.nodeClass = lnClass;
}

/**
* Sets LNode Type
* Sets LNode Type
*
* @param lnType
*/
public void setNodeType(String lnType){
public void setNodeType(String lnType) {
this.nodeType = lnType;
}

/**
* Sets LNode Prefix value
*
* @param prefix input
*/
public void setPrefix(String prefix){
public void setPrefix(String prefix) {
this.prefix = prefix;
}

/**
* Extracts LNode ExtRef informations
*
* @param lnAdapter input
* @return LNodeDTO object
*/
public static LNodeDTO extractExtRefInfo(LNAdapter lnAdapter) {
String lnClass = lnAdapter.getLNClass() == null ? "" : lnAdapter.getLNClass();
LNodeDTO lNodeDTO = new LNodeDTO(lnAdapter.getLNInst(),lnClass,lnAdapter.getPrefix(), lnAdapter.getLnType());
if(lnAdapter.hasInputs()){
LNodeDTO lNodeDTO = new LNodeDTO(lnAdapter.getLNInst(), lnClass, lnAdapter.getPrefix(), lnAdapter.getLnType());
if (lnAdapter.hasInputs()) {
lnAdapter.getExtRefs(null).forEach(tExtRef -> {
ExtRefInfo extRefInfo = new ExtRefInfo(tExtRef);
lNodeDTO.addExtRefInfo(extRefInfo);
Expand All @@ -244,6 +252,7 @@ public static LNodeDTO extractExtRefInfo(LNAdapter lnAdapter) {

/**
* Adds ExtRef Info to LNode ExtRefs
*
* @param extRef input
*/
public void addExtRefInfo(ExtRefInfo extRef) {
Expand All @@ -252,6 +261,7 @@ public void addExtRefInfo(ExtRefInfo extRef) {

/**
* Adds list of ExtRef Info into LNode
*
* @param extRefs input
*/
public void addAllExtRefInfo(List<ExtRefInfo> extRefs) {
Expand All @@ -260,6 +270,7 @@ public void addAllExtRefInfo(List<ExtRefInfo> extRefs) {

/**
* Adds Control Block to LNode Control Blocks
*
* @param controlBlock input
*/
public void addControlBlock(ControlBlock controlBlock) {
Expand All @@ -278,14 +289,16 @@ public void addControlBlock(ControlBlock controlBlock) {

/**
* Adds lis of Control Block to LNode Control Blocks
*
* @param controlBlockInfoList input
*/
public void addAllControlBlocks(List<ControlBlock> controlBlockInfoList){
public void addAllControlBlocks(List<ControlBlock> controlBlockInfoList) {
controlBlockInfoList.forEach(this::addControlBlock);
}

/**
* Adds list of DataSet to LNode
*
* @param dataSetList input
*/
public void addAllDatSets(List<DataSetInfo> dataSetList) {
Expand All @@ -294,6 +307,7 @@ public void addAllDatSets(List<DataSetInfo> dataSetList) {

/**
* Adds DataTypeTemplate's sumarised data
*
* @param dataAttributeRef input
*/
public void addDataAttributeRef(DataAttributeRef dataAttributeRef) {
Expand All @@ -302,6 +316,7 @@ public void addDataAttributeRef(DataAttributeRef dataAttributeRef) {

/**
* Adds list of DataTypeTemplate's sumarised data
*
* @param dataAttributeRefs input
*/
public void addAllDataAttributeRef(List<DataAttributeRef> dataAttributeRefs) {
Expand All @@ -310,14 +325,16 @@ public void addAllDataAttributeRef(List<DataAttributeRef> dataAttributeRefs) {

/**
* Gets DataTypeTemplate's sumarised data
*
* @return Set of DataAttributeRef object
*/
public Set<DataAttributeRef> getDataAttributeRefs(){
public Set<DataAttributeRef> getDataAttributeRefs() {
return Set.of(dataAttributeRefs.toArray(new DataAttributeRef[0]));
}

/**
* Adds DataSet information to LNode
*
* @param dataSetInfo input
*/
public void addDataSet(DataSetInfo dataSetInfo) {
Expand Down
Loading
Loading