Skip to content

Commit

Permalink
Release 0.0.4 (#103)
Browse files Browse the repository at this point in the history
* [#65] : correcting history for automation service

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#65 ==> 95] : correcting history for automation service: add test

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* Update SCL communication import method to allow the import of the att… (#91)

* Update SCL communication import method to allow the import of the attributes Address et PhysConn if present.

Signed-off-by: SAINTIER FRANCOIS <francois.saintier@rte-france.com>

* [#66] : WIP

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : WIP to be refactored

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* Update SCL communication import method to allow the import of the att… (#91)

* Update SCL communication import method to allow the import of the attributes Address et PhysConn if present.

Signed-off-by: SAINTIER FRANCOIS <francois.saintier@rte-france.com>
Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#65] : correcting history for automation service

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#65 ==> 95] : correcting history for automation service: add test

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : WIP refactoring and test needed

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : WIP add files and tests, refactoring

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : moving code to subnetwork and refactoring

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : delete not yet used code

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : WIP

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : WIP to be refactored

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : refactoring after remarks for pull request

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#66] : delete commented code and update pom.xml

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* Added CII Best Practices Badge + removed unused LFX Security Tool badge

Signed-off-by: Flurb <private@tjalma.com>

* [#88] : add private COMPAS_SCL_FILE_TYPE in created SCD (#102)

[#88] : add private COMPAS_SCL_FILE_TYPE in created SCD

Signed-off-by: Aliou DIAITE <aliou.diaite@rte-france.com>

* [#70] : all updatable DA should be returned

Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>

Co-authored-by: SaintierFr <99645240+SaintierFr@users.noreply.github.com>
Co-authored-by: Flurb <private@tjalma.com>
Co-authored-by: massifben <105049157+massifben@users.noreply.github.com>
  • Loading branch information
4 people authored Jun 22, 2022
1 parent a64fe00 commit 9fc367c
Show file tree
Hide file tree
Showing 50 changed files with 4,416 additions and 526 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SPDX-License-Identifier: Apache-2.0
-->

[![REUSE status](https://api.reuse.software/badge/github.com/com-pas/compas-sct)](https://api.reuse.software/info/github.com/com-pas/compas-sct)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5925/badge)](https://bestpractices.coreinfrastructure.org/projects/5925)

# System Configuration Tool (SCT) components

Expand Down
13 changes: 11 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<version>1.18.24</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -68,6 +68,11 @@
<artifactId>scl2007b4</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand All @@ -80,6 +85,10 @@
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl2007b4</artifactId>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down Expand Up @@ -132,4 +141,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
35 changes: 31 additions & 4 deletions sct-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.6.28</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -67,12 +73,29 @@
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand All @@ -83,21 +106,25 @@
<goals>
<goal>unpack</goal>
</goals>

<configuration>
<includes>**/SCL2007B4/*.xsd, **/SCL_CoMPAS.xsd</includes>
<artifactItems>
<artifactItem>
<groupId>org.lfenergy.compas.xsd</groupId>
<artifactId>compas-scl-xsd</artifactId>
<version>0.0.4</version>
</artifactItem>
<artifactItem>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>0.8.0</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,34 @@

import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.sct.commons.dto.HeaderDTO;
import org.lfenergy.compas.sct.commons.dto.SubNetworkDTO;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.SclService;

import java.util.Optional;
import java.util.*;

@Slf4j
public class SclAutomationService {

private static final Map<Pair<String, String>, List<String>> comMap = Map.of(
Pair.of("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString()), Arrays.asList("PROCESS_AP", "TOTO_AP_GE"),
Pair.of("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.IP.toString()), Arrays.asList("ADMIN_AP","TATA_AP_EFFACEC"));

private SclAutomationService(){throw new IllegalStateException("SclAutomationService class"); }

public static SclRootAdapter createSCD(@NonNull SCL ssd, @NonNull HeaderDTO headerDTO) throws ScdException {
public static SclRootAdapter createSCD(@NonNull SCL ssd, @NonNull HeaderDTO headerDTO, Set<SCL> stds) throws ScdException {
SclRootAdapter scdAdapter = SclService.initScl(Optional.ofNullable(headerDTO.getId()),
headerDTO.getVersion(),headerDTO.getRevision());
if(!headerDTO.getHistoryItems().isEmpty()) {
headerDTO.getHistoryItems().forEach(hItem ->
SclService.addHistoryItem(scdAdapter.getCurrentElem(), hItem.getWho(), hItem.getWhat(), hItem.getWhy()));
HeaderDTO.HistoryItem hItem = headerDTO.getHistoryItems().get(0);
SclService.addHistoryItem(scdAdapter.getCurrentElem(), hItem.getWho(), hItem.getWhat(), hItem.getWhy());
}
SclService.addSubstation(scdAdapter.getCurrentElem(), ssd);
SclService.addSubstation(scdAdapter.getCurrentElem(), ssd);
SclService.importSTDElementsInSCD(scdAdapter, stds, comMap);
return scdAdapter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -29,11 +31,15 @@ void init(){

@Test
void createSCD() throws Exception {
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO);
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd.xml");
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std));
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
assertNull(expectedSCD.getCurrentElem().getHeader().getHistory());
assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());
assertEquals(1, expectedSCD.getCurrentElem().getIED().size());
assertNotNull(expectedSCD.getCurrentElem().getDataTypeTemplates());
assertEquals(2, expectedSCD.getCurrentElem().getCommunication().getSubNetwork().size());
}

@Test
Expand All @@ -44,7 +50,10 @@ void createSCD_With_HItem() throws Exception {
historyItem.setWhy("because");
headerDTO.getHistoryItems().add(historyItem);
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO);
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std1, std2, std3));
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
assertEquals(1 ,expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());
Expand All @@ -62,16 +71,20 @@ void createSCD_With_HItems() throws Exception {
historyItemBis.setWhy("because bis");
headerDTO.getHistoryItems().addAll(Arrays.asList(historyItem, historyItemBis));
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO);
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO,Set.of(std1, std2, std3));
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
assertEquals(2 ,expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
assertEquals(1, expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
assertEquals("what", expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().get(0).getWhat());
}


@Test
void createSCD_SSD_Without_Substation() throws Exception {
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd_without_substations.xml");
assertThrows(ScdException.class,
() -> SclAutomationService.createSCD(ssd, headerDTO) );
() -> SclAutomationService.createSCD(ssd, headerDTO, new HashSet<>()) );
}

}
Loading

0 comments on commit 9fc367c

Please sign in to comment.