Skip to content

Commit

Permalink
Merge pull request #129 from com-pas/develop
Browse files Browse the repository at this point in the history
Merge develop branch into main branch for Release 0.1.0
  • Loading branch information
AliouDIAITE authored Aug 17, 2022
2 parents 9fc367c + 488cb22 commit ab7a9d6
Show file tree
Hide file tree
Showing 70 changed files with 2,055 additions and 684 deletions.
24 changes: 23 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<sonar.coverage.exclusions>sct-coverage/**</sonar.coverage.exclusions>
<aggregate.report.dir>../sct-coverage/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
<scl-extension.version>0.9.1</scl-extension.version>
<compas-scl-xsd.version>0.0.4</compas-scl-xsd.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -71,7 +73,12 @@
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>0.8.0</version>
<version>${scl-extension.version}</version>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.xsd</groupId>
<artifactId>compas-scl-xsd</artifactId>
<version>${compas-scl-xsd.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down Expand Up @@ -104,6 +111,16 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.lfenergy.compas.xsd</groupId>
<artifactId>compas-scl-xsd</artifactId>
<version>${compas-scl-xsd.version}</version>
</plugin>
<plugin>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>${scl-extension.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -119,6 +136,11 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
</plugin>
</plugins>
</pluginManagement>

Expand Down
6 changes: 4 additions & 2 deletions sct-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<version>local-SNAPSHOT</version>
</parent>

<groupId>org.lfenergy.compas</groupId>
<artifactId>sct-app</artifactId>
<version>local-SNAPSHOT</version>
<name>SCT-APP</name>
Expand Down Expand Up @@ -112,7 +111,10 @@
<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>
</artifactItem>
<artifactItem>
<groupId>org.lfenergy.compas.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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 org.lfenergy.compas.sct.commons.scl.SubstationService;

import java.util.*;

Expand All @@ -32,7 +33,7 @@ public static SclRootAdapter createSCD(@NonNull SCL ssd, @NonNull HeaderDTO head
HeaderDTO.HistoryItem hItem = headerDTO.getHistoryItems().get(0);
SclService.addHistoryItem(scdAdapter.getCurrentElem(), hItem.getWho(), hItem.getWhat(), hItem.getWhy());
}
SclService.addSubstation(scdAdapter.getCurrentElem(), ssd);
SubstationService.addSubstation(scdAdapter.getCurrentElem(), ssd);
SclService.importSTDElementsInSCD(scdAdapter, stds, comMap);
return scdAdapter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Set;

import static org.junit.jupiter.api.Assertions.*;
import static org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller.assertIsMarshallable;

class SclAutomationServiceTest {

Expand All @@ -30,20 +31,25 @@ void init(){
}

@Test
void createSCD() throws Exception {
void createSCD_should_return_generatedSCD() throws Exception {
// Given
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd.xml");
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
// When
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std));
// Then
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());
assertIsMarshallable(expectedSCD.getCurrentElem());
}

@Test
void createSCD_With_HItem() throws Exception {
// Given
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
historyItem.setWhat("what");
historyItem.setWho("me");
Expand All @@ -53,14 +59,18 @@ void createSCD_With_HItem() throws Exception {
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
// When
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std1, std2, std3));
// Then
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
assertEquals(1 ,expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());
assertIsMarshallable(expectedSCD.getCurrentElem());
}

@Test
void createSCD_With_HItems() throws Exception {
// Given
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
historyItem.setWhat("what");
historyItem.setWho("me");
Expand All @@ -74,17 +84,22 @@ void createSCD_With_HItems() throws Exception {
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
// When
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO,Set.of(std1, std2, std3));
// Then
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
assertEquals(1, expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
assertEquals("what", expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().get(0).getWhat());
assertIsMarshallable(expectedSCD.getCurrentElem());
}

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

}
}
13 changes: 10 additions & 3 deletions sct-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
Expand Down Expand Up @@ -112,6 +112,7 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -166,7 +167,10 @@
<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>
</artifactItem>
<artifactItem>
<groupId>org.lfenergy.compas.core</groupId>
Expand Down Expand Up @@ -196,6 +200,9 @@
<source>${project.build.directory}/xsd/SCL2007B4/SCL.xsd</source>
<source>${project.build.directory}/xsd/SCL_CoMPAS.xsd</source>
</sources>
<xjbSources>
<xjbSource>${project.basedir}/src/main/resources/binding_configuration.xjb</xjbSource>
</xjbSources>
<packageName>org.lfenergy.compas.scl2007b4.model</packageName>
<noPackageLevelAnnotations>true</noPackageLevelAnnotations>
</configuration>
Expand All @@ -214,4 +221,4 @@

</plugins>
</build>
</project>
</project>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
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.scl2007b4.model.*;
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;
Expand Down Expand Up @@ -79,14 +72,12 @@ public void validateDestination(SclRootAdapter sclRootAdapter) throws ScdExcepti
)
)
);
if(!iedName.getLnClass().isEmpty()) {
if (iedName.isSetLnClass()) {
try {
lDeviceAdapter.getLNAdapter(iedName.getLnClass().get(0), iedName.getLnInst(), iedName.getPrefix());
} catch (ScdException e){
} catch (ScdException e) {
throw new ScdException("Control block destination: " + e.getMessage());
}
} else {
Utils.setField(iedName,"lnClass",null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void addDaiValues(List<TVal> vals) {
}

public void addDaiValue(TVal val) {
if(val.getSGroup() == null){
if(!val.isSetSGroup()){
daiValues.put(0L,val.getValue());
} else {
daiValues.put(val.getSGroup(), val.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ public FCDAInfo(String dataSet, TFCDA tfcda) {
lnInst = tfcda.getLnInst();
doName = new DoTypeName(tfcda.getDoName());
daName = new DaTypeName(tfcda.getDaName());
ix = tfcda.getIx();
ix = tfcda.isSetIx() ? tfcda.getIx() : null;
}


@JsonIgnore
public TFCDA getFCDA(){
TFCDA tfcda = new TFCDA();
Expand Down Expand Up @@ -75,4 +74,4 @@ public TFCDA getFCDA(){
public boolean isValid() {
return doName != null && doName.isDefined();
}
}
}
Loading

0 comments on commit ab7a9d6

Please sign in to comment.