Skip to content

Commit

Permalink
Trying out docker for demo script (#39)
Browse files Browse the repository at this point in the history
# Aim
Easier to run demo

# Method
Creating a docker-based setup that runs all scripts

# Consequences
Relative path to NOAKADEXPI repo had to be renamed in dexpisvg.xslt so
the path works in the docker image. This means running the
transformation locally does not work anymore.

dexpi.html is now hardcoded to have 14 lines before the svg. 

Rdfox license must now have a hardcoded position in the repo

Xslt transformation uses the unix tool xsltproc in stead of C#, since
faster and easier in docker

xslt transformation for rotation refactored to be calculated in C#

The result of the rml transformation is stored in the same location as
before (pandid.trig), while the generated svg is stored in
"www/index.html".

# User story: 
https://dev.azure.com/EquinorASA/Spine/_workitems/edit/190800

---------

Co-authored-by: Embla Øye <[email protected]>
  • Loading branch information
daghovland and eoye authored Nov 21, 2024
1 parent 32b2a4d commit 96e3d41
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 119 deletions.
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
C01V04-VER.EX01.xml
C01V04-VER.EX01.trig
dexpi.properties
pandid.xml
pandid.trig
rml/segments.trig
client/.idea
.vs
client/Boundaries/Dexpi2Svg/test.svg
rml/C03V04.trig
www/C03V04.svg
client/Boundaries/Dexpi2Svg/bin
client/Boundaries/Dexpi2Svg/obj
client/Boundaries/Boundaries/bin
client/Boundaries/Boundaries/obj
client/Boundaries/TestBoundaries/obj
client/Boundaries/TestBoundaries/bin
aibel_dexpi/*
aibel_dexpi.xml
output.svg
local
chex.egg-info
__pycache__
/owl/boundary.properties
/owl/catalog-v001.xml
/www/node_modules/
/RDFox.lic
/.idea/
/www/.idea
/www/index.html
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

A repository for SSI experiments with DEXPI.

[RML mappings](rml/README.md)
* To start up the demo, see [docker/README.md](docker/README.md)

[RDFox scripts](rdfox/README.md)
* To use the demo, see [www/README.md](www/README.md)

* For the mappings from Dexpi to IMF see the [RML mappings](rml/README.md)

* For the backend setup of the triplestore, see the [RDFox scripts](rdfox/README.md)
17 changes: 17 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Docker-based demo setup

## Prerequisites
* Install Docker and Docker-compose [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)

* Copy the RDFox license file to [../RDFox.lic](../RDFox.lic)

* Find a dexpi file, and copy it to [../rml_mappings/pandid.xml](../rml_mappings/pandid.xml)

## Running

* From the root folder in the project ([../](../)), run
```
docker-compose -f docker/docker-compose.yml up --build
```

* Open [http://localhost:8080](http://localhost:8080)
35 changes: 35 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

services:
rdfox:
image: oxfordsemantic/rdfox:7.2a
command: -license.file /home/rdfox/.RDFox/RDFox.lic sandbox /home/rdfox/.RDFox/rdfox dexpi
stdin_open: true
tty: true
ports:
- 12110:12110
volumes:
- type: bind
source: ../
target: /home/rdfox/.RDFox/
depends_on:
rml-mapper:
condition: service_completed_successfully
rml-mapper:
build: rml-mapper
tty: true
volumes:
- type: bind
source: ../
target: /app/local/
web:
build: web
tty: true
ports:
- 8080:80
volumes:
- type: bind
source: ../www
target: /var/www/html/
depends_on:
rml-mapper:
condition: service_completed_successfully
24 changes: 24 additions & 0 deletions docker/rml-mapper/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use official Java image as the base image
FROM eclipse-temurin:21

# Set the working directory
WORKDIR /app

# Download the JAR file from the release URL and rename it to rmlmapper.jar
ADD https://github.com/RMLio/rmlmapper-java/releases/download/v7.1.2/rmlmapper-7.1.2-r374-all.jar /app/rmlmapper.jar

# Install Git, xsltproc and apache
RUN apt-get update && \
apt-get install -y git xsltproc dos2unix

# 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
RUN chmod +x /app/demo.sh

# Run the rml mappings
ENTRYPOINT "/app/demo.sh"

21 changes: 21 additions & 0 deletions docker/rml-mapper/demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This script is for use inside the docker container defined in the Dockerfile in this folder
# See README.md for instructions

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

# Copy the lacking Origo symbol
cp /app/local/xslt/PV001A_Origo.svg /app/NOAKADEXPI/Symbols/Origo

# Create svg
xsltproc --novalid -o /app/dexpi.svg /app/local/xslt/dexpisvg.xslt /app/local/rml_mappings/pandid.xml

## Copy svg into html
head -n 14 /app/local/www/dexpi.html > /app/local/www/index.html
cat /app/dexpi.svg >> /app/local/www/index.html
tail -n +14 /app/local/www/dexpi.html >> /app/local/www/index.html


14 changes: 14 additions & 0 deletions docker/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use official Java image as the base image
FROM eclipse-temurin:21

# Set the working directory
WORKDIR /app

# apache
RUN apt-get update && \
apt-get install -y apache2


# Run the web server
ENTRYPOINT ["apache2ctl", "-D", "FOREGROUND"]

4 changes: 4 additions & 0 deletions rml_mappings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* 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"

## Running
You can either run the docker command documented in [../docker/README.md](../docker/README.md), which as a side-effect will run the mappings.
Or you can run it using java:

* Install java jdk version 17 or newer
* *Use java jdk version 17 when building rml-mapper*. To check the java version used run `mvn -version`.
If the version 17 is not used, install this and update the `JAVA_HOME` system variable to point to version 17.
Expand Down
106 changes: 0 additions & 106 deletions www/RunGuide.md

This file was deleted.

47 changes: 47 additions & 0 deletions xslt/PV001A_Origo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 38 additions & 5 deletions www/dexpisvg.xslt → xslt/dexpisvg.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,42 @@
<xsl:variable name="refZ"
select="$PositionNode/Reference/@Z" />

<!-- Calculate the angle using the custom extension function -->
<xsl:variable name="angle"
select="math:CalculateAngle($axisX, $axisY, $axisZ, $refX, $refY, $refZ)" />
<!-- Calculate the angle using the custom extension function TODO: Find out if can be removed -->
<!-- <xsl:variable name="angle"-->
<!-- select="math:CalculateAngle($axisX, $axisY, $axisZ, $refX, $refY, $refZ)" />-->

<!-- Calculate the angle using some assumptions, probably wrong
See Proteus "P&ID Profile file specification 3.3.3, page 14 -->
<xsl:variable name="refangle">
<xsl:choose>
<xsl:when test="$refX = 0 and $refY = 1 and $refZ = 0">270</xsl:when>
<xsl:when test="$refX = 1 and $refY = 0 and $refZ = 0">0</xsl:when>
<xsl:when test="$refX = -1 and $refY = 0 and $refZ = 0">180</xsl:when>
<xsl:when test="$refX = 0 and $refY = -1 and $refZ = 0">90</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">This combination of reference values is not handled:
X: <xsl:value-of select="$refX" />
Y: <xsl:value-of select="$refY" />
Z: <xsl:value-of select="$refZ" />
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="angle">
<xsl:choose>
<xsl:when test="$axisX = 0 and $axisY= 0 and $axisZ = 1"><xsl:value-of select="$refangle" />
</xsl:when>
<xsl:when test="$axisX = 0 and $axisY= 0 and $axisZ = -1"><xsl:value-of select="- $refangle" />
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">This combination of reference values is not handled:
<xsl:value-of select="$axisX" />
<xsl:value-of select="$axisY" />
<xsl:value-of select="$axisZ" />
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<!-- Output the SVG rotate and translate commands -->
<xsl:attribute
Expand Down Expand Up @@ -280,9 +313,9 @@
select="//ShapeCatalogue/*[@ComponentName=$componentName]/GenericAttributes/GenericAttribute/@Value" />
<xsl:variable
name="path"
select="concat('../../../../NOAKADEXPI/Symbols/Origo/', $shapeValue, '_Origo.svg')" />
select="concat('../../NOAKADEXPI/Symbols/Origo/', $shapeValue, '_Origo.svg')" />
<xsl:if
test="not($path = '../../../../NOAKADEXPI/Symbols/Origo/BORDER_A1_Origo.svg')">
test="not($path = '../../NOAKADEXPI/Symbols/Origo/BORDER_A1_Origo.svg')">
<xsl:if test="$shapeValue">
<a id="{concat('https://assetid.equinor.com/plantx#', $id)}" class="node">
<g>
Expand Down

0 comments on commit 96e3d41

Please sign in to comment.