Skip to content

Commit c382daf

Browse files
authored
Merge pull request #338 from com-pas/develop
Release
2 parents fdc489d + 986df2e commit c382daf

27 files changed

+538
-20542
lines changed

.github/workflows/automate_javadoc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
DEPENDABOT_BRANCH: dependabot/javadoc-${{ github.head_ref || github.ref_name }}-${{ github.event.pull_request.number }}
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121

2222
- name: Set up JDK 17
2323
uses: actions/setup-java@v3
@@ -40,7 +40,7 @@ jobs:
4040
4141
- name: Import GPG key
4242
id: import_gpg
43-
uses: crazy-max/ghaction-import-gpg@v5
43+
uses: crazy-max/ghaction-import-gpg@v6
4444
with:
4545
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY_BOT}}
4646
git_user_signingkey: true

.github/workflows/build-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- name: Set up JDK 17
2727
uses: actions/setup-java@v3

.github/workflows/release-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
packages: write
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020

2121
- name: Set up JDK 17
2222
uses: actions/setup-java@v3

.github/workflows/reuse.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515
- name: REUSE Compliance Check
16-
uses: fsfe/reuse-action@v1
16+
uses: fsfe/reuse-action@v2

.github/workflows/sonarcloud-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
full_name: ${{ github.event.repository.full_name }}
4242
env:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
- uses: actions/checkout@v3
44+
- uses: actions/checkout@v4
4545
with:
4646
repository: ${{ github.event.workflow_run.head_repository.full_name }}
4747
ref: ${{ github.event.workflow_run.head_branch }}

.github/workflows/sonarcloud-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
if: ${{ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }}
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefService.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,41 +112,50 @@ public List<SclReportItem> updateAllExtRefIedNames(SCL scd) {
112112
}
113113

114114
@Override
115-
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd) {
115+
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, Set<FcdaForDataSetsCreation> allowedFcdas) {
116+
checkFcdaInitDataPresence(allowedFcdas);
116117
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
117118
Stream<LDeviceAdapter> lDeviceAdapters = sclRootAdapter.streamIEDAdapters().flatMap(IEDAdapter::streamLDeviceAdapters);
118-
return createDataSetAndControlBlocks(lDeviceAdapters);
119+
return createDataSetAndControlBlocks(lDeviceAdapters, allowedFcdas);
119120
}
120121

121122
@Override
122-
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName) {
123+
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, Set<FcdaForDataSetsCreation> allowedFcdas) {
124+
checkFcdaInitDataPresence(allowedFcdas);
123125
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
124126
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
125-
return createDataSetAndControlBlocks(iedAdapter.streamLDeviceAdapters());
127+
return createDataSetAndControlBlocks(iedAdapter.streamLDeviceAdapters(), allowedFcdas);
126128

127129
}
128130

129131
@Override
130-
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst) {
132+
public List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst, Set<FcdaForDataSetsCreation> allowedFcdas) {
131133
if (StringUtils.isBlank(targetIedName)) {
132134
throw new ScdException("IED.name parameter is missing");
133135
}
136+
checkFcdaInitDataPresence(allowedFcdas);
134137
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
135138
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
136139
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst(targetLDeviceInst);
137-
return createDataSetAndControlBlocks(Stream.of(lDeviceAdapter));
140+
return createDataSetAndControlBlocks(Stream.of(lDeviceAdapter), allowedFcdas);
138141
}
139142

140-
private List<SclReportItem> createDataSetAndControlBlocks(Stream<LDeviceAdapter> lDeviceAdapters) {
143+
private void checkFcdaInitDataPresence(Set<FcdaForDataSetsCreation> allowedFcdas) {
144+
if (allowedFcdas == null || allowedFcdas.isEmpty()) {
145+
throw new ScdException("Accepted FCDAs list is empty, you should initialize allowed FCDA lists with CsvHelper class before");
146+
}
147+
}
148+
149+
private List<SclReportItem> createDataSetAndControlBlocks(Stream<LDeviceAdapter> lDeviceAdapters, Set<FcdaForDataSetsCreation> allowedFcdas) {
141150
return lDeviceAdapters
142-
.map(LDeviceAdapter::createDataSetAndControlBlocks)
151+
.map(lDeviceAdapter -> lDeviceAdapter.createDataSetAndControlBlocks(allowedFcdas))
143152
.flatMap(List::stream)
144153
.toList();
145154
}
146155

147156
@Override
148157
public List<SclReportItem> configureNetworkForAllControlBlocks(SCL scd, ControlBlockNetworkSettings controlBlockNetworkSettings,
149-
RangesPerCbType rangesPerCbType) {
158+
RangesPerCbType rangesPerCbType) {
150159
List<SclReportItem> sclReportItems = new ArrayList<>();
151160
sclReportItems.addAll(configureNetworkForControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType.gse(), ControlBlockEnum.GSE));
152161
sclReportItems.addAll(configureNetworkForControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType.sampledValue(), ControlBlockEnum.SAMPLED_VALUE));

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/ExtRefEditor.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66

77
import org.lfenergy.compas.scl2007b4.model.SCL;
88
import org.lfenergy.compas.scl2007b4.model.TExtRef;
9-
import org.lfenergy.compas.sct.commons.dto.*;
9+
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings;
10+
import org.lfenergy.compas.sct.commons.dto.ExtRefInfo;
11+
import org.lfenergy.compas.sct.commons.dto.FcdaForDataSetsCreation;
12+
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
1013
import org.lfenergy.compas.sct.commons.exception.ScdException;
1114
import org.lfenergy.compas.sct.commons.util.ILDEPFSettings;
1215
import org.lfenergy.compas.sct.commons.util.Utils;
1316

1417
import java.util.List;
18+
import java.util.Set;
1519

1620
/**
1721
* Service class that will be used to create, update or delete elements related to the {@link TExtRef <em>TExtRef</em>} object.
@@ -61,29 +65,32 @@ public interface ExtRefEditor {
6165
/**
6266
* Create All DataSet and ControlBlock in the SCL based on the ExtRef
6367
*
64-
* @param scd input SCD object. It could be modified by adding new DataSet and ControlBlocks
68+
* @param scd input SCD object. It could be modified by adding new DataSet and ControlBlocks
69+
* @param allowedFcdas List of allowed FCDA for DataSets and Control Blocks creation
6570
* @return list of encountered errors
6671
*/
67-
List<SclReportItem> createDataSetAndControlBlocks(SCL scd);
72+
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, Set<FcdaForDataSetsCreation> allowedFcdas);
6873

6974
/**
7075
* Create All DataSet and ControlBlock for the ExtRef in given IED
7176
*
7277
* @param scd input SCD object. The object will be modified with the new DataSet and ControlBlocks
7378
* @param targetIedName the name of the IED where the ExtRef are
79+
* @param allowedFcdas List of allowed FCDA for DataSets and Control Blocks creation
7480
* @return list of encountered errors
7581
*/
76-
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName);
82+
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, Set<FcdaForDataSetsCreation> allowedFcdas);
7783

7884
/**
7985
* Create All DataSet and ControlBlock for the ExtRef in given IED and LDevice
8086
*
8187
* @param scd input SCD object. The object will be modified with the new DataSet and ControlBlocks
8288
* @param targetIedName the name of the IED where the ExtRef are
8389
* @param targetLDeviceInst the name of the LDevice where the ExtRef are
90+
* @param allowedFcdas List of allowed FCDA for DataSets and Control Blocks creation
8491
* @return list of encountered errors
8592
*/
86-
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst);
93+
List<SclReportItem> createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst, Set<FcdaForDataSetsCreation> allowedFcdas);
8794

8895
/**
8996
* Configure the network for all the ControlBlocks.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* // SPDX-FileCopyrightText: 2023 RTE FRANCE
3+
* //
4+
* // SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package org.lfenergy.compas.sct.commons.dto;
8+
9+
import com.opencsv.bean.CsvBindByPosition;
10+
import lombok.AllArgsConstructor;
11+
import lombok.EqualsAndHashCode;
12+
import lombok.Getter;
13+
import lombok.NoArgsConstructor;
14+
15+
@NoArgsConstructor
16+
@AllArgsConstructor
17+
@Getter
18+
@EqualsAndHashCode
19+
public class FcdaForDataSetsCreation {
20+
21+
@CsvBindByPosition(position = 0)
22+
private String lnClass;
23+
@CsvBindByPosition(position = 1)
24+
private String doName;
25+
@CsvBindByPosition(position = 2)
26+
private String daName;
27+
@CsvBindByPosition(position = 3)
28+
private String fc;
29+
}

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/DOTypeAdapter.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,22 @@ public Pair<String,DOTypeAdapter> findPathDoTypeToDA(String daName) throws ScdEx
252252

253253
/**
254254
* Find path from a SDO to DA (defined by names)
255+
*
255256
* @param sdoName SDO from which find a path
256-
* @param daName DA for which find a path to
257+
* @param daName DA for which find a path to
257258
* @return pair of DO/SDO and DoType. DO/SDO references the DOType
258259
* @throws ScdException when inconsistency are found in th SCL's
259-
* DataTypeTemplate (unknown reference for example). Which should normally not happens.
260+
* DataTypeTemplate (unknown reference for example). Which should normally not happens.
260261
*/
261-
Pair<String,DOTypeAdapter> findPathSDOToDA(String sdoName, String daName) throws ScdException {
262-
String errMsg = String.format("No coherence or path between DO/SDO(%s) and DA(%s)", sdoName,daName);
262+
public Pair<String, DOTypeAdapter> findPathSDOToDA(String sdoName, String daName) throws ScdException {
263+
String errMsg = String.format("No coherence or path between DO/SDO(%s) and DA(%s)", sdoName, daName);
263264
Optional<TSDO> opSdo = getSDOByName(sdoName);
264-
if(opSdo.isEmpty()) {
265+
if (opSdo.isEmpty()) {
265266
throw new ScdException(errMsg);
266267
}
267268

268269
DOTypeAdapter doTypeAdapter = parentAdapter.getDOTypeAdapterById(opSdo.get().getType()).orElse(null);
269-
if(doTypeAdapter == null) {
270+
if (doTypeAdapter == null) {
270271
throw new ScdException(errMsg);
271272
}
272273
if(doTypeAdapter.containsDAWithDAName(daName)){

0 commit comments

Comments
 (0)