-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements sct-data for postgres (using spring-data)
Implements sct-service package These services were implemented (in sct-service and sct-common) - add History - add IED with DataTypeTemplate - get ExtRef information - get ExtRef potential binders - update ExtRef binder - add/get subnetworks Signed-off-by: Mohamed Sylla <mohamed.sylla@rte-france.com>
- Loading branch information
Showing
96 changed files
with
5,272 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-FileCopyrightText: 2021 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.dto; | ||
|
||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.lfenergy.compas.scl2007b4.model.TConnectedAP; | ||
import org.lfenergy.compas.sct.commons.scl.com.ConnectedAPAdapter; | ||
|
||
import java.util.Objects; | ||
|
||
@Setter | ||
@Getter | ||
@NoArgsConstructor | ||
public class ConnectedApDTO { | ||
private String iedName; | ||
private String apName; | ||
|
||
public ConnectedApDTO(ConnectedAPAdapter connectedAPAdapter) { | ||
this.iedName = connectedAPAdapter.getIedName(); | ||
this.apName = connectedAPAdapter.getApName(); | ||
} | ||
|
||
public static ConnectedApDTO from(ConnectedAPAdapter connectedAPAdapter) { | ||
ConnectedApDTO connectedApDTO = new ConnectedApDTO(); | ||
connectedApDTO.iedName = connectedAPAdapter.getIedName(); | ||
connectedApDTO.apName = connectedAPAdapter.getApName(); | ||
|
||
return connectedApDTO; | ||
} | ||
} |
146 changes: 146 additions & 0 deletions
146
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ControlBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package org.lfenergy.compas.sct.commons.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.lfenergy.compas.scl2007b4.model.TClientLN; | ||
import org.lfenergy.compas.scl2007b4.model.TControl; | ||
import org.lfenergy.compas.scl2007b4.model.TControlWithIEDName; | ||
import org.lfenergy.compas.scl2007b4.model.TPredefinedTypeOfSecurityEnum; | ||
import org.lfenergy.compas.scl2007b4.model.TServiceSettingsNoDynEnum; | ||
import org.lfenergy.compas.scl2007b4.model.TServiceType; | ||
import org.lfenergy.compas.scl2007b4.model.TServices; | ||
import org.lfenergy.compas.sct.commons.Utils; | ||
import org.lfenergy.compas.sct.commons.exception.ScdException; | ||
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; | ||
import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; | ||
import org.lfenergy.compas.sct.commons.scl.ied.LDeviceAdapter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public abstract class ControlBlock<T extends ControlBlock> { | ||
protected String id; /// appID or smvID | ||
protected String name; | ||
protected String dataSetRef; | ||
protected String desc; | ||
protected long confRev; | ||
protected List<TControlWithIEDName.IEDName> iedNames = new ArrayList<>(); | ||
protected TPredefinedTypeOfSecurityEnum securityEnable = TPredefinedTypeOfSecurityEnum.NONE; | ||
|
||
protected abstract Class<T> getClassType(); | ||
public abstract TServiceType getServiceType(); | ||
|
||
public abstract <U extends TControl> U createControlBlock(); | ||
|
||
public T cast(Object obj){ | ||
if (!obj.getClass().isAssignableFrom(getClassType())) { | ||
throw new UnsupportedOperationException("Cannot cast object to " + getClassType()); | ||
} | ||
return (T) obj; | ||
} | ||
|
||
public void validateCB() throws ScdException { | ||
|
||
if(id == null || id.isBlank()){ | ||
throw new ScdException("Control block ID is missing"); | ||
} | ||
|
||
if(name == null || name.isBlank()){ | ||
throw new ScdException("Control block Name is missing"); | ||
} | ||
|
||
if(dataSetRef != null && dataSetRef.isBlank()){ | ||
throw new ScdException("Control block datSet is missing"); | ||
} | ||
|
||
if(iedNames.stream().anyMatch( iedName -> iedName == null || | ||
iedName.getValue() == null || iedName.getValue().isBlank() || | ||
iedName.getLdInst() == null || iedName.getLdInst().isBlank())) { | ||
throw new ScdException("Control block destination IEDs are not well defined"); | ||
} | ||
} | ||
|
||
public void validateDestination(SclRootAdapter sclRootAdapter) throws ScdException { | ||
for(TControlWithIEDName.IEDName iedName : iedNames){ | ||
IEDAdapter iedAdapter =sclRootAdapter.getIEDAdapter(iedName.getValue()); | ||
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst(iedName.getLdInst()) | ||
.orElseThrow( | ||
() -> new ScdException( | ||
String.format( | ||
"Unknown LDevice [%s] in IED [%s]", iedName.getLdInst(),iedName.getValue() | ||
) | ||
) | ||
); | ||
if(!iedName.getLnClass().isEmpty()) { | ||
lDeviceAdapter.getLNAdapter(iedName.getLnClass().get(0),iedName.getLnInst(), iedName.getPrefix()); | ||
} else { | ||
Utils.setField(iedName,"lnClass",null); | ||
} | ||
} | ||
} | ||
|
||
public final void validateSecurityEnabledValue(IEDAdapter iedAdapter) throws ScdException { | ||
TServices tServices = iedAdapter.getServices(); | ||
validateSecurityEnabledValue(tServices); | ||
} | ||
|
||
protected Long getConfRev() { | ||
if(dataSetRef == null || dataSetRef.isBlank()){ | ||
return 0L; | ||
} | ||
return 10000L ; | ||
} | ||
|
||
protected abstract void validateSecurityEnabledValue(TServices tServices) throws ScdException; | ||
|
||
public static TControlWithIEDName.IEDName toIEDName(TClientLN clientLN){ | ||
|
||
TControlWithIEDName.IEDName iedName = new TControlWithIEDName.IEDName(); | ||
iedName.setValue(clientLN.getIedName()); | ||
iedName.setApRef(clientLN.getApRef()); | ||
iedName.setLdInst(clientLN.getLdInst()); | ||
iedName.setPrefix(clientLN.getPrefix()); | ||
iedName.setLnInst(clientLN.getLnInst()); | ||
iedName.getLnClass().addAll(clientLN.getLnClass()); | ||
|
||
return iedName; | ||
} | ||
|
||
public TServiceSettingsNoDynEnum getControlBlockServiceSetting(TServices tServices){ | ||
if(tServices == null) { | ||
return TServiceSettingsNoDynEnum.FIX; | ||
} | ||
|
||
if (getServiceType() == TServiceType.GOOSE && tServices.getGSESettings() != null){ | ||
return tServices.getGSESettings().getCbName(); | ||
} | ||
if(getServiceType() == TServiceType.SMV && tServices.getSMVSettings() != null){ | ||
return tServices.getSMVSettings().getCbName(); | ||
} | ||
if(getServiceType() == TServiceType.REPORT && tServices.getReportSettings() != null){ | ||
return tServices.getReportSettings().getCbName(); | ||
} | ||
return TServiceSettingsNoDynEnum.FIX; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String values = iedNames.stream().map(TControlWithIEDName.IEDName::getValue) | ||
.collect(Collectors.joining(",")); | ||
return "ControlBlock{" + | ||
"id='" + id + '\'' + | ||
", name='" + name + '\'' + | ||
", dataSetRef='" + dataSetRef + '\'' + | ||
", desc='" + desc + '\'' + | ||
", confRev=" + confRev + | ||
", iedNames=" + values + | ||
", securityEnable=" + securityEnable + | ||
'}'; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DaTypeName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-FileCopyrightText: 2021 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.lfenergy.compas.scl2007b4.model.TFCEnum; | ||
|
||
import java.util.Objects; | ||
|
||
@Getter | ||
@Setter | ||
public class DaTypeName extends DataTypeName{ | ||
public static final String VALIDATION_REGEX | ||
= "[a-zA-Z][a-zA-Z0-9]*(\\([0-9]+\\))?(\\.[a-zA-Z][a-zA-Z0-9]*(\\([0-9]+\\))?)*"; | ||
private TFCEnum fc; | ||
private String type; | ||
private String bType; | ||
|
||
public DaTypeName(String dataName) { | ||
super(dataName); | ||
validationPattern = VALIDATION_REGEX; | ||
} | ||
|
||
public DaTypeName(String name, String names) { | ||
super(name, names); | ||
validationPattern = VALIDATION_REGEX; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || o.getClass() != getClass()) return false; | ||
if (!super.equals(o)) return false; | ||
DaTypeName that = (DaTypeName) o; | ||
return fc == that.fc && | ||
Objects.equals(bType, that.bType) && | ||
Objects.equals(type, that.type); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), fc, bType, type); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/DataSetInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.lfenergy.compas.sct.commons.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class DataSetInfo { | ||
private String name; | ||
private List<FCDAInfo> fcdaInfos = new ArrayList<>(); | ||
|
||
public DataSetInfo(String name){ | ||
this.name = name; | ||
} | ||
|
||
public void addFCDAInfo(FCDAInfo fcdaInfo){ | ||
fcdaInfos.add(fcdaInfo); | ||
} | ||
|
||
public List<FCDAInfo> getFcdaInfos(){ | ||
return Collections.unmodifiableList(fcdaInfos); | ||
} | ||
|
||
public void setName(String name){ | ||
this.name = name; | ||
} | ||
} |
Oops, something went wrong.