diff --git a/.github/workflows/pull-request-check.yml b/.github/workflows/pull-request-check.yml
index c4e9fc8c0..fc741019e 100644
--- a/.github/workflows/pull-request-check.yml
+++ b/.github/workflows/pull-request-check.yml
@@ -20,8 +20,8 @@ jobs:
- name: Setup JDK
uses: graalvm/setup-graalvm@v1
with:
- version: '22.3.1'
- java-version: '17'
+ java-version: '17.0.8'
+ distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
@@ -42,8 +42,8 @@ jobs:
# https://github.com/actions/virtual-environments/issues/3420#issuecomment-861342418
uses: al-cheb/configure-pagefile-action@v1.3
with:
- minimum-size: 16GB
- maximum-size: 16GB
+ minimum-size: 32GB
+ maximum-size: 32GB
disk-root: "C:"
- name: Set Swap Space (Linux)
diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml
index a67069bd4..cbb0896a8 100644
--- a/.github/workflows/release-workflow.yml
+++ b/.github/workflows/release-workflow.yml
@@ -66,8 +66,8 @@ jobs:
- name: Setup JDK
uses: graalvm/setup-graalvm@v1
with:
- version: '22.3.1'
- java-version: '17'
+ java-version: '17.0.8'
+ distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
@@ -135,8 +135,8 @@ jobs:
- name: Setup JDK
uses: graalvm/setup-graalvm@v1
with:
- version: '22.3.1'
- java-version: '17'
+ java-version: '17.0.8'
+ distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
@@ -156,8 +156,8 @@ jobs:
# https://github.com/actions/virtual-environments/issues/3420#issuecomment-861342418
uses: al-cheb/configure-pagefile-action@v1.3
with:
- minimum-size: 16GB
- maximum-size: 16GB
+ minimum-size: 32GB
+ maximum-size: 32GB
disk-root: "C:"
- name: Build and run tests
@@ -211,8 +211,8 @@ jobs:
- name: Setup JDK
uses: graalvm/setup-graalvm@v1
with:
- version: '22.3.1'
- java-version: '17'
+ java-version: '17.0.8'
+ distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'false'
@@ -230,7 +230,7 @@ jobs:
- name: Prepare release
run: |
# Create Windows CLI zip
- zip -9 -r samm-cli-windows.zip samm.exe *.dll lib/
+ zip -9 -r samm-cli-windows.zip samm.exe *.dll
# Full release: Maven Central
# The (apparently) only way to retrieve the staging profile id
diff --git a/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/AspectModelLoader.java b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/AspectModelLoader.java
index 9a7d68efd..038a20378 100644
--- a/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/AspectModelLoader.java
+++ b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/AspectModelLoader.java
@@ -22,11 +22,6 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.rdf.model.RDFNode;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.rdf.model.Statement;
-import org.apache.jena.vocabulary.RDF;
import org.eclipse.esmf.aspectmodel.UnsupportedVersionException;
import org.eclipse.esmf.aspectmodel.resolver.AspectModelResolver;
import org.eclipse.esmf.aspectmodel.resolver.FileSystemStrategy;
@@ -43,18 +38,23 @@
import org.eclipse.esmf.metamodel.NamedElement;
import org.eclipse.esmf.metamodel.impl.DefaultModelNamespace;
import org.eclipse.esmf.samm.KnownVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableSet;
-
import io.vavr.control.Try;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement;
+import org.apache.jena.vocabulary.RDF;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Provides functionality to load an Aspect Model from a {@link VersionedModel} and use the correct SAMM resources to
- * instantiate it. To load a regular Aspect Model, use {@link #getElements(VersionedModel)} or {@link #getElementsUnchecked(VersionedModel)}.
+ * instantiate it. To load a regular Aspect Model, use {@link #getElements(VersionedModel)} or
+ * {@link #getElementsUnchecked(VersionedModel)}.
* To load elements from an RDF model that might contain elements from multiple namespaces, use {@link #getNamespaces(VersionedModel)}.
- *
+ *
* Instances of {@code VersionedModel} are gained through an {@link AspectModelResolver}.
*/
public class AspectModelLoader {
@@ -91,6 +91,7 @@ private static void validateNamespaceOfCustomUnits( final SAMM samm, final Model
* collection of {@link ModelNamespace}. Use this method only when you expect the RDF model to contain more than
* one namespace (which is not the case when aspect models contain the usual element definitions with one namespace per file),
* otherwise use {@link #getElements(VersionedModel)}.
+ *
* @param versionedModel The RDF model representation of the Aspect model
* @return the list of namespaces
*/
@@ -111,6 +112,7 @@ public static Try> getNamespaces( final VersionedModel vers
/**
* Creates Java instances for model element classes from the RDF input model
+ *
* @param versionedModel The RDF model representation of the Aspect model
* @return the list of loaded model elements on success
*/
@@ -152,9 +154,10 @@ public static Try> getElements( final VersionedModel versione
/**
* Does the same as {@link #getElements(VersionedModel)} but throws an exception in case of failures.
+ *
* @param versionedModel The RDF model representation of the Aspect model
- * @throws AspectLoadingException when elements can not be loaded
* @return the list of model elements
+ * @throws AspectLoadingException when elements can not be loaded
*/
public static List getElementsUnchecked( final VersionedModel versionedModel ) {
return getElements( versionedModel ).getOrElseThrow( cause -> {
@@ -164,7 +167,9 @@ public static List getElementsUnchecked( final VersionedModel vers
}
/**
- * Convenience method that does the same as {@link #getElements(VersionedModel)} except it will return only the aspects contained in the model.
+ * Convenience method that does the same as {@link #getElements(VersionedModel)} except it will return only the aspects contained in the
+ * model.
+ *
* @param versionedModel The RDF model representation of the Aspect model
* @return the list of model aspects
*/
@@ -177,9 +182,10 @@ public static Try> getAspects( final VersionedModel versionedModel
/**
* Does the same as {@link #getAspects(VersionedModel)} but throws an exception in case of failures.
+ *
* @param versionedModel The RDF model representation of the Aspect model
- * @throws AspectLoadingException when elements can not be loaded
* @return the list of model aspects
+ * @throws AspectLoadingException when elements can not be loaded
*/
public static List getAspectsUnchecked( final VersionedModel versionedModel ) {
return getAspects( versionedModel ).getOrElseThrow( cause -> {
@@ -217,10 +223,11 @@ public static Aspect getSingleAspectUnchecked( final VersionedModel versionedMod
throw new AspectLoadingException( cause );
} );
}
-
+
/**
* Similar to {@link #getSingleAspect(VersionedModel)}, except that a predicate can be provided to select which of potentially
* multiple aspects should be selected
+ *
* @param versionedModel the RDF model reprensentation of the Aspect model
* @param selector the predicate to select an Aspect
* @return the selected Aspect, or a failure if 0 or more than 1 matching Aspects were found
@@ -243,14 +250,16 @@ public static Try getSingleAspect( final VersionedModel versionedModel,
* The closure of the loaded model contains exactly one Aspect
* The Aspect has the same name as the file's basename
*
- * The method is intended for use in tests and comparable use cases, not as a general replacement for loading Aspect Models, since it does not
+ * The method is intended for use in tests and comparable use cases, not as a general replacement for loading Aspect Models, since it
+ * does not
* handle model files with less or more than one Aspect.
+ *
* @param input the model file
* @return the loaded Aspect Context
*/
public static Try getAspectContext( final File input ) {
return AspectModelResolver.loadAndResolveModel( input ).flatMap( versionedModel ->
- getSingleAspect( versionedModel, aspect -> aspect.getName().equals( input.getName() ) )
+ getSingleAspect( versionedModel, aspect -> input.getName().equals( aspect.getName() + ".ttl" ) )
.map( aspect -> new AspectContext( versionedModel, aspect ) ) );
}
}
diff --git a/core/esmf-aspect-model-aas-generator/pom.xml b/core/esmf-aspect-model-aas-generator/pom.xml
index 229e82bf1..ac42d9517 100644
--- a/core/esmf-aspect-model-aas-generator/pom.xml
+++ b/core/esmf-aspect-model-aas-generator/pom.xml
@@ -41,6 +41,7 @@
org.eclipse.esmf
esmf-test-resources
+ test
org.junit.jupiter
diff --git a/core/esmf-aspect-model-document-generators/pom.xml b/core/esmf-aspect-model-document-generators/pom.xml
index 3375eefa2..c9bde8861 100644
--- a/core/esmf-aspect-model-document-generators/pom.xml
+++ b/core/esmf-aspect-model-document-generators/pom.xml
@@ -65,35 +65,13 @@
org.apache.commons
commons-text
-
- guru.nidi
- graphviz-java-min-deps
-
-
- guru.nidi.com.eclipsesource.j2v8
- j2v8_linux_x86_64
-
-
-
-
-
- org.webjars.npm
- viz.js-graphviz-java
-
-
org.apache.xmlgraphics
batik-rasterizer
-
-
- org.graalvm.js
- js
-
-
- org.graalvm.js
- js-scriptengine
+ org.graphper
+ graph-support
com.github.curious-odd-man
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/DocumentGenerationException.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/DocumentGenerationException.java
index e73221b7a..53f93992e 100644
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/DocumentGenerationException.java
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/DocumentGenerationException.java
@@ -19,4 +19,8 @@ public class DocumentGenerationException extends RuntimeException {
public DocumentGenerationException( final String message ) {
super( message );
}
+
+ public DocumentGenerationException( final Throwable cause ) {
+ super( cause );
+ }
}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractDiagram.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractDiagram.java
new file mode 100644
index 000000000..f0df21d26
--- /dev/null
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractDiagram.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
+ *
+ * See the AUTHORS file(s) distributed with this work for additional
+ * information regarding authorship.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+package org.eclipse.esmf.aspectmodel.generator.diagram;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+class AbstractDiagram {
+ private final Box focusBox;
+ private final Set boxes;
+ private final Set edges;
+
+ // Used for the special case where a value element is rendered as a string (as part of a parent's attribute)
+ private String scalarValue = null;
+
+ public AbstractDiagram( final Box focusBox ) {
+ this.focusBox = focusBox;
+ boxes = new HashSet<>();
+ addBox( focusBox );
+ edges = new HashSet<>();
+ }
+
+ static final AbstractDiagram EMPTY = new AbstractDiagram( null );
+
+ public void addBox( final Box box ) {
+ if ( box != null ) {
+ boxes.add( box );
+ }
+ }
+
+ public void addEdge( final Edge edge ) {
+ edges.add( edge );
+ }
+
+ public void addBoxes( final Collection boxes ) {
+ for ( final Box box : boxes ) {
+ addBox( box );
+ }
+ }
+
+ public void addEdges( final Collection edges ) {
+ this.edges.addAll( edges );
+ }
+
+ public void add( final AbstractDiagram abstractDiagram ) {
+ addBoxes( abstractDiagram.getBoxes() );
+ addEdges( abstractDiagram.getEdges() );
+ }
+
+ public void setScalarValue( final String value ) {
+ scalarValue = value;
+ }
+
+ public Set getBoxes() {
+ return boxes;
+ }
+
+ public Set getEdges() {
+ return edges;
+ }
+
+ public Box getFocusBox() {
+ return focusBox;
+ }
+
+ public String getScalarValue() {
+ return scalarValue;
+ }
+}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGenerator.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGenerator.java
index 70c2cbe61..407ccd3b0 100644
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGenerator.java
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGenerator.java
@@ -13,164 +13,76 @@
package org.eclipse.esmf.aspectmodel.generator.diagram;
+import static org.graphper.api.Html.table;
+import static org.graphper.api.Html.td;
+
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.GraphicsEnvironment;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.UncheckedIOException;
+import java.io.StringReader;
import java.nio.charset.StandardCharsets;
+import java.util.AbstractMap;
import java.util.Base64;
-import java.util.EnumMap;
-import java.util.List;
+import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.Scanner;
+import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
-import java.util.stream.StreamSupport;
+import java.util.stream.Collectors;
-import org.eclipse.esmf.aspectmodel.UnsupportedVersionException;
+import org.eclipse.esmf.aspectmodel.generator.DocumentGenerationException;
import org.eclipse.esmf.aspectmodel.generator.LanguageCollector;
-import org.eclipse.esmf.aspectmodel.resolver.services.MetaModelUrls;
-import org.eclipse.esmf.aspectmodel.resolver.services.TurtleLoader;
-import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel;
-import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
-import org.eclipse.esmf.aspectmodel.vocabulary.SAMM;
-import org.eclipse.esmf.samm.KnownVersion;
-
-import com.google.common.collect.ImmutableList;
-import guru.nidi.graphviz.engine.Graphviz;
-import guru.nidi.graphviz.model.MutableGraph;
-import guru.nidi.graphviz.parse.Parser;
-import org.apache.commons.text.StringEscapeUtils;
-import org.apache.commons.text.WordUtils;
-import org.apache.jena.query.ARQ;
-import org.apache.jena.query.Query;
-import org.apache.jena.query.QueryFactory;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.rdf.model.ModelFactory;
-import org.apache.jena.rdf.model.Property;
-import org.apache.jena.rdf.model.RDFNode;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.rdf.model.ResourceFactory;
-import org.apache.jena.rdf.model.Statement;
-import org.apache.jena.vocabulary.RDF;
-
+import org.eclipse.esmf.metamodel.AspectContext;
+
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.image.PNGTranscoder;
+import org.apache.commons.io.IOUtils;
+import org.graphper.api.Graphviz;
+import org.graphper.api.Html;
+import org.graphper.api.Line;
+import org.graphper.api.Node;
+import org.graphper.api.attributes.Color;
+import org.graphper.api.attributes.Labeljust;
+import org.graphper.api.attributes.NodeShapeEnum;
+import org.graphper.draw.ExecuteException;
+
+/**
+ * Generate SVG and PNG diagrams from Aspect Models
+ */
public class AspectModelDiagramGenerator {
public enum Format {
PNG,
- SVG,
- DOT;
+ SVG;
public String getArtifactFilename( final String aspectName, final Locale language ) {
return String.format( "%s_%s.%s", aspectName, language.toLanguageTag(), toString().toLowerCase() );
}
}
- private final Map> aspectToBoxmodelQueryFiles = new EnumMap<>( KnownVersion.class );
-
private static final String FONT_NAME = "Roboto Condensed";
private static final String FONT_FILE = "diagram/RobotoCondensed-Regular.ttf";
- static final String GET_ELEMENT_NAME_FUNC = "urn:samm:org.eclipse.esmf.samm:function:2.0.0#getElementName";
- static final String GET_NAMESPACE_FUNC = "urn:samm:org.eclipse.esmf.samm:function:2.0.0#getNamespace";
-
- private final Query boxmodelToDotQuery;
- private final BoxModel boxModelNamespace;
-
- protected final Model model;
- final KnownVersion metaModelVersion;
-
- private final SparqlExecutor sparqlExecutor;
-
- public AspectModelDiagramGenerator( final VersionedModel versionedModel ) {
- final ImmutableList queryFilesForAllMetaModelVersions = ImmutableList.of(
- "aspect",
- "characteristic",
- "collection",
- "constraint",
- "entity",
- "enumeration",
- "metamodelnode",
- "operation",
- "property",
- "unit",
- "aspect-operation-edges",
- "aspect-property-edges",
- "characteristic-characteristic-edges",
- "characteristic-entity-edges",
- "characteristic-metamodelnode-edges",
- "operation-property-edges",
- "property-characteristic-edges",
- "enumeration-entityinstance",
- "entityinstance",
- "quantifiable-unit-edges",
- "either",
- "either-left-characteristic-edges",
- "either-right-characteristic-edges",
- "structuredvalue",
- "structuredvalue-property-edges",
- "entityinstance-nestedentityinstance-edges",
- "entityinstance-entity-edges",
- "collection-elementcharacteristic-edges",
- "characteristic-constraint-edges"
- );
-
- final ImmutableList queryFilesForMetaModelVersionsAsOf2_0_0 = ImmutableList.of(
- "abstractentity",
- "entity-abstractentity-edges",
- "abstractproperty",
- "entity-abstractproperty-edges"
- );
-
- aspectToBoxmodelQueryFiles.put( KnownVersion.SAMM_1_0_0,
- ImmutableList. builder().addAll( queryFilesForAllMetaModelVersions )
- .build() );
-
- aspectToBoxmodelQueryFiles.put( KnownVersion.SAMM_2_0_0,
- ImmutableList. builder().addAll( queryFilesForAllMetaModelVersions )
- .addAll( queryFilesForMetaModelVersionsAsOf2_0_0 )
- .build() );
+ private final AspectContext aspectContext;
- aspectToBoxmodelQueryFiles.put( KnownVersion.SAMM_2_1_0,
- ImmutableList. builder().addAll( queryFilesForAllMetaModelVersions )
- .addAll( queryFilesForMetaModelVersionsAsOf2_0_0 )
- .build() );
-
- ARQ.init();
- model = versionedModel.getModel();
- metaModelVersion = KnownVersion.fromVersionString( versionedModel.getMetaModelVersion().toString() )
- .orElseThrow( () -> new UnsupportedVersionException( versionedModel.getMetaModelVersion() ) );
- boxmodelToDotQuery = QueryFactory.create( getInputStreamAsString( "boxmodel2dot.sparql" ) );
- boxModelNamespace = new BoxModel( metaModelVersion );
-
- sparqlExecutor = new SparqlExecutor()
- .useCustomFunction( GET_ELEMENT_NAME_FUNC, new GetElementNameFunctionFactory( model ) )
- .useCustomFunction( GET_NAMESPACE_FUNC, new GetNamespaceFunctionFactory( model ) )
- ;
+ public AspectModelDiagramGenerator( final AspectContext aspectContext ) {
+ this.aspectContext = aspectContext;
}
InputStream getInputStream( final String resource ) {
return getClass().getClassLoader().getResourceAsStream( resource );
}
- String getInputStreamAsString( final String resource ) {
- try ( final InputStream resourceStream = getInputStream(
- "diagram/" + metaModelVersion.toString().toLowerCase() + "/" + resource );
- final Scanner scanner = new Scanner( resourceStream, StandardCharsets.UTF_8.name() ) ) {
- return scanner.useDelimiter( "\\A" ).next();
- } catch ( final IOException ioException ) {
- throw new UncheckedIOException( ioException );
- }
- }
-
- @SuppressWarnings( "squid:S1166" )
- private void generatePng( final String dotInput, final OutputStream output ) throws IOException {
+ private void generatePng( final String svgInput, final OutputStream output ) {
// To make the font available during PNG generation, it needs to be registered
// in Java Runtime's graphics environment
try {
@@ -178,13 +90,21 @@ private void generatePng( final String dotInput, final OutputStream output ) thr
final Font f = Font.createFont( Font.TRUETYPE_FONT, tmpFontFile );
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont( f );
- } catch ( final FontFormatException e ) {
+
+ final String input = svgInput.replaceAll(
+ "", "" );
+
+ final TranscoderInput inputSvgImage = new TranscoderInput( new StringReader( input ) );
+ final TranscoderOutput outputPngImage = new TranscoderOutput( output );
+ final PNGTranscoder pngTranscoder = new PNGTranscoder();
+ pngTranscoder.transcode( inputSvgImage, outputPngImage );
+ output.flush();
+ output.close();
+ } catch ( final FontFormatException exception ) {
// Will only happen if the loaded .ttf file is invalid
+ } catch ( final IOException | TranscoderException exception ) {
+ throw new DocumentGenerationException( exception );
}
-
- final MutableGraph g = new Parser().read( dotInput );
- final Graphviz graphviz = Graphviz.fromGraph( g );
- graphviz.render( guru.nidi.graphviz.engine.Format.PNG ).toOutputStream( output );
}
private File generateTmpFontFile() throws IOException {
@@ -209,14 +129,18 @@ private String base64EncodeInputStream( final InputStream in ) throws IOExceptio
}
}
- private void generateSvg( final String dotInput, final OutputStream output ) throws IOException {
- final MutableGraph g = new Parser().read( dotInput );
- final Graphviz graphviz = Graphviz.fromGraph( g );
+ public void generateSvg( final Locale language, final OutputStream out )
+ throws IOException {
+ final DiagramVisitor diagramVisitor = new DiagramVisitor( language );
+ final AbstractDiagram diagram = aspectContext.aspect().accept( diagramVisitor, Optional.empty() );
+ final Graphviz graphviz = render( diagram );
+
+ try ( final InputStream fontStream = getInputStream( FONT_FILE ) ) {
+ final String svgDocument = new String( graphviz.toSvgStr().getBytes( System.getProperty( "file.encoding" ) ),
+ StandardCharsets.UTF_8 )
+ .replace( "", "" )
+ .replace( "", "" );
- // Render SVG
- try ( final ByteArrayOutputStream svgOutput = new ByteArrayOutputStream();
- final InputStream fontStream = getInputStream( FONT_FILE ) ) {
- graphviz.render( guru.nidi.graphviz.engine.Format.SVG ).toOutputStream( svgOutput );
// To make the font available in the generated SVG, it needs to be Base64-encoded
// and embedded in the file.
final String fontInBase64 = base64EncodeInputStream( fontStream );
@@ -227,83 +151,34 @@ private void generateSvg( final String dotInput, final OutputStream output ) thr
+ "\");\n"
+ "}\n"
+ "";
- final String result = svgOutput.toString( StandardCharsets.UTF_8 )
+ final String result = svgDocument
.replaceFirst( ">", ">" + css );
- output.write( result.getBytes( StandardCharsets.UTF_8 ) );
+ out.write( result.getBytes( StandardCharsets.UTF_8 ) );
+ } catch ( final ExecuteException exception ) {
+ throw new DocumentGenerationException( exception );
}
}
- private void breakLongLinesAndEscapeTexts( final Model model ) {
- final Property text = boxModelNamespace.text();
- final Iterable statementIterable = () -> model.listStatements( null, text, (RDFNode) null );
- StreamSupport.stream( statementIterable.spliterator(), false ).toList()
- .forEach( oldStatement -> {
- final String newValue = WordUtils.wrap( oldStatement.getLiteral().getString(), 60, "\\l ", false );
- final String escapedValue = StringEscapeUtils.escapeHtml4( newValue );
- final Statement newStatement = ResourceFactory.createStatement( oldStatement.getSubject(), oldStatement.getPredicate(),
- ResourceFactory.createPlainLiteral( escapedValue ) );
- model.remove( oldStatement );
- model.add( newStatement );
- } );
- }
-
- /**
- * Takes a RDF/Turtle input stream of the Aspect Model and creates the corresponding diagram in DOT format
- *
- * @return The corresponding diagram in DOT format
- */
- private String generateDot( final Locale language ) {
- final Model targetModel = ModelFactory.createDefaultModel();
- aspectToBoxmodelQueryFiles.get( metaModelVersion )
- .stream()
- .map( queryName -> getInputStreamAsString( queryName + "2boxmodel.sparql" ) )
- .map( queryString -> queryString
- .replace( "\"en\"", "\"" + language.toLanguageTag() + "\"" ) )
- .map( QueryFactory::create )
- .forEach( query -> sparqlExecutor.executeConstruct( model, query, targetModel ) );
-
- breakLongLinesAndEscapeTexts( targetModel );
-
- targetModel.add( targetModel.createResource(), boxModelNamespace.rootElement(), getAspect() );
- MetaModelUrls.url( "meta-model", metaModelVersion, "prefix-declarations.ttl" )
- .map( TurtleLoader::openUrl )
- .map( TurtleLoader::loadTurtle )
- .ifPresent( tryModel -> tryModel.forEach( targetModel::add ) );
-
- final String queryResult = sparqlExecutor.executeQuery( targetModel, boxmodelToDotQuery, "dotStatement" );
- final String template = getInputStreamAsString( "aspect2dot.mustache" );
- return template.replace( "{{&statements}}", queryResult )
- .replace( "{{&fontname}}", FONT_NAME )
- .replace( "\\\"", "\"" );
- }
-
- private Resource getAspect() {
- final SAMM samm = new SAMM( metaModelVersion );
- return model.listStatements( null, RDF.type, samm.Aspect() ).nextStatement().getSubject();
- }
-
- private String getAspectName() {
- final Resource aspect = getAspect();
- final AspectModelUrn aspectUrn = AspectModelUrn.fromUrn( aspect.getURI() );
- return aspectUrn.getName();
- }
-
/**
* Generates a diagram for the Aspect in the given output format and target language.
*
- * @param outputFormat One of SVG, PNG or DOT
+ * @param outputFormat One of SVG or PNG
* @param language The language for which the diagram should be generated
* @param out The output stream the diagram is written to
- * @throws IOException if a write error occurs
+ * @throws DocumentGenerationException if diagram generation fails
*/
- public void generateDiagram( final Format outputFormat, final Locale language, final OutputStream out )
- throws IOException {
- final String dotResult = generateDot( language );
+ public void generateDiagram( final Format outputFormat, final Locale language, final OutputStream out ) {
+ final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ try {
+ generateSvg( language, buffer );
+ final String svgResult = buffer.toString( StandardCharsets.UTF_8 );
- switch ( outputFormat ) {
- case DOT -> out.write( dotResult.getBytes( StandardCharsets.UTF_8 ) );
- case PNG -> generatePng( dotResult, out );
- case SVG -> generateSvg( dotResult, out );
+ switch ( outputFormat ) {
+ case PNG -> generatePng( svgResult, out );
+ case SVG -> IOUtils.copy( new ByteArrayInputStream( svgResult.getBytes() ), out );
+ }
+ } catch ( final IOException exception ) {
+ throw new DocumentGenerationException( exception );
}
}
@@ -313,15 +188,15 @@ public void generateDiagram( final Format outputFormat, final Locale language, f
* ASPECTNAME_XX.EXT where ASPECTNAME is the samm:name of the Aspect, XX is the language tag
* and EXT is the file extension for the respective output format.
*
- * @param outputFormat One of SVG, PNG or DOT
+ * @param outputFormat One of SVG or PNG
* @param nameMapper The callback function that maps diagram artifact names to OutputStreams
* @throws IOException if a write error occurs
*/
public void generateDiagrams( final Format outputFormat, final Function nameMapper )
throws IOException {
- for ( final Locale language : LanguageCollector.collectUsedLanguages( model ) ) {
+ for ( final Locale language : LanguageCollector.collectUsedLanguages( aspectContext.aspect() ) ) {
try ( final OutputStream outputStream = nameMapper
- .apply( outputFormat.getArtifactFilename( getAspectName(), language ) ) ) {
+ .apply( outputFormat.getArtifactFilename( aspectContext.aspect().getName(), language ) ) ) {
generateDiagram( outputFormat, language, outputStream );
}
}
@@ -340,16 +215,16 @@ public void generateDiagrams( final Format outputFormat, final Function targetFormats, final Locale language,
final Function nameMapper ) throws IOException {
- final String dotResult = generateDot( language );
- final String aspectName = getAspectName();
+ final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ generateSvg( language, buffer );
+ final String svgDocument = buffer.toString( StandardCharsets.UTF_8 );
+ final String aspectName = aspectContext.aspect().getName();
for ( final Format format : targetFormats ) {
- try ( final OutputStream outputStream = nameMapper
- .apply( format.getArtifactFilename( aspectName, language ) ) ) {
+ try ( final OutputStream outputStream = nameMapper.apply( format.getArtifactFilename( aspectName, language ) ) ) {
switch ( format ) {
- case DOT -> outputStream.write( dotResult.getBytes( StandardCharsets.UTF_8 ) );
- case PNG -> generatePng( dotResult, outputStream );
- case SVG -> generateSvg( dotResult, outputStream );
+ case PNG -> generatePng( svgDocument, outputStream );
+ case SVG -> outputStream.write( svgDocument.getBytes( StandardCharsets.UTF_8 ) );
}
}
}
@@ -366,8 +241,51 @@ public void generateDiagrams( final Set targetFormats, final Locale lang
* @throws IOException if a write error occurs
*/
public void generateDiagrams( final Set targetFormats, final Function nameMapper ) throws IOException {
- for ( final Locale language : LanguageCollector.collectUsedLanguages( model ) ) {
+ for ( final Locale language : LanguageCollector.collectUsedLanguages( aspectContext.aspect() ) ) {
generateDiagrams( targetFormats, language, nameMapper );
}
}
+
+ private Graphviz render( final AbstractDiagram diagram ) {
+ final Color bgColor = Color.ofRGB( "#cfdbed" );
+ final String fontName = "Roboto Condensed";
+ final Map nodes = new HashMap<>();
+
+ final Graphviz.GraphvizBuilder graphvizBuilder = Graphviz.digraph()
+ .fontSize( 12f )
+ .tempNode( Node.builder().shape( NodeShapeEnum.PLAIN ).build() );
+
+ final Map boxMap = diagram.getBoxes()
+ .stream()
+ .map( box -> {
+ final Html.Table table = table()
+ .color( Color.BLACK ).bgColor( bgColor ).cellBorder( 0 ).border( 1 ).cellSpacing( 0 ).cellPadding( 4 )
+ .tr( td().text( "«" + box.getPrototype() + "»" ).fontName( fontName ).align( Labeljust.CENTER ) );
+ if ( !box.getTitle().isEmpty() ) {
+ table.tr( td().text( box.getTitle() ).fontName( fontName ).align( Labeljust.CENTER ) );
+ }
+ if ( !box.getEntries().isEmpty() ) {
+ table.tr( td().cellPadding( 1 ).bgColor( Color.BLACK ).height( 1 ) );
+ box.getEntries()
+ .forEach( entry -> table.tr( td().cellPadding( 3 ).text( entry ).fontName( fontName ).align( Labeljust.LEFT ) ) );
+ }
+ final Node node = Node.builder().color( Color.BLACK ).table( table ).build();
+ return new AbstractMap.SimpleEntry<>( box, node );
+ } )
+ .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue ) );
+ boxMap.values().forEach( graphvizBuilder::addNode );
+ diagram.getEdges()
+ .stream()
+ .map( edge -> {
+ final Node from = boxMap.get( edge.from() );
+ final Node to = boxMap.get( edge.to() );
+ return Line.builder( from, to )
+ .label( edge.label() )
+ .fontName( fontName )
+ .fontSize( 12 )
+ .build();
+ } )
+ .forEach( graphvizBuilder::addLine );
+ return graphvizBuilder.build();
+ }
}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Box.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Box.java
new file mode 100644
index 000000000..eb8ce5f07
--- /dev/null
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Box.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
+ *
+ * See the AUTHORS file(s) distributed with this work for additional
+ * information regarding authorship.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+package org.eclipse.esmf.aspectmodel.generator.diagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Box {
+ private String prototype;
+ private final String title;
+ private final List entries = new ArrayList<>();
+
+ public Box( final String prototype, final String title ) {
+ this.prototype = prototype;
+ this.title = title;
+ }
+
+ public void addEntry( final List entry ) {
+ entries.addAll( entry );
+ }
+
+ public void setPrototype( final String prototype ) {
+ this.prototype = prototype;
+ }
+
+ public String getPrototype() {
+ return prototype;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public List getEntries() {
+ return entries;
+ }
+}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/BoxModel.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/BoxModel.java
deleted file mode 100644
index 804012a89..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/BoxModel.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
- *
- * See the AUTHORS file(s) distributed with this work for additional
- * information regarding authorship.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * SPDX-License-Identifier: MPL-2.0
- */
-
-package org.eclipse.esmf.aspectmodel.generator.diagram;
-
-import org.apache.jena.rdf.model.Property;
-import org.apache.jena.rdf.model.Resource;
-
-import org.eclipse.esmf.samm.KnownVersion;
-import org.eclipse.esmf.aspectmodel.vocabulary.SAMM;
-import org.eclipse.esmf.aspectmodel.vocabulary.Namespace;
-
-public final class BoxModel implements Namespace {
- private final KnownVersion metaModelVersion;
- private final SAMM samm;
-
- public BoxModel( final KnownVersion metaModelVersion ) {
- this.metaModelVersion = metaModelVersion;
- samm = new SAMM( metaModelVersion );
- }
-
- @Override
- public String getUri() {
- return samm.getBaseUri() + "meta-model:" + metaModelVersion.toVersionString() + "/boxmodel";
- }
-
- public Resource box() {
- return resource( "Box" );
- }
-
- public Resource edge() {
- return resource( "Edge" );
- }
-
- public Resource entry() {
- return resource( "Entry" );
- }
-
- public Property prototype() {
- return property( "prototype" );
- }
-
- public Property title() {
- return property( "title" );
- }
-
- public Property entries() {
- return property( "entries" );
- }
-
- public Property fillcolor() {
- return property( "fillcolor" );
- }
-
- public Property text() {
- return property( "text" );
- }
-
- public Property from() {
- return property( "from" );
- }
-
- public Property to() {
- return property( "to" );
- }
-
- public Property rootElement() {
- return property( "rootElement" );
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Context.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Context.java
new file mode 100644
index 000000000..53493f1bb
--- /dev/null
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Context.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
+ *
+ * See the AUTHORS file(s) distributed with this work for additional
+ * information regarding authorship.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+package org.eclipse.esmf.aspectmodel.generator.diagram;
+
+record Context(
+ Box parent,
+ String prototype,
+ String edgeLabel
+) {
+ Context( final Box parent ) {
+ this( parent, "", "" );
+ }
+
+ Context( final Box parent, final String prototype ) {
+ this( parent, prototype, "" );
+ }
+}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/DiagramVisitor.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/DiagramVisitor.java
new file mode 100644
index 000000000..0989120b5
--- /dev/null
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/DiagramVisitor.java
@@ -0,0 +1,631 @@
+/*
+ * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
+ *
+ * See the AUTHORS file(s) distributed with this work for additional
+ * information regarding authorship.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+package org.eclipse.esmf.aspectmodel.generator.diagram;
+
+import java.math.BigInteger;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+import org.eclipse.esmf.aspectmodel.vocabulary.SAMM;
+import org.eclipse.esmf.characteristic.Code;
+import org.eclipse.esmf.characteristic.Collection;
+import org.eclipse.esmf.characteristic.Duration;
+import org.eclipse.esmf.characteristic.Either;
+import org.eclipse.esmf.characteristic.Enumeration;
+import org.eclipse.esmf.characteristic.Measurement;
+import org.eclipse.esmf.characteristic.Quantifiable;
+import org.eclipse.esmf.characteristic.Set;
+import org.eclipse.esmf.characteristic.SingleEntity;
+import org.eclipse.esmf.characteristic.SortedSet;
+import org.eclipse.esmf.characteristic.State;
+import org.eclipse.esmf.characteristic.StructuredValue;
+import org.eclipse.esmf.characteristic.TimeSeries;
+import org.eclipse.esmf.characteristic.Trait;
+import org.eclipse.esmf.constraint.EncodingConstraint;
+import org.eclipse.esmf.constraint.FixedPointConstraint;
+import org.eclipse.esmf.constraint.LanguageConstraint;
+import org.eclipse.esmf.constraint.LengthConstraint;
+import org.eclipse.esmf.constraint.RangeConstraint;
+import org.eclipse.esmf.constraint.RegularExpressionConstraint;
+import org.eclipse.esmf.metamodel.AbstractEntity;
+import org.eclipse.esmf.metamodel.Aspect;
+import org.eclipse.esmf.metamodel.Characteristic;
+import org.eclipse.esmf.metamodel.CollectionValue;
+import org.eclipse.esmf.metamodel.ComplexType;
+import org.eclipse.esmf.metamodel.Constraint;
+import org.eclipse.esmf.metamodel.Entity;
+import org.eclipse.esmf.metamodel.EntityInstance;
+import org.eclipse.esmf.metamodel.Event;
+import org.eclipse.esmf.metamodel.ModelElement;
+import org.eclipse.esmf.metamodel.NamedElement;
+import org.eclipse.esmf.metamodel.Operation;
+import org.eclipse.esmf.metamodel.Property;
+import org.eclipse.esmf.metamodel.Scalar;
+import org.eclipse.esmf.metamodel.ScalarValue;
+import org.eclipse.esmf.metamodel.StructureElement;
+import org.eclipse.esmf.metamodel.Unit;
+import org.eclipse.esmf.metamodel.Value;
+import org.eclipse.esmf.metamodel.datatypes.LangString;
+import org.eclipse.esmf.metamodel.impl.BoundDefinition;
+import org.eclipse.esmf.metamodel.visitor.AspectVisitor;
+import org.eclipse.esmf.samm.KnownVersion;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.text.WordUtils;
+import org.apache.jena.vocabulary.RDF;
+import org.apache.jena.vocabulary.XSD;
+
+/**
+ * AspectVisitor that creates an {@link AbstractDiagram} representation for the given Aspect Model.
+ */
+public class DiagramVisitor implements AspectVisitor> {
+ private final Locale locale;
+ private final Map seenElements = new HashMap<>();
+
+ public DiagramVisitor( final Locale locale ) {
+ this.locale = locale;
+ }
+
+ @Override
+ public AbstractDiagram visitBase( final ModelElement modelElement, final Optional context ) {
+ return AbstractDiagram.EMPTY;
+ }
+
+ @Override
+ public AbstractDiagram visitStructureElement( final StructureElement element, final Optional context ) {
+ final AbstractDiagram result = defaultBox( element, context.orElseThrow().prototype() );
+ final Box box = result.getFocusBox();
+ for ( final Property property : element.getProperties() ) {
+ final StringBuilder labelBuilder = new StringBuilder();
+ labelBuilder.append( element instanceof Event ? "parameter" : "property" );
+ if ( property.isOptional() ) {
+ labelBuilder.append( " (optional)" );
+ } else if ( property.isNotInPayload() ) {
+ labelBuilder.append( " (not in payload)" );
+ }
+ if ( !property.getName().equals( property.getPayloadName() ) ) {
+ labelBuilder.append( " (" ).append( property.getPayloadName() ).append( ")" );
+ }
+ result.add( childElementDiagram( box, property, labelBuilder.toString() ) );
+ }
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitAspect( final Aspect aspect, final Optional context ) {
+ if ( seenElements.containsKey( aspect ) ) {
+ return new AbstractDiagram( seenElements.get( aspect ) );
+ }
+
+ final AbstractDiagram result = visitStructureElement( aspect, Optional.of( new Context( null, "Aspect" ) ) );
+ final Box box = result.getFocusBox();
+ aspect.getEvents().stream().map( event -> childElementDiagram( box, event, "event" ) ).forEach( result::add );
+ aspect.getOperations().stream().map( operation -> childElementDiagram( box, operation, "operation" ) ).forEach( result::add );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitEntity( final Entity entity, final Optional context ) {
+ if ( seenElements.containsKey( entity ) ) {
+ return new AbstractDiagram( seenElements.get( entity ) );
+ }
+
+ final AbstractDiagram result = visitStructureElement( entity,
+ context.map( oldContext -> new Context( oldContext.parent(), "Entity" ) ) );
+ final Box box = result.getFocusBox();
+ entity.getExtends().stream().map( superType -> childElementDiagram( box, superType, "extends" ) ).forEach( result::add );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitProperty( final Property property, final Optional context ) {
+ if ( seenElements.containsKey( property ) ) {
+ return new AbstractDiagram( seenElements.get( property ) );
+ }
+
+ final AbstractDiagram result = defaultBox( property, (property.isAbstract() ? "Abstract" : "") + "Property" );
+ final Box box = result.getFocusBox();
+ property.getCharacteristic()
+ .filter( characteristic -> !(characteristic.getAspectModelUrn().isEmpty() && characteristic.getName()
+ .equals( "UnnamedCharacteristic" )) )
+ .map( characteristic ->
+ childElementDiagram( box, characteristic, "characteristic" ) )
+ .ifPresent( result::add );
+ property.getExtends().ifPresent( superProperty -> result.add( childElementDiagram( box, superProperty, "extends" ) ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitCharacteristic( final Characteristic characteristic, final Optional context ) {
+ if ( seenElements.containsKey( characteristic ) ) {
+ return new AbstractDiagram( seenElements.get( characteristic ) );
+ }
+
+ final AbstractDiagram result = defaultBox( characteristic, "Characteristic" );
+ final Box box = result.getFocusBox();
+ characteristic.getDataType().ifPresent( type -> {
+ if ( type.isScalar() ) {
+ final Scalar scalar = type.as( Scalar.class );
+ final String typeName = scalar.getUrn().replace( XSD.NS, "" ).replace( RDF.uri, "" )
+ .replace( new SAMM( KnownVersion.getLatest() ).getNamespace(), "" );
+ result.getFocusBox().addEntry( attribute( "dataType", String.class, () -> typeName ) );
+ } else {
+ result.add( childElementDiagram( box, type.as( ComplexType.class ), "dataType" ) );
+ }
+ } );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitOperation( final Operation operation, final Optional context ) {
+ if ( seenElements.containsKey( operation ) ) {
+ return new AbstractDiagram( seenElements.get( operation ) );
+ }
+
+ final AbstractDiagram result = defaultBox( operation, "Operation" );
+ final Box box = result.getFocusBox();
+
+ for ( final Property property : operation.getInput() ) {
+ result.add( childElementDiagram( box, property, "input" ) );
+ }
+ operation.getOutput().ifPresent( output -> result.add( childElementDiagram( box, output, "output" ) ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitAbstractEntity( final AbstractEntity abstractEntity, final Optional context ) {
+ if ( seenElements.containsKey( abstractEntity ) ) {
+ return new AbstractDiagram( seenElements.get( abstractEntity ) );
+ }
+
+ final AbstractDiagram result =
+ visitStructureElement( abstractEntity, context.map( oldContext -> new Context( oldContext.parent(), "AbstractEntity" ) ) );
+ final Box box = result.getFocusBox();
+ abstractEntity.getExtends().stream().map( superType -> childElementDiagram( box, superType, "extends" ) ).forEach( result::add );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitEvent( final Event event, final Optional context ) {
+ if ( seenElements.containsKey( event ) ) {
+ return new AbstractDiagram( seenElements.get( event ) );
+ }
+ return visitStructureElement( event, context.map( oldContext -> new Context( oldContext.parent(), "Event" ) ) );
+ }
+
+ @Override
+ public AbstractDiagram visitUnit( final Unit unit, final Optional context ) {
+ if ( seenElements.containsKey( unit ) ) {
+ return new AbstractDiagram( seenElements.get( unit ) );
+ }
+
+ final AbstractDiagram result = defaultBox( unit, "Unit" );
+ final Box box = result.getFocusBox();
+ unit.getSymbol().ifPresent( symbol -> box.addEntry( attribute( "symbol", String.class, () -> symbol ) ) );
+ unit.getReferenceUnit().ifPresent( referenceUnit ->
+ box.addEntry( attribute( "referenceUnit", String.class, () -> referenceUnit ) ) );
+ unit.getCode().ifPresent( code -> box.addEntry( attribute( "code", String.class, () -> code ) ) );
+ unit.getConversionFactor().ifPresent( conversionFactor ->
+ box.addEntry( attribute( "conversionFactor", String.class, () -> conversionFactor ) ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitTrait( final Trait trait, final Optional context ) {
+ if ( seenElements.containsKey( trait ) ) {
+ return new AbstractDiagram( seenElements.get( trait ) );
+ }
+
+ final AbstractDiagram result = defaultBox( trait, "Trait" );
+ final Box box = result.getFocusBox();
+ result.add( childElementDiagram( box, trait.getBaseCharacteristic(), "baseCharacteristic" ) );
+ for ( final Constraint constraint : trait.getConstraints() ) {
+ result.add( childElementDiagram( box, constraint, "constraint" ) );
+ }
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitLengthConstraint( final LengthConstraint lengthConstraint, final Optional context ) {
+ if ( seenElements.containsKey( lengthConstraint ) ) {
+ return new AbstractDiagram( seenElements.get( lengthConstraint ) );
+ }
+
+ final AbstractDiagram result = defaultBox( lengthConstraint, "LengthConstraint" );
+ final Box box = result.getFocusBox();
+ lengthConstraint.getMinValue().ifPresent( minValue -> box.addEntry( attribute( "minValue", BigInteger.class, () -> minValue ) ) );
+ lengthConstraint.getMinValue().ifPresent( maxValue -> box.addEntry( attribute( "maxValue", BigInteger.class, () -> maxValue ) ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitRangeConstraint( final RangeConstraint rangeConstraint, final Optional context ) {
+ if ( seenElements.containsKey( rangeConstraint ) ) {
+ return new AbstractDiagram( seenElements.get( rangeConstraint ) );
+ }
+
+ final AbstractDiagram result = defaultBox( rangeConstraint, "RangeConstraint" );
+ final Box box = result.getFocusBox();
+ rangeConstraint.getMinValue().ifPresent( minValue -> box.addEntry( attribute( "minValue", ScalarValue.class, () -> minValue ) ) );
+ rangeConstraint.getMaxValue().ifPresent( maxValue -> box.addEntry( attribute( "maxValue", ScalarValue.class, () -> maxValue ) ) );
+ if ( rangeConstraint.getLowerBoundDefinition() == BoundDefinition.AT_LEAST
+ || rangeConstraint.getLowerBoundDefinition() == BoundDefinition.GREATER_THAN ) {
+ box.addEntry( attribute( "lowerBoundDefinition", String.class,
+ () -> rangeConstraint.getLowerBoundDefinition().toString().toLowerCase() ) );
+ }
+ if ( rangeConstraint.getUpperBoundDefinition() == BoundDefinition.AT_MOST
+ || rangeConstraint.getUpperBoundDefinition() == BoundDefinition.LESS_THAN ) {
+ box.addEntry( attribute( "upperBoundDefinition", String.class,
+ () -> rangeConstraint.getUpperBoundDefinition().toString().toLowerCase() ) );
+ }
+
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitFixedPointConstraint( final FixedPointConstraint fixedPointConstraint, final Optional context ) {
+ if ( seenElements.containsKey( fixedPointConstraint ) ) {
+ return new AbstractDiagram( seenElements.get( fixedPointConstraint ) );
+ }
+
+ final AbstractDiagram result = defaultBox( fixedPointConstraint, "FixedPointConstraint" );
+ final Box box = result.getFocusBox();
+ box.addEntry( attribute( "integer", Integer.class, fixedPointConstraint::getInteger ) );
+ box.addEntry( attribute( "scale", Integer.class, fixedPointConstraint::getScale ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitEncodingConstraint( final EncodingConstraint encodingConstraint, final Optional context ) {
+ if ( seenElements.containsKey( encodingConstraint ) ) {
+ return new AbstractDiagram( seenElements.get( encodingConstraint ) );
+ }
+
+ final AbstractDiagram result = defaultBox( encodingConstraint, "EncodingConstraint" );
+ final Box box = result.getFocusBox();
+ box.addEntry( attribute( "charset", Charset.class, encodingConstraint::getValue ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitLanguageConstraint( final LanguageConstraint languageConstraint, final Optional context ) {
+ if ( seenElements.containsKey( languageConstraint ) ) {
+ return new AbstractDiagram( seenElements.get( languageConstraint ) );
+ }
+
+ final AbstractDiagram result = defaultBox( languageConstraint, "LanguageConstraint" );
+ final Box box = result.getFocusBox();
+ box.addEntry( attribute( "charset", String.class, () -> languageConstraint.getLanguageCode().toLanguageTag() ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitRegularExpressionConstraint( final RegularExpressionConstraint regularExpressionConstraint,
+ final Optional context ) {
+ if ( seenElements.containsKey( regularExpressionConstraint ) ) {
+ return new AbstractDiagram( seenElements.get( regularExpressionConstraint ) );
+ }
+
+ final AbstractDiagram result = defaultBox( regularExpressionConstraint, "RegularExpressionConstraint" );
+ final Box box = result.getFocusBox();
+ box.addEntry( attribute( "value", String.class, regularExpressionConstraint::getValue ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitQuantifiable( final Quantifiable quantifiable, final Optional context ) {
+ if ( seenElements.containsKey( quantifiable ) ) {
+ return new AbstractDiagram( seenElements.get( quantifiable ) );
+ }
+
+ final AbstractDiagram result = visitCharacteristic( quantifiable, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "Quantifiable" );
+ quantifiable.getUnit().ifPresent( unit -> result.add( childElementDiagram( box, unit, "unit" ) ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitMeasurement( final Measurement measurement, final Optional context ) {
+ if ( seenElements.containsKey( measurement ) ) {
+ return new AbstractDiagram( seenElements.get( measurement ) );
+ }
+
+ final AbstractDiagram result = visitQuantifiable( measurement, context );
+ result.getFocusBox().setPrototype( "Measurement" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitCode( final Code code, final Optional context ) {
+ if ( seenElements.containsKey( code ) ) {
+ return new AbstractDiagram( seenElements.get( code ) );
+ }
+
+ final AbstractDiagram result = visitCharacteristic( (Characteristic) code, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "Code" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitCollection( final Collection collection, final Optional context ) {
+ if ( seenElements.containsKey( collection ) ) {
+ return new AbstractDiagram( seenElements.get( collection ) );
+ }
+
+ final AbstractDiagram result;
+ if ( collection.getElementCharacteristic().isPresent() ) {
+ // If the collection has an elementCharacteristic, don't use visitCharacteristic to prevent additional dataType edge
+ result = defaultBox( collection, "Collection" );
+ } else {
+ result = visitCharacteristic( (Characteristic) collection, context );
+ result.getFocusBox().setPrototype( "Collection" );
+ }
+
+ final Box box = result.getFocusBox();
+ collection.getElementCharacteristic().ifPresent( elementCharacteristic ->
+ result.add( childElementDiagram( box, elementCharacteristic, "elementCharacteristic" ) ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitList( final org.eclipse.esmf.characteristic.List list, final Optional context ) {
+ if ( seenElements.containsKey( list ) ) {
+ return new AbstractDiagram( seenElements.get( list ) );
+ }
+
+ final AbstractDiagram result = visitCollection( list, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "List" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitSet( final Set set, final Optional context ) {
+ if ( seenElements.containsKey( set ) ) {
+ return new AbstractDiagram( seenElements.get( set ) );
+ }
+
+ final AbstractDiagram result = visitCollection( set, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "Set" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitSortedSet( final SortedSet sortedSet, final Optional context ) {
+ if ( seenElements.containsKey( sortedSet ) ) {
+ return new AbstractDiagram( seenElements.get( sortedSet ) );
+ }
+
+ final AbstractDiagram result = visitCollection( sortedSet, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "SortedSet" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitDuration( final Duration duration, final Optional context ) {
+ if ( seenElements.containsKey( duration ) ) {
+ return new AbstractDiagram( seenElements.get( duration ) );
+ }
+
+ final AbstractDiagram result = visitQuantifiable( duration, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "Duration" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitEnumeration( final Enumeration enumeration, final Optional context ) {
+ if ( seenElements.containsKey( enumeration ) ) {
+ return new AbstractDiagram( seenElements.get( enumeration ) );
+ }
+
+ final AbstractDiagram result = visitCharacteristic( enumeration, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "Enumeration" );
+ final AbstractDiagram collectionDiagram = processValuesCollection( box, enumeration.getValues(), "value" );
+ if ( collectionDiagram.getScalarValue() == null ) {
+ result.add( collectionDiagram );
+ } else {
+ box.addEntry( attribute( "values", String.class, () -> String.join( ", ", collectionDiagram.getScalarValue() ) ) );
+ }
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitEither( final Either either, final Optional context ) {
+ final AbstractDiagram result = defaultBox( either, "Either" );
+ final Box box = result.getFocusBox();
+ result.add( childElementDiagram( box, either.getLeft(), "left" ) );
+ result.add( childElementDiagram( box, either.getRight(), "right" ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitSingleEntity( final SingleEntity singleEntity, final Optional context ) {
+ if ( seenElements.containsKey( singleEntity ) ) {
+ return new AbstractDiagram( seenElements.get( singleEntity ) );
+ }
+
+ final AbstractDiagram result = visitCharacteristic( (Characteristic) singleEntity, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "SingleEntity" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitState( final State state, final Optional context ) {
+ final AbstractDiagram result = visitEnumeration( state, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "State" );
+ final AbstractDiagram valueDiagram = state.getDefaultValue().accept( this, Optional.of( new Context( box ) ) );
+ result.add( valueDiagram );
+ if ( valueDiagram.getScalarValue() != null ) {
+ box.addEntry( attribute( "defaultValue", String.class, valueDiagram::getScalarValue ) );
+ }
+ if ( valueDiagram.getFocusBox() != null ) {
+ result.addEdge( new Edge( box, valueDiagram.getFocusBox(), "defaultValue" ) );
+ }
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitStructuredValue( final StructuredValue structuredValue, final Optional context ) {
+ final AbstractDiagram result = visitCharacteristic( (Characteristic) structuredValue, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "StructuredValue" );
+ int index = 1;
+ for ( final Object element : structuredValue.getElements() ) {
+ if ( element instanceof final Property property ) {
+ result.add( childElementDiagram( box, property, "element (%d)".formatted( index ) ) );
+ index++;
+ }
+ }
+
+ box.addEntry( attribute( "deconstructionRule", String.class, structuredValue::getDeconstructionRule ) );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitTimeSeries( final TimeSeries timeSeries, final Optional context ) {
+ final AbstractDiagram result = visitSortedSet( timeSeries, context );
+ final Box box = result.getFocusBox();
+ box.setPrototype( "TimeSeries" );
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitScalarValue( final ScalarValue value, final Optional context ) {
+ final AbstractDiagram result = new AbstractDiagram( null );
+ if ( value.getValue() instanceof final LangString langString ) {
+ result.setScalarValue( "\"%s\"@%s".formatted( langString.getValue(), langString.getLanguageTag() ) );
+ } else {
+ result.setScalarValue( value.getValue().toString() );
+ }
+ return result;
+ }
+
+ @Override
+ public AbstractDiagram visitCollectionValue( final CollectionValue collection, final Optional context ) {
+ return context.map( parentContext -> processValuesCollection( parentContext.parent(), collection.getValues(),
+ Optional.ofNullable( parentContext.edgeLabel() ).orElse( "value" ) ) ).orElse( AbstractDiagram.EMPTY );
+ }
+
+ @Override
+ public AbstractDiagram visitEntityInstance( final EntityInstance instance, final Optional context ) {
+ if ( seenElements.containsKey( instance ) ) {
+ return new AbstractDiagram( seenElements.get( instance ) );
+ }
+
+ final AbstractDiagram result = defaultBox( instance, instance.getEntityType().getName() );
+ final Box box = result.getFocusBox();
+ result.add( childElementDiagram( box, instance.getEntityType(), "type" ) );
+ for ( final Map.Entry assertion : instance.getAssertions().entrySet() ) {
+ final Property property = assertion.getKey();
+ final String propertyName = property.getName()
+ + (property.getPayloadName().equals( property.getName() ) ? "" : " (%s)".formatted( property.getPayloadName() ));
+ final AbstractDiagram valueDiagram = assertion.getValue().accept( this, Optional.of( new Context( box, "", propertyName ) ) );
+ if ( valueDiagram.getScalarValue() == null ) {
+ // If the value's diagram representation's scalar value is not set, the value is itself a box
+ result.add( valueDiagram );
+ // If the value is a collection, it doesn't have a focus box
+ if ( valueDiagram.getFocusBox() != null ) {
+ result.addEdge( new Edge( box, valueDiagram.getFocusBox(), propertyName ) );
+ }
+ } else {
+ // If the value's diagram representation's scalar value is set, use it for an attribute entry in the entity instance's box
+ box.addEntry( attribute( propertyName, String.class, valueDiagram::getScalarValue ) );
+ }
+ }
+
+ return result;
+ }
+
+ private > AbstractDiagram processValuesCollection( final Box parentBox, final T collection,
+ final String edgeLabel ) {
+ final AbstractDiagram result = new AbstractDiagram( null );
+ boolean hasScalarValues = false;
+ final List scalarValues = new ArrayList<>();
+ for ( final Value value : collection ) {
+ final AbstractDiagram valueDiagram = value.accept( this, Optional.of( new Context( parentBox ) ) );
+ if ( valueDiagram.getScalarValue() == null ) {
+ result.add( valueDiagram );
+ result.addEdge( new Edge( parentBox, valueDiagram.getFocusBox(), edgeLabel ) );
+ } else {
+ hasScalarValues = true;
+ scalarValues.add( valueDiagram.getScalarValue() );
+ }
+ }
+ if ( hasScalarValues ) {
+ result.setScalarValue( String.join( ", ", scalarValues ) );
+ }
+ return result;
+ }
+
+ private AbstractDiagram childElementDiagram( final Box parent, final ModelElement child, final String edgeLabel ) {
+ final Optional childElementContext = Optional.of( new Context( parent ) );
+ final AbstractDiagram result = child.accept( this, childElementContext );
+ result.addEdge( new Edge( parent, result.getFocusBox(), edgeLabel ) );
+ return result;
+ }
+
+ private AbstractDiagram defaultBox( final NamedElement element, final String prototype ) {
+ final Box box = new Box( prototype, element.getAspectModelUrn().isPresent() ? element.getName() : "" );
+ final ImmutableList.Builder standardAttributes = ImmutableList.builder();
+ element.getPreferredNames().stream()
+ .filter( preferredName -> preferredName.getLanguageTag().equals( locale ) )
+ .findFirst()
+ .map( LangString::getValue )
+ .ifPresent( preferredName ->
+ standardAttributes.addAll( attribute( "preferredName", String.class, () -> preferredName ) ) );
+ element.getDescriptions().stream()
+ .filter( description -> description.getLanguageTag().equals( locale ) )
+ .findFirst()
+ .map( LangString::getValue )
+ .ifPresent( description ->
+ standardAttributes.addAll( attribute( "description", String.class, () -> description ) ) );
+ if ( !element.getSee().isEmpty() ) {
+ standardAttributes.addAll( attribute( "see", String.class, () -> String.join( ", ", element.getSee() ) ) );
+ }
+ box.addEntry( standardAttributes.build() );
+ seenElements.put( element, box );
+ return new AbstractDiagram( box );
+ }
+
+ private List attribute( final String attributeName, final Class type, final Supplier attribute ) {
+ final String value;
+ if ( type.equals( ScalarValue.class ) ) {
+ value = ((ScalarValue) attribute.get()).getValue().toString();
+ } else {
+ value = attribute.get().toString();
+ }
+
+ final String entry = "%s: %s".formatted( attributeName, value );
+ final String[] lines = WordUtils.wrap( entry, 60 ).split( "\n" );
+ final ImmutableList.Builder builder = ImmutableList.builder();
+ for ( int i = 0; i < lines.length; i++ ) {
+ builder.add( i > 0 ? " " + lines[i] : lines[i] );
+ }
+ return builder.build();
+ }
+}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Edge.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Edge.java
new file mode 100644
index 000000000..efd7bf05f
--- /dev/null
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/Edge.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
+ *
+ * See the AUTHORS file(s) distributed with this work for additional
+ * information regarding authorship.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+package org.eclipse.esmf.aspectmodel.generator.diagram;
+
+record Edge(
+ Box from,
+ Box to,
+ String label
+) {
+ Edge( final Box from, final Box to, final String label ) {
+ this.from = from;
+ this.to = to;
+ this.label = label;
+ }
+}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/FontMeasurement.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/FontMeasurement.java
new file mode 100644
index 000000000..c2ac03ba2
--- /dev/null
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/FontMeasurement.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
+ *
+ * See the AUTHORS file(s) distributed with this work for additional
+ * information regarding authorship.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+package org.eclipse.esmf.aspectmodel.generator.diagram;
+
+import java.awt.Font;
+import java.awt.font.FontRenderContext;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.apache_gs.commons.lang3.StringUtils;
+import org.graphper.def.FlatPoint;
+import org.graphper.layout.MeasureText;
+
+public class FontMeasurement implements MeasureText {
+ @Override
+ public int order() {
+ return -1;
+ }
+
+ @Override
+ public boolean envSupport() {
+ return true;
+ }
+
+ @Override
+ public FlatPoint measure( final String text, final String fontName, final double fontSize ) {
+ if ( StringUtils.isEmpty( text ) || fontSize <= 0 ) {
+ return new FlatPoint( 0, 0 );
+ }
+
+ final Font font = new Font( fontName, Font.PLAIN, (int) fontSize );
+ final AffineTransform affineTransform = font.getTransform();
+ final FontRenderContext fontRenderContext = new FontRenderContext( affineTransform, true, true );
+ final Rectangle2D stringBounds = font.getStringBounds( text, fontRenderContext );
+ final int width = (int) (stringBounds.getWidth()) + 10;
+ final int height = (int) (stringBounds.getHeight());
+ return new FlatPoint( height, width );
+ }
+}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/GetElementNameFunctionFactory.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/GetElementNameFunctionFactory.java
deleted file mode 100644
index 66a500d65..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/GetElementNameFunctionFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
- *
- * See the AUTHORS file(s) distributed with this work for additional
- * information regarding authorship.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * SPDX-License-Identifier: MPL-2.0
- */
-
-package org.eclipse.esmf.aspectmodel.generator.diagram;
-
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.sparql.function.Function;
-import org.apache.jena.sparql.function.FunctionFactory;
-
-/**
- * {@link FunctionFactory} for the {@link getElementName} SPARQL function.
- */
-public class GetElementNameFunctionFactory implements FunctionFactory {
-
- private getElementName getElementNameFunction;
-
- /**
- * @param context the {@link Model} holding the Aspect model which is being processed by the SPARQL queries using the custom {@link getElementName}
- * function.
- */
- public GetElementNameFunctionFactory( final Model context ) {
- this.getElementNameFunction = new getElementName( context );
- }
-
- @Override
- public Function create( String s ) {
- return getElementNameFunction;
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/GetNamespaceFunctionFactory.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/GetNamespaceFunctionFactory.java
deleted file mode 100644
index 6498420e8..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/GetNamespaceFunctionFactory.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
- *
- * See the AUTHORS file(s) distributed with this work for additional
- * information regarding authorship.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * SPDX-License-Identifier: MPL-2.0
- */
-
-package org.eclipse.esmf.aspectmodel.generator.diagram;
-
-import org.apache.jena.graph.Node;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.sparql.expr.NodeValue;
-import org.apache.jena.sparql.function.Function;
-import org.apache.jena.sparql.function.FunctionBase1;
-import org.apache.jena.sparql.function.FunctionFactory;
-import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
-
-/**
- * {@link FunctionFactory} for the {@link getNamespace} SPARQL function.
- */
-public class GetNamespaceFunctionFactory implements FunctionFactory {
-
- private final getNamespace getNamespace;
-
- /**
- */
- public GetNamespaceFunctionFactory( final Model context ) {
- this.getNamespace = new getNamespace( context.getNsPrefixURI( "" ) );
- }
-
- @Override
- public Function create( String s ) {
- return getNamespace;
- }
-
- /**
- * A custom SPARQL function which provides the namespace of a model element.
- */
- private static class getNamespace extends FunctionBase1 {
-
- private final String defaultNs;
-
- public getNamespace( String defaultNs ) {
- this.defaultNs = defaultNs;
- }
-
- @Override
- public NodeValue exec( NodeValue nodeValue ) {
- final Node node = nodeValue.asNode();
- if ( node.isBlank() || !node.isURI() ) {
- return NodeValue.makeNodeString( defaultNs );
- }
- final AspectModelUrn nodeUrn = AspectModelUrn.fromUrn( node.getURI() );
- return NodeValue.makeString( nodeUrn.getUrnPrefix() );
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/SparqlExecutor.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/SparqlExecutor.java
deleted file mode 100644
index 349963050..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/SparqlExecutor.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
- *
- * See the AUTHORS file(s) distributed with this work for additional
- * information regarding authorship.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * SPDX-License-Identifier: MPL-2.0
- */
-
-package org.eclipse.esmf.aspectmodel.generator.diagram;
-
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-
-import org.apache.jena.query.Query;
-import org.apache.jena.query.QueryExecution;
-import org.apache.jena.query.QueryExecutionFactory;
-import org.apache.jena.query.QuerySolution;
-import org.apache.jena.rdf.model.Literal;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.sparql.function.FunctionFactory;
-import org.apache.jena.sparql.function.FunctionRegistry;
-
-/**
- * Utility class to help execute SPARQL queries, wrapping some tricky implementation details of the library used (Jena).
- */
-public class SparqlExecutor {
-
- private FunctionRegistry customFunctions;
-
- public SparqlExecutor() {
- // by default, use the global function registry (the same for all contexts)
- customFunctions = FunctionRegistry.get();
- }
-
- /**
- * Use a custom function when executing queries, the function will be unique to this executor instance.
- *
- * @param name Name of the function
- * @param functionFactory Function factory
- * @return this to allow fluent registration of more than one function
- */
- public SparqlExecutor useCustomFunction( final String name, final FunctionFactory functionFactory ) {
- ensureContextSpecificFunctionRegistry();
- customFunctions.put( name, functionFactory );
- return this;
- }
-
- // Workaround: current Jena implementation uses a single global function registry for all contexts;
- // so as we want to register a context-specific function, we need also a context-specific function registry
- private void ensureContextSpecificFunctionRegistry() {
- final FunctionRegistry global = FunctionRegistry.get();
- if ( customFunctions == global ) {
- customFunctions = new FunctionRegistry();
- global.keys().forEachRemaining( uri -> customFunctions.put( uri, global.get( uri ) ) );
- }
- }
-
- /**
- * Executes a SPARQL query that is assumed to generate a flat list of literals
- *
- * @param model The model to query against
- * @param query The query
- * @return The string resulting by concatenating the result list in to a multi line string
- */
- @SuppressWarnings( "squid:S1905" )
- public String executeQuery( final Model model, final Query query, final String literalName ) {
- try ( final QueryExecution qexec = QueryExecutionFactory.create( query, model ) ) {
- FunctionRegistry.set( qexec.getContext(), customFunctions );
- return StreamSupport.stream( ((Iterable) (qexec::execSelect)).spliterator(), false )
- .map( solution -> solution.getLiteral( literalName ) )
- .map( Literal::toString )
- .collect( Collectors.joining( "\n" ) );
- }
- }
-
- /**
- * Executes a SPARQL construct query.
- *
- * @param model The model to query against
- * @param query The query
- * @param targetModel The result of the operation
- */
- public void executeConstruct( final Model model, final Query query, final Model targetModel ) {
- try ( final QueryExecution qexec = QueryExecutionFactory.create( query, model ) ) {
- FunctionRegistry.set( qexec.getContext(), customFunctions );
- qexec.execConstruct( targetModel );
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/getElementName.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/getElementName.java
deleted file mode 100644
index 6aee843d8..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/getElementName.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
- *
- * See the AUTHORS file(s) distributed with this work for additional
- * information regarding authorship.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * SPDX-License-Identifier: MPL-2.0
- */
-
-package org.eclipse.esmf.aspectmodel.generator.diagram;
-
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import org.apache.jena.graph.Node;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.rdf.model.RDFNode;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.rdf.model.Statement;
-import org.apache.jena.rdf.model.impl.ModelCom;
-import org.apache.jena.sparql.expr.NodeValue;
-import org.apache.jena.sparql.function.FunctionBase1;
-import org.apache.jena.vocabulary.RDF;
-
-import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
-
-/**
- * A custom SPARQL function which provides the name of an Aspect model element which may be defined as a named node or an anonymous node. In case the element
- * is defined as a named node, the name from the URN of the element is returned. In case the element is defined as an anonymous node, a synthetic name is
- * returned.
- */
-public class getElementName extends FunctionBase1 {
-
- private Model context;
-
- /**
- * @param context the {@link Model} holding the Aspect model which is being processed by the SPARQL queries using the custom {@link getElementName}
- * function.
- */
- public getElementName( final Model context ) {
- super();
- this.context = context;
- }
-
- @Override
- public NodeValue exec( NodeValue nodeValue ) {
- final Node node = nodeValue.asNode();
- if ( node.isBlank() ) {
- final Resource nodeResource = ((ModelCom) context).getNodeAs( node, Resource.class );
- final List nodeProperties = context.listStatements( nodeResource, null, (RDFNode) null ).toList();
- final String nodePropertyValues = nodeProperties.stream().map( Statement::getObject )
- .filter( rdfNode -> !rdfNode.isAnon() )
- .map( RDFNode::toString )
- .collect( Collectors.joining( ":" ) );
- final String randomPart = UUID.nameUUIDFromBytes( nodePropertyValues.getBytes() ).toString()
- .substring( 0, 7 );
- final Node typePropertyValue = context.listStatements( nodeResource, RDF.type, (RDFNode) null ).nextStatement().getObject().asNode();
- final AspectModelUrn typePropertyUrn = AspectModelUrn.fromUrn( typePropertyValue.getURI() );
- final String syntheticElementName = typePropertyUrn.getName() + randomPart;
- return NodeValue.makeString( syntheticElementName );
- }
- final AspectModelUrn nodeUrn = AspectModelUrn.fromUrn( node.getURI() );
- return NodeValue.makeString( nodeUrn.getName() );
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/docu/AspectModelDocumentationGenerator.java b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/docu/AspectModelDocumentationGenerator.java
index 588e4279f..f126f9da4 100644
--- a/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/docu/AspectModelDocumentationGenerator.java
+++ b/core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/docu/AspectModelDocumentationGenerator.java
@@ -241,7 +241,7 @@ private String byteArrayOutputStreamToString( final ByteArrayOutputStream output
}
private String insertAspectModelDiagram( final String html, final Locale language ) throws IOException {
- final AspectModelDiagramGenerator diagramGenerator = new AspectModelDiagramGenerator( context.rdfModel() );
+ final AspectModelDiagramGenerator diagramGenerator = new AspectModelDiagramGenerator( context );
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
diagramGenerator.generateDiagram( AspectModelDiagramGenerator.Format.SVG, language, buffer );
final String encodedImage = "data:image/svg+xml;base64," +
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/META-INF/services/org.graphper.layout.MeasureText b/core/esmf-aspect-model-document-generators/src/main/resources/META-INF/services/org.graphper.layout.MeasureText
new file mode 100644
index 000000000..0ec1e50a0
--- /dev/null
+++ b/core/esmf-aspect-model-document-generators/src/main/resources/META-INF/services/org.graphper.layout.MeasureText
@@ -0,0 +1 @@
+org.eclipse.esmf.aspectmodel.generator.diagram.FontMeasurement
\ No newline at end of file
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-operation-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-operation-edges2boxmodel.sparql
deleted file mode 100644
index bdec54dbb..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-operation-edges2boxmodel.sparql
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix rdf:
-prefix :
-prefix func:
-
-# Generate edges between Aspects and Operations
-construct {
- ?edge a :Edge .
- ?edge :title "operation" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?aspect a samm:Aspect .
- ?aspect samm:name ?aspectName .
- ?operation a samm:Operation .
- ?operation samm:name ?operationName .
- filter( exists { ?aspect samm:operations/rdf:rest*/rdf:first ?operation } )
-
- bind( concat( ?aspectName, "Aspect" ) as ?aspectBoxName )
- bind( iri( concat( func:getNamespace( ?aspect ), ?aspectBoxName ) ) as ?from )
- bind( concat( ?operationName, "Operation" ) as ?operationBoxName )
- bind( iri( concat( func:getNamespace( ?operation ), ?operationBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?aspect ), ?aspectBoxName, "_To_", ?operationBoxName ) ) as ?edge )
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-property-edges2boxmodel.sparql
deleted file mode 100644
index ade6bf3bb..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-property-edges2boxmodel.sparql
+++ /dev/null
@@ -1,139 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-e:
-prefix rdf:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates edges between Aspects or Entites and Properties
-construct {
- ?edge a :Edge .
- ?edge :title ?title .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- # Aspect/Entity -> Property Edges (properties); excludes Entities which are refined
- {
- ?aspectOrEntity samm:refines?/rdf:type ?class .
- filter( ?class in ( samm:Aspect, samm:Entity ) )
- #exclude entities from our shared name-space
- filter ( ! strstarts( str( ?aspectOrEntity ), str ( samm-e: ) ) )
-
- ?aspectOrEntity samm:name ?aspectOrEntityName .
-
- ?property samm:refines?/rdf:type samm:Property .
- ?property samm:name ?propertyName .
- filter( exists { ?aspectOrEntity samm:properties/rdf:rest*/rdf:first/samm:property? ?property } )
- filter( not exists { [] samm:refines ?aspectOrEntity } )
-
- bind( if( ?class = samm:Aspect, "Aspect", "Entity" ) as ?typeName )
- bind( concat( ?aspectOrEntityName, ?typeName ) as ?aspectOrEntityBoxName )
- bind( iri( concat( func:getNamespace( ?aspectOrEntity ), ?aspectOrEntityBoxName ) ) as ?from )
-
- bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?aspectOrEntity ), ?aspectOrEntityBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:optional "true"^^xsd:boolean .
- ?propertyNode samm:payloadName ?payloadName
- bind( concat("property (optional) (", str(?payloadName), ")") as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:optional "true"^^xsd:boolean .
- bind( "property (optional)" as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:notInPayload "true"^^xsd:boolean .
- bind( "property (not in payload)" as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:payloadName ?payloadName
- bind( concat("property (", str(?payloadName), ")") as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- bind( "property" as ?title )
- }
- }
-
- union
-
- # add Properties which are defined in an Entity A which is refined, but are themselves not refined,
- # to the Entity B which refines Entity A
- {
- ?refiningEntity samm:refines/rdf:type samm:Entity .
- ?refiningEntity samm:refines ?refinedEntity .
- ?property samm:refines?/rdf:type samm:Property .
- filter( exists { ?refinedEntity samm:properties/rdf:rest*/rdf:first/samm:property? ?property } )
- filter( not exists { [] samm:refines ?property } )
-
- ?refiningEntity samm:name ?entityName .
- ?property samm:name ?propertyName .
- bind( concat( ?entityName, "Entity" ) as ?entityBoxName )
- bind( iri( concat( func:getNamespace( ?refiningEntity ), ?entityBoxName ) ) as ?from )
-
- bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?refiningEntity ), ?entityBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:optional "true"^^xsd:boolean .
- ?propertyNode samm:payloadName ?payloadName
- bind( concat("property (optional) (", str(?payloadName), ")") as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:optional "true"^^xsd:boolean .
- bind( "property (optional)" as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:notInPayload "true"^^xsd:boolean .
- bind( "property (not in payload)" as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- ?propertyNode samm:property ?property .
- ?propertyNode samm:payloadName ?payloadName
- bind( concat("property (", str(?payloadName), ")") as ?title )
- }
-
- optional {
- ?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
- bind( "property" as ?title )
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect2boxmodel.sparql
deleted file mode 100644
index f09233f08..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect2boxmodel.sparql
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Aspects
-construct {
- ?aspectBox a :Box .
- ?aspectBox :prototype "Aspect" .
- ?aspectBox :title ?aspectName .
- ?aspectBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- )
-} where {
- ?aspect a samm:Aspect .
- ?aspect samm:name ?aspectName .
-
- bind( concat( ?aspectName, "Aspect" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?aspect ), ?boxName ) ) as ?aspectBox )
-
- optional {
- ?aspect samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?aspect samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- #subquery which concatenates all values for the samm:see attributes
- optional {
- {
- select ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) ?aspect
- where {
- select *
- where {
- ?aspect a samm:Aspect .
- ?aspect samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?aspect
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect2dot.mustache b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect2dot.mustache
deleted file mode 100644
index 48bb95449..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect2dot.mustache
+++ /dev/null
@@ -1,23 +0,0 @@
-digraph AspectModel {
- graph [
- overlap=false
- ]
-
- node [
- fontname="{{&fontname}}"
- fontsize=12
- shape="record"
- style="filled"
- gradientangle=0
- fillcolor="#e8eef7:#b7c9e3"
- ]
-
- edge [
- fontname="{{&fontname}}"
- fontsize=10
- len=3
- ]
-
-{{&statements}}
-
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/boxmodel.ttl b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/boxmodel.ttl
deleted file mode 100644
index d0bbe42c5..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/boxmodel.ttl
+++ /dev/null
@@ -1,102 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-@prefix rdf: .
-@prefix rdfs: .
-@prefix xsd: .
-@prefix : .
-
-# This file defines the elements of the intermediary format for generating diagrams,
-# the box model. It includes the following elements:
-#
-# Box
-# +---------------------+ +---------------------+
-# | «prototype» | | |
-# | title | Edge | Box |
-# +---------------------+ | |
-# | title: text +----------- title --------------------->+ |
-# | title: text | | |
-# | (entries) | | |
-# +---------------------+ +---------------------+
-#
-# So, from an Aspect model, a graph such as the following is created (and subsequently processed
-# into a tool-specific diagram representation, in our case Graphviz dot format, by boxmodel2dot.sparql):
-#
-# :AccelerationAspect a :Box ;
-# :entries ( [ a :Entry ;
-# :text "CISS Acceleration Aspect" ;
-# :title "preferredName"
-# ]
-# [ a :Entry ;
-# :title "description" ;
-# :text "The Acceleration Aspect"
-# ]
-# ) ;
-# :prototype "Aspect" ;
-# :title "Acceleration" .
-#
-# :acceleration_xProperty
-# a :Box ;
-# :entries ( [ a :Entry ;
-# :title "preferredName" ;
-# :text "Acceleration X"
-# ]
-# [ a :Entry ;
-# :title "description" ;
-# :text "The x axis"
-# ]
-# ) ;
-# :prototype "Property" ;
-# :title "acceleration_x" .
-#
-# :AccelerationAspect_To_acceleration_xProperty
-# a :Edge ;
-# :from :AccelerationAspect ;
-# :title "property" ;
-# :to :acceleration_xProperty .
-#
-# ... etc.
-
-:Box a rdfs:Class .
-
-:Edge a rdfs:Class .
-
-:Entry a rdfs:Class .
-
-# Boxes have prototypes
-
-:prototype a rdf:Property .
-
-# Boxes, Edges and Entries have titles
-
-:title a rdf:Property .
-
-# Boxes have either a list of entries (rdf:List of Entry, preserves order),
-
-:entries a rdf:Property .
-
-# or alternatively a set of Entrys
-
-:entry a rdf:Property .
-
-# Boxes can specify an overriding color
-
-:fillcolor a rdf:Property .
-
-# Entries have texts
-
-:text a rdf:Property .
-
-# Edges have source (from) and destinations (to)
-
-:from a rdf:Property .
-
-:to a rdf:Property .
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/boxmodel2dot.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/boxmodel2dot.sparql
deleted file mode 100644
index 05909b895..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/boxmodel2dot.sparql
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-
-# Transforms a box model (boxes and edges) into Graphviz/dot statements
-select ?dotStatement
-where {
- # Boxes
- {
- ?box a :Box .
- ?box :title ?title .
-
- optional {
- ?box :prototype ?prototype .
- }
- bind( coalesce( concat( " «", ?prototype, "»\\n" ), "" ) as ?prototypeString )
-
- optional {
- select ?box ( group_concat( ?attribute; separator="" ) as ?attributes )
- where {
- {
- select ?box ?attribute
- where {
- ?box (:entries/rdf:rest*/rdf:first)|(:entry) ?entry .
- ?entry :title ?entryTitle .
- optional {
- ?entry :text ?entryText .
- }
- bind( if( bound( ?entryText ), concat( ?entryTitle, ": ", str( ?entryText ) , "\\l" ) , "" ) as ?attribute )
- }
- }
- }
- group by ?box
- }
-
- optional {
- ?box :fillcolor ?fillcolor .
- }
- bind( coalesce( concat( ", fillcolor=\\\"", ?fillcolor, "\\\"" ), "" ) as ?fillcolorAttribute )
-
- bind( replace( str( ?box ), "[^#]*#(.*)", "$1") as ?boxName )
- bind( replace( coalesce( concat( "|", ?attributes ), "" ), "<", "\\\\<" ) as ?attributes0 )
- bind( replace( ?attributes0, ">", "\\\\>" ) as ?attributes1 )
- bind( replace( ?attributes1, "\\{", "\\\\{" ) as ?attributes2 )
- bind( replace( ?attributes2, "\\}", "\\\\}" ) as ?attributes3 )
- bind( replace( ?attributes3, "\\\"", "\\\\\"" ) as ?attributes4 )
- bind( concat( ?boxName, " [label=\"{", ?prototypeString, ?title, ?attributes4, ?fillcolorAttribute, "}\"]" ) as ?dotStatement )
- }
-
- union
-
- # Edges
- {
- ?edge a :Edge .
- ?edge :title ?title .
- ?edge :from ?from .
- ?edge :to ?to .
-
- bind( replace( str( ?from ), "[^#]*#(.*)", "$1") as ?fromBoxName )
- bind( replace( str( ?to ), "[^#]*#(.*)", "$1") as ?toBoxName )
-
- bind( concat( ?fromBoxName, " -> ", ?toBoxName, " [label=\"", ?title, "\"]" ) as ?dotStatement )
- }
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-characteristic-edges2boxmodel.sparql
deleted file mode 100644
index 423591507..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-characteristic-edges2boxmodel.sparql
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix :
-prefix func:
-
-# Generates edges between Trait and other Characteristics (baseCharacteristic)
-construct {
- ?edge a :Edge .
- ?edge :title "baseCharacteristic" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic samm:name ?characteristicName .
- ?characteristic samm-c:baseCharacteristic ?baseCharacteristic .
- ?baseCharacteristic samm:name ?baseCharacteristicName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?box1Name )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name ) ) as ?from )
-
- bind( concat( ?baseCharacteristicName, "Characteristic" ) as ?box2Name )
- bind( iri( concat( func:getNamespace( ?baseCharacteristic ), ?box2Name ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-constraint-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-constraint-edges2boxmodel.sparql
deleted file mode 100644
index e63930918..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-constraint-edges2boxmodel.sparql
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix samm-e:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates edges between Trait and Constraints (constraint)
-construct {
- ?edge a :Edge .
- ?edge :title "constraint" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic samm-c:constraint ?constraint .
- ?characteristic samm:name ?characteristicName .
-
- bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from )
-
- optional {
- ?constraint samm:name ?givenConstraintName .
- }
-
- # Calculate logical hash for constraint in case it does not have a samm:name
- # The constraint might also be defined as an anonymous node
- {
- select * where {
- ?constraint rdf:type/rdfs:subClassOf* samm:Constraint .
- filter( sameTerm( ?propertySubQueryConstraint, ?constraint ) )
- {
- select ?propertySubQueryConstraint ( group_concat( ?serializedProperty; separator=":" ) as ?constraintPropertyValues )
- where {
- select *
- where {
- ?propertySubQueryConstraint rdf:type/rdfs:subClassOf* samm:Constraint .
- ?propertySubQueryConstraint ?anyProperty ?constraintPropertyValue .
- bind( concat( str( ?anyProperty ), "=", str( ?constraintPropertyValue ) ) as ?serializedProperty )
- }
- order by str( ?serializedProperty )
- }
- group by ?propertySubQueryConstraint
- }
- }
- }
-
- bind( coalesce( concat( ?givenConstraintName, "Constraint" ),
- concat( "Constraint", substr( md5( ?constraintPropertyValues ), 0, 11 ) ) ) as ?constraintBoxName )
-
- bind( iri( concat( func:getNamespace( ?constraint ), ?constraintBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?constraintBoxName ) ) as ?edge )
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-entity-edges2boxmodel.sparql
deleted file mode 100644
index 6293caccb..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-entity-edges2boxmodel.sparql
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-e:
-prefix rdf:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates edges between Characteristic and Entities (dataType)
-construct {
- ?edge a :Edge .
- ?edge :title "dataType" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic samm:dataType ?entity .
- filter( ! strstarts( str( ?entity ), str( xsd: ) )
- && ! strstarts( str( ?entity ), str( rdf: ) )
- && ! strstarts( str( ?entity ), str ( samm-e: ) ) )
- ?characteristic samm:name ?characteristicName .
- ?entity samm:name ?entityName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from )
-
- bind( concat( ?entityName, "Entity" ) as ?entityBoxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?entityBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?entityBoxName ) ) as ?edge )
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-metamodelnode-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-metamodelnode-edges2boxmodel.sparql
deleted file mode 100644
index 35648d7ef..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-metamodelnode-edges2boxmodel.sparql
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix rdf:
-prefix rdfs:
-prefix :
-prefix func:
-
-# Generates edges between Characteristic and Meta Model Properties (dataType)
-construct {
- ?edge a :Edge .
- ?edge :title "dataType" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic samm:dataType ?metaModelElement .
- filter ( ?metaModelElement in ( samm:Property ) )
- ?characteristic samm:name ?characteristicName .
- ?metaModelElement rdfs:label ?metaModelElementName .
-
- bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from )
- bind( concat( ?metaModelElementName, "MetaModelElement" ) as ?metaModelElementBoxName )
- bind( iri( concat( func:getNamespace( ?metaModelElement ), ?metaModelElementBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?metaModelElementBoxName ) ) as ?edge )
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic2boxmodel.sparql
deleted file mode 100644
index 82213b895..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic2boxmodel.sparql
+++ /dev/null
@@ -1,115 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Characteristics that are not Collections, Constraints, Enumeration/State or StructuredValue
-construct {
- ?characteristicBox a :Box .
- ?characteristicBox :prototype "Characteristic" .
- ?characteristicBox :title ?characteristicName .
- ?characteristicBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "dataType" ;
- :text ?dataType
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- )
-} where {
- ?characteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
-
- # Apply only to those Characteristics which are used in the Aspect model,
- # i.e. where a directed link from an Aspect to the Characteristic exists.
- # (<>|!<>) matches any RDF property.
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?characteristic .
- } )
-
- # Don't apply to Constraints
- filter( !exists { ?characteristic samm-c:baseCharacteristic [] } )
- # Don't apply to Enumerations or States
- filter( !exists { ?characteristic a samm-c:Enumeration } && !exists { ?characteristic a samm-c:State } )
- # Don't apply to Collections
- filter( !exists { ?characteristic rdf:type/rdfs:subClassOf* samm-c:Collection } )
- # Don't apply to Either
- filter( !exists { ?characteristic rdf:type/rdfs:subClassOf* samm-c:Either } )
- # Don't apply to StructuredValue
- filter( !exists { ?characteristic rdf:type/rdfs:subClassOf* samm-c:StructuredValue } )
-
- ?characteristic samm:name ?characteristicName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?boxName ) ) as ?characteristicBox )
-
- optional {
- ?characteristic samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?characteristic samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- optional {
- ?characteristic samm:dataType ?dataTypeValue .
- filter( strstarts( str( ?dataTypeValue ), str( xsd: ) )
- || strstarts( str( ?dataTypeValue ), str( rdf: ) )
- || strstarts( str( ?dataTypeValue ), str( samm: ) ) )
- bind( replace( str( ?dataTypeValue ), "[^#]*#(.*)", "$1") as ?dataType )
- }
-
- # Subquery which concatenates all values for the samm:see attributes
- optional {
- {
- select * where {
- ?characteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
- filter ( str( ?subQueryCharacteristic ) = str( ?characteristic ) )
- {
- select ?subQueryCharacteristic ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- select *
- where {
- ?subQueryCharacteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
- ?subQueryCharacteristic samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?subQueryCharacteristic
- }
- }
- }
- }
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection-elementcharacteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection-elementcharacteristic-edges2boxmodel.sparql
deleted file mode 100644
index 3659074ff..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection-elementcharacteristic-edges2boxmodel.sparql
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix :
-prefix func:
-
-# Generates edges between Collections and Element Characteristics
-construct {
- ?edge a :Edge .
- ?edge :title "element Characteristic" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic samm:name ?characteristicName .
- ?characteristic samm-c:elementCharacteristic ?elementCharacteristic .
- ?elementCharacteristic samm:name ?elementCharacteristicName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?box1Name )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name ) ) as ?from )
-
- bind( concat( ?elementCharacteristicName, "Characteristic" ) as ?box2Name )
- bind( iri( concat( func:getNamespace( ?elementCharacteristic ), ?box2Name ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection2boxmodel.sparql
deleted file mode 100644
index 95eb1bc75..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection2boxmodel.sparql
+++ /dev/null
@@ -1,156 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix mmm:
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-prefix func:
-
-# Generates boxes for Collection Characteristics
-construct {
- ?characteristicBox a :Box .
- ?characteristicBox :prototype "Characteristic + Collection" .
- ?characteristicBox :title ?characteristicName .
- ?characteristicBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "dataType" ;
- :text ?dataType
- ]
- [
- a :Entry ;
- :title "ordered" ;
- :text ?ordered
- ]
- [
- a :Entry ;
- :title "allowDuplicates" ;
- :text ?allowDuplicates
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- )
-} where {
- ?characteristic rdf:type/rdfs:subClassOf* samm-c:Collection .
-
- # Apply only to those Characteristics which are used in the Aspect model,
- # i.e. where a directed link from an Aspect to the Characteristic exists.
- # (<>|!<>) matches any RDF property.
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?characteristic .
- } )
-
- ?characteristic samm:name ?characteristicName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?boxName ) ) as ?characteristicBox )
-
- optional {
- ?characteristic samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?characteristic samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- optional {
- ?characteristic samm:dataType ?dataTypeValue .
- filter( strstarts( str( ?dataTypeValue ), str( xsd: ) )
- || strstarts( str( ?dataTypeValue ), str( rdf: ) ) )
- bind( replace( str( ?dataTypeValue ), "[^#]*#(.*)", "$1") as ?dataType )
- }
-
- # Join the characteristic from the result-set for the query below with the characteristic from this main query
- filter( ?characteristicName = ?name )
- # Query which determines the ordered and allowDuplicates attributes
- {
- select distinct ?name ?ordered ?allowDuplicates
- where {
- # Handles the cases with > 1 edges from Characteristic to Collection
- {
- # Select all collection classes
- ?char rdf:type/rdfs:subClassOf* ?collection1 .
- ?collection1 mmm:ordered [] .
-
- # Reselect all collection classes
- ?char rdf:type/rdfs:subClassOf* ?collection2 .
- ?collection2 mmm:ordered ?booleanOrdered .
- bind( str( ?booleanOrdered ) as ?ordered )
- ?collection2 mmm:allowDuplicates ?booleanAllowDuplicates .
- bind( str( ?booleanAllowDuplicates ) as ?allowDuplicates )
-
- # Find only those pairs where left and right are different
- filter( ?collection1 != ?collection2 )
-
- # Filter to get first level in subclass hierarchy. Only the ordered and allowDuplicates attributes from the
- # top level collection class are relevant. E.g. for the SortedSet the attributes from the SortedSet need
- # to be returned and not the attributes from the Collection which is the SortedSet's super class
- filter( not exists { ?collection1 rdfs:subClassOf ?collection2 } )
- ?char samm:name ?name .
- }
-
- union
-
- # Handles the cases with 1 edge from Characteristic to Collection
- {
- ?char rdf:type/mmm:ordered ?booleanOrdered .
- bind( str( ?booleanOrdered ) as ?ordered )
- ?char rdf:type/mmm:allowDuplicates ?booleanAllowDuplicates .
- bind( str( ?booleanAllowDuplicates ) as ?allowDuplicates )
- ?char samm:name ?name .
- }
- }
- }
-
- #subquery which concatenates all values for the samm:see attributes
- optional {
- {
- select * where {
- ?characteristic rdf:type/rdfs:subClassOf* samm-c:Collection .
- filter( str( ?subQueryCharacteristic ) = str( ?characteristic ) )
- {
- select ?subQueryCharacteristic ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- select *
- where {
- ?subQueryCharacteristic rdf:type/rdfs:subClassOf* samm-c:Collection .
- ?subQueryCharacteristic samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?subQueryCharacteristic
- }
- }
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/constraint2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/constraint2boxmodel.sparql
deleted file mode 100644
index 5e09773a6..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/constraint2boxmodel.sparql
+++ /dev/null
@@ -1,244 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Constraints
-construct {
- ?constraintBox a :Box .
- ?constraintBox :prototype "Constraint" .
- ?constraintBox :title ?constraintName .
- ?constraintBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "minValue" ;
- :text ?minValue
- ]
- [
- a :Entry ;
- :title "maxValue" ;
- :text ?maxValue
- ]
- [
- a :Entry ;
- :title "value" ;
- :text ?value
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- [
- a :Entry ;
- :title "lowerBoundDefinition" ;
- :text ?lowerBoundDefinitionValue
- ]
- [
- a :Entry ;
- :title "upperBoundDefinition" ;
- :text ?upperBoundDefinitionValue
- ]
- [
- a :Entry ;
- :title "scale" ;
- :text ?scale
- ]
- [
- a :Entry ;
- :title "integer" ;
- :text ?integer
- ]
- )
-} where {
- ?constraint rdf:type/rdfs:subClassOf* samm:Constraint .
-
- # Apply only to those Constraints which are used in the Aspect model,
- # i.e. where a directed link from an Aspect to the Constraint exists.
- # (<>|!<>) matches any RDF property.
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?constraint .
- } )
-
- optional {
- ?constraint samm:name ?givenConstraintName .
- }
-
- # Calculate logical hash for constraint in case it does not have a samm:name
- # The constraint might also be defined as an anonymous node
- {
- select * where {
- ?constraint rdf:type/rdfs:subClassOf* samm:Constraint .
- filter( sameTerm( ?propertySubQueryConstraint, ?constraint ) )
- {
- select ?propertySubQueryConstraint ( group_concat( ?serializedProperty; separator=":" ) as ?constraintPropertyValues )
- where {
- select *
- where {
- ?propertySubQueryConstraint rdf:type/rdfs:subClassOf* samm:Constraint .
- ?propertySubQueryConstraint ?anyProperty ?constraintPropertyValue .
- bind( concat( str( ?anyProperty ), "=", str( ?constraintPropertyValue ) ) as ?serializedProperty )
- }
- order by str( ?serializedProperty )
- }
- group by ?propertySubQueryConstraint
- }
- }
- }
-
- bind( coalesce( concat( ?givenConstraintName, "Constraint" ),
- concat( "Constraint", substr( md5( ?constraintPropertyValues ), 0, 11 ) ) ) as ?boxName )
-
- ?constraint a ?constraintType .
- bind( coalesce( ?givenConstraintName, strafter( str( ?constraintType ), "#" ) ) as ?constraintName )
-
- bind( iri( concat( func:getNamespace( ?constraint ), ?boxName ) ) as ?constraintBox )
-
- optional {
- ?constraint samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?constraint samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- #subquery which concatenates all values for the samm:see attributes
- optional {
- {
- select * where {
- ?constraint rdf:type/rdfs:subClassOf* samm:Constraint .
- filter( sameTerm( ?seeSubQueryConstraint, ?constraint ) )
- {
- select ?seeSubQueryConstraint ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- select *
- where {
- ?seeSubQueryConstraint rdf:type/rdfs:subClassOf* samm:Constraint .
- ?seeSubQueryConstraint samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?seeSubQueryConstraint
- }
- }
- }
- }
-
- # minValue (RangeConstraint or LengthConstraint)
- optional {
- ?constraint a ?constraintType .
- filter( ?constraintType in ( samm-c:RangeConstraint, samm-c:LengthConstraint ) )
- filter( exists { ?constraint samm-c:minValue [] } )
- ?constraint samm-c:minValue ?numericMinValue .
- bind( str( ?numericMinValue ) as ?minValue )
- }
-
- # maxValue (RangeConstraint or LengthConstraint)
- optional {
- ?constraint a ?constraintType .
- filter( ?constraintType in ( samm-c:RangeConstraint, samm-c:LengthConstraint ) )
- filter( exists { ?constraint samm-c:maxValue [] } )
- ?constraint samm-c:maxValue ?numericMaxValue .
- bind( str( ?numericMaxValue ) as ?maxValue )
- }
-
- # value (EncodingConstraint)
- optional {
- ?constraint a samm-c:EncodingConstraint .
- ?constraint samm:value ?givenValue .
- bind( replace( str( ?givenValue ), "[^#]*#(.*)", "$1" ) as ?value )
- }
-
- # value (RegularExpressionConstraint)
- optional {
- ?constraint a samm-c:RegularExpressionConstraint .
- ?constraint samm:value ?givenValue .
- bind( replace( ?givenValue, "\\\\", "\\\\\\\\" ) as ?value0 )
- bind( replace( ?value0, "\\|", "\\\\|" ) as ?value )
- }
-
- # lowerBoundDefinition (RangeConstraint)
- optional {
- ?constraint a samm-c:RangeConstraint .
- filter( exists { ?constraint samm-c:lowerBoundDefinition [] } )
- ?constraint samm-c:lowerBoundDefinition ?lowerBoundDefinition .
- bind( replace( str( ?lowerBoundDefinition ), "[^#]*#(.*)", "$1" ) as ?lowerBoundDefinitionValue )
- }
-
- # minValue exists without lowerBoundDefinition (RangeConstraint)
- optional {
- ?constraint a samm-c:RangeConstraint .
- filter( exists { ?constraint samm-c:minValue [] } )
- filter( not exists { ?constraint samm-c:lowerBoundDefinition [] } )
- bind( "AT_LEAST" as ?lowerBoundDefinitionValue )
- }
-
- # upperBoundDefinition (RangeConstraint)
- optional {
- ?constraint a samm-c:RangeConstraint .
- filter( exists { ?constraint samm-c:upperBoundDefinition [] } )
- ?constraint samm-c:upperBoundDefinition ?upperBoundDefinition .
- bind( replace( str( ?upperBoundDefinition ), "[^#]*#(.*)", "$1" ) as ?upperBoundDefinitionValue )
- }
-
- # maxValue exists without upperBoundDefinition (RangeConstraint)
- optional {
- ?constraint a samm-c:RangeConstraint .
- filter( exists { ?constraint samm-c:maxValue [] } )
- filter( not exists { ?constraint samm-c:upperBoundDefinition [] } )
- bind( "AT_MOST" as ?upperBoundDefinitionValue )
- }
-
- # no lowerBoundDefinition exists (RangeConstraint)
- optional {
- ?constraint a samm-c:RangeConstraint .
- filter( not exists { ?constraint samm-c:minValue [] } )
- filter( not exists { ?constraint samm-c:lowerBoundDefinition [] } )
- bind( "OPEN" as ?lowerBoundDefinitionValue )
- }
-
- # no upperBoundDefinition exists (RangeConstraint)
- optional {
- ?constraint a samm-c:RangeConstraint .
- filter( not exists { ?constraint samm-c:maxValue [] } )
- filter( not exists { ?constraint samm-c:upperBoundDefinition [] } )
- bind( "OPEN" as ?upperBoundDefinitionValue )
- }
-
- # scale and integer (FixedPoint Constraint)
- optional {
- ?constraint a samm-c:FixedPointConstraint .
- ?constraint samm-c:scale ?scale .
- ?constraint samm-c:integer ?integer .
- }
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either-left-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either-left-characteristic-edges2boxmodel.sparql
deleted file mode 100644
index 005d318ff..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either-left-characteristic-edges2boxmodel.sparql
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix :
-prefix func:
-
-# Generates edges between Either Characteristic and its left type Characteristic
-construct {
- ?edge a :Edge .
- ?edge :title "left" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic rdf:type/rdfs:subClassOf* samm-c:Either .
- ?characteristic samm:name ?characteristicName .
- ?characteristic samm-c:left ?leftTypeCharacteristic .
- ?leftTypeCharacteristic samm:name ?leftTypeCharacteristicName .
-
- bind( concat( ?characteristicName, "Characteristic" ) as ?box1Name )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name ) ) as ?from )
-
- bind( concat( ?leftTypeCharacteristicName, "Characteristic" ) as ?box2Name )
- bind( iri( concat( func:getNamespace( ?leftTypeCharacteristic ), ?box2Name ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either-right-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either-right-characteristic-edges2boxmodel.sparql
deleted file mode 100644
index 2c19fd28d..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either-right-characteristic-edges2boxmodel.sparql
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix :
-prefix func:
-
-# Generates edges between Either Characteristic and its left type Characteristic
-construct {
- ?edge a :Edge .
- ?edge :title "right" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic rdf:type/rdfs:subClassOf* samm-c:Either .
- ?characteristic samm:name ?characteristicName .
- ?characteristic samm-c:right ?rightTypeCharacteristic .
- ?rightTypeCharacteristic samm:name ?rightTypeCharacteristicName .
-
- bind( concat( ?characteristicName, "Characteristic" ) as ?box1Name )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name ) ) as ?from )
-
- bind( concat( ?rightTypeCharacteristicName, "Characteristic" ) as ?box2Name )
- bind( iri( concat( func:getNamespace( ?rightTypeCharacteristic ), ?box2Name ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either2boxmodel.sparql
deleted file mode 100644
index 391e7f56c..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/either2boxmodel.sparql
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Collection Characteristics
-construct {
- ?characteristicBox a :Box .
- ?characteristicBox :prototype "Characteristic + Either" .
- ?characteristicBox :title ?characteristicName .
- ?characteristicBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- )
-} where {
- ?characteristic rdf:type/rdfs:subClassOf* samm-c:Either .
-
- # Apply only to those Characteristics which are used in the Aspect model,
- # i.e. where a directed link from an Aspect to the Characteristic exists.
- # (<>|!<>) matches any RDF property.
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?characteristic .
- } )
-
- ?characteristic samm:name ?characteristicName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?boxName ) ) as ?characteristicBox )
-
- optional {
- ?characteristic samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?characteristic samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- #subquery which concatenates all values for the samm:see attributes
- optional {
- {
- select * where {
- ?characteristic rdf:type/rdfs:subClassOf* samm-c:Either .
- filter( str( ?subQueryCharacteristic ) = str( ?characteristic ) )
- {
- select ?subQueryCharacteristic ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- select *
- where {
- ?subQueryCharacteristic rdf:type/rdfs:subClassOf* samm-c:Either .
- ?subQueryCharacteristic samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?subQueryCharacteristic
- }
- }
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entity2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entity2boxmodel.sparql
deleted file mode 100644
index 99cf7b4e0..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entity2boxmodel.sparql
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-e:
-prefix rdf:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Entities; excludes Entities which are refined
-construct {
- ?entityBox a :Box .
- ?entityBox :prototype "Entity" .
- ?entityBox :title ?entityName .
- ?entityBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- )
-} where {
- ?entity samm:refines?/rdf:type samm:Entity .
- #exclude entities from our shared name-space
- filter ( ! strstarts( str( ?entity ), str ( samm-e: ) ) )
- ?entity samm:name ?entityName .
-
- bind( concat( ?entityName, "Entity" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?entity ), ?boxName ) ) as ?entityBox )
-
- optional {
- ?entity samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?entity samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- optional {
- {
- select ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) ?entity
- where {
- select *
- where {
- ?entity samm:refines?/rdf:type samm:Entity .
- #exclude entities from our shared name-space
- filter ( ! strstarts( str( ?entity ), str ( samm-e: ) ) )
- ?entity samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?entity
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance-entity-edges2boxmodel.sparql
deleted file mode 100644
index 934b31b88..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance-entity-edges2boxmodel.sparql
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix samm-e:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates edges between Entity Instances and Entities
-construct {
- ?edge a :Edge .
- ?edge :title ?title .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?instance a ?entity .
- ?entity a samm:Entity .
-
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?instance .
- } && exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?entity .
- } )
-
- bind( strafter( str( ?entity ), "#" ) as ?entityName )
- bind( concat( ?entityName, "Entity" ) as ?entityBoxName )
-
- bind( strafter( str( ?instance ), "#" ) as ?instanceName )
- bind( concat( ?instanceName, "EntityInstance" ) as ?instanceBoxName )
-
- bind( iri( concat( func:getNamespace( ?instance ), ?instanceBoxName ) ) as ?from )
- bind( iri( concat( func:getNamespace( ?entity ), ?entityBoxName ) ) as ?to )
- bind( iri( concat( func:getNamespace( ?instance ), ?instanceBoxName, "_To_", ?entityBoxName ) ) as ?edge )
- bind( "is a" as ?title )
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql
deleted file mode 100644
index 6c2d4155e..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix samm-e:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates edges between Entity Instances and nested Entity Instances
-construct {
- ?edge a :Edge .
- ?edge :title ?title .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?instance a ?entity .
- ?entity a samm:Entity .
-
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?instance .
- } && exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?entity .
- } )
-
- ?entity samm:properties/rdf:rest*/rdf:first*/samm:property* ?property .
- ?property samm:name ?propertyName .
- ?property samm:characteristic/samm-c:baseCharacteristc*/samm:dataType ?dataType .
- filter ( exists { ?dataType rdf:type/rdfs:subclassOf* samm:Entity } ) .
-
- bind( strafter( str( ?instance ), "#" ) as ?instanceName )
- bind( concat( ?instanceName, "EntityInstance" ) as ?instanceBoxName )
-
- ?instance ?property ?propertyValue
- optional {
- ?instance ?property ?propertyValue
- filter ( !isBlank( ?propertyValue ) )
- bind( strafter( str( ?propertyValue ), "#" ) as ?nestedInstanceName )
- }
-
- optional {
- ?propertyValue rdf:rest*/rdf:first ?listValue
- filter ( isBlank( ?propertyValue ) )
- bind( strafter( str( ?listValue ), "#" ) as ?nestedInstanceName )
- }
-
- bind( iri( concat( func:getNamespace( ?instance ), ?instanceBoxName ) ) as ?from )
- bind( concat( ?nestedInstanceName, "EntityInstance" ) as ?nestedInstanceBoxName )
- bind( iri( concat( func:getNamespace( if( !isBlank( ?propertyValue ), ?propertyValue, ?listValue )), ?nestedInstanceBoxName ) ) as ?to )
- bind( iri( concat( func:getNamespace( ?instance ), ?instanceBoxName, "_To_", ?nestedInstanceBoxName ) ) as ?edge )
- bind( concat( ?propertyName, " value" ) as ?title )
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance2boxmodel.sparql
deleted file mode 100644
index d86e7ff1d..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/entityinstance2boxmodel.sparql
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix samm-e:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Entity instances
-construct {
- ?entityBox a :Box .
- ?entityBox :prototype ?prototype .
- ?entityBox :title ?instanceName .
- ?entityBox :entry [
- a :Entry ;
- :title ?entryTitle ;
- :text ?entryText
- ] .
-} where {
- ?instance a ?entity .
- ?entity a samm:Entity .
-
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?instance .
- } && exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?entity .
- } )
-
- ?entity samm:name ?prototype .
- bind( strafter( str( ?instance ), "#" ) as ?instanceName )
-
- bind( concat( ?instanceName, "EntityInstance" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?instance ), ?boxName ) ) as ?entityBox )
-
- ?entity samm:properties/rdf:rest*/rdf:first*/samm:property* ?property .
- ?property samm:characteristic/samm-c:baseCharacteristc*/samm:dataType ?dataType .
- filter ( not exists { ?dataType rdf:type/rdfs:subclassOf* samm:Entity } ) .
-
- ?property samm:name ?propertyName .
- bind( ?propertyName as ?entryTitle )
-
- ?instance ?property ?propertyValue .
- bind( str( ?propertyValue ) as ?value )
-
- optional {
- select ?property ( group_concat( distinct ?listValue;separator=";" ) as ?value ) {
- ?instance ?property ?propertyValue
- filter ( isBlank(?propertyValue) )
- ?propertyValue rdf:rest*/rdf:first ?listValue
- }
- group by ?property
- }
-
- bind( str( ?value ) as ?entryText )
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/enumeration-entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/enumeration-entityinstance2boxmodel.sparql
deleted file mode 100644
index 0de6ab26b..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/enumeration-entityinstance2boxmodel.sparql
+++ /dev/null
@@ -1,45 +0,0 @@
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix :
-prefix func:
-
-# Generates edges between Enumerations and Entity instances
-construct {
- ?edge a :Edge .
- ?edge :title ?title .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?characteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
-
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?characteristic .
- } )
-
- # Don't apply to Constraints
- filter( !exists { ?characteristic samm-c:baseCharacteristic [] } )
- # Don't apply to Collections
- filter( !exists { ?characteristic rdf:type/rdfs:subClassOf* samm-c:Collection } )
- # Apply only to Enumerations
- filter( exists { ?characteristic a samm-c:Enumeration }
- || exists { ?characteristic a samm-c:State } )
-
- # Apply to Enumerations with Complex values
- ?characteristic samm-c:values/rdf:rest*/rdf:first ?instance .
- ?instance rdf:type/rdfs:subClassOf* ?instanceClass
- filter( exists { ?instanceClass rdf:type/rdfs:subClassOf* samm:Entity} )
-
- ?characteristic samm:name ?characteristicName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from )
- ?characteristic samm-c:values/rdf:rest*/rdf:first ?instance .
- bind( strafter( str( ?instance ), "#" ) as ?instanceName )
- bind( concat( ?instanceName, "EntityInstance" ) as ?instanceBoxName )
-
- bind( iri( concat( func:getNamespace( ?instance ), ?instanceBoxName ) ) as ?to )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?instanceBoxName ) ) as ?edge )
- bind( "value" as ?title )
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/enumeration2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/enumeration2boxmodel.sparql
deleted file mode 100644
index dd3a7c90e..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/enumeration2boxmodel.sparql
+++ /dev/null
@@ -1,176 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Enumeration and State Characteristics
-construct {
- ?characteristicBox a :Box .
- ?characteristicBox :prototype "Characteristic + Enumeration" .
- ?characteristicBox :title ?characteristicName .
- ?characteristicBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "dataType" ;
- :text ?dataType
- ]
- [
- a :Entry ;
- :title "values" ;
- :text ?values
- ]
- [
- a :Entry ;
- :title "defaultValue" ;
- :text ?defaultValue
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- )
-} where {
- ?characteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
-
- # Apply only to those Characteristics which are used in the Aspect model,
- # i.e. where a directed link from an Aspect to the Characteristic exists.
- # (<>|!<>) matches any RDF property.
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?characteristic .
- } )
-
- # Apply only to Enumerations
- filter( exists { ?characteristic a samm-c:Enumeration } || exists { ?characteristic a samm-c:State } )
-
- ?characteristic samm:name ?characteristicName .
- bind( concat( ?characteristicName, "Characteristic" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?boxName ) ) as ?characteristicBox )
-
- optional {
- ?characteristic samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?characteristic samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- #subquery which concatenates all values for the samm:see attributes
- optional {
- {
- select * where {
- ?characteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
- filter( str( ?subQueryCharacteristic ) = str( ?characteristic ) )
- {
- select ?subQueryCharacteristic ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- select *
- where {
- ?subQueryCharacteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
- ?subQueryCharacteristic samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?subQueryCharacteristic
- }
- }
- }
- }
-
- optional {
- {
- select ?characteristic ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- ?characteristic rdf:type/rdfs:subClassOf* samm:Characteristic .
- filter( exists {
- ?aspect a samm:Aspect .
- ?aspect (<>|!<>)* ?characteristic .
- } )
- filter( !exists { ?characteristic samm-c:baseCharacteristic [] } )
- filter( !exists { ?characteristic rdf:type/rdfs:subClassOf* samm-c:Collection } )
- filter( exists { ?characteristic a samm-c:Enumeration } || exists { ?characteristic a samm-c:State } )
- ?characteristic samm:see ?seeValue .
- }
- group by ?characteristic
- }
- }
-
- # The datatype is optional, because only for literal types (i.e. strings) they
- # should be shown as attributes in the box. For types that are shown as other
- # boxes in the diagram (e.g. Meta Model Properties), an edge should be
- # generated instead.
- optional {
- ?characteristic samm:dataType ?dataTypeValue .
- filter( strstarts( str( ?dataTypeValue ), str( xsd: ) )
- || strstarts( str( ?dataTypeValue ), str( rdf: ) )
- || str( ?dataTypeValue) = str( samm:curie ) )
- bind(
- replace(
- replace(
- replace( str( ?dataTypeValue ), str( xsd: ), "xsd:" ),
- str( rdf: ), "rdf:" ),
- str( samm: ), "samm:" )
- as ?dataType )
- }
-
- # Attributes specific to Enumeration and State
- ?characteristic a ?characteristicType .
- filter( ?characteristicType in ( samm-c:Enumeration, samm-c:State ) )
-
- # values (Enumeration and State)
- optional {
- # Process here only basic types, i.e. lists of scalars
- ?characteristic samm-c:values/rdf:first ?firstValue .
- filter( strstarts( coalesce( str( datatype( ?firstValue ) ), str( ?firstValue ) ), str( xsd: ) ) )
-
- {
- select ?characteristic ( group_concat( ?serializedValue; separator=", " ) as ?values )
- where {
- ?characteristic samm-c:values/rdf:rest*/rdf:first ?value .
- bind(
- replace(
- replace(
- replace( str( ?value ), str( xsd: ), "xsd:" ),
- str( rdf: ), "rdf:" ),
- str( samm: ), "samm:" )
- as ?serializedValue )
- }
- group by ?characteristic
- }
- }
-
- # defaultValue (State)
- optional {
- filter( ?characteristicType in ( samm-c:State ) )
- ?characteristic samm-c:defaultValue ?defaultValue .
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/metamodelnode2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/metamodelnode2boxmodel.sparql
deleted file mode 100644
index d9329d26b..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/metamodelnode2boxmodel.sparql
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix rdf:
-prefix rdfs:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Meta Model Properties
-construct {
- ?metaModelNodeBox a :Box .
- ?metaModelNodeBox :title ?metaModelElementName .
- ?metaModelNodeBox :entries () .
- ?metaModelNodeBox :fillcolor "orange" .
-} where {
- [] samm:dataType ?metaModelElement .
- filter( ?metaModelElement in ( samm:Property ) )
- ?metaModelElement rdfs:label ?metaModelElementName .
- bind( concat( ?metaModelElementName, "MetaModelElement" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?metaModelElement ), ?boxName ) ) as ?metaModelNodeBox )
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/operation-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/operation-property-edges2boxmodel.sparql
deleted file mode 100644
index 4cd6d5541..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/operation-property-edges2boxmodel.sparql
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix rdf:
-prefix :
-prefix func:
-
-# Generates edges between Operations and Properties (input and output)
-construct {
- ?edge a :Edge .
- ?edge :title ?title .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
-
- # Operation -> Property (input)
- {
- ?operation a samm:Operation .
- ?operation samm:name ?operationName .
- ?operation samm:input/rdf:rest*/rdf:first ?property .
- ?property samm:name ?propertyName .
-
- bind( concat( ?operationName, "Operation" ) as ?operationBoxName )
- bind( iri( concat( func:getNamespace( ?operation ), ?operationBoxName ) ) as ?from )
- bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to )
- bind( "input" as ?title )
-
- bind( iri( concat( func:getNamespace( ?operation ), ?operationBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
- }
-
- union
-
- # Operation -> Property (output)
- {
- ?operation a samm:Operation .
- ?operation samm:name ?operationName .
- ?operation samm:output ?property .
- ?property samm:name ?propertyName .
-
- bind( concat( ?operationName, "Operation" ) as ?operationBoxName )
- bind( iri( concat( func:getNamespace( ?operation ), ?operationBoxName ) ) as ?from )
- bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to )
- bind( "output" as ?title )
-
- bind( iri( concat( func:getNamespace( ?operation ), ?operationBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
- }
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/operation2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/operation2boxmodel.sparql
deleted file mode 100644
index 3a8c2c415..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/operation2boxmodel.sparql
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix rdf:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Operations
-construct {
- ?operationBox a :Box .
- ?operationBox :prototype "Operation" .
- ?operationBox :title ?operationName .
- ?operationBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- )
-} where {
- ?aspect a samm:Aspect .
- ?aspect samm:operations/rdf:rest*/rdf:first ?operation .
-
- ?operation samm:name ?operationName .
-
- bind( concat( ?operationName, "Operation" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?aspect ), ?boxName ) ) as ?operationBox )
-
- optional {
- ?operation samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?operation samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- optional {
- {
- select ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) ?operation
- where {
- select *
- where {
- ?aspect a samm:Aspect .
- ?aspect samm:operations/rdf:rest*/rdf:first ?operation .
- ?operation samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?operation
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/property-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/property-characteristic-edges2boxmodel.sparql
deleted file mode 100644
index ff60513e5..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/property-characteristic-edges2boxmodel.sparql
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-e:
-prefix rdf:
-prefix :
-prefix func:
-
-# Generates edges between Properties and Characteristics (characteristic)
-construct {
- ?edge a :Edge .
- ?edge :title "characteristic" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- #process Properties defined in the Aspect Model being processed
- {
- ?property samm:refines?/rdf:type samm:Property .
- #exclude properties from our shared name-space
- filter ( ! strstarts( str( ?property ), str ( samm-e: ) ) )
-
- ?property samm:name ?propertyName .
- ?property samm:characteristic ?characteristic .
- ?characteristic samm:name ?characteristicName .
-
- bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?from )
- bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName, "_To_", ?characteristicBoxName ) ) as ?edge )
- }
-
- union
-
- #process Properties which are defined in an Entity which is refined, but are themselves not refined
- {
- ?refiningEntity samm:refines/rdf:type samm:Entity .
- ?refiningEntity samm:refines ?refinedEntity .
-
- ?property samm:refines?/rdf:type samm:Property .
- filter( exists { ?refinedEntity samm:properties/rdf:rest*/rdf:first ?property } )
- filter( not exists { [] samm:refines ?property } )
-
- ?property samm:name ?propertyName .
- ?property samm:characteristic ?characteristic .
- ?characteristic samm:name ?characteristicName .
-
- bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?from )
- bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
- bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName, "_To_", ?characteristicBoxName ) ) as ?edge )
- }
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/property2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/property2boxmodel.sparql
deleted file mode 100644
index 727167471..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/property2boxmodel.sparql
+++ /dev/null
@@ -1,146 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-e:
-prefix rdf:
-prefix xsd:
-prefix :
-prefix func:
-
-# Generates boxes for Properties; excludes Properties which are refined
-construct {
- ?propertyBox a :Box .
- ?propertyBox :prototype "Property" .
- ?propertyBox :title ?propertyName .
- ?propertyBox :entries (
- [
- a :Entry ;
- :title "preferredName" ;
- :text ?preferredName
- ]
- [
- a :Entry ;
- :title "description" ;
- :text ?description
- ]
- [
- a :Entry ;
- :title "see" ;
- :text ?seeValues
- ]
- [
- a :Entry ;
- :title "exampleValue" ;
- :text ?exampleValue
- ]
- )
-} where {
- #process Properties defined in the Aspect Model being processed
- {
- ?property samm:refines?/rdf:type samm:Property .
- #exclude properties from our shared name-space
- filter ( ! strstarts( str( ?property ), str ( samm-e: ) ) )
- ?property samm:name ?propertyName .
-
- bind( concat( ?propertyName, "Property" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?property ), ?boxName ) ) as ?propertyBox )
-
- optional {
- ?property samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?property samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- optional {
- ?property samm:exampleValue ?exampleValue .
- }
-
- #subquery which concatenates all values for the samm:see attributes
- optional {
- select * where {
- ?property samm:refines?/rdf:type samm:Property .
- filter( str( ?subQueryProperty ) = str( ?property ) )
- {
- select ?subQueryProperty ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- select *
- where {
- ?subQueryProperty samm:refines?/rdf:type samm:Property .
- ?subQueryProperty samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?subQueryProperty
- }
- }
- }
- }
-
- union
-
- #process Properties which are defined in an Entity which is refined, but are themselves not refined
- {
- ?refiningEntity samm:refines/rdf:type samm:Entity .
- ?refiningEntity samm:refines ?refinedEntity .
-
- ?property samm:refines?/rdf:type samm:Property .
- filter( exists { ?refinedEntity samm:properties/rdf:rest*/rdf:first ?property } )
- filter( not exists { [] samm:refines ?property } )
-
- ?property samm:name ?propertyName .
-
- bind( concat( ?propertyName, "Property" ) as ?boxName )
- bind( iri( concat( func:getNamespace( ?property ), ?boxName ) ) as ?propertyBox )
-
- optional {
- ?property samm:preferredName ?preferredNameValue .
- filter( lang( ?preferredNameValue ) = "en" )
- bind( xsd:string( ?preferredNameValue ) as ?preferredName )
- }
-
- optional {
- ?property samm:description ?descriptionValue .
- filter( lang( ?descriptionValue ) = "en" )
- bind( xsd:string( ?descriptionValue ) as ?description )
- }
-
- optional {
- ?property samm:exampleValue ?exampleValue .
- }
-
- #subquery which concatenates all values for the samm:see attributes
- optional {
- select * where {
- ?property samm:refines?/rdf:type samm:Property .
- filter (str( ?subQueryProperty ) = str( ?property ) )
- {
- select ?subQueryProperty ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
- where {
- select *
- where {
- ?subQueryProperty samm:refines?/rdf:type samm:Property .
- ?subQueryProperty samm:see ?seeValue .
- }
- order by str( ?seeValue )
- }
- group by ?subQueryProperty
- }
- }
- }
- }
-}
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/quantifiable-unit-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/quantifiable-unit-edges2boxmodel.sparql
deleted file mode 100644
index 1b1d079cb..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/quantifiable-unit-edges2boxmodel.sparql
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix rdfs:
-prefix :
-prefix func:
-
-# Generates edges between Quantifiables and Units (unit)
-construct {
- ?edge a :Edge .
- ?edge :title "unit" .
- ?edge :from ?from .
- ?edge :to ?to .
-} where {
- ?quantifiable samm-c:unit ?unit .
- ?property samm:refines?/rdf:type samm:Property .
- filter( exists { ?property samm:characteristic/( samm-c:baseCharacteristic* | rdfs:subClassOf* ) ?quantifiable } )
- ?quantifiable samm:name ?quantifiableName .
- bind( replace( str( ?unit ), "[^#]*#(.*)", "$1") as ?unitName )
- bind( concat( ucase( substr( ?unitName, 1, 1 ) ), substr( ?unitName, 2 ) ) as ?upperUnitName )
-
- bind( concat( ?quantifiableName, "Characteristic" ) as ?quantifiableBoxName )
- bind( iri( concat( func:getNamespace( ?quantifiable ), ?quantifiableBoxName ) ) as ?from )
- bind( concat( ?upperUnitName, "Unit" ) as ?unitBoxName )
- bind( iri( concat( func:getNamespace( ?unit ), ?unitBoxName ) ) as ?to )
-
- bind( iri( concat( func:getNamespace( ?quantifiable ), ?quantifiableBoxName, "_To_", ?unitBoxName ) ) as ?edge )
-}
-
diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/quantitykind2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/quantitykind2boxmodel.sparql
deleted file mode 100644
index 017010025..000000000
--- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/quantitykind2boxmodel.sparql
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
-#
-# See the AUTHORS file(s) distributed with this work for additional
-# information regarding authorship.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# SPDX-License-Identifier: MPL-2.0
-
-prefix samm:
-prefix samm-c:
-prefix rdf:
-prefix xsd: