Skip to content

Commit 70a57e1

Browse files
author
Dennis Labordus
committed
Merge branch 'develop' into dependabot/maven/io.github.riseclipse-fr.centralesupelec.edf.riseclipse.main-1.2.6
Signed-off-by: Dennis Labordus <[email protected]>
2 parents c43370f + 92b9af6 commit 70a57e1

File tree

13 files changed

+25
-81
lines changed

13 files changed

+25
-81
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,16 @@ Image there is a volume `/data/ocl` which can be used to add these files, see ou
4949
example how to.
5050

5151
In this directory, you can use subdirectories like `SemanticConstraints` as RiseClipse is doing. And there is a special
52-
filter that when you create a directory `FileSpecifics`. In this directory you can create for instance a directory `CID`
53-
to put constraints specific for an SCL File Type. Known types are `SSD`, `IID`, `ICD`, `SCD`, `CID`, `SED`, `ISD`,
54-
`STD`.
52+
directory `FileSpecifics`. In this directory mostly file specific rules are added. There are functions that can be used
53+
in the OCL Rules to determine the type of file, like `isInICDFile()`.
5554

5655
For instance,
5756

5857
```
5958
data
6059
└── ocl
6160
├── FileSpecifics
62-
│ └── CID
63-
│ └── Busbar.ocl
61+
│ └── DOType.ocl
6462
└── SemanticConstraints
6563
└── Busbar.ocl
6664
```

app/src/test/java/org/lfenergy/compas/scl/validator/rest/CompasOclFileCollectorFromJarTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
class CompasOclFileCollectorFromJarTest extends AbstractCompasOclFileCollectorTest {
1515
@Test
1616
void getDefaultOclFiles_WhenCalledWithoutCustomDirectory_ThenListReturned() {
17-
assertValidateOclFileCollector(new CompasOclFileCollector(null), 230);
17+
assertValidateOclFileCollector(new CompasOclFileCollector(null), 212);
1818
}
1919

2020
@Test
2121
void getDefaultOclFiles_WhenCalledWithCustomDirectory_ThenListReturned() {
22-
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 231);
22+
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 213);
2323
}
2424
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SPDX-License-Identifier: Apache-2.0
2727
<compas.scl.xsd.version>0.0.4</compas.scl.xsd.version>
2828
<compas.core.version>0.9.0</compas.core.version>
2929

30-
<quarkus.platform.version>2.9.2.Final</quarkus.platform.version>
30+
<quarkus.platform.version>2.10.0.Final</quarkus.platform.version>
3131
<slf4j.version>1.7.36</slf4j.version>
3232
<openpojo.version>0.9.1</openpojo.version>
3333
</properties>

riseclipse/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SPDX-License-Identifier: Apache-2.0
2929
<eclipse.ocl.version>1.17.0</eclipse.ocl.version>
3030
<antlr.runtime.version>3.2.0</antlr.runtime.version>
3131

32-
<riseclipse.scl.version>1.2.3</riseclipse.scl.version>
32+
<riseclipse.scl.version>1.2.4</riseclipse.scl.version>
3333
<riseclipse.main.version>1.2.6</riseclipse.main.version>
3434

3535
<riseclipse.p2.root>${project.basedir}/riseclipse-p2-to-m2</riseclipse.p2.root>

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/impl/OclFileLoader.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
import org.eclipse.ocl.pivot.utilities.OCL;
1212
import org.eclipse.ocl.pivot.validation.ComposedEValidator;
1313
import org.eclipse.ocl.xtext.completeocl.validation.CompleteOCLEObjectValidator;
14-
import org.lfenergy.compas.scl.extensions.model.SclFileType;
1514
import org.lfenergy.compas.scl.validator.exception.SclValidatorException;
16-
import org.lfenergy.compas.scl.validator.util.OclUtil;
1715
import org.slf4j.Logger;
1816
import org.slf4j.LoggerFactory;
1917

@@ -55,9 +53,8 @@ public OclFileLoader(Path tempDirectoryPath, List<URI> oclFiles) {
5553
}
5654
}
5755

58-
public void loadOCLDocuments(SclFileType type) {
56+
public void loadOCLDocuments() {
5957
oclFiles.stream()
60-
.filter(uri -> OclUtil.includeOnType(uri, type))
6158
.forEach(this::addOCLDocument);
6259
}
6360

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/impl/SclModelLoader.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.eclipse.emf.common.util.URI;
99
import org.eclipse.emf.ecore.resource.Resource;
1010
import org.eclipse.emf.ecore.resource.ResourceSet;
11+
import org.lfenergy.compas.scl.extensions.model.SclFileType;
1112
import org.lfenergy.compas.scl.validator.exception.SclValidatorException;
1213
import org.slf4j.Logger;
1314
import org.slf4j.LoggerFactory;
@@ -33,11 +34,12 @@ public SclModelLoader() {
3334
.put(Resource.Factory.Registry.DEFAULT_EXTENSION, new SclResourceFactoryImpl());
3435
}
3536

36-
public Resource load(String sclData) {
37+
public Resource load(String sclData, SclFileType type) {
3738
LOGGER.debug("Loading SCL Data in RiseClipse.");
3839
try {
39-
UUID uuid = UUID.randomUUID();
40-
Resource resource = resourceSet.createResource(URI.createURI(uuid.toString()));
40+
// Make a fake filename, but the extension is used by the OCL Rules to determine the Type of SCL File.
41+
var filename = UUID.randomUUID().toString() + "." + type.name();
42+
var resource = resourceSet.createResource(URI.createURI(filename));
4143
resource.load(new ByteArrayInputStream(sclData.getBytes(StandardCharsets.UTF_8)), new HashMap<>());
4244
return resource;
4345
} catch (Exception exp) {

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/impl/SclRiseClipseValidator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.lfenergy.compas.scl.validator.util.OclUtil;
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
23+
2324
import java.nio.file.Path;
2425
import java.util.ArrayList;
2526
import java.util.List;
@@ -53,14 +54,14 @@ public List<ValidationError> validate(SclFileType type, String sclData) {
5354
OclFileLoader oclFileLoader = new OclFileLoader(tempDirectory, oclFiles);
5455
try {
5556
// Load all the OCL Files, adding them to the OCL Instance.
56-
LOGGER.info("Loading OCL Files for type '{}'.", type);
57-
oclFileLoader.loadOCLDocuments(type);
57+
LOGGER.info("Loading OCL Files.");
58+
oclFileLoader.loadOCLDocuments();
5859
oclFileLoader.prepareValidator(validator);
5960

6061
// Load the SCL File as Resource ready to be processed.
6162
LOGGER.info("Loading SCL Data for type '{}'.", type);
6263
var sclLoader = new SclModelLoader();
63-
var resource = sclLoader.load(sclData);
64+
var resource = sclLoader.load(sclData, type);
6465

6566
LOGGER.info("Validating SCL Data for type '{}'.", type);
6667
var diagnostician = new CompasDiagnostician(validatorRegistry);

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/util/OclUtil.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
package org.lfenergy.compas.scl.validator.util;
55

66
import fr.centralesupelec.edf.riseclipse.iec61850.scl.SclPackage;
7-
import org.eclipse.emf.common.util.URI;
8-
import org.lfenergy.compas.scl.extensions.model.SclFileType;
97
import org.lfenergy.compas.scl.validator.exception.SclValidatorException;
108
import org.slf4j.Logger;
119
import org.slf4j.LoggerFactory;
1210

13-
import static java.io.File.separator;
1411
import static org.lfenergy.compas.scl.validator.exception.SclValidatorErrorCode.OCL_MODEL_PACKAGE_NOT_FOUND;
1512

1613
public class OclUtil {
@@ -35,16 +32,4 @@ public static void setupOcl() {
3532
throw new SclValidatorException(OCL_MODEL_PACKAGE_NOT_FOUND, "SCL package not found");
3633
}
3734
}
38-
39-
public static boolean includeOnType(URI uri, SclFileType type) {
40-
var fullPath = uri.path();
41-
// OCL Files that are not in the directory 'FileSpecifics' will always be included.
42-
// In the directory 'FileSpecifics' only the OCL Files that are in the directory 'Common' and
43-
// from the directory for the requested SCL File, for instance 'CID', will be included.
44-
var include = fullPath.contains(separator + FILE_SPECIFICS_DIR_NAME + separator + type + separator)
45-
|| fullPath.contains(separator + FILE_SPECIFICS_DIR_NAME + separator + COMMON_DIR_NAME + separator)
46-
|| !fullPath.contains(separator + FILE_SPECIFICS_DIR_NAME + separator);
47-
LOGGER.debug("Full Path '{}' will be included: {}", fullPath, include);
48-
return include;
49-
}
5035
}

riseclipse/validator-riseclipse/src/test/java/org/lfenergy/compas/scl/validator/collector/CompasOclFileCollectorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
class CompasOclFileCollectorTest extends AbstractCompasOclFileCollectorTest {
99
@Test
1010
void getDefaultOclFiles_WhenCalledWithoutCustomDirectory_ThenListReturned() {
11-
assertValidateOclFileCollector(new CompasOclFileCollector(null), 230);
11+
assertValidateOclFileCollector(new CompasOclFileCollector(null), 212);
1212
}
1313

1414
@Test
1515
void getDefaultOclFiles_WhenCalledWithCustomDirectory_ThenListReturned() {
16-
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 231);
16+
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 213);
1717
}
1818
}

0 commit comments

Comments
 (0)