-
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.
feat(#341): Création de Services compas
- DataSetService - DoService - DoTypeService - ExtRefReaderService - IedService - LdeviceService - LnService - LnodeTypeService - renommage de LdeviceStatus en ActiveStatus Signed-off-by: gleizesDor <115622893+gleizesDor@users.noreply.github.com>
- Loading branch information
1 parent
7a7f543
commit 2297563
Showing
79 changed files
with
2,670 additions
and
793 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
33 changes: 33 additions & 0 deletions
33
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataSetService.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,33 @@ | ||
// SPDX-FileCopyrightText: 2022 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.LN0; | ||
import org.lfenergy.compas.scl2007b4.model.TAnyLN; | ||
import org.lfenergy.compas.scl2007b4.model.TDataSet; | ||
import org.lfenergy.compas.scl2007b4.model.TLN; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class DataSetService { | ||
|
||
public Stream<TDataSet> getDataSets(TAnyLN tAnyLN) { | ||
return switch (tAnyLN) { | ||
case LN0 ln0 -> ln0.isSetDataSet() ? ln0.getDataSet().stream() : Stream.empty(); | ||
case TLN tln -> tln.isSetDataSet() ? tln.getDataSet().stream() : Stream.empty(); | ||
default -> throw new IllegalStateException("Unexpected value: " + tAnyLN); | ||
}; | ||
} | ||
|
||
public Stream<TDataSet> getFilteredDataSets(TAnyLN tAnyLN, Predicate<TDataSet> dataSetPredicate) { | ||
return getDataSets(tAnyLN).filter(dataSetPredicate); | ||
} | ||
|
||
public Optional<TDataSet> findDataSet(TAnyLN tAnyLN, Predicate<TDataSet> dataSetPredicate) { | ||
return getFilteredDataSets(tAnyLN, dataSetPredicate).findFirst(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoService.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,28 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TDO; | ||
import org.lfenergy.compas.scl2007b4.model.TLNodeType; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class DoService { | ||
|
||
public Stream<TDO> getDos(TLNodeType tlNodeType) { | ||
return tlNodeType.getDO().stream(); | ||
} | ||
|
||
public Stream<TDO> getFilteredDos(TLNodeType tlNodeType, Predicate<TDO> tdoPredicate) { | ||
return getDos(tlNodeType).filter(tdoPredicate); | ||
} | ||
|
||
public Optional<TDO> findDo(TLNodeType tlNodeType, Predicate<TDO> tdoPredicate) { | ||
return getFilteredDos(tlNodeType, tdoPredicate).findFirst(); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DoTypeService.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,28 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TDataTypeTemplates; | ||
import org.lfenergy.compas.scl2007b4.model.TDOType; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class DoTypeService { | ||
|
||
public Stream<TDOType> getDoTypes(TDataTypeTemplates tDataTypeTemplates) { | ||
return tDataTypeTemplates.getDOType().stream(); | ||
} | ||
|
||
public Stream<TDOType> getFilteredDoTypes(TDataTypeTemplates tDataTypeTemplates, Predicate<TDOType> tdoTypePredicate) { | ||
return getDoTypes(tDataTypeTemplates).filter(tdoTypePredicate); | ||
} | ||
|
||
public Optional<TDOType> findDoType(TDataTypeTemplates tDataTypeTemplates, Predicate<TDOType> tdoTypePredicate) { | ||
return getFilteredDoTypes(tDataTypeTemplates, tdoTypePredicate).findFirst(); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefReaderService.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,24 @@ | ||
// SPDX-FileCopyrightText: 2022 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.LN0; | ||
import org.lfenergy.compas.scl2007b4.model.TAnyLN; | ||
import org.lfenergy.compas.scl2007b4.model.TExtRef; | ||
import org.lfenergy.compas.scl2007b4.model.TLN; | ||
import org.lfenergy.compas.sct.commons.api.ExtRefReader; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class ExtRefReaderService implements ExtRefReader { | ||
|
||
public Stream<TExtRef> getExtRefs(TAnyLN tAnyLN) { | ||
return switch (tAnyLN) { | ||
case LN0 ln0 -> ln0.isSetInputs() ? ln0.getInputs().getExtRef().stream() : Stream.empty(); | ||
case TLN tln -> tln.isSetInputs() ? tln.getInputs().getExtRef().stream() : Stream.empty(); | ||
default -> throw new IllegalStateException("Unexpected value: " + tAnyLN); | ||
}; | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/IedService.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,23 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.SCL; | ||
import org.lfenergy.compas.scl2007b4.model.TIED; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class IedService { | ||
|
||
public Stream<TIED> getFilteredIeds(SCL scd, Predicate<TIED> iedPredicate) { | ||
return scd.getIED().stream().filter(iedPredicate); | ||
} | ||
|
||
public Optional<TIED> findIed(SCL scd, Predicate<TIED> iedPredicate) { | ||
return getFilteredIeds(scd, iedPredicate).findFirst(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.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,46 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.*; | ||
import org.lfenergy.compas.sct.commons.util.ActiveStatus; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class LdeviceService { | ||
|
||
public Stream<TLDevice> getLdevices(TIED tied) { | ||
if (!tied.isSetAccessPoint()) { | ||
return Stream.empty(); | ||
} | ||
return tied.getAccessPoint() | ||
.stream() | ||
.map(TAccessPoint::getServer) | ||
.filter(Objects::nonNull) | ||
.filter(TServer::isSetLDevice) | ||
.flatMap(tServer -> tServer.getLDevice().stream()); | ||
} | ||
|
||
public Stream<TLDevice> getActiveLdevices(TIED tied) { | ||
return getLdevices(tied) | ||
.filter(ldevice -> getLdeviceStatus(ldevice).map(ActiveStatus.ON::equals).orElse(false)); | ||
} | ||
|
||
public Stream<TLDevice> getFilteredLdevices(TIED tied, Predicate<TLDevice> ldevicePredicate) { | ||
return getLdevices(tied).filter(ldevicePredicate); | ||
} | ||
|
||
public Optional<TLDevice> findLdevice(TIED tied, Predicate<TLDevice> ldevicePredicate) { | ||
return getFilteredLdevices(tied, ldevicePredicate).findFirst(); | ||
} | ||
|
||
public Optional<ActiveStatus> getLdeviceStatus(TLDevice tlDevice) { | ||
LnService lnService = new LnService(); | ||
return lnService.getDaiModStval(tlDevice.getLN0()); | ||
} | ||
} |
Oops, something went wrong.