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: -prefix unit: -prefix : -prefix func: - -# Generates boxes for QuantityKinds -construct { - ?quantityKindBox a :Box . - ?quantityKindBox :prototype "QuantityKind" . - ?quantityKindBox :title ?upperQuantityKindName . - ?quantityKindBox :entries () -} where { - [] samm-c:unit/unit:referenceUnit?/unit:quantityKind ?quantityKind . - ?quantityKind samm:name ?quantityKindName . - bind( concat( ucase( substr( ?quantityKindName, 1, 1 ) ), substr( ?quantityKindName, 2 ) ) as ?upperQuantityKindName ) - bind( concat( replace( ?upperQuantityKindName, "-", "" ), "QuantityKind" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?quantityKind ), ?boxName ) ) as ?quantityKindBox ) -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/structuredvalue-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/structuredvalue-property-edges2boxmodel.sparql deleted file mode 100644 index e9580a5eb..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/structuredvalue-property-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 StructuredValues its elements Properties -construct { - ?edge a :Edge . - ?edge :title ?propertyName . - ?edge :from ?from . - ?edge :to ?to . -} where { - ?characteristic rdf:type/rdfs:subClassOf* samm-c:StructuredValue . - ?characteristic samm:name ?characteristicName . - - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from ) - - ?characteristic samm-c:elements/rdf:rest*/rdf:first ?element . - filter( exists { ?element a samm:Property } ) - ?element samm:name ?propertyName . - bind( concat( ?propertyName, "Property" ) as ?propertyBoxName ) - bind( iri( concat( func:getNamespace( ?element ), ?propertyBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?propertyBoxName ) ) as ?edge ) -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/structuredvalue2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/structuredvalue2boxmodel.sparql deleted file mode 100644 index 172a16b8d..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/structuredvalue2boxmodel.sparql +++ /dev/null @@ -1,132 +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 StrucuredValue Characteristics -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 - ] - [ - a :Entry ; - :title "deconstructionRule" ; - :text ?deconstructionRule - ] - [ - a :Entry ; - :title "elements" ; - :text ?elementsList - ] - ) -} where { - ?characteristic rdf:type/rdfs:subClassOf* samm-c:StructuredValue . - - # 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: ) ) - || 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 - } - } - } - } - - ?characteristic samm-c:deconstructionRule ?rule0 . - bind( replace( str( ?rule0 ), "\\\\", "\\\\\\\\" ) as ?rule1 ) - bind( replace( ?rule1, "\\|", "\\\\|" ) as ?deconstructionRule ) - - ?characteristic samm-c:elements ?elements . - { - select ?characteristic ( group_concat( ?elementsListPart; separator=" " ) as ?elementsList ) - where { - ?characteristic samm-c:elements ?elements . - ?elements rdf:rest*/rdf:first ?listEntry . - optional { - ?listEntry samm:name ?propertyName . - } - bind( if ( exists { ?listEntry a samm:Property }, ?propertyName, concat( "'", str( ?listEntry), "'" ) ) as ?elementsListPart ) - } - group by ?characteristic - } -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/unit-quantitykind-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/unit-quantitykind-edges2boxmodel.sparql deleted file mode 100644 index e6dd6a3f5..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/unit-quantitykind-edges2boxmodel.sparql +++ /dev/null @@ -1,41 +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 unit: -prefix : -prefix func: - -# Generates edges between Units and QuantityKinds (quantityKind) -construct { - ?edge a :Edge . - ?edge :title "quantityKind" . - ?edge :from ?from . - ?edge :to ?to . -} where { - [] samm-c:unit ?unit . - ?unit unit:referenceUnit?/unit:quantityKind ?quantityKind . - ?unit samm:name ?unitName . - bind( concat( ucase( substr( ?unitName, 1, 1 ) ), substr( ?unitName, 2 ) ) as ?upperUnitName ) - ?quantityKind samm:name ?quantityKindGivenName . - bind( concat( ?quantityKindGivenName, "QuantityKind" ) as ?quantityKindName ) - bind( concat( ucase( substr( ?quantityKindName, 1, 1 ) ), substr( ?quantityKindName, 2 ) ) as ?upperQuantityKindName ) - - bind( concat( ?upperUnitName, "Unit" ) as ?unitBoxName ) - bind( iri( concat( func:getNamespace( ?unit ), ?unitBoxName ) ) as ?from ) - bind( replace( ?upperQuantityKindName, "-", "" ) as ?quantityKindBoxName ) - bind( iri( concat( func:getNamespace( ?quantityKind ), ?quantityKindBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?unit ), ?unitBoxName, "_To_", ?quantityKindBoxName ) ) as ?edge ) -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/unit2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/unit2boxmodel.sparql deleted file mode 100644 index 279ac727c..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/unit2boxmodel.sparql +++ /dev/null @@ -1,46 +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 unit: -prefix : -prefix func: - -# Generates boxes for Units -construct { - ?unitBox a :Box . - ?unitBox :prototype "Unit" . - ?unitBox :title ?upperUnitName . - ?unitBox :entries ( - [ - a :Entry ; - :title "symbol" ; - :text ?symbol - ] - ) -} where { - ?measurement samm-c:unit ?unit . - # Select only those Units that are used in the Aspect - filter( exists { ?property samm:characteristic/( samm-c:baseCharacteristic* | rdfs:subClassOf* ) ?measurement } ) - ?unit samm:name ?unitName . - bind( concat( ucase( substr( ?unitName, 1, 1 ) ), substr( ?unitName, 2 ) ) as ?upperUnitName ) - - bind( concat( ?upperUnitName, "Unit" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?unit ), ?boxName ) ) as ?unitBox ) - - optional { - ?unit unit:symbol ?symbol - } -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/abstractentity2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/abstractentity2boxmodel.sparql deleted file mode 100644 index 190b79ebf..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/abstractentity2boxmodel.sparql +++ /dev/null @@ -1,74 +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 Abstract Entities -construct { - ?abstractEntityBox a :Box . - ?abstractEntityBox :prototype "Abstract Entity" . - ?abstractEntityBox :title ?abstractEntityName . - ?abstractEntityBox :modelElement ?abstractEntity . - ?abstractEntityBox :entries ( - [ - a :Entry ; - :title "preferredName" ; - :text ?preferredName - ] - [ - a :Entry ; - :title "description" ; - :text ?description - ] - [ - a :Entry ; - :title "see" ; - :text ?seeValues - ] - ) -} where { - ?abstractEntity rdf:type samm:AbstractEntity . - bind( strafter( str( ?abstractEntity ), "#" ) as ?abstractEntityName ) - - bind( concat( ?abstractEntityName, "AbstractEntity" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?abstractEntity ), ?boxName ) ) as ?abstractEntityBox ) - - optional { - ?abstractEntity samm:preferredName ?preferredNameValue . - filter( lang( ?preferredNameValue ) = "en" ) - bind( xsd:string( ?preferredNameValue ) as ?preferredName ) - } - - optional { - ?abstractEntity samm:description ?descriptionValue . - filter( lang( ?descriptionValue ) = "en" ) - bind( xsd:string( ?descriptionValue ) as ?description ) - } - - optional { - { - select ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) ?abstractEntity - where { - select * - where { - ?abstractEntity rdf:type samm:AbstractEntity . - ?abstractEntity samm:see ?seeValue . - } - order by str( ?seeValue ) - } - group by ?abstractEntity - } - } -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/abstractproperty2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/abstractproperty2boxmodel.sparql deleted file mode 100644 index 9e927de81..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/abstractproperty2boxmodel.sparql +++ /dev/null @@ -1,83 +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 -construct { - ?propertyBox a :Box . - ?propertyBox :prototype "AbstractProperty" . - ?propertyBox :title ?propertyName . - ?propertyBox :modelElement ?property . - ?propertyBox :entries ( - [ - a :Entry ; - :title "preferredName" ; - :text ?preferredName - ] - [ - a :Entry ; - :title "description" ; - :text ?description - ] - [ - a :Entry ; - :title "see" ; - :text ?seeValues - ] - ) -} where { - #process Properties defined in the Aspect Model being processed - { - ?property rdf:type samm:AbstractProperty . - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - - bind( concat( ?propertyName, "AbstractProperty" ) 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 ) - } - - #subquery which concatenates all values for the samm:see attributes - optional { - select * where { - ?property rdf:type samm:Property . - filter( str( ?subQueryProperty ) = str( ?property ) ) - { - select ?subQueryProperty ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) - where { - select * - where { - ?subQueryProperty 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_2_0_0/aspect-operation-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/aspect-operation-edges2boxmodel.sparql deleted file mode 100644 index 50c4ebf73..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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 . - bind( strafter( str( ?aspect ), "#" ) as ?aspectName ) . - ?operation a samm:Operation . - bind( strafter( str( ?operation ), "#" ) as ?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_2_0_0/aspect-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/aspect-property-edges2boxmodel.sparql deleted file mode 100644 index 6999798dd..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/aspect-property-edges2boxmodel.sparql +++ /dev/null @@ -1,82 +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 Entities or Abstract Entities and Properties -construct { - ?edge a :Edge . - ?edge :title ?title . - ?edge :from ?from . - ?edge :to ?to . -} where { - # Aspect/Entity/Abstract Entity -> Property Edges (properties) - ?aspectOrEntityOrAbstractEntity rdf:type ?class . - filter( ?class in ( samm:Aspect, samm:Entity, samm:AbstractEntity ) ) - - bind( strafter( str( ?aspectOrEntityOrAbstractEntity ), "#" ) as ?aspectOrEntityOrAbstractEntityName ) . - - ?property rdf:type ?propertyClass . - filter( ?propertyClass in ( samm:Property, samm:AbstractProperty ) ) - - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - filter( exists { ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first/samm:property? ?property } ) - - bind( str( ?class ) as ?fullClassName ) - bind( strafter( ?fullClassName, "#" ) as ?typeName ) - bind( concat( ?aspectOrEntityOrAbstractEntityName, ?typeName ) as ?aspectOrEntityOrAbstractEntityBoxName ) - bind( iri( concat( func:getNamespace( ?aspectOrEntityOrAbstractEntity ), ?aspectOrEntityOrAbstractEntityBoxName ) ) as ?from ) - - bind( if( exists { ?property a samm:AbstractProperty }, "AbstractProperty", "Property" ) as ?propertyClassName ) - bind( concat( ?propertyName, ?propertyClassName ) as ?propertyBoxName ) - bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?aspectOrEntityOrAbstractEntity ), ?aspectOrEntityOrAbstractEntityBoxName, "_To_", ?propertyBoxName ) ) as ?edge ) - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:optional true . - ?propertyNode samm:payloadName ?payloadName - bind( concat( "property (optional) (", str( ?payloadName ), ")" ) as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:optional true . - bind( "property (optional)" as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:notInPayload true . - bind( "property (not in payload)" as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:payloadName ?payloadName - bind( concat( "property (", str( ?payloadName ), ")" ) as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity 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_2_0_0/aspect2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/aspect2boxmodel.sparql deleted file mode 100644 index e3193d6a8..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/aspect2boxmodel.sparql +++ /dev/null @@ -1,74 +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 :modelElement ?aspect . - ?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 . - bind( strafter( str( ?aspect ), "#" ) as ?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_2_0_0/aspect2dot.mustache b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/aspect2dot.mustache deleted file mode 100644 index 48bb95449..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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_2_0_0/boxmodel.ttl b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/boxmodel.ttl deleted file mode 100644 index 7d2224423..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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_2_0_0/boxmodel2dot.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/boxmodel2dot.sparql deleted file mode 100644 index 7d875dc94..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/boxmodel2dot.sparql +++ /dev/null @@ -1,104 +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 sh: -prefix : - -# Transforms a box model (boxes and edges) into Graphviz/dot statements -select ?dotStatement -where { - # Boxes - { - ?box a :Box . - ?box :title ?givenTitle . - - optional { - ?box :modelElement ?modelElement . - bind( concat( strbefore( str( ?modelElement ), "#" ), "#" ) as ?modelElementRdfNamespace ) - - samm:prefixDeclarations sh:declare ?declaration . - ?declaration sh:prefix ?rdfPrefix . - ?declaration sh:namespace ?rdfNamespace . - filter( str( ?rdfNamespace ) = str( ?modelElementRdfNamespace ) ) - bind( concat( str( ?rdfPrefix ), ":" ) as ?titlePrefix ) - } - - bind( concat( coalesce( ?titlePrefix, "" ), ?givenTitle ) as ?title ) - - optional { - ?box :prototype ?prototype . - } - bind( coalesce( concat( " «", ?prototype, "»\\n" ), "" ) as ?prototypeString ) - - # Show only boxes that are reachable via an edge from the Aspect - [] :rootElement ?aspect . - ?aspectBox a :Box . - ?aspectBox :modelElement ?aspect . - filter( exists { ?aspectBox (^:from/:to)* ?box } ) - - 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 . - - # Show only boxes that are reachable via an edge from the Aspect - [] :rootElement ?aspect . - ?aspectBox a :Box . - ?aspectBox :modelElement ?aspect . - filter( exists { ?aspectBox (^:from/: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_2_0_0/characteristic-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-characteristic-edges2boxmodel.sparql deleted file mode 100644 index e1ac047c1..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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 { - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - ?characteristic samm-c:baseCharacteristic ?baseCharacteristic . - bind( func:getElementName( ?baseCharacteristic ) as ?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_2_0_0/characteristic-constraint-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-constraint-edges2boxmodel.sparql deleted file mode 100644 index d2922d508..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-constraint-edges2boxmodel.sparql +++ /dev/null @@ -1,41 +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 . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from ) - - bind( func:getElementName( ?constraint ) as ?constraintName ) - bind( concat( ?constraintName, "Constraint" ) 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_2_0_0/characteristic-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-entity-edges2boxmodel.sparql deleted file mode 100644 index 7ef6579c2..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-entity-edges2boxmodel.sparql +++ /dev/null @@ -1,42 +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 or Abstract Entities (dataType) -construct { - ?edge a :Edge . - ?edge :title "dataType" . - ?edge :from ?from . - ?edge :to ?to . -} where { - ?characteristic samm:dataType ?entityOrAbstractEntity . - filter( ! strstarts( str( ?entityOrAbstractEntity ), str( xsd: ) ) - && ! strstarts( str( ?entityOrAbstractEntity ), str( rdf: ) ) - && ! strstarts( str( ?entityOrAbstractEntity ), str ( samm-e: ) ) ) - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - bind( strafter( str( ?entityOrAbstractEntity ), "#" ) as ?entityOrAbstractEntityName ) . - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from ) - - ?entityOrAbstractEntity rdf:type ?entityOrAbstractEntityClass - bind( str(?entityOrAbstractEntityClass) as ?entityOrAbstractEntityFullClassName ) . - bind( strafter(?entityOrAbstractEntityFullClassName, "#") as ?entityOrAbstractEntityTypeName ) . - bind( concat( ?entityOrAbstractEntityName, ?entityOrAbstractEntityTypeName ) as ?entityOrAbstractEntityBoxName ) - bind( iri( concat( func:getNamespace( ?entityOrAbstractEntity ), ?entityOrAbstractEntityBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?entityOrAbstractEntityBoxName ) ) as ?edge ) -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-metamodelnode-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-metamodelnode-edges2boxmodel.sparql deleted file mode 100644 index d6f3dcf63..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic-metamodelnode-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 rdf: -prefix rdfs: -prefix : -prefix func: -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 ) ) - bind( func:getElementName( ?characteristic ) as ?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_2_0_0/characteristic2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic2boxmodel.sparql deleted file mode 100644 index 4c862c264..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/characteristic2boxmodel.sparql +++ /dev/null @@ -1,116 +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 :modelElement ?characteristic . - ?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 } ) - - bind( func:getElementName( ?characteristic ) as ?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_2_0_0/collection-elementcharacteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/collection-elementcharacteristic-edges2boxmodel.sparql deleted file mode 100644 index e8c536ea4..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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-c:elementCharacteristic ?elementCharacteristic . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - bind( func:getElementName( ?elementCharacteristic ) as ?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_2_0_0/collection2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/collection2boxmodel.sparql deleted file mode 100644 index e303d807c..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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: - -# Generates boxes for Collection Characteristics -construct { - ?characteristicBox a :Box . - ?characteristicBox :prototype "Characteristic + Collection" . - ?characteristicBox :title ?characteristicName . - ?characteristicBox :modelElement ?characteristic . - ?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 . - } ) - - bind( func:getElementName( ?characteristic ) as ?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 } ) - bind( func:getElementName( ?char ) as ?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 ) - bind( func:getElementName( ?char ) as ?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_2_0_0/constraint2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/constraint2boxmodel.sparql deleted file mode 100644 index fb0a84f37..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/constraint2boxmodel.sparql +++ /dev/null @@ -1,214 +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 :modelElement ?constraint . - ?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 . - } ) - - bind( func:getElementName( ?constraint ) as ?constraintName ) - bind( iri( concat( func:getNamespace( ?constraint ), ?constraintName ) ) 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_2_0_0/either-left-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/either-left-characteristic-edges2boxmodel.sparql deleted file mode 100644 index 283fab324..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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 . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - ?characteristic samm-c:left ?leftTypeCharacteristic . - bind( func:getElementName( ?leftTypeCharacteristic ) as ?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_2_0_0/either-right-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/either-right-characteristic-edges2boxmodel.sparql deleted file mode 100644 index 13ade41bd..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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 . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - ?characteristic samm-c:right ?rightTypeCharacteristic . - bind( func:getElementName( ?rightTypeCharacteristic ) as ?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_2_0_0/either2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/either2boxmodel.sparql deleted file mode 100644 index 1e4d52380..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/either2boxmodel.sparql +++ /dev/null @@ -1,91 +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 :modelElement ?characteristic . - ?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 . - } ) - - bind( func:getElementName( ?characteristic ) as ?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_2_0_0/entity-abstractentity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity-abstractentity-edges2boxmodel.sparql deleted file mode 100644 index fc763c838..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity-abstractentity-edges2boxmodel.sparql +++ /dev/null @@ -1,47 +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 Entities or Abstract Entities and Properties -construct { - ?edge a :Edge . - ?edge :title "extends" . - ?edge :from ?from . - ?edge :to ?to . -} where { - ?extendingEntityOrAbstractEntity samm:extends ?extendedEntityOrAbstractEntity . - - bind( strafter( str( ?extendingEntityOrAbstractEntity ), "#" ) as ?extendingEntityOrAbstractEntityName ) . - bind( strafter( str( ?extendedEntityOrAbstractEntity ), "#" ) as ?extendedEntityOrAbstractEntityName ) . - - ?extendingEntityOrAbstractEntity rdf:type ?extendingEntityOrAbstractEntityClass . - ?extendedEntityOrAbstractEntity rdf:type ?extendedEntityOrAbstractEntityClass . - - bind( str(?extendingEntityOrAbstractEntityClass) as ?extendingEntityOrAbstractEntityFullClassName ) . - bind( strafter(?extendingEntityOrAbstractEntityFullClassName, "#") as ?extendingEntityOrAbstractEntityTypeName ) . - - bind( str(?extendedEntityOrAbstractEntityClass) as ?extendedEntityOrAbstractEntityFullClassName ) . - bind( strafter(?extendedEntityOrAbstractEntityFullClassName, "#") as ?extendedEntityOrAbstractEntityTypeName ) . - - bind( concat( ?extendingEntityOrAbstractEntityName, ?extendingEntityOrAbstractEntityTypeName ) as ?extendingEntityOrAbstractEntityBoxName ) . - bind( iri( concat( func:getNamespace( ?extendingEntityOrAbstractEntity ), ?extendingEntityOrAbstractEntityBoxName ) ) as ?from ) . - - bind( concat( ?extendedEntityOrAbstractEntityName, ?extendedEntityOrAbstractEntityTypeName ) as ?extendedEntityOrAbstractEntityBoxName ) . - bind( iri( concat( func:getNamespace( ?extendedEntityOrAbstractEntity ), ?extendedEntityOrAbstractEntityBoxName ) ) as ?to ) . - - bind( iri( concat( func:getNamespace( ?extendingEntityOrAbstractEntity ), ?extendingEntityOrAbstractEntityBoxName, "_To_", ?extendedEntityOrAbstractEntityBoxName ) ) as ?edge ) . -} \ No newline at end of file diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity-abstractproperty-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity-abstractproperty-edges2boxmodel.sparql deleted file mode 100644 index 1e035453d..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity-abstractproperty-edges2boxmodel.sparql +++ /dev/null @@ -1,70 +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 Entities and Abstract Properties, -# as well as an intermediary node between the Entity and the Abstract Property -# for the implementation of the Property itself, which is then linked to the used Characteristic -construct { - ?edge1 a :Edge . - ?edge1 :title "property" . - ?edge1 :from ?entityBox . - ?edge1 :to ?box . - - ?box a :Box . - ?box :title ?boxTitle . - - ?edge2 a :Edge . - ?edge2 :title "characteristic" . - ?edge2 :from ?box . - ?edge2 :to ?characteristicBox . - - ?edge3 a :Edge . - ?edge3 :title "extends" . - ?edge3 :from ?box . - ?edge3 :to ?propertyBox . -} where { - ?entity rdf:type samm:Entity . - - bind( strafter( str( ?entity ), "#" ) as ?entityName ) . - - ?property rdf:type samm:AbstractProperty . - - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - filter( exists { ?entity samm:properties/rdf:rest*/rdf:first/samm:extends ?property } ) - - bind( concat( ?entityName, "Entity" ) as ?entityBoxName ) - bind( iri( concat( func:getNamespace( ?entity ), ?entityBoxName ) ) as ?entityBox ) - - bind( concat( ?entityName, ?propertyName, "Usage" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?property ), ?boxName ) ) as ?box ) - bind( concat( "Usage of ", ?propertyName, " in ", ?entityName ) as ?boxTitle ) - - bind( concat( ?propertyName, "AbstractProperty" ) as ?propertyBoxName ) - bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?propertyBox ) - - bind( iri( concat( func:getNamespace( ?entity ), ?entityBoxName, "_To_", ?boxName ) ) as ?edge1 ) - bind( iri( concat( func:getNamespace( ?property ), ?boxName, "_To_", ?propertyBoxName ) ) as ?edge3 ) - - ?entity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:extends ?property . - ?propertyNode samm:characteristic ?characteristic . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?characteristicBox ) - bind( iri( concat( func:getNamespace( ?property ), ?boxName, "_To_", ?characteristicBoxName ) ) as ?edge2 ) -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity2boxmodel.sparql deleted file mode 100644 index c65583300..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entity2boxmodel.sparql +++ /dev/null @@ -1,75 +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 -construct { - ?entityBox a :Box . - ?entityBox :prototype "Entity" . - ?entityBox :title ?entityName . - ?entityBox :modelElement ?entity . - ?entityBox :entries ( - [ - a :Entry ; - :title "preferredName" ; - :text ?preferredName - ] - [ - a :Entry ; - :title "description" ; - :text ?description - ] - [ - a :Entry ; - :title "see" ; - :text ?seeValues - ] - ) -} where { - ?entity rdf:type samm:Entity . - bind( strafter( str( ?entity ), "#" ) as ?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 rdf:type samm:Entity . - ?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_2_0_0/entityinstance-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entityinstance-entity-edges2boxmodel.sparql deleted file mode 100644 index d73f4f3fc..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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_2_0_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql deleted file mode 100644 index 7ea1c4b01..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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 . - bind( strafter( str( ?property ), "#" ) as ?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_2_0_0/entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entityinstance2boxmodel.sparql deleted file mode 100644 index efcf661e0..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/entityinstance2boxmodel.sparql +++ /dev/null @@ -1,70 +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 :modelElement ?instance . - ?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 . - } ) - - bind( strafter( str( ?entity ), "#" ) as ?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 } ) . - - bind( strafter( str( ?property ), "#" ) as ?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_2_0_0/enumeration-entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/enumeration-entityinstance2boxmodel.sparql deleted file mode 100644 index 84459a938..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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} ) - - bind( func:getElementName( ?characteristic ) as ?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_2_0_0/enumeration2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/enumeration2boxmodel.sparql deleted file mode 100644 index 2d10a04f9..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/enumeration2boxmodel.sparql +++ /dev/null @@ -1,177 +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 :modelElement ?characteristic . - ?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 } ) - - bind( func:getElementName( ?characteristic ) as ?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_2_0_0/metamodelnode2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/metamodelnode2boxmodel.sparql deleted file mode 100644 index a1882462c..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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_2_0_0/operation-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/operation-property-edges2boxmodel.sparql deleted file mode 100644 index 37822a9d3..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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 . - bind( strafter( str( ?operation ), "#" ) as ?operationName ) . - ?operation samm:input/rdf:rest*/rdf:first ?property . - bind( strafter( str( ?property ), "#" ) as ?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 . - bind( strafter( str( ?operation ), "#" ) as ?operationName ) . - ?operation samm:output ?property . - bind( strafter( str( ?property ), "#" ) as ?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_2_0_0/operation2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/operation2boxmodel.sparql deleted file mode 100644 index 00ed30233..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/operation2boxmodel.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 samm: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Operations -construct { - ?operationBox a :Box . - ?operationBox :prototype "Operation" . - ?operationBox :title ?operationName . - ?operationBox :modelElement ?operation . - ?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 . - - bind( strafter( str( ?operation ), "#" ) as ?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_2_0_0/property-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/property-characteristic-edges2boxmodel.sparql deleted file mode 100644 index 53eaf99dc..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/property-characteristic-edges2boxmodel.sparql +++ /dev/null @@ -1,41 +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 rdf:type samm:Property . - - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - ?property samm:characteristic ?characteristic . - bind( func:getElementName( ?characteristic ) as ?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_2_0_0/property2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/property2boxmodel.sparql deleted file mode 100644 index ad95209f6..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/property2boxmodel.sparql +++ /dev/null @@ -1,92 +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 -construct { - ?propertyBox a :Box . - ?propertyBox :prototype "Property" . - ?propertyBox :title ?propertyName . - ?propertyBox :modelElement ?property . - ?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 rdf:type samm:Property . - bind( strafter( str( ?property ), "#" ) as ?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 rdf:type samm:Property . - filter( str( ?subQueryProperty ) = str( ?property ) ) - { - select ?subQueryProperty ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) - where { - select * - where { - ?subQueryProperty 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_2_0_0/quantifiable-unit-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/quantifiable-unit-edges2boxmodel.sparql deleted file mode 100644 index 1a3daaac3..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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 rdf:type samm:Property . - filter( exists { ?property samm:characteristic/( samm-c:baseCharacteristic* | rdfs:subClassOf* ) ?quantifiable } ) - bind( func:getElementName( ?quantifiable ) as ?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_2_0_0/quantitykind2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/quantitykind2boxmodel.sparql deleted file mode 100644 index 00231a9d0..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_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: -prefix : -prefix func: - -# Generates boxes for QuantityKinds -construct { - ?quantityKindBox a :Box . - ?quantityKindBox :prototype "QuantityKind" . - ?quantityKindBox :title ?upperQuantityKindName . - ?quantityKindBox :modelElement ?quantityKind . - ?quantityKindBox :entries () -} where { - [] samm-c:unit/samm:referenceUnit?/samm:quantityKind ?quantityKind . - bind( strafter( str( ?quantityKind ), "#" ) as ?quantityKindName ) . - bind( concat( ucase( substr( ?quantityKindName, 1, 1 ) ), substr( ?quantityKindName, 2 ) ) as ?upperQuantityKindName ) - bind( concat( replace( ?upperQuantityKindName, "-", "" ), "QuantityKind" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?quantityKind ), ?boxName ) ) as ?quantityKindBox ) -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/structuredvalue-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/structuredvalue-property-edges2boxmodel.sparql deleted file mode 100644 index 1a772743d..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/structuredvalue-property-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 StructuredValues its elements Properties -construct { - ?edge a :Edge . - ?edge :title ?propertyName . - ?edge :from ?from . - ?edge :to ?to . -} where { - ?characteristic rdf:type/rdfs:subClassOf* samm-c:StructuredValue . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from ) - - ?characteristic samm-c:elements/rdf:rest*/rdf:first ?property . - filter( exists { ?property a samm:Property } ) - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - bind( concat( ?propertyName, "Property" ) as ?propertyBoxName ) - bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?propertyBoxName ) ) as ?edge ) -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/structuredvalue2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/structuredvalue2boxmodel.sparql deleted file mode 100644 index f38447263..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/structuredvalue2boxmodel.sparql +++ /dev/null @@ -1,131 +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 StrucuredValue Characteristics -construct { - ?characteristicBox a :Box . - ?characteristicBox :prototype "Characteristic" . - ?characteristicBox :title ?characteristicName . - ?characteristicBox :modelElement ?characteristic . - ?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 - ] - [ - a :Entry ; - :title "deconstructionRule" ; - :text ?deconstructionRule - ] - [ - a :Entry ; - :title "elements" ; - :text ?elementsList - ] - ) -} where { - ?characteristic rdf:type/rdfs:subClassOf* samm-c:StructuredValue . - - # 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 . - } ) - - bind( func:getElementName( ?characteristic ) as ?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 - } - } - } - } - - ?characteristic samm-c:deconstructionRule ?rule0 . - bind( replace( str( ?rule0 ), "\\\\", "\\\\\\\\" ) as ?rule1 ) - bind( replace( ?rule1, "\\|", "\\\\|" ) as ?deconstructionRule ) - - ?characteristic samm-c:elements ?elements . - { - select ?characteristic ( group_concat( ?elementsListPart; separator=" " ) as ?elementsList ) - where { - ?characteristic samm-c:elements ?elements . - ?elements rdf:rest*/rdf:first ?listEntry . - bind( strafter( str( ?listEntry ), "#" ) as ?propertyName ) . - bind( if ( exists { ?listEntry a samm:Property }, ?propertyName, concat( "'", str( ?listEntry), "'" ) ) as ?elementsListPart ) - } - group by ?characteristic - } -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/unit-quantitykind-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/unit-quantitykind-edges2boxmodel.sparql deleted file mode 100644 index a08006407..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/unit-quantitykind-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 : -prefix func: - -# Generates edges between Units and QuantityKinds (quantityKind) -construct { - ?edge a :Edge . - ?edge :title "quantityKind" . - ?edge :from ?from . - ?edge :to ?to . -} where { - [] samm-c:unit ?unit . - ?unit samm:referenceUnit?/samm:quantityKind ?quantityKind . - bind( strafter( str( ?unit ), "#" ) as ?unitName ) . - bind( concat( ucase( substr( ?unitName, 1, 1 ) ), substr( ?unitName, 2 ) ) as ?upperUnitName ) - bind( strafter( str( ?quantityKind ), "#" ) as ?quantityKindGivenName ) . - bind( concat( ?quantityKindGivenName, "QuantityKind" ) as ?quantityKindName ) - bind( concat( ucase( substr( ?quantityKindName, 1, 1 ) ), substr( ?quantityKindName, 2 ) ) as ?upperQuantityKindName ) - - bind( concat( ?upperUnitName, "Unit" ) as ?unitBoxName ) - bind( iri( concat( func:getNamespace( ?unit ), ?unitBoxName ) ) as ?from ) - bind( replace( ?upperQuantityKindName, "-", "" ) as ?quantityKindBoxName ) - bind( iri( concat( func:getNamespace( ?quantityKind ), ?quantityKindBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?unit ), ?unitBoxName, "_To_", ?quantityKindBoxName ) ) as ?edge ) -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/unit2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/unit2boxmodel.sparql deleted file mode 100644 index d18e81319..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_0_0/unit2boxmodel.sparql +++ /dev/null @@ -1,46 +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 Units -construct { - ?unitBox a :Box . - ?unitBox :prototype "Unit" . - ?unitBox :title ?upperUnitName . - ?unitBox :modelElement ?unit . - ?unitBox :entries ( - [ - a :Entry ; - :title "symbol" ; - :text ?symbol - ] - ) -} where { - ?measurement samm-c:unit ?unit . - # Select only those Units that are used in the Aspect - filter( exists { ?property samm:characteristic/( samm-c:baseCharacteristic* | rdfs:subClassOf* ) ?measurement } ) - bind( strafter( str( ?unit ), "#" ) as ?unitName ) . - bind( concat( ucase( substr( ?unitName, 1, 1 ) ), substr( ?unitName, 2 ) ) as ?upperUnitName ) - - bind( concat( ?upperUnitName, "Unit" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?unit ), ?boxName ) ) as ?unitBox ) - - optional { - ?unit samm:symbol ?symbol - } -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/abstractentity2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/abstractentity2boxmodel.sparql deleted file mode 100644 index d1d238acc..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/abstractentity2boxmodel.sparql +++ /dev/null @@ -1,74 +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 - -prefix samm: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Abstract Entities -construct { - ?abstractEntityBox a :Box . - ?abstractEntityBox :prototype "Abstract Entity" . - ?abstractEntityBox :title ?abstractEntityName . - ?abstractEntityBox :modelElement ?abstractEntity . - ?abstractEntityBox :entries ( - [ - a :Entry ; - :title "preferredName" ; - :text ?preferredName - ] - [ - a :Entry ; - :title "description" ; - :text ?description - ] - [ - a :Entry ; - :title "see" ; - :text ?seeValues - ] - ) -} where { - ?abstractEntity rdf:type samm:AbstractEntity . - bind( strafter( str( ?abstractEntity ), "#" ) as ?abstractEntityName ) - - bind( concat( ?abstractEntityName, "AbstractEntity" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?abstractEntity ), ?boxName ) ) as ?abstractEntityBox ) - - optional { - ?abstractEntity samm:preferredName ?preferredNameValue . - filter( lang( ?preferredNameValue ) = "en" ) - bind( xsd:string( ?preferredNameValue ) as ?preferredName ) - } - - optional { - ?abstractEntity samm:description ?descriptionValue . - filter( lang( ?descriptionValue ) = "en" ) - bind( xsd:string( ?descriptionValue ) as ?description ) - } - - optional { - { - select ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) ?abstractEntity - where { - select * - where { - ?abstractEntity rdf:type samm:AbstractEntity . - ?abstractEntity samm:see ?seeValue . - } - order by str( ?seeValue ) - } - group by ?abstractEntity - } - } -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/abstractproperty2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/abstractproperty2boxmodel.sparql deleted file mode 100644 index c14d6a04c..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/abstractproperty2boxmodel.sparql +++ /dev/null @@ -1,83 +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 - -prefix samm: -prefix samm-e: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Properties -construct { - ?propertyBox a :Box . - ?propertyBox :prototype "AbstractProperty" . - ?propertyBox :title ?propertyName . - ?propertyBox :modelElement ?property . - ?propertyBox :entries ( - [ - a :Entry ; - :title "preferredName" ; - :text ?preferredName - ] - [ - a :Entry ; - :title "description" ; - :text ?description - ] - [ - a :Entry ; - :title "see" ; - :text ?seeValues - ] - ) -} where { - #process Properties defined in the Aspect Model being processed - { - ?property rdf:type samm:AbstractProperty . - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - - bind( concat( ?propertyName, "AbstractProperty" ) 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 ) - } - - #subquery which concatenates all values for the samm:see attributes - optional { - select * where { - ?property rdf:type samm:Property . - filter( str( ?subQueryProperty ) = str( ?property ) ) - { - select ?subQueryProperty ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) - where { - select * - where { - ?subQueryProperty 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_2_1_0/aspect-operation-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/aspect-operation-edges2boxmodel.sparql deleted file mode 100644 index 7bc5dab19..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/aspect-operation-edges2boxmodel.sparql +++ /dev/null @@ -1,36 +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 - -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 . - bind( strafter( str( ?aspect ), "#" ) as ?aspectName ) . - ?operation a samm:Operation . - bind( strafter( str( ?operation ), "#" ) as ?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_2_1_0/aspect-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/aspect-property-edges2boxmodel.sparql deleted file mode 100644 index 1ed54b551..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/aspect-property-edges2boxmodel.sparql +++ /dev/null @@ -1,82 +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 - -prefix samm: -prefix samm-e: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates edges between Aspects or Entities or Abstract Entities and Properties -construct { - ?edge a :Edge . - ?edge :title ?title . - ?edge :from ?from . - ?edge :to ?to . -} where { - # Aspect/Entity/Abstract Entity -> Property Edges (properties) - ?aspectOrEntityOrAbstractEntity rdf:type ?class . - filter( ?class in ( samm:Aspect, samm:Entity, samm:AbstractEntity ) ) - - bind( strafter( str( ?aspectOrEntityOrAbstractEntity ), "#" ) as ?aspectOrEntityOrAbstractEntityName ) . - - ?property rdf:type ?propertyClass . - filter( ?propertyClass in ( samm:Property, samm:AbstractProperty ) ) - - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - filter( exists { ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first/samm:property? ?property } ) - - bind( str( ?class ) as ?fullClassName ) - bind( strafter( ?fullClassName, "#" ) as ?typeName ) - bind( concat( ?aspectOrEntityOrAbstractEntityName, ?typeName ) as ?aspectOrEntityOrAbstractEntityBoxName ) - bind( iri( concat( func:getNamespace( ?aspectOrEntityOrAbstractEntity ), ?aspectOrEntityOrAbstractEntityBoxName ) ) as ?from ) - - bind( if( exists { ?property a samm:AbstractProperty }, "AbstractProperty", "Property" ) as ?propertyClassName ) - bind( concat( ?propertyName, ?propertyClassName ) as ?propertyBoxName ) - bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?aspectOrEntityOrAbstractEntity ), ?aspectOrEntityOrAbstractEntityBoxName, "_To_", ?propertyBoxName ) ) as ?edge ) - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:optional true . - ?propertyNode samm:payloadName ?payloadName - bind( concat( "property (optional) (", str( ?payloadName ), ")" ) as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:optional true . - bind( "property (optional)" as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:notInPayload true . - bind( "property (not in payload)" as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:property ?property . - ?propertyNode samm:payloadName ?payloadName - bind( concat( "property (", str( ?payloadName ), ")" ) as ?title ) - } - - optional { - ?aspectOrEntityOrAbstractEntity 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_2_1_0/aspect2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/aspect2boxmodel.sparql deleted file mode 100644 index 29ad04024..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/aspect2boxmodel.sparql +++ /dev/null @@ -1,74 +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 - -prefix samm: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Aspects -construct { - ?aspectBox a :Box . - ?aspectBox :prototype "Aspect" . - ?aspectBox :title ?aspectName . - ?aspectBox :modelElement ?aspect . - ?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 . - bind( strafter( str( ?aspect ), "#" ) as ?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_2_1_0/aspect2dot.mustache b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/aspect2dot.mustache deleted file mode 100644 index 48bb95449..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_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_2_1_0/boxmodel.ttl b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/boxmodel.ttl deleted file mode 100644 index 833880a1c..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/boxmodel.ttl +++ /dev/null @@ -1,102 +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 -@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_2_1_0/boxmodel2dot.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/boxmodel2dot.sparql deleted file mode 100644 index 6239efdde..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/boxmodel2dot.sparql +++ /dev/null @@ -1,104 +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 - -prefix samm: -prefix rdf: -prefix rdfs: -prefix xsd: -prefix sh: -prefix : - -# Transforms a box model (boxes and edges) into Graphviz/dot statements -select ?dotStatement -where { - # Boxes - { - ?box a :Box . - ?box :title ?givenTitle . - - optional { - ?box :modelElement ?modelElement . - bind( concat( strbefore( str( ?modelElement ), "#" ), "#" ) as ?modelElementRdfNamespace ) - - samm:prefixDeclarations sh:declare ?declaration . - ?declaration sh:prefix ?rdfPrefix . - ?declaration sh:namespace ?rdfNamespace . - filter( str( ?rdfNamespace ) = str( ?modelElementRdfNamespace ) ) - bind( concat( str( ?rdfPrefix ), ":" ) as ?titlePrefix ) - } - - bind( concat( coalesce( ?titlePrefix, "" ), ?givenTitle ) as ?title ) - - optional { - ?box :prototype ?prototype . - } - bind( coalesce( concat( " «", ?prototype, "»\\n" ), "" ) as ?prototypeString ) - - # Show only boxes that are reachable via an edge from the Aspect - [] :rootElement ?aspect . - ?aspectBox a :Box . - ?aspectBox :modelElement ?aspect . - filter( exists { ?aspectBox (^:from/:to)* ?box } ) - - 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 . - - # Show only boxes that are reachable via an edge from the Aspect - [] :rootElement ?aspect . - ?aspectBox a :Box . - ?aspectBox :modelElement ?aspect . - filter( exists { ?aspectBox (^:from/: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_2_1_0/characteristic-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-characteristic-edges2boxmodel.sparql deleted file mode 100644 index 3d065b14d..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-characteristic-edges2boxmodel.sparql +++ /dev/null @@ -1,36 +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 - -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 { - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - ?characteristic samm-c:baseCharacteristic ?baseCharacteristic . - bind( func:getElementName( ?baseCharacteristic ) as ?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_2_1_0/characteristic-constraint-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-constraint-edges2boxmodel.sparql deleted file mode 100644 index f7bd12d4d..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-constraint-edges2boxmodel.sparql +++ /dev/null @@ -1,41 +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 - -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 . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from ) - - bind( func:getElementName( ?constraint ) as ?constraintName ) - bind( concat( ?constraintName, "Constraint" ) 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_2_1_0/characteristic-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-entity-edges2boxmodel.sparql deleted file mode 100644 index 35ed1ed51..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-entity-edges2boxmodel.sparql +++ /dev/null @@ -1,42 +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 - -prefix samm: -prefix samm-e: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates edges between Characteristic and Entities or Abstract Entities (dataType) -construct { - ?edge a :Edge . - ?edge :title "dataType" . - ?edge :from ?from . - ?edge :to ?to . -} where { - ?characteristic samm:dataType ?entityOrAbstractEntity . - filter( ! strstarts( str( ?entityOrAbstractEntity ), str( xsd: ) ) - && ! strstarts( str( ?entityOrAbstractEntity ), str( rdf: ) ) - && ! strstarts( str( ?entityOrAbstractEntity ), str ( samm-e: ) ) ) - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - bind( strafter( str( ?entityOrAbstractEntity ), "#" ) as ?entityOrAbstractEntityName ) . - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from ) - - ?entityOrAbstractEntity rdf:type ?entityOrAbstractEntityClass - bind( str(?entityOrAbstractEntityClass) as ?entityOrAbstractEntityFullClassName ) . - bind( strafter(?entityOrAbstractEntityFullClassName, "#") as ?entityOrAbstractEntityTypeName ) . - bind( concat( ?entityOrAbstractEntityName, ?entityOrAbstractEntityTypeName ) as ?entityOrAbstractEntityBoxName ) - bind( iri( concat( func:getNamespace( ?entityOrAbstractEntity ), ?entityOrAbstractEntityBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?entityOrAbstractEntityBoxName ) ) as ?edge ) -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-metamodelnode-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-metamodelnode-edges2boxmodel.sparql deleted file mode 100644 index 3cd88803b..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic-metamodelnode-edges2boxmodel.sparql +++ /dev/null @@ -1,38 +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 - -prefix samm: -prefix rdf: -prefix rdfs: -prefix : -prefix func: -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 ) ) - bind( func:getElementName( ?characteristic ) as ?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_2_1_0/characteristic2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic2boxmodel.sparql deleted file mode 100644 index 3f0c9d5d3..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/characteristic2boxmodel.sparql +++ /dev/null @@ -1,116 +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 - -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 :modelElement ?characteristic . - ?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 } ) - - bind( func:getElementName( ?characteristic ) as ?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_2_1_0/collection-elementcharacteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/collection-elementcharacteristic-edges2boxmodel.sparql deleted file mode 100644 index 3aba7c3ed..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/collection-elementcharacteristic-edges2boxmodel.sparql +++ /dev/null @@ -1,36 +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 - -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-c:elementCharacteristic ?elementCharacteristic . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - bind( func:getElementName( ?elementCharacteristic ) as ?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_2_1_0/collection2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/collection2boxmodel.sparql deleted file mode 100644 index 5f32cf236..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/collection2boxmodel.sparql +++ /dev/null @@ -1,156 +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 - -prefix mmm: -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 + Collection" . - ?characteristicBox :title ?characteristicName . - ?characteristicBox :modelElement ?characteristic . - ?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 . - } ) - - bind( func:getElementName( ?characteristic ) as ?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 } ) - bind( func:getElementName( ?char ) as ?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 ) - bind( func:getElementName( ?char ) as ?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_2_1_0/constraint2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/constraint2boxmodel.sparql deleted file mode 100644 index 2afb9fd53..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/constraint2boxmodel.sparql +++ /dev/null @@ -1,214 +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 - -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 :modelElement ?constraint . - ?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 . - } ) - - bind( func:getElementName( ?constraint ) as ?constraintName ) - bind( iri( concat( func:getNamespace( ?constraint ), ?constraintName ) ) 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_2_1_0/either-left-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/either-left-characteristic-edges2boxmodel.sparql deleted file mode 100644 index 219e6af47..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/either-left-characteristic-edges2boxmodel.sparql +++ /dev/null @@ -1,38 +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 - -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 . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - ?characteristic samm-c:left ?leftTypeCharacteristic . - bind( func:getElementName( ?leftTypeCharacteristic ) as ?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_2_1_0/either-right-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/either-right-characteristic-edges2boxmodel.sparql deleted file mode 100644 index f3c8f9268..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/either-right-characteristic-edges2boxmodel.sparql +++ /dev/null @@ -1,38 +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 - -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 . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - ?characteristic samm-c:right ?rightTypeCharacteristic . - bind( func:getElementName( ?rightTypeCharacteristic ) as ?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_2_1_0/either2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/either2boxmodel.sparql deleted file mode 100644 index befe74858..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/either2boxmodel.sparql +++ /dev/null @@ -1,91 +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 - -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 :modelElement ?characteristic . - ?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 . - } ) - - bind( func:getElementName( ?characteristic ) as ?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_2_1_0/entity-abstractentity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity-abstractentity-edges2boxmodel.sparql deleted file mode 100644 index fce2acfa5..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity-abstractentity-edges2boxmodel.sparql +++ /dev/null @@ -1,47 +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 - -prefix samm: -prefix samm-e: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates edges between Aspects or Entities or Abstract Entities and Properties -construct { - ?edge a :Edge . - ?edge :title "extends" . - ?edge :from ?from . - ?edge :to ?to . -} where { - ?extendingEntityOrAbstractEntity samm:extends ?extendedEntityOrAbstractEntity . - - bind( strafter( str( ?extendingEntityOrAbstractEntity ), "#" ) as ?extendingEntityOrAbstractEntityName ) . - bind( strafter( str( ?extendedEntityOrAbstractEntity ), "#" ) as ?extendedEntityOrAbstractEntityName ) . - - ?extendingEntityOrAbstractEntity rdf:type ?extendingEntityOrAbstractEntityClass . - ?extendedEntityOrAbstractEntity rdf:type ?extendedEntityOrAbstractEntityClass . - - bind( str(?extendingEntityOrAbstractEntityClass) as ?extendingEntityOrAbstractEntityFullClassName ) . - bind( strafter(?extendingEntityOrAbstractEntityFullClassName, "#") as ?extendingEntityOrAbstractEntityTypeName ) . - - bind( str(?extendedEntityOrAbstractEntityClass) as ?extendedEntityOrAbstractEntityFullClassName ) . - bind( strafter(?extendedEntityOrAbstractEntityFullClassName, "#") as ?extendedEntityOrAbstractEntityTypeName ) . - - bind( concat( ?extendingEntityOrAbstractEntityName, ?extendingEntityOrAbstractEntityTypeName ) as ?extendingEntityOrAbstractEntityBoxName ) . - bind( iri( concat( func:getNamespace( ?extendingEntityOrAbstractEntity ), ?extendingEntityOrAbstractEntityBoxName ) ) as ?from ) . - - bind( concat( ?extendedEntityOrAbstractEntityName, ?extendedEntityOrAbstractEntityTypeName ) as ?extendedEntityOrAbstractEntityBoxName ) . - bind( iri( concat( func:getNamespace( ?extendedEntityOrAbstractEntity ), ?extendedEntityOrAbstractEntityBoxName ) ) as ?to ) . - - bind( iri( concat( func:getNamespace( ?extendingEntityOrAbstractEntity ), ?extendingEntityOrAbstractEntityBoxName, "_To_", ?extendedEntityOrAbstractEntityBoxName ) ) as ?edge ) . -} \ No newline at end of file diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity-abstractproperty-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity-abstractproperty-edges2boxmodel.sparql deleted file mode 100644 index f07ffec60..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity-abstractproperty-edges2boxmodel.sparql +++ /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 - -prefix samm: -prefix samm-e: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates edges between Entities and Abstract Properties, -# as well as an intermediary node between the Entity and the Abstract Property -# for the implementation of the Property itself, which is then linked to the used Characteristic -construct { - ?edge1 a :Edge . - ?edge1 :title "property" . - ?edge1 :from ?entityBox . - ?edge1 :to ?box . - - ?box a :Box . - ?box :title ?boxTitle . - - ?edge2 a :Edge . - ?edge2 :title "characteristic" . - ?edge2 :from ?box . - ?edge2 :to ?characteristicBox . - - ?edge3 a :Edge . - ?edge3 :title "extends" . - ?edge3 :from ?box . - ?edge3 :to ?propertyBox . -} where { - ?entity rdf:type samm:Entity . - - bind( strafter( str( ?entity ), "#" ) as ?entityName ) . - - ?property rdf:type samm:AbstractProperty . - - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - filter( exists { ?entity samm:properties/rdf:rest*/rdf:first/samm:extends ?property } ) - - bind( concat( ?entityName, "Entity" ) as ?entityBoxName ) - bind( iri( concat( func:getNamespace( ?entity ), ?entityBoxName ) ) as ?entityBox ) - - bind( concat( ?entityName, ?propertyName, "Usage" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?property ), ?boxName ) ) as ?box ) - bind( concat( "Usage of ", ?propertyName, " in ", ?entityName ) as ?boxTitle ) - - bind( concat( ?propertyName, "AbstractProperty" ) as ?propertyBoxName ) - bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?propertyBox ) - - bind( iri( concat( func:getNamespace( ?entity ), ?entityBoxName, "_To_", ?boxName ) ) as ?edge1 ) - bind( iri( concat( func:getNamespace( ?property ), ?boxName, "_To_", ?propertyBoxName ) ) as ?edge3 ) - - ?entity samm:properties/rdf:rest*/rdf:first ?propertyNode . - ?propertyNode samm:extends ?property . - ?propertyNode samm:characteristic ?characteristic . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?characteristicBox ) - bind( iri( concat( func:getNamespace( ?property ), ?boxName, "_To_", ?characteristicBoxName ) ) as ?edge2 ) -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity2boxmodel.sparql deleted file mode 100644 index 4b08518c7..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entity2boxmodel.sparql +++ /dev/null @@ -1,75 +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 - -prefix samm: -prefix samm-e: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Entities -construct { - ?entityBox a :Box . - ?entityBox :prototype "Entity" . - ?entityBox :title ?entityName . - ?entityBox :modelElement ?entity . - ?entityBox :entries ( - [ - a :Entry ; - :title "preferredName" ; - :text ?preferredName - ] - [ - a :Entry ; - :title "description" ; - :text ?description - ] - [ - a :Entry ; - :title "see" ; - :text ?seeValues - ] - ) -} where { - ?entity rdf:type samm:Entity . - bind( strafter( str( ?entity ), "#" ) as ?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 rdf:type samm:Entity . - ?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_2_1_0/entityinstance-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entityinstance-entity-edges2boxmodel.sparql deleted file mode 100644 index 8c9e4baa2..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entityinstance-entity-edges2boxmodel.sparql +++ /dev/null @@ -1,49 +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 - -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_2_1_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql deleted file mode 100644 index 224169e5e..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql +++ /dev/null @@ -1,65 +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 - -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 . - bind( strafter( str( ?property ), "#" ) as ?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_2_1_0/entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entityinstance2boxmodel.sparql deleted file mode 100644 index 1c2baa152..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/entityinstance2boxmodel.sparql +++ /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 - -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 :modelElement ?instance . - ?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 . - } ) - - bind( strafter( str( ?entity ), "#" ) as ?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 } ) . - - bind( strafter( str( ?property ), "#" ) as ?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_2_1_0/enumeration-entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/enumeration-entityinstance2boxmodel.sparql deleted file mode 100644 index 19d195260..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_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} ) - - bind( func:getElementName( ?characteristic ) as ?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_2_1_0/enumeration2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/enumeration2boxmodel.sparql deleted file mode 100644 index f8d5428e6..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/enumeration2boxmodel.sparql +++ /dev/null @@ -1,177 +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 - -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 :modelElement ?characteristic . - ?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 } ) - - bind( func:getElementName( ?characteristic ) as ?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_2_1_0/metamodelnode2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/metamodelnode2boxmodel.sparql deleted file mode 100644 index 720edeb76..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/metamodelnode2boxmodel.sparql +++ /dev/null @@ -1,32 +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 - -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_2_1_0/operation-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/operation-property-edges2boxmodel.sparql deleted file mode 100644 index c367a5778..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/operation-property-edges2boxmodel.sparql +++ /dev/null @@ -1,59 +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 - -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 . - bind( strafter( str( ?operation ), "#" ) as ?operationName ) . - ?operation samm:input/rdf:rest*/rdf:first ?property . - bind( strafter( str( ?property ), "#" ) as ?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 . - bind( strafter( str( ?operation ), "#" ) as ?operationName ) . - ?operation samm:output ?property . - bind( strafter( str( ?property ), "#" ) as ?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_2_1_0/operation2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/operation2boxmodel.sparql deleted file mode 100644 index bbdab5037..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/operation2boxmodel.sparql +++ /dev/null @@ -1,77 +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 - -prefix samm: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Operations -construct { - ?operationBox a :Box . - ?operationBox :prototype "Operation" . - ?operationBox :title ?operationName . - ?operationBox :modelElement ?operation . - ?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 . - - bind( strafter( str( ?operation ), "#" ) as ?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_2_1_0/property-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/property-characteristic-edges2boxmodel.sparql deleted file mode 100644 index 0f3a4bd72..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/property-characteristic-edges2boxmodel.sparql +++ /dev/null @@ -1,41 +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 - -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 rdf:type samm:Property . - - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - ?property samm:characteristic ?characteristic . - bind( func:getElementName( ?characteristic ) as ?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_2_1_0/property2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/property2boxmodel.sparql deleted file mode 100644 index 642ca61a5..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/property2boxmodel.sparql +++ /dev/null @@ -1,92 +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 - -prefix samm: -prefix samm-e: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Properties -construct { - ?propertyBox a :Box . - ?propertyBox :prototype "Property" . - ?propertyBox :title ?propertyName . - ?propertyBox :modelElement ?property . - ?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 rdf:type samm:Property . - bind( strafter( str( ?property ), "#" ) as ?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 rdf:type samm:Property . - filter( str( ?subQueryProperty ) = str( ?property ) ) - { - select ?subQueryProperty ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) - where { - select * - where { - ?subQueryProperty 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_2_1_0/quantifiable-unit-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/quantifiable-unit-edges2boxmodel.sparql deleted file mode 100644 index 9db7e0af4..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/quantifiable-unit-edges2boxmodel.sparql +++ /dev/null @@ -1,40 +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 - -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 rdf:type samm:Property . - filter( exists { ?property samm:characteristic/( samm-c:baseCharacteristic* | rdfs:subClassOf* ) ?quantifiable } ) - bind( func:getElementName( ?quantifiable ) as ?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_2_1_0/quantitykind2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/quantitykind2boxmodel.sparql deleted file mode 100644 index ac8ecfe78..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/quantitykind2boxmodel.sparql +++ /dev/null @@ -1,32 +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 - -prefix samm: -prefix samm-c: -prefix rdf: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for QuantityKinds -construct { - ?quantityKindBox a :Box . - ?quantityKindBox :prototype "QuantityKind" . - ?quantityKindBox :title ?upperQuantityKindName . - ?quantityKindBox :modelElement ?quantityKind . - ?quantityKindBox :entries () -} where { - [] samm-c:unit/samm:referenceUnit?/samm:quantityKind ?quantityKind . - bind( strafter( str( ?quantityKind ), "#" ) as ?quantityKindName ) . - bind( concat( ucase( substr( ?quantityKindName, 1, 1 ) ), substr( ?quantityKindName, 2 ) ) as ?upperQuantityKindName ) - bind( concat( replace( ?upperQuantityKindName, "-", "" ), "QuantityKind" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?quantityKind ), ?boxName ) ) as ?quantityKindBox ) -} diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/structuredvalue-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/structuredvalue-property-edges2boxmodel.sparql deleted file mode 100644 index feb50af10..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/structuredvalue-property-edges2boxmodel.sparql +++ /dev/null @@ -1,40 +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 - -prefix samm: -prefix samm-c: -prefix rdf: -prefix rdfs: -prefix : -prefix func: - -# Generates edges between StructuredValues its elements Properties -construct { - ?edge a :Edge . - ?edge :title ?propertyName . - ?edge :from ?from . - ?edge :to ?to . -} where { - ?characteristic rdf:type/rdfs:subClassOf* samm-c:StructuredValue . - bind( func:getElementName( ?characteristic ) as ?characteristicName ) - - bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName ) - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from ) - - ?characteristic samm-c:elements/rdf:rest*/rdf:first ?property . - filter( exists { ?property a samm:Property } ) - bind( strafter( str( ?property ), "#" ) as ?propertyName ) . - bind( concat( ?propertyName, "Property" ) as ?propertyBoxName ) - bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?propertyBoxName ) ) as ?edge ) -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/structuredvalue2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/structuredvalue2boxmodel.sparql deleted file mode 100644 index 66c491776..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/structuredvalue2boxmodel.sparql +++ /dev/null @@ -1,131 +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 - -prefix samm: -prefix samm-c: -prefix rdf: -prefix rdfs: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for StrucuredValue Characteristics -construct { - ?characteristicBox a :Box . - ?characteristicBox :prototype "Characteristic" . - ?characteristicBox :title ?characteristicName . - ?characteristicBox :modelElement ?characteristic . - ?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 - ] - [ - a :Entry ; - :title "deconstructionRule" ; - :text ?deconstructionRule - ] - [ - a :Entry ; - :title "elements" ; - :text ?elementsList - ] - ) -} where { - ?characteristic rdf:type/rdfs:subClassOf* samm-c:StructuredValue . - - # 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 . - } ) - - bind( func:getElementName( ?characteristic ) as ?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 - } - } - } - } - - ?characteristic samm-c:deconstructionRule ?rule0 . - bind( replace( str( ?rule0 ), "\\\\", "\\\\\\\\" ) as ?rule1 ) - bind( replace( ?rule1, "\\|", "\\\\|" ) as ?deconstructionRule ) - - ?characteristic samm-c:elements ?elements . - { - select ?characteristic ( group_concat( ?elementsListPart; separator=" " ) as ?elementsList ) - where { - ?characteristic samm-c:elements ?elements . - ?elements rdf:rest*/rdf:first ?listEntry . - bind( strafter( str( ?listEntry ), "#" ) as ?propertyName ) . - bind( if ( exists { ?listEntry a samm:Property }, ?propertyName, concat( "'", str( ?listEntry), "'" ) ) as ?elementsListPart ) - } - group by ?characteristic - } -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/unit-quantitykind-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/unit-quantitykind-edges2boxmodel.sparql deleted file mode 100644 index 2d35cf9dc..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/unit-quantitykind-edges2boxmodel.sparql +++ /dev/null @@ -1,40 +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 - -prefix samm: -prefix samm-c: -prefix rdf: -prefix : -prefix func: - -# Generates edges between Units and QuantityKinds (quantityKind) -construct { - ?edge a :Edge . - ?edge :title "quantityKind" . - ?edge :from ?from . - ?edge :to ?to . -} where { - [] samm-c:unit ?unit . - ?unit samm:referenceUnit?/samm:quantityKind ?quantityKind . - bind( strafter( str( ?unit ), "#" ) as ?unitName ) . - bind( concat( ucase( substr( ?unitName, 1, 1 ) ), substr( ?unitName, 2 ) ) as ?upperUnitName ) - bind( strafter( str( ?quantityKind ), "#" ) as ?quantityKindGivenName ) . - bind( concat( ?quantityKindGivenName, "QuantityKind" ) as ?quantityKindName ) - bind( concat( ucase( substr( ?quantityKindName, 1, 1 ) ), substr( ?quantityKindName, 2 ) ) as ?upperQuantityKindName ) - - bind( concat( ?upperUnitName, "Unit" ) as ?unitBoxName ) - bind( iri( concat( func:getNamespace( ?unit ), ?unitBoxName ) ) as ?from ) - bind( replace( ?upperQuantityKindName, "-", "" ) as ?quantityKindBoxName ) - bind( iri( concat( func:getNamespace( ?quantityKind ), ?quantityKindBoxName ) ) as ?to ) - - bind( iri( concat( func:getNamespace( ?unit ), ?unitBoxName, "_To_", ?quantityKindBoxName ) ) as ?edge ) -} - diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/unit2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/unit2boxmodel.sparql deleted file mode 100644 index 879ca5c03..000000000 --- a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_1_0/unit2boxmodel.sparql +++ /dev/null @@ -1,46 +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 - -prefix samm: -prefix samm-c: -prefix rdf: -prefix rdfs: -prefix xsd: -prefix : -prefix func: - -# Generates boxes for Units -construct { - ?unitBox a :Box . - ?unitBox :prototype "Unit" . - ?unitBox :title ?upperUnitName . - ?unitBox :modelElement ?unit . - ?unitBox :entries ( - [ - a :Entry ; - :title "symbol" ; - :text ?symbol - ] - ) -} where { - ?measurement samm-c:unit ?unit . - # Select only those Units that are used in the Aspect - filter( exists { ?property samm:characteristic/( samm-c:baseCharacteristic* | rdfs:subClassOf* ) ?measurement } ) - bind( strafter( str( ?unit ), "#" ) as ?unitName ) . - bind( concat( ucase( substr( ?unitName, 1, 1 ) ), substr( ?unitName, 2 ) ) as ?upperUnitName ) - - bind( concat( ?upperUnitName, "Unit" ) as ?boxName ) - bind( iri( concat( func:getNamespace( ?unit ), ?boxName ) ) as ?unitBox ) - - optional { - ?unit samm:symbol ?symbol - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractConstraint2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractConstraint2BoxModelTest.java deleted file mode 100644 index 58de7473c..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractConstraint2BoxModelTest.java +++ /dev/null @@ -1,49 +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.HashMap; -import java.util.Map; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; - -import org.junit.jupiter.api.BeforeAll; - -public abstract class AbstractConstraint2BoxModelTest extends MetaModelVersions { - - static Map totalNumberOfExpectedEntriesPerMetaModelVersion; - - final String sparqlQueryFileName = "constraint2boxmodel.sparql"; - - protected String boxSelectorStatement( final String constraintIdentifier, - final boolean isConstraintAnonymous ) { - final String ns = isConstraintAnonymous ? ":" : "test:"; - return String.format( "%s a :Box", constraintIdentifier.equals( "*" ) ? "*" : ns + constraintIdentifier ); - } - - protected String entriesSelectorStatement( final String constraintIdentifier, - final boolean isConstraintAnonymous ) { - final String ns = isConstraintAnonymous ? ":" : "test:"; - return String.format( "%s :entries *", constraintIdentifier.equals( "*" ) ? "*" : ns + constraintIdentifier ); - } - - @BeforeAll - public static void setup() { - totalNumberOfExpectedEntriesPerMetaModelVersion = new HashMap<>(); - totalNumberOfExpectedEntriesPerMetaModelVersion.put( KnownVersion.SAMM_1_0_0, 10 ); - totalNumberOfExpectedEntriesPerMetaModelVersion.put( KnownVersion.SAMM_2_0_0, 10 ); - totalNumberOfExpectedEntriesPerMetaModelVersion.put( KnownVersion.SAMM_2_1_0, 10 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractEntity2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractEntity2BoxModelTest.java deleted file mode 100644 index 6afd10cc3..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AbstractEntity2BoxModelTest.java +++ /dev/null @@ -1,55 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class AbstractEntity2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "abstractentity2boxmodel.sparql"; - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - public void testEntityExtendingAbstractEntity( final KnownVersion metaModelVersion ) { - testAbstractEntity( TestAspect.ASPECT_WITH_ABSTRACT_ENTITY, metaModelVersion ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - public void testAspectWithAbstractSingleEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testAbstractEntity( TestAspect.ASPECT_WITH_ABSTRACT_SINGLE_ENTITY, metaModelVersion ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - public void testCollectionWithAbstractEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testAbstractEntity( TestAspect.ASPECT_WITH_COLLECTION_WITH_ABSTRACT_ENTITY, metaModelVersion ); - } - - private void testAbstractEntity( final TestAspect testAspect, final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( testAspect, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "test:AbstractTestEntityAbstractEntity a :Box" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:AbstractTestEntityAbstractEntity :title AbstractTestEntity" ) ).toList() ).hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Aspect2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Aspect2BoxModelTest.java deleted file mode 100644 index cb77f13cd..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Aspect2BoxModelTest.java +++ /dev/null @@ -1,114 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class Aspect2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "aspect2boxmodel.sparql"; - private final int totalNumberOfExpectedEntries = 3; - private final int indexOfSeeValueEntry = 2; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_SEE_ATTRIBUTE, metaModelVersion ); - final String boxSelectorStatement = "test:AspectWithSeeAttributeAspect a :Box"; - final String entriesSelectorStatement = "test:AspectWithSeeAttributeAspect :entries *"; - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_MULTIPLE_SEE_ATTRIBUTES, metaModelVersion ); - final String boxSelectorStatement = "test:AspectWithMultipleSeeAttributesAspect a :Box"; - final String entriesSelectorStatement = "test:AspectWithMultipleSeeAttributesAspect :entries *"; - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, - "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITHOUT_SEE_ATTRIBUTE, metaModelVersion ); - final String boxSelectorStatement = "test:AspectWithoutSeeAttributeAspect a :Box"; - final String entriesSelectorStatement = "test:AspectWithoutSeeAttributeAspect :entries *"; - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testAspectWithProperty( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_PROPERTY, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyAspect_To_testPropertyProperty a :Edge" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyAspect_To_testPropertyProperty :title property" ) ).toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testAspectWithOptionalProperty( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_OPTIONAL_PROPERTY, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( context.selector( "test:AspectWithOptionalPropertyAspect_To_testPropertyProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:AspectWithOptionalPropertyAspect_To_testPropertyProperty :title property (optional)" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testAspectWithPropertyWithPayloadName( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_PROPERTY_WITH_PAYLOAD_NAME, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyWithPayloadNameAspect_To_testPropertyProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:AspectWithPropertyWithPayloadNameAspect_To_testPropertyProperty :title property (test)" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testAspectWithOptionalPropertyWithPayloadName( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_OPTIONAL_PROPERTY_WITH_PAYLOAD_NAME, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( context.selector( "test:AspectWithOptionalPropertyWithPayloadNameAspect_To_testPropertyProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( - queryResult.listStatements( - context.selector( "test:AspectWithOptionalPropertyWithPayloadNameAspect_To_testPropertyProperty :title property (optional) (test)" ) ) - .toList() ).hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGeneratorTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGeneratorTest.java index 9206f0be4..3e780e531 100644 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGeneratorTest.java +++ b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGeneratorTest.java @@ -13,45 +13,34 @@ package org.eclipse.esmf.aspectmodel.generator.diagram; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.Locale; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - +import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel; +import org.eclipse.esmf.metamodel.Aspect; +import org.eclipse.esmf.metamodel.AspectContext; +import org.eclipse.esmf.metamodel.loader.AspectModelLoader; import org.eclipse.esmf.samm.KnownVersion; import org.eclipse.esmf.test.MetaModelVersions; import org.eclipse.esmf.test.TestAspect; +import org.eclipse.esmf.test.TestResources; -public class AspectModelDiagramGeneratorTest extends MetaModelVersions { +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +public class AspectModelDiagramGeneratorTest extends MetaModelVersions { @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testAspectWithRecursivePropertyWithOptional( final KnownVersion metaModelVersion ) throws IOException { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_RECURSIVE_PROPERTY_WITH_OPTIONAL, - metaModelVersion ); - final ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - context.service().generateDiagram( AspectModelDiagramGenerator.Format.DOT, Locale.ENGLISH, outStream ); - final String result = outStream.toString( StandardCharsets.UTF_8 ); - - // Aspect Node - assertThat( result ).containsOnlyOnce( "testPropertyProperty [label=\"{ «Property»\\ntestProperty|}\"]" ); - assertThat( result ).containsOnlyOnce( "TestEntityEntity [label=\"{ «Entity»\\nTestEntity|}\"]" ); - assertThat( result ).containsOnlyOnce( - "testItemCharacteristicCharacteristic [label=\"{ «Characteristic»\\ntestItemCharacteristic|}\"]" ); - assertThat( result ).containsOnlyOnce( - "AspectWithRecursivePropertyWithOptionalAspect [label=\"{ «Aspect»\\nAspectWithRecursivePropertyWithOptional|}\"]" ); - assertThat( result ).containsOnlyOnce( - "testPropertyProperty -> testItemCharacteristicCharacteristic [label=\"characteristic\"]" ); - assertThat( result ) - .containsOnlyOnce( "testItemCharacteristicCharacteristic -> TestEntityEntity [label=\"dataType\"]" ); - assertThat( result ) - .containsOnlyOnce( "TestEntityEntity -> testPropertyProperty [label=\"property (optional)\"]" ); - assertThat( result ).containsOnlyOnce( - "AspectWithRecursivePropertyWithOptionalAspect -> testPropertyProperty [label=\"property\"]" ); + @EnumSource( value = TestAspect.class ) + void testGen( final TestAspect testAspect ) { + final VersionedModel versionedModel = TestResources.getModel( testAspect, KnownVersion.getLatest() ).get(); + final Aspect aspect = AspectModelLoader.getSingleAspect( versionedModel ).getOrElseThrow( () -> new RuntimeException() ); + final AspectContext context = new AspectContext( versionedModel, aspect ); + final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( context ); + assertThatCode( () -> { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + generator.generateDiagram( AspectModelDiagramGenerator.Format.SVG, Locale.ENGLISH, out ); + } ).doesNotThrowAnyException(); } } diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Characteristic2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Characteristic2BoxModelTest.java deleted file mode 100644 index 7fb9d31e1..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Characteristic2BoxModelTest.java +++ /dev/null @@ -1,107 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class Characteristic2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "characteristic2boxmodel.sparql"; - private final String boxSelectorStatement = "test:TestCharacteristicCharacteristic a :Box"; - private final String entriesSelectorStatement = "test:TestCharacteristicCharacteristic :entries *"; - private final int totalNumberOfExpectedEntries = 4; - private final int indexOfSeeValueEntry = 3; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testOnlyUsedCharacteristicsAreProcessedExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_USED_AND_UNUSED_CHARACTERISTIC, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "test:UsedTestCharacteristicCharacteristic a :Box" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:UnusedTestCharacteristicCharacteristic a :Box" ) ).toList() ).hasSize( 0 ); - assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ).hasSize( totalNumberOfExpectedEntries ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_CHARACTERISTIC_WITH_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_CHARACTERISTIC_WITH_MULTIPLE_SEE_ATTRIBUTES, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, - "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_CHARACTERISTIC_WITHOUT_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsNotPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - public void testAspectWithAbstractEntityExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ABSTRACT_ENTITY, metaModelVersion ); - - final Model queryResult = context.executeQuery( "characteristic-entity-edges2boxmodel.sparql" ); - - assertThat( queryResult - .listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult - .listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :from test:EntityCharacteristicCharacteristic" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult - .listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :to test:ExtendingTestEntityEntity" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - public void testAspectWithAbstractSingleEntityExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ABSTRACT_SINGLE_ENTITY, metaModelVersion ); - - final Model queryResult = context.executeQuery( "characteristic-entity-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :from test:EntityCharacteristicCharacteristic" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:EntityCharacteristicCharacteristic_To_ExtendingTestEntityEntity :to test:ExtendingTestEntityEntity" ) ) - .toList() ).hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Collection2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Collection2BoxModelTest.java deleted file mode 100644 index ad5cfcb0c..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Collection2BoxModelTest.java +++ /dev/null @@ -1,109 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class Collection2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "collection2boxmodel.sparql"; - private final String boxSelectorStatement = "test:TestCollectionCharacteristic a :Box"; - private final String entriesSelectorStatement = "test:TestCollectionCharacteristic :entries *"; - private final int totalNumberOfExpectedEntries = 6; - private final int indexOfSeeValueEntry = 5; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testOnlyUsedCollectionsAreProcessedExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_USED_AND_UNUSED_COLLECTION, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "test:UsedTestCollectionCharacteristic a :Box" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:UnusedTestCollectionCharacteristic a :Box" ) ).toList() ).hasSize( 0 ); - assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ).hasSize( totalNumberOfExpectedEntries ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_COLLECTION_WITH_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_COLLECTION_WITH_MULTIPLE_SEE_ATTRIBUTES, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_COLLECTION_WITHOUT_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsNotPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testCollectionWithElementCharacteristicExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_COLLECTIONS_WITH_ELEMENT_CHARACTERISTIC_AND_SIMPLE_DATA_TYPE, metaModelVersion ); - - final Model queryResult = context.executeQuery( "collection-elementcharacteristic-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic a :Edge" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic :to samm-c:TextCharacteristic" ) ) - .toList() ).hasSize( 1 ); - assertThat( - queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic :from test:TestCollectionTwoCharacteristic" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:TestCollectionTwoCharacteristic_To_TextCharacteristic :title element Characteristic" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - public void testCollectionWithAbstractEntityExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_COLLECTION_WITH_ABSTRACT_ENTITY, metaModelVersion ); - - final Model queryResult = context.executeQuery( "characteristic-entity-edges2boxmodel.sparql" ); - - assertThat( queryResult - .listStatements( context.selector( "test:EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult - .listStatements( context.selector( - "test:EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity :from test:EntityCollectionCharacteristicCharacteristic" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult - .listStatements( context.selector( - "test:EntityCollectionCharacteristicCharacteristic_To_AbstractTestEntityAbstractEntity :to test:AbstractTestEntityAbstractEntity" ) ) - .toList() ).hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Constraint2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Constraint2BoxModelTest.java deleted file mode 100644 index 4e60d8525..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Constraint2BoxModelTest.java +++ /dev/null @@ -1,93 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.TestAspect; - -class Constraint2BoxModelTest extends AbstractConstraint2BoxModelTest { - private final static String EXPECTED_VALUE_ENTRY_TITLE = "value"; - private final static String EXPECTED_SEE_ENTRY_TITLE = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testOnlyUsedConstraintsAreProcessedExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_USED_AND_UNUSED_CONSTRAINT, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "* a :Box" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ).hasSize( 5 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final String constraintIdentifier = "*"; - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_CONSTRAINT_WITH_MULTIPLE_SEE_ATTRIBUTES, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), - totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 5, - EXPECTED_SEE_ENTRY_TITLE, - "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final String constraintIdentifier = "*"; - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_CONSTRAINT_WITHOUT_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), - totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), 5 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testRegularExpressionConstraintExpectSuccess( final KnownVersion metaModelVersion ) { - final String constraintIdentifier = "*"; - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_NUMERIC_REGULAR_EXPRESSION_CONSTRAINT, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), - totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 4, - EXPECTED_VALUE_ENTRY_TITLE, "\\\\d*\\|x" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testFixedPointConstraintExpectSuccess( final KnownVersion metaModelVersion ) { - final String constraintIdentifier = "*"; - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_FIXED_POINT_CONSTRAINT, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), - totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 8, "scale", "5" ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), - totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 9, "integer", "3" ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Either2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Either2BoxModelTest.java deleted file mode 100644 index 4380cf57a..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Either2BoxModelTest.java +++ /dev/null @@ -1,76 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class Either2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "either2boxmodel.sparql"; - private final String boxSelectorStatement = "test:TestEitherCharacteristic a :Box"; - private final String entriesSelectorStatement = "test:TestEitherCharacteristic :entries *"; - private final int totalNumberOfExpectedEntries = 3; - private final int indexOfSeeValueEntry = 2; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testOnlyUsedCharacteristicsAreProcessedExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_USED_AND_UNUSED_EITHER, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "test:UsedTestEitherCharacteristic a :Box" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:UnusedTestEitherCharacteristic a :Box" ) ).toList() ) - .hasSize( 0 ); - assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ) - .hasSize( totalNumberOfExpectedEntries ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_EITHER_WITH_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_EITHER_WITH_MULTIPLE_SEE_ATTRIBUTES, - metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_EITHER_WITHOUT_SEE_ATTRIBUTE, - metaModelVersion ); - context.executeAttributeIsNotPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfSeeValueEntry ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Entity2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Entity2BoxModelTest.java deleted file mode 100644 index b1cfb6980..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Entity2BoxModelTest.java +++ /dev/null @@ -1,206 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; -import org.eclipse.esmf.test.TestEntity; - -class Entity2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "entity2boxmodel.sparql"; - private final int totalNumberOfExpectedEntries = 3; - private final int indexOfSeeValueEntry = 2; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.ENTITY_WITH_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, "test:EntityWithSeeAttributeEntity a :Box", - "test:EntityWithSeeAttributeEntity :entries *", - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.ENTITY_WITH_MULTIPLE_SEE_ATTRIBUTES, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, "test:EntityWithMultipleSeeAttributesEntity a :Box", - "test:EntityWithMultipleSeeAttributesEntity :entries *", - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, - "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.ENTITY_WITHOUT_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, "test:EntityWithoutSeeAttributeEntity a :Box", - "test:EntityWithoutSeeAttributeEntity :entries *", - totalNumberOfExpectedEntries, indexOfSeeValueEntry ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributeIsPresentOnSharedEntityExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.SHARED_ENTITY_WITH_SEE_ATTRIBUTE, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "test:SharedEntityWithSeeAttributeEntity a :Box" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "samm-e:SharedEntityEntity a :Box" ) ).toList() ) - .hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testEntityWithOptionalAndNotInPayloadProperty( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.ENTITY_WITH_OPTIONAL_AND_NOT_IN_PAYLOAD_PROPERTY, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( - queryResult.listStatements( context.selector( - "test:EntityWithOptionalAndNotInPayloadPropertyEntity_To_testPropertyOneProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult - .listStatements( context.selector( - "test:EntityWithOptionalAndNotInPayloadPropertyEntity_To_testPropertyOneProperty :title property" ) ) - .toList() ).hasSize( 1 ); - - assertThat( - queryResult.listStatements( context.selector( - "test:EntityWithOptionalAndNotInPayloadPropertyEntity_To_testPropertyTwoProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( - "test:EntityWithOptionalAndNotInPayloadPropertyEntity_To_testPropertyTwoProperty :title property (optional)" ) ) - .toList() ).hasSize( 1 ); - - assertThat( queryResult - .listStatements( context.selector( - "test:EntityWithOptionalAndNotInPayloadPropertyEntity_To_testPropertyThreeProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( - "test:EntityWithOptionalAndNotInPayloadPropertyEntity_To_testPropertyThreeProperty :title property (not in payload)" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testEntityWithOptionalProperty( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.ENTITY_WITH_OPTIONAL_PROPERTY, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( - queryResult.listStatements( context.selector( - "test:EntityWithOptionalPropertyEntity_To_testPropertyProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( - "test:EntityWithOptionalPropertyEntity_To_testPropertyProperty :title property (optional)" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testEntityWithOptionalPropertyWithPayloadName( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.ENTITY_WITH_OPTIONAL_PROPERTY_WITH_PAYLOAD_NAME, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( - queryResult.listStatements( context.selector( - "test:EntityWithOptionalPropertyWithPayloadNameEntity_To_testPropertyProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( - "test:EntityWithOptionalPropertyWithPayloadNameEntity_To_testPropertyProperty :title property (optional) (test)" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testEntityWithPropertyWithPayloadName( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestEntity.ENTITY_WITH_PROPERTY_WITH_PAYLOAD_NAME, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( - queryResult.listStatements( context.selector( - "test:EntityWithPropertyWithPayloadNameEntity_To_testPropertyProperty a :Edge" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( - "test:EntityWithPropertyWithPayloadNameEntity_To_testPropertyProperty :title property (test)" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - void testAspectWithAbstractEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testExtendingEntity( TestAspect.ASPECT_WITH_ABSTRACT_ENTITY, metaModelVersion ); - testExtendingEntityEdges( TestAspect.ASPECT_WITH_ABSTRACT_ENTITY, metaModelVersion ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - void testAspectWithAbstractSingleEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testExtendingEntity( TestAspect.ASPECT_WITH_ABSTRACT_SINGLE_ENTITY, metaModelVersion ); - testExtendingEntityEdges( TestAspect.ASPECT_WITH_ABSTRACT_SINGLE_ENTITY, metaModelVersion ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - void testCollectionWithAbstractEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testExtendingEntity( TestAspect.ASPECT_WITH_COLLECTION_WITH_ABSTRACT_ENTITY, metaModelVersion ); - testExtendingEntityEdges( TestAspect.ASPECT_WITH_COLLECTION_WITH_ABSTRACT_ENTITY, metaModelVersion ); - } - - private void testExtendingEntity( final TestAspect testAspect, final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( testAspect, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "test:ExtendingTestEntityEntity a :Box" ) ).toList() ).hasSize( 1 ); - } - - private void testExtendingEntityEdges( final TestAspect testAspect, final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( testAspect, metaModelVersion ); - - final Model queryResult = context.executeQuery( "entity-abstractentity-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_AbstractTestEntityAbstractEntity a :Edge" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_AbstractTestEntityAbstractEntity :from test:ExtendingTestEntityEntity" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_AbstractTestEntityAbstractEntity :to test:AbstractTestEntityAbstractEntity" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_AbstractTestEntityAbstractEntity :title extends" ) - ).toList() ).hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/EntityInstance2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/EntityInstance2BoxModelTest.java deleted file mode 100644 index ca8a1fbb9..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/EntityInstance2BoxModelTest.java +++ /dev/null @@ -1,188 +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 static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.apache.jena.rdf.model.Literal; -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.RDFNode; -import org.apache.jena.rdf.model.Statement; -import org.apache.jena.rdf.model.StmtIterator; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class EntityInstance2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "entityinstance2boxmodel.sparql"; - private final String entityInstance2EntityInstanceEdgesSparqlQueryFileName = "entityinstance-nestedentityinstance-edges2boxmodel.sparql"; - private final String entityInstance2EntityEdgesSparqlQueryFileName = "entityinstance-entity-edges2boxmodel.sparql"; - private final String boxSelectorStatement = "test:TestEntityInstanceEntityInstance a :Box"; - private final String entriesSelectorStatement = "test:TestEntityInstanceEntityInstance :entry *"; - private final String codePropertyTitleSelectorStatement = "* :title code"; - private final String codePropertyTestSelectorStatement = "* :text 3"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceWithScalarProperties2BoxModelExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_SCALAR_PROPERTIES, - metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertTestEntityInstanceBox( queryResult, context, 2 ); - assertThat( queryResult.listStatements( context.selector( "* :title description" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "* :text foo" ) ).toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceWithScalarListProperty2BoxModelExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_SCALAR_LIST_PROPERTY, - metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertTestEntityInstanceBox( queryResult, context, 2 ); - assertThat( queryResult.listStatements( context.selector( "* :title testList" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "* :text *" ) ) - .mapWith( Statement::getObject ) - .filterKeep( RDFNode::isLiteral ) - .mapWith( RDFNode::asLiteral ) - .mapWith( Literal::getString ) - .toList() ).contains( "3" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceWithNestedEntityListProperty2BoxModelExpectSuccess( - final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( - TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_NESTED_ENTITY_LIST_PROPERTY, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertTestEntityInstanceBox( queryResult, context, 1 ); - - assertNestedEntityInstanceBox( queryResult, context, "NestedEntityInstanceEntityInstance", "bar" ); - assertNestedEntityInstanceBox( queryResult, context, "NestedEntityInstanceTwoEntityInstance", "baz" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceWithNestedEntityProperty2BoxModelExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_NESTED_ENTITY_PROPERTY, - metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertTestEntityInstanceBox( queryResult, context, 1 ); - assertNestedEntityInstanceBox( queryResult, context, "NestedEntityInstanceEntityInstance", "bar" ); - } - - private void assertTestEntityInstanceBox( final Model queryResult, final TestContext context, - final int expectedNumberOfEntries ) { - assertThat( queryResult.listStatements( context.selector( boxSelectorStatement ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( entriesSelectorStatement ) ).toList() ) - .hasSize( expectedNumberOfEntries ); - assertThat( queryResult.listStatements( context.selector( codePropertyTitleSelectorStatement ) ).toList() ) - .hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( codePropertyTestSelectorStatement ) ).toList() ) - .hasSize( 1 ); - } - - private void assertNestedEntityInstanceBox( final Model queryResult, final TestContext context, - final String expectedInstanceBoxName, final String expectedPropertyValue ) { - final StmtIterator nestedEntityBoxStatement = queryResult - .listStatements( context.selector( "test:" + expectedInstanceBoxName + " a :Box" ) ); - assertThat( nestedEntityBoxStatement.toList() ).hasSize( 1 ); - - final List nestedEntityEntries = queryResult - .listStatements( context.selector( "test:" + expectedInstanceBoxName + " :entry *" ) ).toList(); - assertThat( nestedEntityEntries ).hasSize( 1 ); - - final RDFNode entryNode = nestedEntityEntries.get( 0 ).getObject(); - context.assertEntry( List.of( entryNode ), 1, 0, "nestedEntityProperty", expectedPropertyValue ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceToEntityInstanceEdgesWithoutListPropertyExpectSuccess( - final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_NESTED_ENTITY_PROPERTY, - metaModelVersion ); - - final Model queryResult = context.executeQuery( entityInstance2EntityInstanceEdgesSparqlQueryFileName ); - - assertEdge( queryResult, context, "TestEntityInstanceEntityInstance", "NestedEntityInstanceEntityInstance", - "nestedEntity value" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceToEntityInstanceEdgesWithListPropertyExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( - TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_NESTED_ENTITY_LIST_PROPERTY, metaModelVersion ); - - final Model queryResult = context.executeQuery( entityInstance2EntityInstanceEdgesSparqlQueryFileName ); - - assertEdge( queryResult, context, "TestEntityInstanceEntityInstance", "NestedEntityInstanceEntityInstance", - "testList value" ); - assertEdge( queryResult, context, "TestEntityInstanceEntityInstance", "NestedEntityInstanceTwoEntityInstance", - "testList value" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceToEntityEdgesWithoutListPropertyExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_NESTED_ENTITY_PROPERTY, - metaModelVersion ); - - final Model queryResult = context.executeQuery( entityInstance2EntityEdgesSparqlQueryFileName ); - - assertEdge( queryResult, context, "TestEntityInstanceEntityInstance", "TestEntityEntity", "is a" ); - assertEdge( queryResult, context, "NestedEntityInstanceEntityInstance", "NestedEntityEntity", "is a" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEntityInstanceToEntityEdgesWithListPropertyExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( - TestAspect.ASPECT_WITH_ENTITY_INSTANCE_WITH_NESTED_ENTITY_LIST_PROPERTY, metaModelVersion ); - - final Model queryResult = context.executeQuery( entityInstance2EntityEdgesSparqlQueryFileName ); - - assertEdge( queryResult, context, "TestEntityInstanceEntityInstance", "TestEntityEntity", "is a" ); - assertEdge( queryResult, context, "NestedEntityInstanceEntityInstance", "NestedEntityEntity", "is a" ); - assertEdge( queryResult, context, "NestedEntityInstanceTwoEntityInstance", "NestedEntityEntity", "is a" ); - } - - private void assertEdge( final Model queryResult, final TestContext context, final String fromBoxName, - final String toBoxName, final String title ) { - final String edgeName = fromBoxName + "_To_" + toBoxName; - - assertThat( queryResult.listStatements( context.selector( "test:" + edgeName + " a :Edge" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:" + edgeName + " :to test:" + toBoxName ) ).toList() ) - .hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:" + edgeName + " :from test:" + fromBoxName ) ).toList() ) - .hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:" + edgeName + " :title " + title ) ).toList() ) - .hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Enumeration2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Enumeration2BoxModelTest.java deleted file mode 100644 index 292ff6067..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Enumeration2BoxModelTest.java +++ /dev/null @@ -1,117 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -public class Enumeration2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "enumeration2boxmodel.sparql"; - private final int totalNumberOfExpectedEntries = 6; - private final int indexOfSeeValueEntry = 5; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testOnlyUsedEnumerationsAreProcessedExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_USED_AND_UNUSED_ENUMERATION, - metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( - queryResult.listStatements( context.selector( "test:UsedTestEnumerationCharacteristic a :Box" ) ).toList() ) - .hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:UnusedTestEnumerationCharacteristic a :Box" ) ) - .toList() ) - .hasSize( 0 ); - assertThat( queryResult.listStatements( context.selector( "* :text *" ) ).toList() ).hasSize( 5 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final String characteristicIdentifier = "TestEnumeration"; - final String boxSelectorStatement = boxSelectorStatement( characteristicIdentifier, false ); - final String entriesSelectorStatement = entriesSelectorStatement( characteristicIdentifier, false ); - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUMERATION_WITH_SEE_ATTRIBUTE, - metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final boolean newerThanSamm1 = metaModelVersion.isNewerThan( KnownVersion.SAMM_1_0_0 ); - final String characteristicIdentifier = newerThanSamm1 ? "*" : "TestEnumeration"; - final String boxSelectorStatement = boxSelectorStatement( characteristicIdentifier, newerThanSamm1 ); - final String entriesSelectorStatement = entriesSelectorStatement( characteristicIdentifier, newerThanSamm1 ); - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUMERATION_WITH_MULTIPLE_SEE_ATTRIBUTES, - metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, - "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final String characteristicIdentifier = "TestEnumeration"; - final String boxSelectorStatement = boxSelectorStatement( characteristicIdentifier, false ); - final String entriesSelectorStatement = entriesSelectorStatement( characteristicIdentifier, false ); - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUMERATION_WITHOUT_SEE_ATTRIBUTE, - metaModelVersion ); - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testOnlyRightSeeAttributeIsSelected( final KnownVersion metaModelVersion ) { - // See attribute was rendered also on elements on which it was not declared: - // https://github.com/eclipse-esmf/esmf-sdk/issues/196 - String characteristicIdentifier = "Enum1"; - String boxSelectorStatement = boxSelectorStatement( characteristicIdentifier, false ); - String entriesSelectorStatement = entriesSelectorStatement( characteristicIdentifier, false ); - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUM_ONLY_ONE_SEE, metaModelVersion ); - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry ); - - characteristicIdentifier = "Enum2"; - boxSelectorStatement = boxSelectorStatement( characteristicIdentifier, false ); - entriesSelectorStatement = entriesSelectorStatement( characteristicIdentifier, false ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "https://test.com" ); - } - - private String boxSelectorStatement( final String characteristicIdentifier, final boolean isAnonymous ) { - final String subject = characteristicIdentifier.equals( "*" ) ? "*" - : String.format( "%s:%sCharacteristic", isAnonymous ? "" : "test", characteristicIdentifier ); - return subject + " a :Box"; - } - - private String entriesSelectorStatement( final String characteristicIdentifier, final boolean isAnonymous ) { - final String subject = characteristicIdentifier.equals( "*" ) ? "*" : - String.format( "%s:%sCharacteristic", isAnonymous ? "" : "test", characteristicIdentifier ); - return subject + " :entries *"; - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/EnumerationEntityInstance2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/EnumerationEntityInstance2BoxModelTest.java deleted file mode 100644 index 274980562..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/EnumerationEntityInstance2BoxModelTest.java +++ /dev/null @@ -1,61 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class EnumerationEntityInstance2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "enumeration-entityinstance2boxmodel.sparql"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testEdgeSetForEnumeration( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUMERATION_WITHOUT_SCALAR_VARIABLE, - metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( - context.selector( "test:EvaluationResultsCharacteristic_To_ResultGoodEntityInstance a :Edge" ) ).toList() ) - .hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( - "test:EvaluationResultsCharacteristic_To_ResultGoodEntityInstance :to test:ResultGoodEntityInstance" ) ) - .toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( - "test:EvaluationResultsCharacteristic_To_ResultGoodEntityInstance :from test:EvaluationResultsCharacteristic" ) ) - .toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testNoEdgeSetForEnumerationWithScalarVariables( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUMERATION_WITH_SCALAR_VARIABLE, - metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - // Edge may not be present, as this is a scalar value. - assertThat( queryResult - .listStatements( context.selector( "test:TestScalarEnumerationCharacteristic_To_EntityInstance a :Edge" ) ) - .toList() ).hasSize( 0 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Operation2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Operation2BoxModelTest.java deleted file mode 100644 index afe27130c..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Operation2BoxModelTest.java +++ /dev/null @@ -1,58 +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.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class Operation2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "operation2boxmodel.sparql"; - private final String boxSelectorStatement = "test:testOperationOperation a :Box"; - private final String entriesSelectorStatement = "test:testOperationOperation :entries *"; - private final int totalNumberOfExpectedEntries = 3; - private final int indexOfSeeValueEntry = 2; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_OPERATION_WITH_SEE_ATTRIBUTE, - metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_OPERATION_WITH_MULTIPLE_SEE_ATTRIBUTES, - metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, - "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_OPERATION_WITHOUT_SEE_ATTRIBUTE, - metaModelVersion ); - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, - totalNumberOfExpectedEntries, indexOfSeeValueEntry ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Property2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Property2BoxModelTest.java deleted file mode 100644 index 8b52dadad..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/Property2BoxModelTest.java +++ /dev/null @@ -1,155 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; -import org.eclipse.esmf.test.TestProperty; - -class Property2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "property2boxmodel.sparql"; - private final int totalNumberOfExpectedEntries = 4; - private final int indexOfSeeValueEntry = 2; - private final String expectedSeeEntryTitle = "see"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestProperty.PROPERTY_WITH_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, "test:propertyWithSeeAttributeProperty a :Box", - "test:propertyWithSeeAttributeProperty :entries *", - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, "http://example.com/" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestProperty.PROPERTY_WITH_MULTIPLE_SEE_ATTRIBUTES, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, "test:propertyWithMultipleSeeAttributesProperty a :Box", - "test:propertyWithMultipleSeeAttributesProperty :entries *", - totalNumberOfExpectedEntries, indexOfSeeValueEntry, expectedSeeEntryTitle, - "http://example.com/, http://example.com/me" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributeIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestProperty.PROPERTY_WITHOUT_SEE_ATTRIBUTE, metaModelVersion ); - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, "test:propertyWithoutSeeAttributeProperty a :Box", - "test:propertyWithoutSeeAttributeProperty :entries *", - totalNumberOfExpectedEntries, indexOfSeeValueEntry ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testSeeAttributeIsPresentOnSharedPropertyExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestProperty.SHARED_PROPERTY_WITH_SEE_ATTRIBUTE, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( - queryResult.listStatements( context.selector( "test:sharedPropertyWithSeeAttributeProperty a :Box" ) ) - .toList() ) - .hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "samm-e:sharedPropertyProperty a :Box" ) ).toList() ) - .hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testExampleValueIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestProperty.PROPERTY_WITH_EXAMPLE_VALUE, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, "test:propertyWithExampleValueProperty a :Box", - "test:propertyWithExampleValueProperty :entries *", - totalNumberOfExpectedEntries, 3, "exampleValue", "foo" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testExampleValueIsNotPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestProperty.PROPERTY_WITHOUT_EXAMPLE_VALUE, metaModelVersion ); - context.executeAttributeIsNotPresentTest( sparqlQueryFileName, "test:propertyWithoutExampleValueProperty a :Box", - "test:propertyWithoutExampleValueProperty :entries *", - totalNumberOfExpectedEntries, 3 ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - void testAspectWithAbstractEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testAbstractAndExtendingEntityPropertyBoxes( TestAspect.ASPECT_WITH_ABSTRACT_ENTITY, metaModelVersion ); - testAbstractAndExtendingEntityPropertyEdges( TestAspect.ASPECT_WITH_ABSTRACT_ENTITY, metaModelVersion ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - void testAspectWithAbstractSingleEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testAbstractAndExtendingEntityPropertyBoxes( TestAspect.ASPECT_WITH_ABSTRACT_SINGLE_ENTITY, metaModelVersion ); - testAbstractAndExtendingEntityPropertyEdges( TestAspect.ASPECT_WITH_ABSTRACT_SINGLE_ENTITY, metaModelVersion ); - } - - @ParameterizedTest - @MethodSource( value = "versionsStartingWith2_0_0" ) - void testCollectionWithAbstractEntityExpectSuccess( final KnownVersion metaModelVersion ) { - testAbstractAndExtendingEntityPropertyBoxes( TestAspect.ASPECT_WITH_COLLECTION_WITH_ABSTRACT_ENTITY, metaModelVersion ); - testAbstractAndExtendingEntityPropertyEdges( TestAspect.ASPECT_WITH_COLLECTION_WITH_ABSTRACT_ENTITY, metaModelVersion ); - } - - private void testAbstractAndExtendingEntityPropertyBoxes( final TestAspect testAspect, final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( testAspect, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( "test:entityPropertyProperty a :Box" ) ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( context.selector( "test:abstractTestPropertyProperty a :Box" ) ).toList() ).hasSize( 1 ); - } - - private void testAbstractAndExtendingEntityPropertyEdges( final TestAspect testAspect, final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( testAspect, metaModelVersion ); - - final Model queryResult = context.executeQuery( "aspect-property-edges2boxmodel.sparql" ); - - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_entityPropertyProperty a :Edge" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_entityPropertyProperty :from test:ExtendingTestEntityEntity" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_entityPropertyProperty :to test:entityPropertyProperty" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:ExtendingTestEntityEntity_To_abstractTestPropertyProperty a :Edge" ) - ).toList() ).isEmpty(); - assertThat( queryResult.listStatements( - context.selector( "test:AbstractTestEntityAbstractEntity_To_entityPropertyProperty a :Edge" ) - ).toList() ).isEmpty(); - - assertThat( queryResult.listStatements( - context.selector( "test:AbstractTestEntityAbstractEntity_To_abstractTestPropertyProperty a :Edge" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:AbstractTestEntityAbstractEntity_To_abstractTestPropertyProperty :from test:AbstractTestEntityAbstractEntity" ) - ).toList() ).hasSize( 1 ); - assertThat( queryResult.listStatements( - context.selector( "test:AbstractTestEntityAbstractEntity_To_abstractTestPropertyProperty :to test:abstractTestPropertyProperty" ) - ).toList() ).hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/PropertyCharacteristicEdges2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/PropertyCharacteristicEdges2BoxModelTest.java deleted file mode 100644 index e2169bf10..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/PropertyCharacteristicEdges2BoxModelTest.java +++ /dev/null @@ -1,41 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class PropertyCharacteristicEdges2BoxModelTest extends MetaModelVersions { - - private final String sparqlQueryFileName = "property-characteristic-edges2boxmodel.sparql"; - - @ParameterizedTest - @MethodSource( value = "versionsUpToIncluding1_0_0" ) - void testPropertyToCharacteristicEdgeFromSharedNamespaceNotPresent( final KnownVersion metaModelVersion ) { - // v1.0 sparql queries were not properly filtering out some properties from shared samm-e namespace - // https://github.com/eclipse-esmf/esmf-sdk/issues/196 - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_ENUM_ONLY_ONE_SEE, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( ":timestampProperty_To_TimestampCharacteristic a :Edge" ) ).toList() ).isEmpty(); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/QuantifiableUnitEdges2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/QuantifiableUnitEdges2BoxModelTest.java deleted file mode 100644 index 305117a0a..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/QuantifiableUnitEdges2BoxModelTest.java +++ /dev/null @@ -1,88 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class QuantifiableUnitEdges2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "quantifiable-unit-edges2boxmodel.sparql"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testQuantifiableHasNoUnitExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_QUANTIFIABLE_WITHOUT_UNIT, metaModelVersion ); - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - assertQuantifiableUnitEdgeModel( context, queryResult, 0 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testQuantifiableHasUnitExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_QUANTIFIABLE_WITH_UNIT, metaModelVersion ); - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - assertQuantifiableUnitEdgeModel( context, queryResult, 1 ); - } - - private void assertQuantifiableUnitEdgeModel( final TestContext context, final Model queryResult, - final int expectedOccurance ) { - assertThat( queryResult - .listStatements( context.selector( "test:TestQuantifiableCharacteristic_To_PercentUnit :to unit:PercentUnit" ) ) - .toList() ) - .hasSize( expectedOccurance ); - assertThat( queryResult.listStatements( - context.selector( - "test:TestQuantifiableCharacteristic_To_PercentUnit :from test:TestQuantifiableCharacteristic" ) ).toList() ) - .hasSize( expectedOccurance ); - assertThat( queryResult - .listStatements( context.selector( "test:TestQuantifiableCharacteristic_To_PercentUnit :title *" ) ).toList() ) - .hasSize( expectedOccurance ); - assertThat( queryResult - .listStatements( context.selector( "test:TestQuantifiableCharacteristic_To_PercentUnit rdf:type :Edge" ) ) - .toList() ) - .hasSize( expectedOccurance ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testMeasurementHasUnitExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_MEASUREMENT_WITH_UNIT, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult - .listStatements( context.selector( "test:TestMeasurementCharacteristic_To_PercentUnit :to unit:PercentUnit" ) ) - .toList() ) - .hasSize( 1 ); - assertThat( queryResult.listStatements( context - .selector( "test:TestMeasurementCharacteristic_To_PercentUnit :from test:TestMeasurementCharacteristic" ) ) - .toList() ) - .hasSize( 1 ); - assertThat( queryResult - .listStatements( context.selector( "test:TestMeasurementCharacteristic_To_PercentUnit :title *" ) ) - .toList() ) - .hasSize( 1 ); - assertThat( queryResult - .listStatements( context.selector( "test:TestMeasurementCharacteristic_To_PercentUnit rdf:type :Edge" ) ) - .toList() ) - .hasSize( 1 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/RangeConstraint2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/RangeConstraint2BoxModelTest.java deleted file mode 100644 index 83a6499d1..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/RangeConstraint2BoxModelTest.java +++ /dev/null @@ -1,76 +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.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.TestAspect; - -class RangeConstraint2BoxModelTest extends AbstractConstraint2BoxModelTest { - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testBoundDefinitionAttributeIsPresentExpectSuccess( final KnownVersion metaModelVersion ) { - final String constraintIdentifier = "*"; - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_RANGE_CONSTRAINT_WITH_BOUND_DEFINITION_ATTRIBUTES, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), - totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 6, "lowerBoundDefinition", "GREATER_THAN" ); - - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), - totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 7, "upperBoundDefinition", "LESS_THAN" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testRangeConstraintWithOnlyLowerBoundDefinitionAndBothValuesExpectSuccess( - final KnownVersion metaModelVersion ) { - final String constraintIdentifier = "*"; - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_RANGE_CONSTRAINT_WITH_ONLY_LOWER_BOUND_DEFINITION_AND_BOTH_VALUES, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 6, "lowerBoundDefinition", "GREATER_THAN" ); - - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 7, "upperBoundDefinition", "AT_MOST" ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - void testRangeConstraintWithOnlyMinValue( final KnownVersion metaModelVersion ) { - final String constraintIdentifier = "*"; - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_RANGE_CONSTRAINT_WITH_ONLY_MIN_VALUE, metaModelVersion ); - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 6, "lowerBoundDefinition", "GREATER_THAN" ); - - context.executeAttributeIsPresentTest( sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 7, "upperBoundDefinition", "OPEN" ); - - context.executeAttributeIsNotPresentTest( - sparqlQueryFileName, boxSelectorStatement( constraintIdentifier, true ), - entriesSelectorStatement( constraintIdentifier, true ), totalNumberOfExpectedEntriesPerMetaModelVersion.get( metaModelVersion ), - 8 ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/SparqlExecutorTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/SparqlExecutorTest.java deleted file mode 100644 index 7ddab29fe..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/SparqlExecutorTest.java +++ /dev/null @@ -1,83 +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 static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.ByteArrayInputStream; -import java.nio.charset.StandardCharsets; - -import org.apache.jena.graph.Node; -import org.apache.jena.query.QueryFactory; -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.junit.jupiter.api.Test; - -import org.eclipse.esmf.aspectmodel.resolver.services.TurtleLoader; - -public class SparqlExecutorTest { - - // function creating synthetic names starting with the given prefix for anonymous nodes - record CustomFunctionFactory(String prefix) implements FunctionFactory { - @Override - public Function create( final String s ) { - return new FunctionBase1() { - @Override - public NodeValue exec( final NodeValue v ) { - final Node node = v.asNode(); - if ( node.isBlank() ) { - return NodeValue.makeString( prefix + "_" + node ); - } - return null; - } - }; - } - } - - @Test - void testCustomFunctionIsUniqueForContext() { - final String modelSource = """ - @prefix : . - [ - a :Object ; - ] - """; - - final String querySource = """ - prefix : - prefix func: - - select ?anonName - where { - { - ?anon a :Object . - } - bind( func:getElementName( ?anon ) as ?anonName ) - } - """; - - final Model model = TurtleLoader.loadTurtle( new ByteArrayInputStream( modelSource.getBytes( StandardCharsets.UTF_8 ) ) ).get(); - final SparqlExecutor executor1 = new SparqlExecutor().useCustomFunction( "urn:SAMM:function:2.0.0#getElementName", - new CustomFunctionFactory( "executor1" ) ); - final SparqlExecutor executor2 = new SparqlExecutor().useCustomFunction( "urn:SAMM:function:2.0.0#getElementName", - new CustomFunctionFactory( "executor2" ) ); - final String result1 = executor1.executeQuery( model, QueryFactory.create( querySource ), "anonName" ); - assertTrue( result1.startsWith( "executor1_" ) ); - final String result2 = executor2.executeQuery( model, QueryFactory.create( querySource ), "anonName" ); - assertTrue( result2.startsWith( "executor2_" ) ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/StructuredValue2BoxModelTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/StructuredValue2BoxModelTest.java deleted file mode 100644 index d2d5ff5bd..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/StructuredValue2BoxModelTest.java +++ /dev/null @@ -1,61 +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 static org.assertj.core.api.Assertions.assertThat; - -import org.apache.jena.rdf.model.Model; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.MetaModelVersions; -import org.eclipse.esmf.test.TestAspect; - -public class StructuredValue2BoxModelTest extends MetaModelVersions { - private final String sparqlQueryFileName = "structuredvalue2boxmodel.sparql"; - private final String boxSelectorStatement = "test:StructuredDateCharacteristic a :Box"; - private final String entriesSelectorStatement = "test:StructuredDateCharacteristic :entries *"; - private final int totalNumberOfExpectedEntries = 6; - - private final int indexOfdeconstructionRuleEntry = 4; - private final String expectedDeconstructionRuleEntryTitle = "deconstructionRule"; - - private final int indexOfElementsEntry = 5; - private final String expectedElementsEntryTitle = "elements"; - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testBoxEntryIsPresent( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_STRUCTURED_VALUE, metaModelVersion ); - - final Model queryResult = context.executeQuery( sparqlQueryFileName ); - - assertThat( queryResult.listStatements( context.selector( boxSelectorStatement ) ).toList() ).hasSize( 1 ); - } - - @ParameterizedTest - @MethodSource( value = "allVersions" ) - public void testAttributesArePresentExpectSuccess( final KnownVersion metaModelVersion ) { - final TestContext context = new TestContext( TestAspect.ASPECT_WITH_STRUCTURED_VALUE, metaModelVersion ); - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfdeconstructionRuleEntry, expectedDeconstructionRuleEntryTitle, - "(\\\\d{4})-(\\\\d{2})-(\\\\d{2})" ); - - context.executeAttributeIsPresentTest( - sparqlQueryFileName, boxSelectorStatement, entriesSelectorStatement, totalNumberOfExpectedEntries, - indexOfElementsEntry, expectedElementsEntryTitle, "year '-' month '-' day" ); - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/TestContext.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/TestContext.java deleted file mode 100644 index ecfa99145..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/diagram/TestContext.java +++ /dev/null @@ -1,187 +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 static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator.*; - -import java.io.InputStream; -import java.util.List; -import java.util.Map; - -import org.apache.jena.query.Query; -import org.apache.jena.query.QueryFactory; -import org.apache.jena.rdf.model.Literal; -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.RDFList; -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.Selector; -import org.apache.jena.rdf.model.SimpleSelector; -import org.apache.jena.rdf.model.Statement; -import org.apache.jena.vocabulary.RDF; -import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel; - -import org.eclipse.esmf.samm.KnownVersion; -import org.eclipse.esmf.test.TestModel; -import org.eclipse.esmf.test.TestResources; - -public class TestContext { - private final AspectModelDiagramGenerator service; - private final KnownVersion version; - private final BoxModel boxModel; - private final SparqlExecutor sparqlExecutor; - - public TestContext( final TestModel model, final KnownVersion version ) { - this.version = version; - final VersionedModel versionedModel = TestResources.getModel( model, version ).get(); - service = new AspectModelDiagramGenerator( versionedModel ); - boxModel = new BoxModel( KnownVersion.getLatest() ); - service.model.setNsPrefix( "", boxModel.getNamespace() ); - service.model.setNsPrefix( "test", "urn:samm:org.eclipse.esmf.test:1.0.0#" ); - - sparqlExecutor = new SparqlExecutor() - .useCustomFunction( GET_ELEMENT_NAME_FUNC, new GetElementNameFunctionFactory( versionedModel.getModel() ) ) - .useCustomFunction( GET_NAMESPACE_FUNC, new GetNamespaceFunctionFactory( versionedModel.getModel() ) ) - ; - } - - /** - * Returns a statement selector in a simple statement syntax. Valid examples: - * :Foo a :Bar - * :Foo a * - * * rdfs:subClassOf * - * - * @param statement The statement, which consists of subject, predicate and object, each of which can be an - * asterisk as wildcard - * @return A statement selector for the pattern - */ - public Selector selector( final String statement ) { - final String[] parts = statement.split( " ", 3 ); - final Resource subject = parts[0].equals( "*" ) ? - null : ResourceFactory.createResource( resolve( parts[0] ) ); - final Property predicate = switch ( parts[1] ) { - case "*" -> null; - case "a" -> RDF.type; - default -> ResourceFactory.createProperty( resolve( parts[1] ) ); - }; - - if ( parts[2].contains( ":" ) ) { - final Resource object = ResourceFactory.createResource( resolve( parts[2] ) ); - return new SimpleSelector( subject, predicate, object ); - } - - final Literal object = parts[2].equals( "*" ) ? - null : ResourceFactory.createStringLiteral( parts[2] ); - return new SimpleSelector( subject, predicate, object ); - } - - /** - * Resolve the namespace of a statement pattern against the prefixes of the Aspect Model, e.g. - * "rdf:type" will return "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", - * ":Box" will return "urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#Box" - * - * @param statementPattern This short statement pattern - * @return The expanded statement pattern - */ - public String resolve( final String statementPattern ) { - final String[] statementParts = statementPattern.split( ":" ); - final Map prefixMap = service.model.getNsPrefixMap(); - return prefixMap.get( statementParts[0] ) + statementParts[1]; - } - - public void executeAttributeIsPresentTest( final String sparqlQueryFileName, - final String boxSelectorStatement, final String entriesSelectorStatement, - final int totalNumberOfExpectedEntries, - final int indexOfExpectedEntry, final String expectedTitle, final String expectedValue ) { - - final Model queryResult = executeQuery( sparqlQueryFileName ); - assertThat( queryResult.listStatements( selector( boxSelectorStatement ) ).toList() ).hasSizeGreaterThanOrEqualTo( 1 ); - - final List entries = queryResult - .listStatements( selector( entriesSelectorStatement ) ) - .nextStatement().getObject().as( RDFList.class ).asJavaList(); - - assertEntry( entries, totalNumberOfExpectedEntries, indexOfExpectedEntry, expectedTitle, expectedValue ); - } - - public void executeAttributeIsNotPresentTest( final String sparqlQueryFileName, - final String boxSelectorStatement, final String entriesSelectorStatement, - final int totalNumberOfExpectedEntries, final int indexOfExpectedEntry ) { - - final Model queryResult = executeQuery( sparqlQueryFileName ); - assertThat( queryResult.listStatements( selector( boxSelectorStatement ) ).toList() ).hasSize( 1 ); - - final List entries = queryResult - .listStatements( selector( entriesSelectorStatement ) ) - .nextStatement().getObject().as( RDFList.class ).asJavaList(); - assertThat( entries ).hasSize( totalNumberOfExpectedEntries ); - - final Statement entryText = entries.get( indexOfExpectedEntry ).asResource().getProperty( boxModel.text() ); - assertThat( entryText ).isNull(); - } - - public Model executeQuery( final String sparqlQueryFileName ) { - final Query query = QueryFactory.create( getInputStreamAsString( sparqlQueryFileName ) ); - final Model queryResult = ModelFactory.createDefaultModel(); - sparqlExecutor.executeConstruct( model(), query, queryResult ); - return queryResult; - } - - public void assertEntry( final List entries, final int totalNumberOfExpectedEntries, - final int indexOfExpectedEntry, final String expectedTitle, final String expectedValue ) { - assertThat( entries ).hasSize( totalNumberOfExpectedEntries ); - - assertThat( entries.get( indexOfExpectedEntry ).asResource().getPropertyResourceValue( RDF.type ) ) - .isEqualTo( boxModel.entry() ); - assertThat( - entries.get( indexOfExpectedEntry ).asResource().getProperty( boxModel.title() ).getObject().asLiteral() - .getString() ).isEqualTo( expectedTitle ); - - final String entryText = entries.get( indexOfExpectedEntry ).asResource().getProperty( boxModel.text() ) - .getObject().asLiteral().getString(); - assertThat( entryText ).isEqualTo( expectedValue ); - } - - public InputStream getInputStream( final String resource ) { - return service.getInputStream( resource ); - } - - public String getInputStreamAsString( final String resource ) { - return service.getInputStreamAsString( resource ); - } - - public Model model() { - return service.model; - } - - public BoxModel boxModel() { - return boxModel; - } - - public KnownVersion getVersion() { - return version; - } - - public String executeQuery( final Model model, final Query query ) { - return sparqlExecutor.executeQuery( model, query, "dotStatement" ); - } - - public AspectModelDiagramGenerator service() { - return service; - } -} diff --git a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/json/AspectModelJsonPayloadGeneratorTest.java b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/json/AspectModelJsonPayloadGeneratorTest.java index e6557e115..a2fbfb11c 100644 --- a/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/json/AspectModelJsonPayloadGeneratorTest.java +++ b/core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/json/AspectModelJsonPayloadGeneratorTest.java @@ -625,7 +625,6 @@ private String generateJsonForModel( final TestAspect model, final KnownVersion final AspectModelJsonPayloadGenerator jsonGenerator = new AspectModelJsonPayloadGenerator( new AspectContext( versionedModel, aspect ) ); try { final var payload = jsonGenerator.generateJson(); - Files.write( Path.of( model.getName() + ".json" ), payload.getBytes( StandardCharsets.UTF_8 ) ); return payload; } catch ( final IOException e ) { throw new RuntimeException( e ); diff --git a/core/esmf-aspect-model-document-generators/src/test/resources/diagram/samm_1_0_0/org.eclipse.esmf.test/1.0.0/BoxModelTest.ttl b/core/esmf-aspect-model-document-generators/src/test/resources/diagram/samm_1_0_0/org.eclipse.esmf.test/1.0.0/BoxModelTest.ttl deleted file mode 100644 index 59fd9ada0..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/resources/diagram/samm_1_0_0/org.eclipse.esmf.test/1.0.0/BoxModelTest.ttl +++ /dev/null @@ -1,44 +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 : . - -:Node1 - a :Box ; - :prototype "Node1Prototype" ; - :title "Node1Title" ; - :entries ( [ - a :Entry ; - :title "entry1title" ; - :text "entry1text" - ] - [ - a :Entry ; - :title "entry2title" ; - :text "entry2text" - ] ) . - -:Node2 - a :Box ; - :prototype "Node2Prototype" ; - :title "Node2Title" . - -:Node3WithFillColor - a :Box ; - :prototype "Node3Prototype" ; - :title "Node3Title" ; - :fillcolor "orange" . - -:Edge1 - a :Edge ; - :from :Node1 ; - :to :Node2 ; - :title "edge" . diff --git a/core/esmf-aspect-model-document-generators/src/test/resources/diagram/samm_2_0_0/org.eclipse.esmf.test/1.0.0/BoxModelTest.ttl b/core/esmf-aspect-model-document-generators/src/test/resources/diagram/samm_2_0_0/org.eclipse.esmf.test/1.0.0/BoxModelTest.ttl deleted file mode 100644 index 6dd62713f..000000000 --- a/core/esmf-aspect-model-document-generators/src/test/resources/diagram/samm_2_0_0/org.eclipse.esmf.test/1.0.0/BoxModelTest.ttl +++ /dev/null @@ -1,44 +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 : . - -:Node1 - a :Box ; - :prototype "Node1Prototype" ; - :title "Node1Title" ; - :entries ( [ - a :Entry ; - :title "entry1title" ; - :text "entry1text" - ] - [ - a :Entry ; - :title "entry2title" ; - :text "entry2text" - ] ) . - -:Node2 - a :Box ; - :prototype "Node2Prototype" ; - :title "Node2Title" . - -:Node3WithFillColor - a :Box ; - :prototype "Node3Prototype" ; - :title "Node3Title" ; - :fillcolor "orange" . - -:Edge1 - a :Edge ; - :from :Node1 ; - :to :Node2 ; - :title "edge" . diff --git a/core/esmf-aspect-model-validator/pom.xml b/core/esmf-aspect-model-validator/pom.xml index 6cfed40c3..b41801e89 100644 --- a/core/esmf-aspect-model-validator/pom.xml +++ b/core/esmf-aspect-model-validator/pom.xml @@ -48,19 +48,11 @@ org.eclipse.esmf esmf-aspect-model-resolver - - org.graalvm.sdk - graal-sdk - org.graalvm.js js runtime - - org.graalvm.js - js-scriptengine - org.projectlombok lombok diff --git a/documentation/developer-guide/modules/ROOT/examples/aspect-models/org.eclipse.esmf.examples.movement/1.0.0/Movement.ttl b/documentation/developer-guide/modules/ROOT/examples/aspect-models/org.eclipse.esmf.examples.movement/1.0.0/Movement.ttl index 3f132cff1..df17bfacb 100644 --- a/documentation/developer-guide/modules/ROOT/examples/aspect-models/org.eclipse.esmf.examples.movement/1.0.0/Movement.ttl +++ b/documentation/developer-guide/modules/ROOT/examples/aspect-models/org.eclipse.esmf.examples.movement/1.0.0/Movement.ttl @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Robert Bosch Manufacturing Solutions GmbH +# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH # # See the AUTHORS file(s) distributed with this work for # additional information regarding authorship. @@ -9,10 +9,10 @@ # # SPDX-License-Identifier: MPL-2.0 -@prefix samm: . -@prefix samm-c: . -@prefix samm-e: . -@prefix unit: . +@prefix samm: . +@prefix samm-c: . +@prefix samm-e: . +@prefix unit: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . diff --git a/documentation/developer-guide/modules/tooling-guide/examples/GenerateDiagrams.java b/documentation/developer-guide/modules/tooling-guide/examples/GenerateDiagrams.java index c1fff3f70..5e8de8648 100644 --- a/documentation/developer-guide/modules/tooling-guide/examples/GenerateDiagrams.java +++ b/documentation/developer-guide/modules/tooling-guide/examples/GenerateDiagrams.java @@ -20,20 +20,22 @@ import org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator; import org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator.Format; import org.eclipse.esmf.aspectmodel.resolver.AspectModelResolver; -import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel; -// end::imports[] +import org.eclipse.esmf.metamodel.AspectContext; +import org.eclipse.esmf.metamodel.loader.AspectModelLoader; + import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Test; +// end::imports[] public class GenerateDiagrams extends AbstractGenerator { @Test public void generateDiagram() throws IOException { // tag::generate[] - // VersionedModel as returned by the AspectModelResolver - final VersionedModel model = // ... + // AspectContext as returned by the AspectModelLoader + final AspectContext model = // ... // end::generate[] - AspectModelResolver.loadAndResolveModel( + AspectModelLoader.getAspectContext( new File( "aspect-models/org.eclipse.esmf.examples.movement/1.0.0/Movement.ttl" ) ).get(); // tag::generate[] diff --git a/pom.xml b/pom.xml index ab29e869a..abdb199db 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.eclipse.esmf esmf-parent - 5 + 6 esmf-sdk-parent @@ -78,6 +78,7 @@ 6.2.3.Final 3.0.4 4.1.2 + 1.1.5 true @@ -213,6 +214,22 @@ poi ${poi-version} + + org.graphper + graph-support + ${graph-support-version} + + + org.graalvm.truffle + truffle-api + ${graalvm-version} + + + org.graalvm.js + js + ${graalvm-version} + + diff --git a/tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateDiagram.java b/tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateDiagram.java index 9c2616803..1eff8824d 100644 --- a/tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateDiagram.java +++ b/tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateDiagram.java @@ -17,17 +17,17 @@ import java.util.Set; import java.util.stream.Collectors; +import org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator; +import org.eclipse.esmf.metamodel.AspectContext; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.eclipse.esmf.metamodel.AspectContext; - -@Mojo( name = "generateDiagram", defaultPhase = LifecyclePhase.GENERATE_RESOURCES ) +@Mojo( name = "generateDiagram", defaultPhase = LifecyclePhase.GENERATE_RESOURCES ) public class GenerateDiagram extends AspectModelMojo { private final Logger logger = LoggerFactory.getLogger( GenerateDiagram.class ); @@ -46,13 +46,13 @@ public void execute() throws MojoExecutionException { .collect( Collectors.toSet() ); for ( final AspectContext aspectModel : aspectModels ) { - final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( aspectModel.rdfModel() ); + final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( aspectModel ); generator.generateDiagrams( formats, name -> getStreamForFile( name, outputDirectory ) ); } } catch ( final IOException exception ) { throw new MojoExecutionException( "Could not generate diagram.", exception ); } catch ( final IllegalArgumentException exception ) { - throw new MojoExecutionException( "Invalid target format provided. Possible formats are dot, svg & png.", exception ); + throw new MojoExecutionException( "Invalid target format provided. Possible formats are svg & png.", exception ); } logger.info( "Successfully generated Aspect Model diagram(s)." ); } diff --git a/tools/esmf-aspect-model-maven-plugin/src/test/java/org/eclipse/esmf/aspectmodel/GenerateDiagramTest.java b/tools/esmf-aspect-model-maven-plugin/src/test/java/org/eclipse/esmf/aspectmodel/GenerateDiagramTest.java index e01b0126e..7f79d5423 100644 --- a/tools/esmf-aspect-model-maven-plugin/src/test/java/org/eclipse/esmf/aspectmodel/GenerateDiagramTest.java +++ b/tools/esmf-aspect-model-maven-plugin/src/test/java/org/eclipse/esmf/aspectmodel/GenerateDiagramTest.java @@ -29,10 +29,10 @@ public void testGenerateDiagramsValidAspectModel() throws Exception { final Mojo generateDiagram = lookupMojo( "generateDiagram", testPom ); assertThatCode( generateDiagram::execute ).doesNotThrowAnyException(); - assertGeneratedFileExists( "Aspect_en.dot" ); + assertGeneratedFileExists( "Aspect_en.svg" ); assertGeneratedFileExists( "Aspect_en.png" ); - deleteGeneratedFile( "Aspect_en.dot" ); + deleteGeneratedFile( "Aspect_en.svg" ); deleteGeneratedFile( "Aspect_en.png" ); } @@ -42,6 +42,6 @@ public void testGenerateDiagramsInvalidTargetFormat() throws Exception { final Mojo generateDiagram = lookupMojo( "generateDiagram", testPom ); assertThatCode( generateDiagram::execute ) .isInstanceOf( MojoExecutionException.class ) - .hasMessage( "Invalid target format provided. Possible formats are dot, svg & png." ); + .hasMessage( "Invalid target format provided. Possible formats are svg & png." ); } } diff --git a/tools/esmf-aspect-model-maven-plugin/src/test/resources/generate-diagram-pom-valid-aspect-model.xml b/tools/esmf-aspect-model-maven-plugin/src/test/resources/generate-diagram-pom-valid-aspect-model.xml index c352f1ede..60f0d0cae 100644 --- a/tools/esmf-aspect-model-maven-plugin/src/test/resources/generate-diagram-pom-valid-aspect-model.xml +++ b/tools/esmf-aspect-model-maven-plugin/src/test/resources/generate-diagram-pom-valid-aspect-model.xml @@ -33,7 +33,7 @@ ${basedir}/target/test-artifacts - dot + svg png diff --git a/tools/samm-cli/pom.xml b/tools/samm-cli/pom.xml index 30d63aa34..8ece14c9a 100644 --- a/tools/samm-cli/pom.xml +++ b/tools/samm-cli/pom.xml @@ -67,6 +67,33 @@ org.graalvm.nativeimage svm provided + + + + org.graalvm-truffle + truffle-api + + + + + org.graalvm.truffle + truffle-api + provided + + + org.graalvm.js + js + runtime + + + org.graalvm.truffle + truffle-api + + + org.graalvm.sdk + graal-sdk + + @@ -207,16 +234,15 @@ customize-resource-config - pre-package + prepare-package java - org.eclipse.esmf.buildtime.CustomizeResourceConfig + org.eclipse.esmf.buildtime.CustomizeGraalVmConfigs - ${project.build.outputDirectory}/META-INF/native-image/${project.groupId}/${project.artifactId}/resource-config.json - + ${project.build.outputDirectory}/META-INF/native-image/${project.groupId}/${project.artifactId} false @@ -252,6 +278,10 @@ org.eclipse.esmf:esmf-semantic-aspect-meta-model javax.annotation:jsr250-api + + org.graalvm.sdk:graal-sdk + org.graalvm.nativeimage:svm + org.graalvm.truffle:truffle-api @@ -298,6 +328,13 @@ org/apache/batik/apps/rasterizer/resources/rasterizer.policy + + + org.jboss.forge.roaster:roaster-jdt + + META-INF/native-image/** + + org.eclipse.esmf:esmf-aspect-meta-model-java @@ -379,6 +416,10 @@ -Aproject=${project.groupId}/${project.artifactId} + --add-exports + java.desktop/sun.awt=ALL-UNNAMED + --add-exports + java.desktop/sun.font=ALL-UNNAMED true @@ -437,11 +478,18 @@ + + + org.apache.maven.plugins + maven-javadoc-plugin + + org.eclipse.esmf.substitution + + - copy-font-configuration @@ -464,53 +512,9 @@ download-single - - file://${env.JAVA_HOME}/lib - + file://${env.JAVA_HOME}/lib fontconfig.bfc - ${project.build.directory}/lib/fontconfig.bfc - - - - copy-fontconfig-properties-src - process-resources - - download-single - - - - file://${env.JAVA_HOME}/lib - - fontconfig.properties.src - ${project.build.directory}/lib/fontconfig.properties.src - - - - copy-psfont-properties-ja - process-resources - - download-single - - - - file://${env.JAVA_HOME}/lib - - psfont.properties.ja - ${project.build.directory}/lib/psfont.properties.ja - - - - copy-psfontj2d-properties - process-resources - - download-single - - - - file://${env.JAVA_HOME}/lib - - psfontj2d.properties - ${project.build.directory}/lib/psfontj2d.properties + ${project.build.outputDirectory}/fontconfig.bfc @@ -537,7 +541,7 @@ build-native - build + compile package @@ -545,6 +549,16 @@ ${main-class} ${binary-name} + + -J-XX:MaxRAMPercentage=90.0 + -J-XX:GCTimeRatio=19 + -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED + -J--add-exports=java.desktop/sun.font=ALL-UNNAMED + + true + + ${project.build.directory}/${project.artifactId}-${project.version}.jar + diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/AbstractCommand.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/AbstractCommand.java index c828eac74..fbafbe273 100644 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/AbstractCommand.java +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/AbstractCommand.java @@ -89,7 +89,7 @@ protected AspectContext loadModelOrFail( final String modelFileName, final Exter protected void generateDiagram( final String inputFileName, final AspectModelDiagramGenerator.Format targetFormat, final String outputFileName, final String languageTag, final ExternalResolverMixin resolverConfig ) throws IOException { final AspectContext context = loadModelOrFail( inputFileName, resolverConfig ); - final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( context.rdfModel() ); + final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( context ); final Set targetFormats = new HashSet<>(); targetFormats.add( targetFormat ); final Set languagesUsedInModel = LanguageCollector.collectUsedLanguages( context.rdfModel().getModel() ); diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/NativeImageHelpers.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/NativeImageHelpers.java index 50de661b0..e70f2c7fc 100644 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/NativeImageHelpers.java +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/NativeImageHelpers.java @@ -16,19 +16,25 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.apache.commons.lang3.SystemUtils; +import org.eclipse.esmf.substitution.IsWindows; /** * Utility class providing helpers and workarounds needed to get the native image working properly on different platforms. */ public class NativeImageHelpers { - public static void ensureRequiredEnvironment() { - if ( System.getProperty( "java.home" ) == null && SystemUtils.OS_NAME.startsWith( "Windows" ) ) { // GraalVM native image on Windows - // font handling which we use in diagram/document generators relies on this variable being set - // and the font config files must be present in the "lib" subdirectory of the path from where the native image is started + if ( System.getProperty( "java.home" ) == null ) { + // Font handling which we use in diagram/document generators relies on this variable being set + // and the font config files must be present in the "lib" subdirectory of the path from where the native image is started. + // The check for the java.home property is done by sun.awt.FontConfiguration#findFontConfigFile which is called + // transitively by other AWT code final Path nativeImagePath = Paths.get( "." ).toAbsolutePath().normalize(); // current working directory System.setProperty( "java.home", nativeImagePath.toString() ); + + if ( new IsWindows().getAsBoolean() ) { + // Set to headless mode, because instantiation of AWT graphics context in Windows is flaky + System.setProperty( "java.awt.headless", "true" ); + } } } } diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/SammCli.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/SammCli.java index 31f97dda3..b72b91aa7 100644 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/SammCli.java +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/SammCli.java @@ -16,11 +16,9 @@ import java.io.InputStream; import java.util.Properties; -import org.fusesource.jansi.AnsiConsole; - -import guru.nidi.graphviz.engine.Graphviz; import org.eclipse.esmf.aspect.AspectCommand; -import org.eclipse.esmf.substitution.GraalVmJsGraphvizEngine; + +import org.fusesource.jansi.AnsiConsole; import picocli.CommandLine; @CommandLine.Command( name = SammCli.COMMAND_NAME, @@ -47,7 +45,8 @@ public SammCli() { final CommandLine.IExecutionExceptionHandler defaultExecutionExceptionHandler = initialCommandLine.getExecutionExceptionHandler(); commandLine = initialCommandLine.setExecutionExceptionHandler( new CommandLine.IExecutionExceptionHandler() { @Override - public int handleExecutionException( final Exception exception, final CommandLine commandLine, final CommandLine.ParseResult parseResult ) + public int handleExecutionException( final Exception exception, final CommandLine commandLine, + final CommandLine.ParseResult parseResult ) throws Exception { if ( exception.getClass().getName() .equals( String.format( "%s.MainClassProcessLauncher$SystemExitCaptured", SammCli.class.getPackageName() ) ) ) { @@ -88,8 +87,6 @@ int runWithExceptionHandler( final CommandLine.IExecutionExceptionHandler except public static void main( final String[] argv ) { NativeImageHelpers.ensureRequiredEnvironment(); - setupGraphvizJava(); - // The disabling color switch needs to be checked before PicoCLI initialization boolean disableColor = false; for ( final String arg : argv ) { @@ -98,6 +95,14 @@ public static void main( final String[] argv ) { } } + // Imply disabling color when PNGs are generated, otherwise ANSI escapes scramble binary output + if ( argv.length >= 4 + && argv[argv.length - 4].equals( "aspect" ) + && argv[argv.length - 2].equals( "to" ) + && argv[argv.length - 1].equals( "png" ) ) { + disableColor = true; + } + if ( !disableColor ) { AnsiConsole.systemInstall(); } @@ -110,10 +115,6 @@ public static void main( final String[] argv ) { System.exit( exitCode ); } - private static void setupGraphvizJava() { - Graphviz.useEngine( new GraalVmJsGraphvizEngine() ); - } - protected String format( final String string ) { return commandLine.getColorScheme().ansi().string( string ); } diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/AspectToCommand.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/AspectToCommand.java index c2b683f0d..96a641660 100644 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/AspectToCommand.java +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/AspectToCommand.java @@ -21,7 +21,6 @@ import org.eclipse.esmf.AbstractCommand; import org.eclipse.esmf.LoggingMixin; -import org.eclipse.esmf.aspect.to.AspectToDotCommand; import org.eclipse.esmf.aspect.to.AspectToHtmlCommand; import org.eclipse.esmf.aspect.to.AspectToJavaCommand; import org.eclipse.esmf.aspect.to.AspectToOpenapiCommand; @@ -32,7 +31,6 @@ @CommandLine.Command( name = AspectToCommand.COMMAND_NAME, description = "Transforms an Aspect Model into another format", subcommands = { CommandLine.HelpCommand.class, - AspectToDotCommand.class, AspectToHtmlCommand.class, AspectToJavaCommand.class, AspectToJsonCommand.class, diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/to/AspectToDotCommand.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/to/AspectToDotCommand.java deleted file mode 100644 index ded517dc7..000000000 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/to/AspectToDotCommand.java +++ /dev/null @@ -1,59 +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.aspect.to; - -import java.io.IOException; - -import org.eclipse.esmf.AbstractCommand; -import org.eclipse.esmf.ExternalResolverMixin; -import org.eclipse.esmf.LoggingMixin; -import org.eclipse.esmf.aspect.AspectToCommand; -import org.eclipse.esmf.aspectmodel.generator.diagram.AspectModelDiagramGenerator; -import org.eclipse.esmf.exception.CommandException; -import picocli.CommandLine; - -@CommandLine.Command( name = AspectToDotCommand.COMMAND_NAME, - description = "Generate DOT (graphviz) diagram for an Aspect Model", - descriptionHeading = "%n@|bold Description|@:%n%n", - parameterListHeading = "%n@|bold Parameters|@:%n", - optionListHeading = "%n@|bold Options|@:%n", - mixinStandardHelpOptions = true -) -public class AspectToDotCommand extends AbstractCommand { - public static final String COMMAND_NAME = "dot"; - - @CommandLine.Option( names = { "--output", "-o" }, description = "Output file path (default: stdout)" ) - private String outputFilePath = "-"; - - @CommandLine.Option( names = { "--language", "-l" }, description = "The language from the model for which the diagram should be generated (default: en)" ) - private String language = "en"; - - @CommandLine.ParentCommand - private AspectToCommand parentCommand; - - @CommandLine.Mixin - private LoggingMixin loggingMixin; - - @CommandLine.Mixin - private ExternalResolverMixin customResolver; - - @Override - public void run() { - try { - generateDiagram( parentCommand.parentCommand.getInput(), AspectModelDiagramGenerator.Format.DOT, outputFilePath, language, customResolver ); - } catch ( final IOException e ) { - throw new CommandException( e ); - } - } -} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/buildtime/CustomizeGraalVmConfigs.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/buildtime/CustomizeGraalVmConfigs.java new file mode 100644 index 000000000..ac91f1744 --- /dev/null +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/buildtime/CustomizeGraalVmConfigs.java @@ -0,0 +1,107 @@ +/* + * 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.buildtime; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Iterator; +import java.util.List; +import java.util.function.Predicate; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * This class runs at build time, after the executable jar for samm-cli has been executed with the GraalVM native image agent, + * but before the native image compiler is started. It will adjust the configs that were created by the native image agent, + * which sometimes create configurations which lead to failures during either compilation or runtime. + */ +public class CustomizeGraalVmConfigs { + public static void main( final String[] args ) throws IOException { + // args[0] is set to the path containing the GraalVM configs to adjust by the Maven build + final File configsDirectory = new File( args[0] ); + if ( !configsDirectory.exists() || !configsDirectory.isDirectory() ) { + System.err.println( "Warning: Native resource config directory " + configsDirectory + " not found, skipping customizing" ); + System.exit( 0 ); + } + final Path configsPath = configsDirectory.toPath(); + adjustResourceConfig( configsPath.resolve( "resource-config.json" ).toFile() ); + adjustReflectConfig( configsPath.resolve( "reflect-config.json" ).toFile() ); + } + + private static void adjustResourceConfig( final File resourceConfig ) throws IOException { + if ( !resourceConfig.exists() ) { + System.err.println( "Warning: Native resource config " + resourceConfig + " not found, skipping customizing" ); + return; + } + + final List> resourceIncludesToDelete = List.of( + // This include is deleted because it leads to "Class path contains multiple SLF4J bindings" warnings + includeNode -> includeNode.asText().contains( "org/slf4j/impl/StaticLoggerBinder.class" ) + ); + final String content = Files.readString( resourceConfig.toPath() ); + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode root = mapper.readTree( content ); + final JsonNode includes = root.get( "resources" ).get( "includes" ); + if ( includes == null || includes.elements() == null ) { + return; + } + for ( final Iterator i = includes.elements(); i.hasNext(); ) { + final JsonNode include = i.next(); + for ( final Predicate decideIfNodeShouldBeDeleted : resourceIncludesToDelete ) { + final JsonNode pattern = include.get( "pattern" ); + if ( pattern != null && decideIfNodeShouldBeDeleted.test( include.get( "pattern" ) ) ) { + i.remove(); + } + } + } + + try ( final FileOutputStream out = new FileOutputStream( resourceConfig ) ) { + mapper.writerWithDefaultPrettyPrinter().writeValue( out, root ); + } + } + + private static void adjustReflectConfig( final File reflectConfig ) throws IOException { + if ( !reflectConfig.exists() ) { + System.err.println( "Warning: Native resource config " + reflectConfig + " not found, skipping customizing" ); + return; + } + + final List> reflectEntriesToDelete = List.of( + // These three reflection entries are added by the native image agent, but cause the native compilation to fail + includeNode -> includeNode.asText().contains( "jdk.internal.loader.BuiltinClassLoader" ), + includeNode -> includeNode.asText().contains( "jdk.internal.loader.ClassLoaders$AppClassLoader" ), + includeNode -> includeNode.asText().contains( "jdk.internal.loader.ClassLoaders$PlatformClassLoader" ) + ); + final String content = Files.readString( reflectConfig.toPath() ); + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode root = mapper.readTree( content ); + for ( final Iterator i = root.elements(); i.hasNext(); ) { + final JsonNode include = i.next(); + for ( final Predicate decideIfNodeShouldBeDeleted : reflectEntriesToDelete ) { + final JsonNode name = include.get( "name" ); + if ( name != null && decideIfNodeShouldBeDeleted.test( include.get( "name" ) ) ) { + i.remove(); + } + } + } + + try ( final FileOutputStream out = new FileOutputStream( reflectConfig ) ) { + mapper.writerWithDefaultPrettyPrinter().writeValue( out, root ); + } + } +} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/buildtime/CustomizeResourceConfig.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/buildtime/CustomizeResourceConfig.java deleted file mode 100644 index d09da16c0..000000000 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/buildtime/CustomizeResourceConfig.java +++ /dev/null @@ -1,56 +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.buildtime; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.util.Iterator; -import java.util.List; -import java.util.function.Predicate; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class CustomizeResourceConfig { - private static final List> INCLUDES_TO_DELETE = List.of( - // This include is deleted because it leads to "Class path contains multiple SLF4J bindings" warnings - includeNode -> includeNode.asText().contains( "org/slf4j/impl/StaticLoggerBinder.class" ) - ); - - public static void main( final String[] args ) throws IOException { - final File file = new File( args[0] ); - if ( !file.exists() ) { - System.err.println( "Warning: Native resource config " + file + " not found, skipping customizing" ); - System.exit( 0 ); - } - final String content = Files.readString( file.toPath() ); - final ObjectMapper mapper = new ObjectMapper(); - final JsonNode root = mapper.readTree( content ); - final JsonNode includes = root.get( "resources" ).get( "includes" ); - for ( final Iterator i = includes.elements(); i.hasNext(); ) { - final JsonNode include = i.next(); - for ( final Predicate decideIfNodeShouldBeDeleted : INCLUDES_TO_DELETE ) { - if ( decideIfNodeShouldBeDeleted.test( include.get( "pattern" ) ) ) { - i.remove(); - } - } - } - - try ( final FileOutputStream out = new FileOutputStream( file ) ) { - mapper.writerWithDefaultPrettyPrinter().writeValue( out, root ); - } - } -} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/GraalJavascriptEngine.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/GraalJavascriptEngine.java deleted file mode 100644 index 66f79bb16..000000000 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/GraalJavascriptEngine.java +++ /dev/null @@ -1,51 +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.substitution; - -import org.graalvm.polyglot.Context; -import org.graalvm.polyglot.PolyglotException; - -import guru.nidi.graphviz.engine.AbstractJavascriptEngine; -import guru.nidi.graphviz.engine.GraphvizException; -import guru.nidi.graphviz.engine.ResultHandler; - -/** - * This class is a copy of guru.nidi.graphviz.engine.GraalJavascriptEngine, which needs to be instantiated from - * the {@link GraalVmJsGraphvizEngine}, because the original class is not public. - */ -public class GraalJavascriptEngine extends AbstractJavascriptEngine { - private final ResultHandler resultHandler = new ResultHandler(); - private final Context context = Context.newBuilder( "js" ).allowAllAccess( true ).build(); - - GraalJavascriptEngine() { - context.getPolyglotBindings().putMember( "handler", resultHandler ); - eval( "function result(r){ Polyglot.import('handler').setResult(r); }" - + "function error(r){ Polyglot.import('handler').setError(r); }" - + "function log(r){ Polyglot.import('handler').log(r); }" ); - } - - @Override - protected String execute( final String js ) { - try { - eval( js ); - return resultHandler.waitFor(); - } catch ( final PolyglotException e ) { - throw new GraphvizException( "Problem executing javascript", e ); - } - } - - private void eval( final String code ) { - context.eval( "js", code ); - } -} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/GraalVmJsGraphvizEngine.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/GraalVmJsGraphvizEngine.java deleted file mode 100644 index a798b6063..000000000 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/GraalVmJsGraphvizEngine.java +++ /dev/null @@ -1,38 +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.substitution; - -import guru.nidi.graphviz.engine.AbstractJsGraphvizEngine; -import guru.nidi.graphviz.engine.JavascriptEngine; -import guru.nidi.graphviz.engine.MissingDependencyException; - -/** - * Custom graphviz-java {@link JavascriptEngine} implementation based on the GraalVM JavaScript engine - */ -public final class GraalVmJsGraphvizEngine extends AbstractJsGraphvizEngine { - public GraalVmJsGraphvizEngine() { - super( true, GraalVmJsGraphvizEngine::buildEngine ); - super.doInit(); - } - - @SuppressWarnings( "squid:S1166" ) - // Can't retrow exception, because logic (including throwing MissingDependencyException) is adapted from graphivz-java core - private static JavascriptEngine buildEngine() { - try { - return new GraalJavascriptEngine(); - } catch ( final ExceptionInInitializerError | NoClassDefFoundError | IllegalStateException exception ) { - throw new MissingDependencyException( "GraalVM JavaScript engine is not available.", "org.graalvm.js:js" ); - } - } -} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/IsLinux.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/IsLinux.java new file mode 100644 index 000000000..7afae7004 --- /dev/null +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/IsLinux.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.substitution; + +import java.util.function.BooleanSupplier; + +/** + * Conditional to execute substitution only on Linux. Use with com.oracle.svm.core.annotate.Substitute's onlyWith attribute. + */ +public class IsLinux implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return "Linux".equals( System.getProperty( "os.name" ) ); + } +} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/IsWindows.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/IsWindows.java new file mode 100644 index 000000000..c0bbc7dfb --- /dev/null +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/IsWindows.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.substitution; + +import java.util.function.BooleanSupplier; + +/** + * Conditional to execute substitution only on Windows. Use with com.oracle.svm.core.annotate.Substitute's onlyWith attribute. + */ +public class IsWindows implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return System.getProperty( "os.name", "" ).startsWith( "Windows" ); + } +} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_guru_nidi_graphviz_engine_GraphvizLoader.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_guru_nidi_graphviz_engine_GraphvizLoader.java deleted file mode 100644 index d38afe59c..000000000 --- a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_guru_nidi_graphviz_engine_GraphvizLoader.java +++ /dev/null @@ -1,45 +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.substitution; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import guru.nidi.graphviz.engine.GraphvizLoader; - -/** - * This is a GraalVM substitution class - * for {@link GraphvizLoader}. - * Reason: The
    isOnClassPath
    method is used to check availability of dependencies at runtime using resource lookup. However, this won't work in - * the native image build, instead, dependencies are wired at build time, so we can provide the relevant information statically. - */ -@TargetClass( GraphvizLoader.class ) -@SuppressWarnings( { - "unused", - "squid:S00101" // Class name uses GraalVM substitution class naming schema, see - // https://github.com/oracle/graal/tree/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk -} ) -public final class Target_guru_nidi_graphviz_engine_GraphvizLoader { - @Substitute - static boolean isOnClasspath( final String resource ) { - return switch ( resource ) { - case "org/apache/batik/transcoder/Transcoder.class" -> true; - case "com/kitfox/svg/SVGDiagram.class" -> false; - case "net/arnx/nashorn/lib/PromiseException.class" -> false; - case "org/apache/commons/exec/CommandLine.class" -> false; - case "com/eclipsesource/v8/V8.class" -> false; - default -> Target_guru_nidi_graphviz_engine_GraphvizLoader.class.getClassLoader().getResource( resource ) != null; - }; - } -} diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_sun_awt_FontConfiguration.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_sun_awt_FontConfiguration.java new file mode 100644 index 000000000..4f71e70be --- /dev/null +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_sun_awt_FontConfiguration.java @@ -0,0 +1,54 @@ +/* + * 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.substitution; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import org.eclipse.esmf.SammCli; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +/** + * This is a GraalVM substitution class + * for sun.awt.FontConfiguration. + * Reason: In Windows, AWT internal will try to load a font config file that is only available at runtime and will be + * looked for - hard coded - in $JAVA_HOME. This substitution redirects this to read the config from the resources instead. + * This only works in conjuction with a build setup that makes the font config available in the build time class path, + * see copy-fontconfig-bfc in pom.xml; as well as a corresponding entry in resource-config.json. + */ +@TargetClass( className = "sun.awt.FontConfiguration", onlyWith = IsWindows.class ) +@SuppressWarnings( { + "unused", + "squid:S00101" // Class name uses GraalVM substitution class naming schema, see + // https://github.com/oracle/graal/tree/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk + , "NewClassNamingConvention" } ) +public final class Target_sun_awt_FontConfiguration { + @Substitute + private void readFontConfigFile( final File f ) { + try ( final InputStream inputStream = SammCli.class.getResourceAsStream( "/fontconfig.bfc" ) ) { + loadBinary( inputStream ); + } catch ( final IOException e ) { + throw new RuntimeException( e ); + } + } + + // Reference to the original loadBinary() method, so that we can call it from readFontConfigFile + @Alias + public static native void loadBinary( InputStream inStream ) throws IOException; +} + diff --git a/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_sun_awt_X11FontManager.java b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_sun_awt_X11FontManager.java new file mode 100644 index 000000000..812919cd2 --- /dev/null +++ b/tools/samm-cli/src/main/java/org/eclipse/esmf/substitution/Target_sun_awt_X11FontManager.java @@ -0,0 +1,63 @@ +/* + * 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.substitution; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +/** + * This is a GraalVM substitution class + * for sun.awt.X11FontManager. + * Reason: In Linux/X11, AWT internal will try to resolve font configuration files from the JDK directory (java.home) + * which will be null in the GraalVM binary. This substitution will hardcode the code path that does not check for those configs. + * Unfortunately, since the GraalVM compiler itself is tripped up by sun.awt classes in the resolution graph, we need to + * trick it by accessing the relevant code via reflection. This in turn means that we need to put X11FontManager & friends into + * reflection-config.json. + */ +@TargetClass( className = "sun.awt.X11FontManager", onlyWith = IsLinux.class ) +@SuppressWarnings( { + "unused", + "squid:S00101" // Class name uses GraalVM substitution class naming schema, see + // https://github.com/oracle/graal/tree/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk + , "NewClassNamingConvention" } ) +public final class Target_sun_awt_X11FontManager { + /** + * This method actually returns a sun.awt.FontConfiguration. Due to the fact that we can not refer to sun.awt classes, + * (X11FontManager & friends are not part of non-Linux JDKs) we return java.lang.Object instead. Luckily for us, the + * Graal substitution mechanism still picks this up and replaces the original method. + * + * @return the font configuration object + */ + @SuppressWarnings( "ProtectedMemberInFinalClass" ) + @Substitute + protected Object createFontConfiguration() { + try { + final Class clazz = Class.forName( "sun.font.FcFontConfiguration" ); + final Class sunFontManagerClazz = Class.forName( "sun.font.SunFontManager" ); + final Constructor constructor = clazz.getConstructor( sunFontManagerClazz ); + final Object fcFontConfig = constructor.newInstance( this ); + final Method init = clazz.getMethod( "init" ); + // ignore result + init.invoke( fcFontConfig ); + return fcFontConfig; + } catch ( final ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | + IllegalAccessException e ) { + throw new RuntimeException( e ); + } + } +} diff --git a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/jni-config.json b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/jni-config.json index d48d06eec..cba7b9792 100644 --- a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/jni-config.json +++ b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/jni-config.json @@ -1,6 +1,461 @@ [ - { - "name":"java.awt.Color", - "allDeclaredFields":true, - "allDeclaredMethods":true - }] +{ + "name":"sun.awt.Win32GraphicsDevice", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"sun.java2d.d3d.D3DGraphicsDevice", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"sun.font.FontConfigManager", + "allDeclaredFields":true, + "allDeclaredMethods":true +}, +{ + "name":"sun.font.FontConfigManager$FontConfigInfo", + "allDeclaredFields":true, + "allDeclaredMethods":true +}, +{ + "name":"sun.font.FontConfigManager$FcCompFont", + "allDeclaredFields":true, + "allDeclaredMethods":true +}, +{ + "name":"sun.font.FontConfigManager$FontConfigFont", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"java.awt.Cursor", + "fields":[{"name":"pData"}, {"name":"type"}], + "methods":[{"name":"setPData","parameterTypes":["long"] }] +}, +{ + "name":"java.awt.Dimension", + "fields":[{"name":"height"}, {"name":"width"}] +}, +{ + "name":"java.awt.Font", + "fields":[{"name":"name"}, {"name":"pData"}, {"name":"size"}, {"name":"style"}], + "methods":[{"name":"getFont","parameterTypes":["java.lang.String"] }, {"name":"getFontPeer","parameterTypes":[] }] +}, +{ + "name":"java.awt.FontMetrics", + "fields":[{"name":"font"}], + "methods":[{"name":"getHeight","parameterTypes":[] }] +}, +{ + "name":"java.awt.Point", + "fields":[{"name":"x"}, {"name":"y"}] +}, +{ + "name":"java.awt.Toolkit", + "methods":[{"name":"getDefaultToolkit","parameterTypes":[] }, {"name":"getFontMetrics","parameterTypes":["java.awt.Font"] }] +}, +{ + "name":"java.awt.desktop.UserSessionEvent$Reason", + "fields":[{"name":"CONSOLE"}, {"name":"LOCK"}, {"name":"REMOTE"}, {"name":"UNSPECIFIED"}] +}, +{ + "name":"java.lang.Thread", + "methods":[{"name":"yield","parameterTypes":[] }] +}, +{ + "name":"java.awt.Color", + "allDeclaredFields":true, + "allDeclaredMethods":true +}, +{ + "name": "java.awt.Insets", + "allDeclaredFields": true, + "allDeclaredMethods": true +}, +{ + "name": "java.awt.event.InputEvent", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name":"java.awt.image.BufferedImage", + "fields":[{"name":"colorModel"}, {"name":"imageType"}, {"name":"raster"}], + "methods":[{"name":"getRGB","parameterTypes":["int","int","int","int","int[]","int","int"] }, {"name":"setRGB","parameterTypes":["int","int","int","int","int[]","int","int"] }] +}, +{ + "name":"java.awt.image.Raster", + "fields":[{"name":"dataBuffer"}, {"name":"height"}, {"name":"minX"}, {"name":"minY"}, {"name":"numBands"}, {"name":"numDataElements"}, {"name":"sampleModel"}, {"name":"sampleModelTranslateX"}, {"name":"sampleModelTranslateY"}, {"name":"width"}] +}, +{ + "name":"java.awt.image.SampleModel", + "fields":[{"name":"height"}, {"name":"width"}], + "methods":[{"name":"getPixels","parameterTypes":["int","int","int","int","int[]","java.awt.image.DataBuffer"] }, {"name":"setPixels","parameterTypes":["int","int","int","int","int[]","java.awt.image.DataBuffer"] }] +}, +{ + "name":"java.awt.image.SinglePixelPackedSampleModel", + "fields":[{"name":"bitMasks"}, {"name":"bitOffsets"}, {"name":"bitSizes"}, {"name":"maxBitSize"}] +}, +{ + "name": "java.awt.AWTEvent", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name":"[Lsun.java2d.loops.GraphicsPrimitive;" +}, +{ + "name":"java.awt.AlphaComposite", + "fields":[{"name":"extraAlpha"}, {"name":"rule"}] +}, +{ + "name":"java.awt.Component", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name":"sun.font.FontDesignMetrics", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name":"java.awt.GraphicsEnvironment", + "methods":[{"name":"getLocalGraphicsEnvironment","parameterTypes":[] }, {"name":"isHeadless","parameterTypes":[] }] +}, +{ + "name":"java.awt.event.KeyEvent", + "fields":[{"name":"isProxyActive"}] +}, +{ + "name":"java.awt.geom.AffineTransform", + "fields":[{"name":"m00"}, {"name":"m01"}, {"name":"m02"}, {"name":"m10"}, {"name":"m11"}, {"name":"m12"}] +}, +{ + "name":"java.awt.geom.GeneralPath", + "methods":[{"name":"","parameterTypes":[] }, {"name":"","parameterTypes":["int","byte[]","int","float[]","int"] }] +}, +{ + "name":"java.awt.geom.Path2D", + "fields":[{"name":"numTypes"}, {"name":"pointTypes"}, {"name":"windingRule"}] +}, +{ + "name":"java.awt.geom.Path2D$Float", + "fields":[{"name":"floatCoords"}] +}, +{ + "name":"java.awt.geom.Point2D$Float", + "fields":[{"name":"x"}, {"name":"y"}], + "methods":[{"name":"","parameterTypes":["float","float"] }] +}, +{ + "name":"java.awt.geom.Rectangle2D$Float", + "fields":[{"name":"height"}, {"name":"width"}, {"name":"x"}, {"name":"y"}], + "methods":[{"name":"","parameterTypes":[] }, {"name":"","parameterTypes":["float","float","float","float"] }] +}, +{ + "name":"java.awt.image.ColorModel", + "fields":[{"name":"colorSpace"}, {"name":"colorSpaceType"}, {"name":"isAlphaPremultiplied"}, {"name":"is_sRGB"}, {"name":"nBits"}, {"name":"numComponents"}, {"name":"pData"}, {"name":"supportsAlpha"}, {"name":"transparency"}], + "methods":[{"name":"getRGBdefault","parameterTypes":[] }] +}, +{ + "name":"java.awt.image.IndexColorModel", + "fields":[{"name":"allgrayopaque"}, {"name":"map_size"}, {"name":"rgb"}, {"name":"transparent_index"}] +}, +{ + "name":"java.lang.Boolean", + "methods":[{"name":"getBoolean","parameterTypes":["java.lang.String"] }] +}, +{ + "name":"java.lang.System", + "methods":[{"name":"load","parameterTypes":["java.lang.String"] }, {"name":"setProperty","parameterTypes":["java.lang.String","java.lang.String"] }] +}, +{ + "name":"java.lang.String", + "methods":[{"name":"toLowerCase","parameterTypes":["java.util.Locale"] }] +}, +{ + "name":"java.util.ArrayList", + "methods":[{"name":"","parameterTypes":["int"] }, {"name":"add","parameterTypes":["java.lang.Object"] }] +}, +{ + "name":"java.util.HashMap", + "methods":[{"name":"containsKey","parameterTypes":["java.lang.Object"] }, {"name":"put","parameterTypes":["java.lang.Object","java.lang.Object"] }] +}, +{ + "name":"sun.awt.AWTAutoShutdown", + "methods":[{"name":"notifyToolkitThreadBusy","parameterTypes":[] }, {"name":"notifyToolkitThreadFree","parameterTypes":[] }] +}, +{ + "name":"sun.awt.SunHints", + "fields":[{"name":"INTVAL_STROKE_PURE"}] +}, +{ + "name":"sun.awt.SunToolkit", + "methods":[{"name":"awtLock","parameterTypes":[] }, {"name":"awtLockNotify","parameterTypes":[] }, {"name":"awtLockNotifyAll","parameterTypes":[] }, {"name":"awtLockWait","parameterTypes":["long"] }, {"name":"awtUnlock","parameterTypes":[] },{"name":"isTouchKeyboardAutoShowEnabled","parameterTypes":[] }] +}, +{ + "name":"sun.awt.Win32GraphicsConfig", + "fields":[{"name":"visual"}] +}, +{ + "name":"sun.awt.Win32GraphicsDevice", + "fields":[{"name":"dynamicColorModel"}] +}, +{ + "name":"sun.awt.Win32GraphicsEnvironment", + "methods":[{"name":"dwmCompositionChanged","parameterTypes":["boolean"] }] +}, +{ + "name":"sun.awt.image.ByteComponentRaster", + "fields":[{"name":"data"}, {"name":"dataOffsets"}, {"name":"pixelStride"}, {"name":"scanlineStride"}, {"name":"type"}] +}, +{ + "name":"sun.awt.image.GifImageDecoder", + "fields":[{"name":"outCode"}, {"name":"prefix"}, {"name":"suffix"}], + "methods":[{"name":"readBytes","parameterTypes":["byte[]","int","int"] }, {"name":"sendPixels","parameterTypes":["int","int","int","int","byte[]","java.awt.image.ColorModel"] }] +}, +{ + "name":"sun.awt.image.BufImgSurfaceData$ICMColorData", + "fields":[{"name":"pData"}], + "methods":[{"name":"","parameterTypes":["long"] }] +}, +{ + "name":"sun.awt.image.ImageRepresentation", + "fields":[{"name":"numSrcLUT"}, {"name":"srcLUTtransIndex"}] +}, +{ + "name":"sun.awt.image.IntegerComponentRaster", + "fields":[{"name":"data"}, {"name":"dataOffsets"}, {"name":"pixelStride"}, {"name":"scanlineStride"}, {"name":"type"}] +}, +{ + "name":"sun.awt.image.SunVolatileImage", + "fields":[{"name":"volSurfaceManager"}] +}, +{ + "name":"sun.awt.image.VolatileSurfaceManager", + "fields":[{"name":"sdCurrent"}] +}, +{ + "name":"sun.awt.windows.WComponentPeer", + "fields":[{"name":"hwnd"}, {"name":"winGraphicsConfig"}], + "methods":[{"name":"disposeLater","parameterTypes":[] }, {"name":"replaceSurfaceData","parameterTypes":[] }, {"name":"replaceSurfaceDataLater","parameterTypes":[] }] +}, +{ + "name":"sun.awt.windows.WDesktopPeer", + "methods":[{"name":"systemSleepCallback","parameterTypes":["boolean"] }, {"name":"userSessionCallback","parameterTypes":["boolean","java.awt.desktop.UserSessionEvent$Reason"] }] +}, +{ + "name":"sun.awt.windows.WObjectPeer", + "fields":[{"name":"createError"}, {"name":"destroyed"}, {"name":"pData"}, {"name":"target"}], + "methods":[{"name":"getPeerForTarget","parameterTypes":["java.lang.Object"] }] +}, +{ + "name":"sun.awt.windows.WToolkit", + "methods":[{"name":"displayChanged","parameterTypes":[] }, {"name":"paletteChanged","parameterTypes":[] }, {"name":"windowsSettingChange","parameterTypes":[] }] +}, +{ + "name":"sun.awt.X11.XErrorHandlerUtil", + "methods":[{"name":"init","parameterTypes":["long"] }] +}, +{ + "name":"sun.awt.X11GraphicsConfig", + "fields":[{"name":"aData"}, {"name":"bitsPerPixel"}] +}, +{ + "name":"sun.awt.X11GraphicsDevice", + "methods":[{"name":"addDoubleBufferVisual","parameterTypes":["int"] }] +}, +{ + "name":"sun.font.CharToGlyphMapper", + "methods":[{"name":"charToGlyph","parameterTypes":["int"] }] +}, +{ + "name":"sun.font.Font2D", + "methods":[{"name":"canDisplay","parameterTypes":["char"] }, {"name":"charToGlyph","parameterTypes":["int"] }, {"name":"charToVariationGlyph","parameterTypes":["int","int"] }, {"name":"getMapper","parameterTypes":[] }, {"name":"getTableBytes","parameterTypes":["int"] }] +}, +{ + "name":"sun.font.FontStrike", + "methods":[{"name":"getGlyphMetrics","parameterTypes":["int"] }] +}, +{ + "name":"sun.font.FreetypeFontScaler", + "methods":[{"name":"invalidateScaler","parameterTypes":[] }] +}, +{ + "name":"sun.font.GlyphList", + "fields":[{"name":"gposx"}, {"name":"gposy"}, {"name":"images"}, {"name":"lcdRGBOrder"}, {"name":"lcdSubPixPos"}, {"name":"len"}, {"name":"positions"}, {"name":"usePositions"}] +}, +{ + "name":"sun.font.GlyphLayout$GVData", + "fields":[{"name":"_count"}, {"name":"_flags"}, {"name":"_glyphs"}, {"name":"_indices"}, {"name":"_positions"}], + "methods":[{"name":"grow","parameterTypes":[] }] +}, +{ + "name":"sun.font.PhysicalStrike", + "fields":[{"name":"pScalerContext"}], + "methods":[{"name":"adjustPoint","parameterTypes":["java.awt.geom.Point2D$Float"] }, {"name":"getGlyphPoint","parameterTypes":["int","int"] }] +}, +{ + "name":"sun.font.StrikeMetrics", + "methods":[{"name":"","parameterTypes":["float","float","float","float","float","float","float","float","float","float"] }] +}, +{ + "name":"sun.font.TrueTypeFont", + "methods":[{"name":"readBlock","parameterTypes":["java.nio.ByteBuffer","int","int"] }, {"name":"readBytes","parameterTypes":["int","int"] }] +}, +{ + "name":"sun.font.Type1Font", + "methods":[{"name":"readFile","parameterTypes":["java.nio.ByteBuffer"] }] +}, +{ + "name":"sun.java2d.Disposer", + "methods":[{"name":"addRecord","parameterTypes":["java.lang.Object","long","long"] }] +}, +{ + "name":"sun.java2d.InvalidPipeException" +}, +{ + "name":"sun.java2d.NullSurfaceData" +}, +{ + "name":"sun.java2d.SunGraphics2D", + "fields":[{"name":"clipRegion"}, {"name":"composite"}, {"name":"eargb"}, {"name":"lcdTextContrast"}, {"name":"pixel"}, {"name":"strokeHint"}] +}, +{ + "name":"sun.java2d.SunGraphicsEnvironment", + "methods":[{"name":"isDisplayLocal","parameterTypes":[] }] +}, +{ + "name":"sun.java2d.SurfaceData", + "fields":[{"name":"pData"}, {"name":"valid"}] +}, +{ + "name":"sun.java2d.d3d.D3DGraphicsDevice$1", + "methods":[{"name":"run","parameterTypes":[] }] +}, +{ + "name":"sun.java2d.d3d.D3DRenderQueue$1", + "methods":[{"name":"run","parameterTypes":[] }] +}, +{ + "name":"sun.java2d.loops.Blit", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.BlitBg", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.CompositeType", + "fields":[{"name":"AnyAlpha"}, {"name":"Src"}, {"name":"SrcNoEa"}, {"name":"SrcOver"}, {"name":"SrcOverNoEa"}, {"name":"Xor"}] +}, +{ + "name":"sun.java2d.loops.DrawGlyphList", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.DrawGlyphListAA", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.DrawGlyphListLCD", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.DrawLine", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.DrawParallelogram", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.DrawPath", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.DrawPolygons", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.DrawRect", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.FillParallelogram", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.FillPath", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.FillRect", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.FillSpans", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.GraphicsPrimitive", + "fields":[{"name":"pNativePrim"}] +}, +{ + "name":"sun.java2d.loops.GraphicsPrimitiveMgr", + "methods":[{"name":"register","parameterTypes":["sun.java2d.loops.GraphicsPrimitive[]"] }] +}, +{ + "name":"sun.java2d.loops.MaskBlit", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.MaskFill", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.ScaledBlit", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.SurfaceType", + "fields":[{"name":"Any3Byte"}, {"name":"Any4Byte"}, {"name":"AnyByte"}, {"name":"AnyColor"}, {"name":"AnyInt"}, {"name":"AnyShort"}, {"name":"ByteBinary1Bit"}, {"name":"ByteBinary2Bit"}, {"name":"ByteBinary4Bit"}, {"name":"ByteGray"}, {"name":"ByteIndexed"}, {"name":"ByteIndexedBm"}, {"name":"FourByteAbgr"}, {"name":"FourByteAbgrPre"}, {"name":"Index12Gray"}, {"name":"Index8Gray"}, {"name":"IntArgb"}, {"name":"IntArgbBm"}, {"name":"IntArgbPre"}, {"name":"IntBgr"}, {"name":"IntRgb"}, {"name":"IntRgbx"}, {"name":"OpaqueColor"}, {"name":"ThreeByteBgr"}, {"name":"Ushort4444Argb"}, {"name":"Ushort555Rgb"}, {"name":"Ushort555Rgbx"}, {"name":"Ushort565Rgb"}, {"name":"UshortGray"}, {"name":"UshortIndexed"}] +}, +{ + "name":"sun.java2d.loops.TransformHelper", + "methods":[{"name":"","parameterTypes":["long","sun.java2d.loops.SurfaceType","sun.java2d.loops.CompositeType","sun.java2d.loops.SurfaceType"] }] +}, +{ + "name":"sun.java2d.loops.XORComposite", + "fields":[{"name":"alphaMask"}, {"name":"xorColor"}, {"name":"xorPixel"}] +}, +{ + "name":"sun.java2d.pipe.Region", + "fields":[{"name":"bands"}, {"name":"endIndex"}, {"name":"hix"}, {"name":"hiy"}, {"name":"lox"}, {"name":"loy"}] +}, +{ + "name":"sun.java2d.pipe.RegionIterator", + "fields":[{"name":"curIndex"}, {"name":"numXbands"}, {"name":"region"}] +}, +{ + "name":"sun.java2d.pipe.ShapeSpanIterator", + "fields":[{"name":"pData"}] +}, +{ + "name":"sun.java2d.xr.XRSurfaceData", + "fields":[{"name":"picture"}, {"name":"xid"}] +}, +{ + "name":"sun.java2d.windows.WindowsFlags", + "fields":[{"name":"d3dEnabled"}, {"name":"d3dSet"}, {"name":"offscreenSharingEnabled"}, {"name":"setHighDPIAware"}] +} + +] diff --git a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/native-image.properties b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/native-image.properties index cd48a2242..fb578d62f 100644 --- a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/native-image.properties +++ b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/native-image.properties @@ -68,6 +68,8 @@ Args = -H:EnableURLProtocols=http,https \ -H:DynamicProxyConfigurationFiles=src/main/resources/META-INF/native-image/${project.groupId}/${project.artifactId}/proxy-config.json \ -H:ReflectionConfigurationFiles=src/main/resources/META-INF/native-image/${project.groupId}/${project.artifactId}/reflect-config.json \ -H:ResourceConfigurationFiles=src/main/resources/META-INF/native-image/${project.groupId}/${project.artifactId}/resource-config.json \ + -H:-DeadlockWatchdogExitOnTimeout \ + -H:DeadlockWatchdogInterval=0 \ -H:+AddAllCharsets \ -H:+ReportExceptionStackTraces \ -H:+PrintClassInitialization \ diff --git a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/reflect-config.json b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/reflect-config.json index 93c618ad3..552e7f521 100644 --- a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/reflect-config.json +++ b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/reflect-config.json @@ -1,188 +1,305 @@ [ - { - "name": "guru.nidi.graphviz.attribute.Style", - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "guru.nidi.graphviz.attribute.Shape", - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "guru.nidi.graphviz.engine.ResultHandler", - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "java.awt.Color", - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "ch.qos.logback.classic.pattern.DateConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MessageConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.NopThrowableInformationConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ContextNameConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldYellowCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LoggerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.ReplacingCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldBlueCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.CyanCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.RedCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.WhiteCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.PropertyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.RootCauseFirstThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MethodOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LevelConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.IdentityCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldWhiteCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MarkerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldCyanCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldMagentaCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.RelativeTimeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.MagentaCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LineOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.FileOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldGreenCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LocalSequenceNumberConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.YellowCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.color.HighlightingCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.GrayCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MDCConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldRedCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.GreenCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BlackCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ThreadConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LineSeparatorConverter", - "allDeclaredConstructors": true - }, - { - "name":"org.eclipse.esmf.aspectmodel.java.JavaCodeGenerationConfig", - "allDeclaredConstructors": true, - "allDeclaredFields":true, - "allDeclaredMethods": true - } +{ + "name":"sun.awt.Win32GraphicsDevice", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"sun.java2d.d3d.D3DGraphicsDevice", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"org.eclipse.esmf.SammCli", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"sun.util.resources.LocaleData$LocaleDataStrategy", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"sun.util.resources.LocaleData", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"sun.font.FontConfigManager$FontConfigInfo", + "allDeclaredFields":true, + "allDeclaredMethods":true +}, +{ + "name":"sun.font.FontConfigManager$FcCompFont", + "allDeclaredFields":true, + "allDeclaredMethods":true +}, +{ + "name":"sun.font.FontConfigManager$FontConfigFont", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name":"[Lorg.graphper.layout.dot.DNode;" +}, +{ + "name":"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"java.awt.Canvas", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name": "java.awt.Color", + "allDeclaredFields": true, + "allDeclaredMethods": true +}, +{ + "name": "java.awt.Insets", + "allDeclaredFields": true, + "allDeclaredMethods": true +}, +{ + "name": "java.awt.event.InputEvent", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name": "java.awt.AWTEvent", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name":"java.awt.Component", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name":"java.awt.Font", + "methods":[{"name":"","parameterTypes":["java.lang.String","int","int"] }] +}, +{ + "name":"java.awt.FontMetrics", + "methods":[{"name":"getHeight","parameterTypes":[] }, {"name":"stringWidth","parameterTypes":["java.lang.String"] }] +}, +{ + "name":"sun.font.FontDesignMetrics", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors":true +}, +{ + "name":"java.util.concurrent.atomic.AtomicBoolean", + "fields":[{"name":"value"}] +}, +{ + "name":"org.apache.batik.bridge.RhinoInterpreterFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.batik.css.parser.Parser", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.batik.ext.awt.image.codec.png.PNGTranscoderInternalCodecWriteAdapter", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.graphper.api.LineAttrs", + "allDeclaredFields":true +}, +{ + "name":"org.graphper.api.NodeAttrs", + "allDeclaredFields":true +}, +{ + "name":"sun.awt.Win32FontManager", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"sun.java2d.marlin.DMarlinRenderingEngine", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"sun.font.CompositeFontDescriptor", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true +}, +{ + "name": "ch.qos.logback.classic.pattern.DateConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.MessageConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.ThrowableProxyConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.NopThrowableInformationConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.ContextNameConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BoldYellowCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.LoggerConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.ReplacingCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BoldBlueCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.CyanCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.RedCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.WhiteCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.PropertyConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.RootCauseFirstThrowableProxyConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.MethodOfCallerConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.LevelConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.IdentityCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BoldWhiteCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.MarkerConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BoldCyanCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BoldMagentaCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.RelativeTimeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.MagentaCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.LineOfCallerConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.FileOfCallerConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BoldGreenCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.LocalSequenceNumberConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.YellowCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.color.HighlightingCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.GrayCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.MDCConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BoldRedCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.GreenCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.core.pattern.color.BlackCompositeConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.ThreadConverter", + "allDeclaredConstructors": true +}, +{ + "name": "ch.qos.logback.classic.pattern.LineSeparatorConverter", + "allDeclaredConstructors": true +}, +{ + "name":"org.eclipse.esmf.aspectmodel.java.JavaCodeGenerationConfig", + "allDeclaredConstructors": true, + "allDeclaredFields":true, + "allDeclaredMethods": true +} ] diff --git a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/resource-config.json b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/resource-config.json index c89181de3..97946689a 100644 --- a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/resource-config.json +++ b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/resource-config.json @@ -1,5 +1,6 @@ { "resources":[ + {"pattern":"java.base:\\Qjdk/internal/icu/impl/data/icudt67b/ubidi.icu\\E"}, {"pattern":"\\Qapplication.properties\\E"}, {"pattern":"\\Qgit.properties\\E"}, {"pattern":"\\Qadminshell.properties\\E"}, @@ -8,19 +9,21 @@ {"pattern":"\\QMETA-INF/services/com.oracle.truffle.api.instrumentation.TruffleInstrument$Provider\\E"}, {"pattern":"\\QMETA-INF/services/javax.script.ScriptEngineFactory\\E"}, {"pattern":"\\QMETA-INF/services/org.apache.jena.sys.JenaSubsystemLifecycle\\E"}, + {"pattern":"\\QMETA-INF/services/org.graphper.draw.CustomizeShapeRender\\E"}, + {"pattern":"\\QMETA-INF/services/org.graphper.layout.MeasureText\\E"}, {"pattern":"samm/[^/]*/([^/]*/)?[a-zA-Z0-9-]+\\.(ttl|js)"}, - {"pattern":"\\Qcom/oracle/truffle/nfi/impl/NFILanguageImpl.class\\E"}, {"pattern":"\\Qlogback.xml\\E"}, + {"pattern":"\\Qcom/oracle/truffle/nfi/impl/NFILanguageImpl.class\\E"}, {"pattern":"\\Qorg/apache/jena/arq/arq-properties.xml\\E"}, {"pattern":"\\Qorg/apache/jena/jena-properties.xml\\E"}, + {"pattern":"\\Qorg/apache/batik/anim/dom/resources/UserAgentStyleSheet.css\\E"}, + {"pattern":"\\Qorg/apache/batik/bridge/resources/help.gif\\E"}, + {"pattern":"\\Qorg/apache/batik/util/resources/XMLResourceDescriptor.properties\\E"}, {"pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E"}, - {"pattern":"\\Qrdf/dash.ttl\\E"}, - {"pattern":"\\Qrdf/shacl.ttl\\E"}, - {"pattern":"\\Qrdf/system-triples.ttl\\E"}, - {"pattern":"\\Qrdf/tosh.ttl\\E"}, - {"pattern":"\\Qguru/nidi/graphviz/engine/render.js\\E"}, - {"pattern":"\\QMETA-INF/resources/webjars/viz.js-graphviz-java/2.1.3/viz.js\\E"}, - {"pattern":"\\QMETA-INF/resources/webjars/viz.js-graphviz-java/2.1.3/full.render.js\\E"} + {"pattern":"\\Qfontconfig.bfc\\E"} ], - "bundles":[{"name":"org.apache.jena.ext.xerces.impl.xpath.regex.message"}] + "bundles":[ + {"name":"org.apache.jena.ext.xerces.impl.xpath.regex.message"}, + {"name":"sun.awt.resources.awt","classNames":["sun.awt.resources.awt"]} + ] } diff --git a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/serialization-config.json b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/serialization-config.json index fe51488c7..f3d7e06e3 100644 --- a/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/serialization-config.json +++ b/tools/samm-cli/src/main/resources/META-INF/native-image/org.eclipse.esmf/samm-cli/serialization-config.json @@ -1 +1,8 @@ -[] +{ + "types":[ + ], + "lambdaCapturingTypes":[ + ], + "proxies":[ + ] +} diff --git a/tools/samm-cli/src/test/java/org/eclipse/esmf/SammCliTest.java b/tools/samm-cli/src/test/java/org/eclipse/esmf/SammCliTest.java index 29509279f..c109afe00 100644 --- a/tools/samm-cli/src/test/java/org/eclipse/esmf/SammCliTest.java +++ b/tools/samm-cli/src/test/java/org/eclipse/esmf/SammCliTest.java @@ -254,55 +254,6 @@ public void testAspectToAasJsonToStdout() { assertThat( contentType( result.stdoutRaw() ) ).isEqualTo( MediaType.text( "plain" ) ); } - @Test - public void testAspectToDotWithDefaultLanguage() { - final File targetFile = outputFile( "output.dot" ); - final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot", "-o", - targetFile.getAbsolutePath() ); - assertThat( result.stdout() ).isEmpty(); - assertThat( result.stderr() ).isEmpty(); - assertThat( targetFile ).exists(); - assertThat( targetFile ).content().contains( "digraph AspectModel" ); - } - - @Test - public void testAspectToDotWithGivenLanguage() { - final File targetFile = outputFile( "output.dot" ); - final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot", "-o", - targetFile.getAbsolutePath(), "--language", - "en" ); - assertThat( result.stdout() ).isEmpty(); - assertThat( result.stderr() ).isEmpty(); - assertThat( targetFile ).exists(); - assertThat( targetFile ).content().startsWith( "digraph AspectModel" ); - } - - @Test - public void testAspectToDotWithNonExistentLanguage() { - final File targetFile = outputFile( "output.dot" ); - final ExecutionResult result = sammCli.apply( "--disable-color", "aspect", defaultInputFile, "to", "dot", "-o", targetFile.getAbsolutePath(), - "--language", "de" ); - assertThat( result.exitStatus() ).isEqualTo( 1 ); - assertThat( result.stdout() ).isEmpty(); - assertThat( result.stderr() ).contains( "The model does not contain the desired language" ); - assertThat( targetFile ).doesNotExist(); - } - - @Test - public void testAspectToDotToStdout() { - final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot" ); - assertThat( result.stdout() ).startsWith( "digraph AspectModel" ); - assertThat( result.stderr() ).isEmpty(); - } - - @Test - public void testAspectToDotWithCustomResolver() { - final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot", "--custom-resolver", - resolverCommand() ); - assertThat( result.stdout() ).startsWith( "digraph AspectModel" ); - assertThat( result.stderr() ).isEmpty(); - } - @Test public void testAspectToHtmlWithDefaultLanguageToFile() { final File targetFile = outputFile( "output.html" );