Skip to content

Commit

Permalink
retours MR
Browse files Browse the repository at this point in the history
Signed-off-by: gleizesDor <115622893+gleizesDor@users.noreply.github.com>
  • Loading branch information
gleizesDor committed Nov 17, 2023
1 parent b0117cb commit 39aae82
Show file tree
Hide file tree
Showing 36 changed files with 386 additions and 642 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!--Ajout de ${argLine} pour ne pas remplacer les arguments-->
<!--keep the existing values using @{argLine} syntax-->
<!-- https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#argLine -->
<argLine>@{argLine} --enable-preview</argLine>
</configuration>
</plugin>
Expand Down
9 changes: 0 additions & 9 deletions sct-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--Ajout de ${argLine} pour ne pas remplacer les arguments-->
<argLine>@{argLine} --enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
9 changes: 0 additions & 9 deletions sct-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--Ajout de ${argLine} pour ne pas remplacer les arguments-->
<argLine>@{argLine} --enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
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();
}
}
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);
};
}
}
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();
}
}
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);
}
}
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());
}
}
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);
}
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);
}
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);
}
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);
}
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@

import lombok.Getter;
import lombok.NoArgsConstructor;
import org.lfenergy.compas.scl2007b4.model.TAnyLN;
import org.lfenergy.compas.sct.commons.scl.lnode.AbstractLNAdapter;
import org.lfenergy.compas.sct.commons.scl.lnode.DataSet;
import org.lfenergy.compas.sct.commons.scl.lnode.Fcda;
import org.lfenergy.compas.scl2007b4.model.TDataSet;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
* A representation of the model object <em><b>Data Set</b></em>.
Expand All @@ -24,71 +18,25 @@
* </p>
* <ul>
* <li>{@link DataSetInfo#getName() <em>Name</em>}</li>
* <li>{@link DataSetInfo#getFCDAInfos() <em>Refers to FCDA infos</em>}</li>
* <li>{@link DataSetInfo#getFcdaInfos()} <em>Refers to FCDA infos</em>}</li>
* </ul>
*
* @see org.lfenergy.compas.scl2007b4.model.TDataSet
*/
@Getter
@NoArgsConstructor
public class DataSetInfo extends LNodeMetaDataEmbedder {
//TODO cet objet est un DTO; il est utilisé pour transporter l'information; il doit être créé par celui qui transporte l'info -> RCONF
//TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info
private String name;
private List<FCDAInfo> fcdaInfos = new ArrayList<>();

/**
* Constructor
* @param name input
*/
public DataSetInfo(String name) {
super();
this.name = name;
}

public DataSetInfo(String name, List<Fcda> fcdas) {
public DataSetInfo(TDataSet tDataSet) {
super();
this.name = name;
this.fcdaInfos = fcdas.stream()
.map(fcda -> fcda.toDto(name))
.toList();
}

/**
* Get Set of DataSet from LnAdapter
* @param lnAdapter object LnAdapter
* @return Set of DataSetInfo
*/
public static Set<DataSetInfo> getDataSets(AbstractLNAdapter<? extends TAnyLN> lnAdapter) {
return lnAdapter.getCurrentElem()
.getDataSet()
this.name = tDataSet.getName();
this.fcdaInfos = tDataSet.getFCDA()
.stream()
.map(DataSet::new)
.map(DataSet::toDto)
.collect(Collectors.toSet());
}

/**
* Add FCDA to FCDA list
* @param fcdaInfo object FCDAInfo containing FCDA datas
*/
public void addFCDAInfo(FCDAInfo fcdaInfo) {
fcdaInfos.add(fcdaInfo);
}

/**
* Get FCDA list from DtaSetInfo
* @return FCDA list
*/
public List<FCDAInfo> getFCDAInfos() {
return Collections.unmodifiableList(fcdaInfos);
}

/**
* Set DataSet name
* @param name string DataSet name
*/
public void setName(String name) {
this.name = name;
.map(fcda -> new FCDAInfo(name, fcda.getFc(), fcda.getLdInst(), fcda.getPrefix(), fcda.getLnClass().get(0), fcda.getLnInst(), new DoTypeName(fcda.getDoName()), new DaTypeName(fcda.getDaName()), fcda.getIx()))
.toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class ExtRefInfo extends LNodeMetaDataEmbedder{
//TODO cet objet est un DTO; il est utilisé pour transporter l'information; il doit être créé par celui qui transporte l'info -> RCONF
//TODO this is a DTO object; it's meant to be used for carry information; he must be created be the one responsible for carying the info
private ExtRefSignalInfo signalInfo;
private ExtRefBindingInfo bindingInfo;
private ExtRefSourceInfo sourceInfo;
Expand Down
Loading

0 comments on commit 39aae82

Please sign in to comment.