Skip to content

Commit

Permalink
Made github actions for mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
daghovland committed Jan 16, 2025
1 parent 673bf3d commit 8fb98b4
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 12 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/rdf_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: "⛓️Test rml-mappings⛓️"

on:
workflow_dispatch:
merge_group:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 19
uses: actions/setup-java@v4
with:
java-version: "19"
distribution: "temurin"

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: install apache jena
run: |
wget https://dlcdn.apache.org/jena/binaries/apache-jena-5.2.0.tar.gz
tar -xzvf apache-jena-*.tar.gz
- name: Check ontologies and mappings are valid rdf
id: validate_ontology_rdf
run: |
export JENA_HOME=$(pwd)/apache-jena-5.2.0/
export PATH="$PATH:$JENA_HOME/bin"
riot --validate owl/*ttl
riot --validate rml_mappings/imf/*
riot --validate rml_mappings/graphics/*
- name: Test imf mappings
run: |
export JENA_HOME=$(pwd)/apache-jena-5.2.0/
export PATH="$PATH:$JENA_HOME/bin"
docker run -v .:/data rmlio/rmlmapper-java:7.2.0 -m rml_mappings/imf/* -o /data/imf.ttl
shacl v --shapes shacl/imf-dexpi.shacl.ttl --data imf.ttl
- name: Test graphics mappings
run: |
export JENA_HOME=$(pwd)/apache-jena-5.2.0/
export PATH="$PATH:$JENA_HOME/bin"
docker run -v .:/data rmlio/rmlmapper-java:7.2.0 -m rml_mappings/graphics/* -o /data/graphics.ttl
shacl v --shapes shacl/imf-graphics.shacl.ttl --data graphics.ttl
- name: SHACL validation
id: shacl_result
run: |
export JENA_HOME=$(pwd)/apache-jena-5.2.0/
export PATH="$PATH:$JENA_HOME/bin"
shacl v --shapes ${{matrix.document_type}}/shacl/*in_transit* --data ${{matrix.document_type}}/results.ttl > shacl_output.txt
- name: format result
id: format
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const shacl = fs.readFileSync('shacl_output.txt', 'utf8');
const result = `
<details><summary>⛓️ Show SHACL result for ${{ matrix.document_type }}⛓️</summary>
\`\`\` trig \n
${shacl}
\`\`\`
</details>
`
return result;
result-encoding: string

- name: Find PR Number
uses: jwalton/gh-find-current-pr@v1
id: pr_number

- name: comment results
uses: marocchino/sticky-pull-request-comment@v2
with:
header: ${{ matrix.document_type }}
number: ${{ steps.pr_number.outputs.pr }}
message: ${{ steps.format.outputs.result }}
1 change: 1 addition & 0 deletions docker/rml-mapper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN apt-get update && \
# Clone the NOAKADEXPI Git repo
RUN git clone https://github.com/equinor/NOAKADEXPI.git /app/NOAKADEXPI


# Copy the demo bash script
COPY demo.sh /app/demo.sh
RUN dos2unix /app/demo.sh
Expand Down
6 changes: 3 additions & 3 deletions docker/rml-mapper/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# This script is for use inside the docker container defined in the Dockerfile in this folder
# See README.md for instructions

# Copy xml for frontend
cp /app/local/rml_mappings/pandid.xml /app/local/www/public/DISC_EXAMPLE-02-02.xml
cp /app/NOAKADEXPI/Blueprint/DISC_EXAMPLE-02/DISC_EXAMPLE-02-02.xml /app/local/www/public/
cp /app/NOAKADEXPI/Blueprint/DISC_EXAMPLE-02/DISC_EXAMPLE-02-02.xml /app/local/rml_mappings/pandid.xml

# Create rdf
cd local/rml_mappings
java -jar /app/rmlmapper.jar -m *map*ttl -s trig -o pandid.trig
java -jar /app/rmlmapper.jar -m imf/*map*ttl -s trig -o pandid.trig
cd /app/

# Copy the lacking Origo symbol
Expand Down
4 changes: 3 additions & 1 deletion rml_mappings/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# RML mappings

This folder contains RML mappings, [to IMF](http://www.imfid.org/) in the folder [imf](imf) and to our custom [graphical format](../examples/graphical.trig) in the folder [graphics](graphics)

## Prerequisites

* Download a proteus xml file, for example [DISC_EXAMPLE-02-01.xml](https://github.com/equinor/NOAKADEXPI/blob/main/Blueprint/DISC_EXAMPLE-02/DISC_EXAMPLE-02-01.xml) to this folder and rename it to "pandid.xml"
Expand All @@ -20,7 +22,7 @@ Or you can run it using java:

## Run
```
java -jar ../../rmlmapper-java/target/rmlmapper-*-all.jar -m *map* -s trig -o pandid.trig
java -jar ../../rmlmapper-java/target/rmlmapper-*-all.jar -m imf/*map* -s trig -o pandid.trig
```

## Example files resources
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
Expand All @@ -10,7 +11,7 @@

:EquipmentBlockMap a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "PlantModel/Equipment"
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

:PipingComponentConnectorMap a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//PipingNetworkSegment/PipingComponent | //PipingNetworkSegment/PropertyBreak"
];
Expand All @@ -29,7 +29,7 @@

:PipingComponentTerminalMap a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//PipingNetworkSegment/PipingComponent/ConnectionPoints/Node[@Type='process'] | //PipingNetworkSegment/PropertyBreak/ConnectionPoints/Node[@Type='process']"
];
Expand Down Expand Up @@ -62,7 +62,7 @@

:PipingComponentBlockMap a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//PipingNetworkSegment/PipingComponent | //PipingNetworkSegment/PropertyBreak"
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@prefix dexpi: <https://rdf.equinor.com/dexpi#> .
@prefix asset: <https://assetid.equinor.com/plantx#> .
@prefix imf: <http://ns.imfid.org/imf#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .


:hasNetworkSegmentConnector
Expand All @@ -20,7 +21,7 @@

:PipingComponentSegmentFromTerminalMap a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//PipingNetworkSystem/PipingNetworkSegment"
];
Expand Down Expand Up @@ -48,7 +49,7 @@

:PipingComponentSegmentToTerminalMap a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//PipingNetworkSegment"
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
@prefix dexpi: <https://rdf.equinor.com/dexpi#> .
@prefix asset: <https://assetid.equinor.com/plantx#> .
@prefix imf: <http://ns.imfid.org/imf#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:PipingNetworkSystemConnector a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//PipingNetworkSystem"
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

:AttributesMap a rr:TriplesMap;
rml:logicalSource [
rml:source "pandid.xml";
rml:source "../pandid.xml";
rml:referenceFormulation ql:XPath;
rml:iterator "//GenericAttributes/GenericAttribute"
].
Expand Down
118 changes: 118 additions & 0 deletions shacl/graphic-dexpi.shacl.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example.org/> .
@prefix css: <https://www.w3.org/TR/css-color-4#> .

:DocumentShape a sh:NodeShape ;
sh:targetClass :PID ;
sh:property [
sh:path :visualisedAs ;
sh:node :GraphicShape ;
] .

:GraphicShape a sh:NodeShape ;
sh:property [
sh:path :hasExtent ;
sh:node :ExtentShape ;
] ;
sh:property [
sh:path :hasSymbol ;
sh:node :SymbolShape ;
] ;
sh:property [
sh:path :hasLine ;
sh:node :LineShape ;
] .

:ExtentShape a sh:NodeShape ;
sh:property [
sh:path :minimumExtent ;
sh:node :PositionShape ;
] ;
sh:property [
sh:path :maximumExtent ;
sh:node :PositionShape ;
] .

:PositionShape a sh:NodeShape ;
sh:property [
sh:path :x ;
sh:datatype xsd:int ;
] ;
sh:property [
sh:path :y ;
sh:datatype xsd:int ;
] ;
sh:property [
sh:path :rotation ;
sh:datatype xsd:int ;
sh:minCount 0 ;
] .

:SymbolShape a sh:NodeShape ;
sh:property [
sh:path :hasPosition ;
sh:node :PositionShape ;
] ;
sh:property [
sh:path :hasGraphics ;
sh:node :GraphicsShape ;
] .

:GraphicsShape a sh:NodeShape ;
sh:property [
sh:path :hasGraphics ;
sh:node :SymbolShape ;
] .

:LineShape a sh:NodeShape ;
sh:property [
sh:path :hasCoordinates ;
sh:node :PositionShape ;
] ;
sh:property [
sh:path :hasStyle ;
sh:node :StyleShape ;
] .

:StyleShape a sh:NodeShape ;
sh:property [
sh:path :hasStroke ;
sh:node :StrokeShape ;
] ;
sh:property [
sh:path :hasStyle ;
sh:datatype css:style ;
] .

:StrokeShape a sh:NodeShape ;
sh:property [
sh:path :dasharray ;
sh:datatype xsd:string ;
] ;
sh:property [
sh:path :width ;
sh:datatype xsd:float ;
] ;
sh:property [
sh:path :color ;
sh:node :ColorShape ;
] .

:ColorShape a sh:NodeShape ;
sh:property [
sh:path :type ;
sh:datatype xsd:string ;
] ;
sh:property [
sh:path :red ;
sh:datatype xsd:int ;
] ;
sh:property [
sh:path :green ;
sh:datatype xsd:int ;
] ;
sh:property [
sh:path :blue ;
sh:datatype xsd:int ;
] .

0 comments on commit 8fb98b4

Please sign in to comment.