Skip to content

Commit 72d0a0d

Browse files
author
Flurb
committed
Merge
Signed-off-by: Flurb <[email protected]>
2 parents bd668c2 + 300af5b commit 72d0a0d

File tree

52 files changed

+970
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+970
-32
lines changed

.github/workflows/release-project.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,17 @@ jobs:
5555
output_file: custom_maven_settings.xml
5656
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
5757
- name: Set version with Maven
58+
# Only set the version for the CoMPAS Modules, excluding the RiseClipse Modules.
5859
run: ./mvnw -B versions:set -DgroupId=org.lfenergy.compas.scl.validator -DnewVersion=${{ steps.extract_tagname.outputs.tagname }}
5960
env:
6061
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6162
- name: Deploy with Maven to GitHub Packages and Docker Hub
62-
run: ./mvnw -B -s custom_maven_settings.xml -Prelease clean deploy
63+
# We need to pass the Repository information, because these are missing/need to be overwritten for the
64+
# RiseClipse Submodules for which we can't update the POM files.
65+
run: |
66+
./mvnw -B -s custom_maven_settings.xml \
67+
-DaltDeploymentRepository=github-packages-compas::default::https://maven.pkg.github.com/com-pas/compas-scl-validator \
68+
-Dmaven.deploy.skip=snapshots \
69+
-Prelease clean deploy
6370
env:
6471
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

DEVELOPMENT.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@ git submodule update
3333
Importing the project is a bit harder for the SCL Validator then normal. It's caused because of the submodules that are
3434
needed from RiseClipse. These projects are Eclipse projects using Eclipse Tycho to build and Eclipse project structure.
3535

36-
A way to make everything work in IntelliJ is importing the project in the following way.
36+
The first step to make it work in IntelliJ is that an Eclipse version needs to be available on your local machine. The
37+
version we know that's working can be found [here](https://www.eclipse.org/downloads/packages/release/2019-06/r)
38+
Download (and install/unzip) Eclipse.
39+
40+
Next a way to make everything work in IntelliJ is importing the project in the following way.
3741

3842
- First step is to just import everything like it are Maven projects;
43+
- Next we need to add a Global Library in IntelliJ. Open the Module Settings and select "Global Libraries". And a new
44+
libraries and name it "ECLIPSE". Point it to the directory "<ECLIPSE_INSTALL_DIR>/plugins";
3945
- Next step is to re-import the RiseClipse Submodule as Eclipse;
40-
- In IntelliJ select "File" -> "New" -> "Module from Existing Sources...";
41-
- Select one of the RiseClipse Submodules, for instance "riseclipse-metamodel-scl2003";
42-
- Next select "Eclipse" by "Import module from External Model";
43-
- Follow the rest of the wizard, only to remember to select all subprojects that are available in the directory;
46+
- In IntelliJ select "File" -> "New" -> "Module from Existing Sources...";
47+
- Select one of the RiseClipse Submodules, for instance "riseclipse-metamodel-scl2003";
48+
- Next select "Eclipse" by "Import module from External Model";
49+
- Follow the rest of the wizard, only to remember to select all subprojects that are available in the directory;
4450

4551
Now the module should be correctly imported in IntelliJ to be used. Check the Module Settings of one of the subprojects
4652
to check if the directory "src" is a Java Source Directory, for instance the module

README.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,61 @@ described in the URL above that the URL can be overwritten locally with an HTTPS
3030
Check the [Development](DEVELOPMENT.md) page for more detail information how to work with this repository, because of
3131
the mixture with RiseClipse.
3232

33+
## Custom OCL Files
34+
35+
There is a way to add custom OCL Files to the validator, for instance to force company specific rules. In the Docker
36+
Image there is a volume `/data/ocl` which can be used to add these files, see our compas-deployment project for an
37+
example how to.
38+
39+
In this directory, you can use subdirectories like `SemanticConstraints` as RiseClipse is doing. And there is a special
40+
filter that when you create a directory `FileSpecifics`. In this directory you can create for instance a directory `CID`
41+
to put constraints specific for an SCL File Type. Known types are `SSD`, `IID`, `ICD`, `SCD`, `CID`, `SED`, `ISD`,
42+
`STD`.
43+
44+
For instance,
45+
46+
```
47+
data
48+
└── ocl
49+
├── FileSpecifics
50+
│ └── CID
51+
│ └── Busbar.ocl
52+
└── SemanticConstraints
53+
└── Busbar.ocl
54+
```
55+
56+
If you are using the validator are library (using JAR Files) there is a property to configure the directory, see
57+
[Common Environment variables](#common-environment-variables)
58+
59+
## NSDoc Files
60+
61+
Because NSDoc File can't be distributed in an OpenSource Project these need to be added during deployment. In the Docker
62+
Image there is a volume `/data/nsdoc` which can be used to add these files, see our compas-deployment project for an
63+
example how to.
64+
65+
Only direct files found in this directory will be processed. Invalid NSDoc Files will be ignored. A directory can look
66+
like this for instance,
67+
68+
```
69+
data
70+
└── nsdoc
71+
├── IEC_61850-7-2_2007B3-en.nsdoc
72+
├── IEC_61850-7-3_2007B3-en.nsdoc
73+
└── IEC_61850-7-4_2007B3-en.nsdoc
74+
75+
```
76+
77+
If you are using the validator are library (using JAR Files) there is a property to configure the directory, see
78+
[Common Environment variables](#common-environment-variables)
79+
3380
## Common Environment variables
3481

3582
Below environment variable(s) can be used to configure the validator.
3683

37-
| Environment variable | Java Property | Description | Example |
38-
|---------------------------------------|---------------------------------------|---------------------------------------------------|-----------|
39-
| COMPAS_VALIDATOR_OCL_CUSTOM_DIRECTORY | compas.validator.ocl.custom.directory | Reference to a directory to load custom OCL Files | /data/ocl |
84+
| Environment variable | Java Property | Description | Example |
85+
|---------------------------------------|---------------------------------------|-------------------------------------------------------------|-------------|
86+
| COMPAS_VALIDATOR_OCL_CUSTOM_DIRECTORY | compas.validator.ocl.custom.directory | Reference to a directory to load custom OCL Files | /data/ocl |
87+
| COMPAS_VALIDATOR_NSDOC_DIRECTORY | compas.validator.nsdoc.directory | Reference to a directory where the NSDoc Files can be found | /data/nsdoc |
4088

4189
## Security
4290

app/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ SPDX-License-Identifier: Apache-2.0
2222
<quarkus.container-image.name>compas-scl-validator</quarkus.container-image.name>
2323
</properties>
2424

25-
<dependencyManagement>
26-
<dependencies>
27-
</dependencies>
28-
</dependencyManagement>
29-
3025
<dependencies>
3126
<dependency>
3227
<groupId>org.lfenergy.compas.scl.validator</groupId>

app/src/main/docker/Dockerfile.jvm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
4949
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
5050

5151
RUN mkdir -p /data/ocl \
52+
&& mkdir -p /data/nsdoc \
5253
&& mkdir -p /data/temp \
5354
&& chown -R 1001 /data \
5455
&& chmod -R "g+rwX" /data
5556
VOLUME /data/ocl
57+
VOLUME /data/nsdoc
5658

5759
EXPOSE 8080
5860
USER 1001

app/src/main/docker/Dockerfile.native

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ RUN chown 1001 /work \
2222
COPY --chown=1001:root target/*-runner /work/application
2323

2424
RUN mkdir -p /data/ocl \
25+
&& mkdir -p /data/nsdoc \
2526
&& mkdir -p /data/temp \
2627
&& chown -R 1001 /data \
2728
&& chmod -R "g+rwX" /data
2829
VOLUME /data/ocl
30+
VOLUME /data/nsdoc
2931

3032
EXPOSE 8080
3133
USER 1001

app/src/main/java/org/lfenergy/compas/scl/validator/rest/CompasSclValidatorConfiguration.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
// SPDX-License-Identifier: Apache-2.0
44
package org.lfenergy.compas.scl.validator.rest;
55

6+
import io.quarkus.runtime.Startup;
67
import org.lfenergy.compas.core.commons.ElementConverter;
78
import org.lfenergy.compas.scl.validator.xsd.SclXsdValidator;
89
import org.lfenergy.compas.scl.validator.collector.CompasOclFileCollector;
910
import org.lfenergy.compas.scl.validator.collector.OclFileCollector;
11+
import org.lfenergy.compas.scl.validator.common.NsdocFinder;
1012
import org.lfenergy.compas.scl.validator.impl.SclRiseClipseValidator;
1113

1214
import javax.enterprise.context.ApplicationScoped;
@@ -40,4 +42,10 @@ public SclRiseClipseValidator createSclRiseClipseValidator(OclFileCollector oclF
4042
public SclXsdValidator createSclXsdValidator() {
4143
return new SclXsdValidator();
4244
}
45+
46+
@Startup
47+
@ApplicationScoped
48+
public NsdocFinder createNsdocFinder(ValidatorProperties properties) {
49+
return new NsdocFinder(properties.nsdocDirectory());
50+
}
4351
}

app/src/main/java/org/lfenergy/compas/scl/validator/rest/SclResourceConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public final class SclResourceConstants {
99
}
1010

1111
public static final String TYPE_PATH_PARAM = "type";
12+
public static final String ID_PARAM = "id";
1213
}

app/src/main/java/org/lfenergy/compas/scl/validator/rest/ValidatorProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public interface ValidatorProperties {
1313
@WithName("ocl.custom.directory")
1414
String oclCustomDirectory();
1515

16+
@WithName("nsdoc.directory")
17+
String nsdocDirectory();
18+
1619
@WithName("temp.directory")
1720
Path tempDirectory();
1821
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.validator.rest.exception;
5+
6+
import org.lfenergy.compas.core.jaxrs.model.ErrorResponse;
7+
import org.lfenergy.compas.scl.validator.exception.NsdocFileNotFoundException;
8+
9+
import javax.ws.rs.core.Response;
10+
import javax.ws.rs.ext.ExceptionMapper;
11+
import javax.ws.rs.ext.Provider;
12+
13+
@Provider
14+
public class NsdocNotFoundExceptionHandler implements ExceptionMapper<NsdocFileNotFoundException> {
15+
@Override
16+
public Response toResponse(NsdocFileNotFoundException exception) {
17+
var response = new ErrorResponse();
18+
response.addErrorMessage(exception.getErrorCode(), exception.getMessage());
19+
return Response.status(Response.Status.NOT_FOUND).entity(response).build();
20+
}
21+
}

0 commit comments

Comments
 (0)