Skip to content

Commit

Permalink
Merge pull request #84 from com-pas/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
Dennis Labordus authored Jun 30, 2022
2 parents c80598e + 8bf67d3 commit 0251a9c
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 112 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ updates:
schedule:
interval: "daily"
open-pull-requests-limit: 5
ignore:
# Next dependencies will be ignored, because they should stay in sync with the 'eclipse.aggr' versions.
- dependency-name: org.eclipse.core:org.eclipse.core.resources
- dependency-name: org.eclipse.emf:org.eclipse.emf.ecore
- dependency-name: org.eclipse.emf:org.eclipse.emf.common
- dependency-name: org.eclipse.ocl:org.eclipse.ocl.pivot
- dependency-name: org.eclipse.ocl:org.eclipse.ocl.xtext.completeocl
- dependency-name: org.eclipse.ocl:org.eclipse.ocl.xtext.oclstdlib
- dependency-name: org.antlr.runtime:org.antlr.runtime
- dependency-name: org.apache.log4j:org.apache.log4j
- dependency-name: javax.inject:javax.inject

- package-ecosystem: "docker"
directory: "/app/src/main/docker/"
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ Image there is a volume `/data/ocl` which can be used to add these files, see ou
example how to.

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

For instance,

```
data
└── ocl
├── FileSpecifics
│ └── CID
│ └── Busbar.ocl
│ └── DOType.ocl
└── SemanticConstraints
└── Busbar.ocl
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
class CompasOclFileCollectorFromJarTest extends AbstractCompasOclFileCollectorTest {
@Test
void getDefaultOclFiles_WhenCalledWithoutCustomDirectory_ThenListReturned() {
assertValidateOclFileCollector(new CompasOclFileCollector(null), 230);
assertValidateOclFileCollector(new CompasOclFileCollector(null), 212);
}

@Test
void getDefaultOclFiles_WhenCalledWithCustomDirectory_ThenListReturned() {
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 231);
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 213);
}
}
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ SPDX-License-Identifier: Apache-2.0
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<compiler-plugin.version>3.10.1</compiler-plugin.version>
<surefire-plugin.version>3.0.0-M6</surefire-plugin.version>
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
<sonarqube-plugin.version>3.2.0</sonarqube-plugin.version>

<compas.scl.xsd.version>0.0.4</compas.scl.xsd.version>
<compas.core.version>0.9.0</compas.core.version>
<compas.core.version>0.9.1</compas.core.version>

<quarkus.platform.version>2.9.0.Final</quarkus.platform.version>
<quarkus.platform.version>2.10.1.Final</quarkus.platform.version>
<slf4j.version>1.7.36</slf4j.version>
<openpojo.version>0.9.1</openpojo.version>
</properties>
Expand Down Expand Up @@ -163,7 +163,7 @@ SPDX-License-Identifier: Apache-2.0
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<executions>
<execution>
<id>make-index</id>
Expand Down
47 changes: 38 additions & 9 deletions riseclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ SPDX-License-Identifier: Apache-2.0
</modules>

<properties>
<eclipse.core.resources.version>3.16.0</eclipse.core.resources.version>
<eclipse.emf.ecore.version>2.26.0</eclipse.emf.ecore.version>
<eclipse.emf.common.version>2.24.0</eclipse.emf.common.version>
<!-- These versions aren't monitored by Dependabot and need to be in sync with the file 'eclipse.aggr'.
When updating the file 'eclipse.aggr' also update these versions. But also check in the directory
'riseclipse/riseclipse-p2-to-m2/target/maven/repository/final', because sometimes the downloaded
version is newer.
-->
<eclipse.core.resources.version>3.17.0</eclipse.core.resources.version>
<eclipse.emf.ecore.version>2.27.0</eclipse.emf.ecore.version>
<eclipse.emf.common.version>2.25.0</eclipse.emf.common.version>
<eclipse.ocl.version>1.17.0</eclipse.ocl.version>
<antlr.runtime.version>3.2.0</antlr.runtime.version>
<log4j.version>1.2.19</log4j.version>
<javax.inject.version>1.0.0</javax.inject.version>

<riseclipse.scl.version>1.2.3</riseclipse.scl.version>
<riseclipse.main.version>1.2.5</riseclipse.main.version>
<riseclipse.main.version>1.2.6</riseclipse.main.version>
<riseclipse.scl.version>1.2.5</riseclipse.scl.version>

<riseclipse.p2.root>${project.basedir}/riseclipse-p2-to-m2</riseclipse.p2.root>
</properties>
Expand All @@ -46,13 +53,25 @@ SPDX-License-Identifier: Apache-2.0
<dependencies>
<dependency>
<groupId>io.github.riseclipse</groupId>
<artifactId>fr.centralesupelec.edf.riseclipse.iec61850.scl</artifactId>
<version>${riseclipse.scl.version}</version>
<artifactId>fr.centralesupelec.edf.riseclipse.main</artifactId>
<version>${riseclipse.main.version}</version>
<exclusions>
<exclusion>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.prefs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.github.riseclipse</groupId>
<artifactId>fr.centralesupelec.edf.riseclipse.main</artifactId>
<version>${riseclipse.main.version}</version>
<artifactId>fr.centralesupelec.edf.riseclipse.iec61850.scl</artifactId>
<version>${riseclipse.scl.version}</version>
<exclusions>
<exclusion>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.prefs</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -114,6 +133,16 @@ SPDX-License-Identifier: Apache-2.0
<artifactId>org.antlr.runtime</artifactId>
<version>${antlr.runtime.version}</version>
</dependency>
<dependency>
<groupId>org.apache.log4j</groupId>
<artifactId>org.apache.log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>${javax.inject.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
2 changes: 1 addition & 1 deletion riseclipse/riseclipse-ocl-constraints-scl2003
38 changes: 18 additions & 20 deletions riseclipse/riseclipse-p2-to-m2/src/main/resources/riseclipse.aggr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<aggregator:Aggregation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:aggregator="http://www.eclipse.org/cbi/p2repo/2011/aggregator/1.1.0" label="Eclipse Projects for RiseClipse" packedStrategy="UNPACK" mavenResult="true" versionFormat="MavenRelease">
<validationSets label="Eclipse needed projects for RiseClipse">
<contributions label="Eclipse Platform 2021-12">
<repositories location="https://download.eclipse.org/releases/2021-12/202112081000/">
<contributions label="Eclipse Platform 2022-06">
<repositories location="https://download.eclipse.org/releases/2022-06/202206151000/">
<bundles name="org.eclipse.core.commands" versionRange="3.10.100"/>
<bundles name="org.eclipse.core.contenttype" versionRange="3.8.100"/>
<bundles name="org.eclipse.core.jobs" versionRange="3.12.0"/>
Expand All @@ -13,44 +13,42 @@
<bundles name="org.eclipse.equinox.preferences" versionRange="3.9.100"/>
<bundles name="org.eclipse.equinox.registry" versionRange="3.11.100"/>
<bundles name="org.eclipse.jdt.annotation" versionRange="2.2.600"/>
<bundles name="org.eclipse.osgi.compatibility.state" versionRange="1.2.500"/>
<bundles name="org.eclipse.osgi.compatibility.state" versionRange="1.2.600"/>
<bundles name="org.eclipse.osgi" versionRange="3.17.100"/>
<bundles name="org.apache.log4j" versionRange="1.2.19.v20220208-1728"/>
<bundles name="com.google.guava" versionRange="30.1.0.v20210127-2300"/>
<bundles name="com.google.inject" versionRange="5.0.1.v20210324-2015"/>
<bundles name="javax.inject" versionRange="1.0.0.v20220405-0441"/>
<bundles name="org.antlr.runtime" versionRange="3.2.0.v20220404-1927"/>
<bundles name="org.aopalliance" versionRange="1.0.0.v20220404-1927"/>
</repositories>
</contributions>
<contributions label="EMF 2.28">
<repositories location="https://download.eclipse.org/releases/2021-12/202112081000/">
<bundles name="org.eclipse.emf.common" versionRange="2.23.0"/>
<bundles name="org.eclipse.emf.ecore" versionRange="2.25.0"/>
<contributions label="EMF 2.30">
<repositories location="https://download.eclipse.org/releases/2022-06/202206151000/">
<bundles name="org.eclipse.emf.common" versionRange="2.25.0"/>
<bundles name="org.eclipse.emf.ecore" versionRange="2.27.0"/>
<bundles name="org.eclipse.emf.ecore.change" versionRange="2.14.0"/>
<bundles name="org.eclipse.emf.ecore.xmi" versionRange="2.16.0"/>
<bundles name="org.eclipse.emf.edit" versionRange="2.16.0"/>
<bundles name="org.eclipse.emf.edit" versionRange="2.17.0"/>
</repositories>
</contributions>
<contributions label="OCL 6.17.0">
<repositories location="https://download.eclipse.org/releases/2021-12/202112081000/">
<contributions label="OCL 6.17.1">
<repositories location="https://download.eclipse.org/releases/2022-06/202206151000/">
<bundles name="org.eclipse.ocl.common" versionRange="1.17.0"/>
<bundles name="org.eclipse.ocl.pivot" versionRange="1.17.0"/>
<bundles name="org.eclipse.ocl.xtext.base" versionRange="1.17.0"/>
<bundles name="org.eclipse.ocl.xtext.completeocl" versionRange="1.17.0"/>
<bundles name="org.eclipse.ocl.xtext.essentialocl" versionRange="1.17.0"/>
<bundles name="org.eclipse.ocl.xtext.oclinecore" versionRange="1.17.0"/>
<bundles name="org.eclipse.ocl.xtext.oclstdlib" versionRange="1.17.0"/>
<bundles name="org.eclipse.xtext" versionRange="2.25.0"/>
<bundles name="org.eclipse.xtext" versionRange="2.27.0"/>
</repositories>
</contributions>
<contributions label="From Orbit">
<repositories location="https://download.eclipse.org/tools/orbit/downloads/drops/R20211213173813/repository">
<bundles name="com.google.guava" versionRange="30.1.0"/>
<bundles name="com.google.inject" versionRange="5.0.1"/>
<bundles name="javax.inject" versionRange="1.0.0"/>
<bundles name="org.antlr.runtime" versionRange="[3.2.0,3.3.0)"/>
<bundles name="org.apache.commons.lang3" versionRange="3.1.0"/>
<bundles name="org.apache.log4j" versionRange="1.2.15"/>
<repositories location="https://download.eclipse.org/tools/orbit/downloads/drops/R20220531185310/repository">
<bundles name="org.apache.commons.cli" versionRange="1.4.0"/>
</repositories>
</contributions>
<validationRepositories location="https://download.eclipse.org/releases/2021-12/202112081000/"/>
<validationRepositories location="https://download.eclipse.org/tools/orbit/downloads/drops/R20211213173813/repository"/>
</validationSets>
<configurations architecture="x86_64"/>
<configurations operatingSystem="linux" windowSystem="gtk" architecture="x86_64"/>
Expand Down
8 changes: 8 additions & 0 deletions riseclipse/validator-riseclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ SPDX-License-Identifier: Apache-2.0
<groupId>org.antlr.runtime</groupId>
<artifactId>org.antlr.runtime</artifactId>
</dependency>
<dependency>
<groupId>org.apache.log4j</groupId>
<artifactId>org.apache.log4j</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>

<!-- Test Dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import org.eclipse.ocl.pivot.utilities.OCL;
import org.eclipse.ocl.pivot.validation.ComposedEValidator;
import org.eclipse.ocl.xtext.completeocl.validation.CompleteOCLEObjectValidator;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.lfenergy.compas.scl.validator.exception.SclValidatorException;
import org.lfenergy.compas.scl.validator.util.OclUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -55,9 +53,8 @@ public OclFileLoader(Path tempDirectoryPath, List<URI> oclFiles) {
}
}

public void loadOCLDocuments(SclFileType type) {
public void loadOCLDocuments() {
oclFiles.stream()
.filter(uri -> OclUtil.includeOnType(uri, type))
.forEach(this::addOCLDocument);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.lfenergy.compas.scl.validator.exception.SclValidatorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -33,11 +34,12 @@ public SclModelLoader() {
.put(Resource.Factory.Registry.DEFAULT_EXTENSION, new SclResourceFactoryImpl());
}

public Resource load(String sclData) {
public Resource load(String sclData, SclFileType type) {
LOGGER.debug("Loading SCL Data in RiseClipse.");
try {
UUID uuid = UUID.randomUUID();
Resource resource = resourceSet.createResource(URI.createURI(uuid.toString()));
// Make a fake filename, but the extension is used by the OCL Rules to determine the Type of SCL File.
var filename = UUID.randomUUID().toString() + "." + type.name();
var resource = resourceSet.createResource(URI.createURI(filename));
resource.load(new ByteArrayInputStream(sclData.getBytes(StandardCharsets.UTF_8)), new HashMap<>());
return resource;
} catch (Exception exp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.lfenergy.compas.scl.validator.util.OclUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -53,14 +54,14 @@ public List<ValidationError> validate(SclFileType type, String sclData) {
OclFileLoader oclFileLoader = new OclFileLoader(tempDirectory, oclFiles);
try {
// Load all the OCL Files, adding them to the OCL Instance.
LOGGER.info("Loading OCL Files for type '{}'.", type);
oclFileLoader.loadOCLDocuments(type);
LOGGER.info("Loading OCL Files.");
oclFileLoader.loadOCLDocuments();
oclFileLoader.prepareValidator(validator);

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

LOGGER.info("Validating SCL Data for type '{}'.", type);
var diagnostician = new CompasDiagnostician(validatorRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
package org.lfenergy.compas.scl.validator.util;

import fr.centralesupelec.edf.riseclipse.iec61850.scl.SclPackage;
import org.eclipse.emf.common.util.URI;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.lfenergy.compas.scl.validator.exception.SclValidatorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

public class OclUtil {
Expand All @@ -35,16 +32,4 @@ public static void setupOcl() {
throw new SclValidatorException(OCL_MODEL_PACKAGE_NOT_FOUND, "SCL package not found");
}
}

public static boolean includeOnType(URI uri, SclFileType type) {
var fullPath = uri.path();
// OCL Files that are not in the directory 'FileSpecifics' will always be included.
// In the directory 'FileSpecifics' only the OCL Files that are in the directory 'Common' and
// from the directory for the requested SCL File, for instance 'CID', will be included.
var include = fullPath.contains(separator + FILE_SPECIFICS_DIR_NAME + separator + type + separator)
|| fullPath.contains(separator + FILE_SPECIFICS_DIR_NAME + separator + COMMON_DIR_NAME + separator)
|| !fullPath.contains(separator + FILE_SPECIFICS_DIR_NAME + separator);
LOGGER.debug("Full Path '{}' will be included: {}", fullPath, include);
return include;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
class CompasOclFileCollectorTest extends AbstractCompasOclFileCollectorTest {
@Test
void getDefaultOclFiles_WhenCalledWithoutCustomDirectory_ThenListReturned() {
assertValidateOclFileCollector(new CompasOclFileCollector(null), 230);
assertValidateOclFileCollector(new CompasOclFileCollector(null), 212);
}

@Test
void getDefaultOclFiles_WhenCalledWithCustomDirectory_ThenListReturned() {
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 231);
assertValidateOclFileCollector(new CompasOclFileCollector("./src/test/data/ocl"), 213);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.lfenergy.compas.scl.validator.exception.SclValidatorException;
import org.lfenergy.compas.scl.validator.util.OclUtil;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down Expand Up @@ -49,7 +48,7 @@ void setup() throws IOException {

@Test
void loadOCLDocuments_WhenCalled_ThenFilesFromListAreLoaded() throws IOException {
loader.loadOCLDocuments(SclFileType.CID);
loader.loadOCLDocuments();

assertEquals(1, Files.lines(tempFile).count());
}
Expand Down
Loading

0 comments on commit 0251a9c

Please sign in to comment.