-
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.
Signed-off-by: gleizesDor <115622893+gleizesDor@users.noreply.github.com>
- Loading branch information
1 parent
b0117cb
commit 39aae82
Showing
36 changed files
with
386 additions
and
642 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
30 changes: 30 additions & 0 deletions
30
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,30 @@ | ||
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 org.lfenergy.compas.sct.commons.api.DataSetReader; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class DataSetService implements DataSetReader { | ||
|
||
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(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
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,20 @@ | ||
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); | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
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,20 @@ | ||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.SCL; | ||
import org.lfenergy.compas.scl2007b4.model.TIED; | ||
import org.lfenergy.compas.sct.commons.api.IedReader; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class IedService implements IedReader { | ||
|
||
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(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
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,55 @@ | ||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.*; | ||
import org.lfenergy.compas.sct.commons.api.LdeviceReader; | ||
import org.lfenergy.compas.sct.commons.util.LdeviceStatus; | ||
|
||
import java.util.Collection; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
import static org.lfenergy.compas.sct.commons.util.CommonConstants.MOD_DO_NAME; | ||
import static org.lfenergy.compas.sct.commons.util.CommonConstants.STVAL_DA_NAME; | ||
|
||
public class LdeviceService implements LdeviceReader { | ||
|
||
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> 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<LdeviceStatus> getLdeviceStatus(TLDevice tlDevice) { | ||
return tlDevice.getLN0() | ||
.getDOI() | ||
.stream() | ||
.filter(tdoi -> MOD_DO_NAME.equals(tdoi.getName())) | ||
.findFirst() | ||
.flatMap(tdoi -> tdoi.getSDIOrDAI() | ||
.stream() | ||
.filter(dai -> dai.getClass().equals(TDAI.class)) | ||
.map(TDAI.class::cast) | ||
.filter(tdai -> STVAL_DA_NAME.equals(tdai.getName())) | ||
.map(TDAI::getVal) | ||
.flatMap(Collection::stream) | ||
.findFirst() | ||
.map(TVal::getValue)) | ||
.map(LdeviceStatus::fromValue); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.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,13 @@ | ||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.*; | ||
import org.lfenergy.compas.sct.commons.api.LnReader; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class LnService implements LnReader { | ||
|
||
public Stream<TAnyLN> getAnylns(TLDevice tlDevice) { | ||
return Stream.concat(Stream.of(tlDevice.getLN0()), tlDevice.getLN().stream()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/DataSetReader.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,15 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.api; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TAnyLN; | ||
import org.lfenergy.compas.scl2007b4.model.TDataSet; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public interface DataSetReader { | ||
|
||
Stream<TDataSet> getDataSets(TAnyLN tAnyLN); | ||
} |
15 changes: 15 additions & 0 deletions
15
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/ExtRefReader.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,15 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.api; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TAnyLN; | ||
import org.lfenergy.compas.scl2007b4.model.TExtRef; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public interface ExtRefReader { | ||
|
||
Stream<TExtRef> getExtRefs(TAnyLN tAnyLN); | ||
} |
19 changes: 19 additions & 0 deletions
19
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/IedReader.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,19 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.api; | ||
|
||
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 interface IedReader { | ||
|
||
Stream<TIED> getFilteredIeds(SCL scd, Predicate<TIED> iedPredicate); | ||
|
||
Optional<TIED> findIed(SCL scd, Predicate<TIED> iedPredicate); | ||
} |
24 changes: 24 additions & 0 deletions
24
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/LdeviceReader.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: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.api; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TIED; | ||
import org.lfenergy.compas.scl2007b4.model.TLDevice; | ||
import org.lfenergy.compas.sct.commons.util.LdeviceStatus; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public interface LdeviceReader { | ||
|
||
Stream<TLDevice> getLdevices(TIED tied); | ||
|
||
Stream<TLDevice> getFilteredLdevices(TIED tied, Predicate<TLDevice> ldevicePredicate); | ||
|
||
Optional<TLDevice> findLdevice(TIED tied, Predicate<TLDevice> ldevicePredicate); | ||
|
||
Optional<LdeviceStatus> getLdeviceStatus(TLDevice tlDevice); | ||
} |
15 changes: 15 additions & 0 deletions
15
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/LnReader.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,15 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons.api; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TAnyLN; | ||
import org.lfenergy.compas.scl2007b4.model.TLDevice; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public interface LnReader { | ||
|
||
Stream<TAnyLN> getAnylns(TLDevice tlDevice); | ||
} |
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
Oops, something went wrong.