diff --git a/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/Namespace.java b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/Namespace.java new file mode 100644 index 000000000..088b0163f --- /dev/null +++ b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/Namespace.java @@ -0,0 +1,9 @@ +package org.eclipse.esmf.metamodel; + +/** + * A Namespace is Structure Element for describing namespace and providing user readable information about Namespace. + * + * @since SAMM 2.2.0 + */ +public interface Namespace extends StructureElement { +} diff --git a/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/impl/DefaultNamespace.java b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/impl/DefaultNamespace.java new file mode 100644 index 000000000..2ce8b1dfe --- /dev/null +++ b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/impl/DefaultNamespace.java @@ -0,0 +1,25 @@ +package org.eclipse.esmf.metamodel.impl; + +import java.util.List; + +import org.eclipse.esmf.metamodel.Namespace; +import org.eclipse.esmf.metamodel.Property; +import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes; +import org.eclipse.esmf.metamodel.visitor.AspectVisitor; + +public class DefaultNamespace extends ModelElementImpl implements Namespace { + + public DefaultNamespace( final MetaModelBaseAttributes metaModelBaseAttributes ) { + super( metaModelBaseAttributes ); + } + + @Override + public List getProperties() { + return null; + } + + @Override + public T accept( AspectVisitor visitor, C context ) { + return null; + } +} diff --git a/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/ModelElementFactory.java b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/ModelElementFactory.java index 9394d77e4..bc9fe3464 100644 --- a/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/ModelElementFactory.java +++ b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/ModelElementFactory.java @@ -61,6 +61,7 @@ import org.eclipse.esmf.metamodel.loader.instantiator.ListInstantiator; import org.eclipse.esmf.metamodel.loader.instantiator.LocaleConstraintInstantiator; import org.eclipse.esmf.metamodel.loader.instantiator.MeasurementInstantiator; +import org.eclipse.esmf.metamodel.loader.instantiator.NamespaceInstantiator; import org.eclipse.esmf.metamodel.loader.instantiator.OperationInstantiator; import org.eclipse.esmf.metamodel.loader.instantiator.PropertyInstantiator; import org.eclipse.esmf.metamodel.loader.instantiator.QuantifiableInstantiator; @@ -102,6 +103,7 @@ public ModelElementFactory( final KnownVersion metaModelVersion, final Model mod registerInstantiator( samm.Event(), new EventInstantiator( this ) ); registerInstantiator( samm.Operation(), new OperationInstantiator( this ) ); registerInstantiator( samm.Property(), new PropertyInstantiator( this ) ); + registerInstantiator( samm.Namespace(), new NamespaceInstantiator( this) ); registerInstantiator( sammc.Code(), new CodeInstantiator( this ) ); registerInstantiator( sammc.Collection(), new CollectionInstantiator( this ) ); diff --git a/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/instantiator/NamespaceInstantiator.java b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/instantiator/NamespaceInstantiator.java new file mode 100644 index 000000000..574654afa --- /dev/null +++ b/core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/loader/instantiator/NamespaceInstantiator.java @@ -0,0 +1,21 @@ +package org.eclipse.esmf.metamodel.loader.instantiator; + +import org.apache.jena.rdf.model.Resource; +import org.eclipse.esmf.metamodel.Namespace; +import org.eclipse.esmf.metamodel.impl.DefaultNamespace; +import org.eclipse.esmf.metamodel.loader.Instantiator; +import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes; +import org.eclipse.esmf.metamodel.loader.ModelElementFactory; + +public class NamespaceInstantiator extends Instantiator { + + public NamespaceInstantiator( final ModelElementFactory modelElementFactory ) { + super( modelElementFactory, Namespace.class ); + } + + @Override + public Namespace apply( final Resource namespace ) { + final MetaModelBaseAttributes metaModelBaseAttributes = buildBaseAttributes( namespace ); + return new DefaultNamespace( metaModelBaseAttributes); + } +} diff --git a/core/esmf-aspect-meta-model-resolver/src/main/java/org/eclipse/esmf/aspectmodel/vocabulary/SAMM.java b/core/esmf-aspect-meta-model-resolver/src/main/java/org/eclipse/esmf/aspectmodel/vocabulary/SAMM.java index f67e3dac7..439e97f46 100644 --- a/core/esmf-aspect-meta-model-resolver/src/main/java/org/eclipse/esmf/aspectmodel/vocabulary/SAMM.java +++ b/core/esmf-aspect-meta-model-resolver/src/main/java/org/eclipse/esmf/aspectmodel/vocabulary/SAMM.java @@ -135,6 +135,10 @@ public Resource Aspect() { return resource( "Aspect" ); } + public Resource Namespace() { + return resource( "Namespace" ); + } + public Property properties() { return property( "properties" ); } 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..9bfd860b9 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 @@ -142,6 +142,8 @@ ImmutableList. builder().addAll( queryFilesForAllMetaModelVersions ) .addAll( queryFilesForMetaModelVersionsAsOf2_0_0 ) .build() ); + //TODO: Add new version of SAMM 2.2.0 + ARQ.init(); model = versionedModel.getModel(); metaModelVersion = KnownVersion.fromVersionString( versionedModel.getMetaModelVersion().toString() ) diff --git a/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/abstractentity2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/abstractentity2boxmodel.sparql new file mode 100644 index 000000000..d1d238acc --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/abstractentity2boxmodel.sparql @@ -0,0 +1,74 @@ +# 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_2_0/abstractproperty2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/abstractproperty2boxmodel.sparql new file mode 100644 index 000000000..c14d6a04c --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/abstractproperty2boxmodel.sparql @@ -0,0 +1,83 @@ +# 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_2_0/aspect-operation-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect-operation-edges2boxmodel.sparql new file mode 100644 index 000000000..7bc5dab19 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect-operation-edges2boxmodel.sparql @@ -0,0 +1,36 @@ +# 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_2_0/aspect-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect-property-edges2boxmodel.sparql new file mode 100644 index 000000000..1ed54b551 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect-property-edges2boxmodel.sparql @@ -0,0 +1,82 @@ +# 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_2_0/aspect2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect2boxmodel.sparql new file mode 100644 index 000000000..29ad04024 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect2boxmodel.sparql @@ -0,0 +1,74 @@ +# 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_2_0/aspect2dot.mustache b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect2dot.mustache new file mode 100644 index 000000000..48bb95449 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/aspect2dot.mustache @@ -0,0 +1,23 @@ +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_2_0/boxmodel.ttl b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/boxmodel.ttl new file mode 100644 index 000000000..833880a1c --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/boxmodel.ttl @@ -0,0 +1,102 @@ +# 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_2_0/boxmodel2dot.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/boxmodel2dot.sparql new file mode 100644 index 000000000..6239efdde --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/boxmodel2dot.sparql @@ -0,0 +1,104 @@ +# 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_2_0/characteristic-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-characteristic-edges2boxmodel.sparql new file mode 100644 index 000000000..3d065b14d --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-characteristic-edges2boxmodel.sparql @@ -0,0 +1,36 @@ +# 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_2_0/characteristic-constraint-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-constraint-edges2boxmodel.sparql new file mode 100644 index 000000000..f7bd12d4d --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-constraint-edges2boxmodel.sparql @@ -0,0 +1,41 @@ +# 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_2_0/characteristic-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-entity-edges2boxmodel.sparql new file mode 100644 index 000000000..35ed1ed51 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-entity-edges2boxmodel.sparql @@ -0,0 +1,42 @@ +# 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_2_0/characteristic-metamodelnode-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-metamodelnode-edges2boxmodel.sparql new file mode 100644 index 000000000..3cd88803b --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic-metamodelnode-edges2boxmodel.sparql @@ -0,0 +1,38 @@ +# 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_2_0/characteristic2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic2boxmodel.sparql new file mode 100644 index 000000000..3f0c9d5d3 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/characteristic2boxmodel.sparql @@ -0,0 +1,116 @@ +# 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_2_0/collection-elementcharacteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/collection-elementcharacteristic-edges2boxmodel.sparql new file mode 100644 index 000000000..3aba7c3ed --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/collection-elementcharacteristic-edges2boxmodel.sparql @@ -0,0 +1,36 @@ +# 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_2_0/collection2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/collection2boxmodel.sparql new file mode 100644 index 000000000..5f32cf236 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/collection2boxmodel.sparql @@ -0,0 +1,156 @@ +# 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_2_0/constraint2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/constraint2boxmodel.sparql new file mode 100644 index 000000000..2afb9fd53 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/constraint2boxmodel.sparql @@ -0,0 +1,214 @@ +# 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_2_0/either-left-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/either-left-characteristic-edges2boxmodel.sparql new file mode 100644 index 000000000..219e6af47 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/either-left-characteristic-edges2boxmodel.sparql @@ -0,0 +1,38 @@ +# 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_2_0/either-right-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/either-right-characteristic-edges2boxmodel.sparql new file mode 100644 index 000000000..f3c8f9268 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/either-right-characteristic-edges2boxmodel.sparql @@ -0,0 +1,38 @@ +# 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_2_0/either2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/either2boxmodel.sparql new file mode 100644 index 000000000..befe74858 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/either2boxmodel.sparql @@ -0,0 +1,91 @@ +# 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_2_0/entity-abstractentity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entity-abstractentity-edges2boxmodel.sparql new file mode 100644 index 000000000..fce2acfa5 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entity-abstractentity-edges2boxmodel.sparql @@ -0,0 +1,47 @@ +# 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_2_0/entity-abstractproperty-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entity-abstractproperty-edges2boxmodel.sparql new file mode 100644 index 000000000..f07ffec60 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entity-abstractproperty-edges2boxmodel.sparql @@ -0,0 +1,70 @@ +# 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_2_0/entity2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entity2boxmodel.sparql new file mode 100644 index 000000000..4b08518c7 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entity2boxmodel.sparql @@ -0,0 +1,75 @@ +# 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_2_0/entityinstance-entity-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entityinstance-entity-edges2boxmodel.sparql new file mode 100644 index 000000000..8c9e4baa2 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entityinstance-entity-edges2boxmodel.sparql @@ -0,0 +1,49 @@ +# 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_2_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql new file mode 100644 index 000000000..224169e5e --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entityinstance-nestedentityinstance-edges2boxmodel.sparql @@ -0,0 +1,65 @@ +# 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_2_0/entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entityinstance2boxmodel.sparql new file mode 100644 index 000000000..1c2baa152 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/entityinstance2boxmodel.sparql @@ -0,0 +1,70 @@ +# 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_2_0/enumeration-entityinstance2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/enumeration-entityinstance2boxmodel.sparql new file mode 100644 index 000000000..19d195260 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/enumeration-entityinstance2boxmodel.sparql @@ -0,0 +1,45 @@ +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_2_0/enumeration2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/enumeration2boxmodel.sparql new file mode 100644 index 000000000..f8d5428e6 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/enumeration2boxmodel.sparql @@ -0,0 +1,177 @@ +# 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_2_0/metamodelnode2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/metamodelnode2boxmodel.sparql new file mode 100644 index 000000000..720edeb76 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/metamodelnode2boxmodel.sparql @@ -0,0 +1,32 @@ +# 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_2_0/operation-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/operation-property-edges2boxmodel.sparql new file mode 100644 index 000000000..c367a5778 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/operation-property-edges2boxmodel.sparql @@ -0,0 +1,59 @@ +# 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_2_0/operation2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/operation2boxmodel.sparql new file mode 100644 index 000000000..bbdab5037 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/operation2boxmodel.sparql @@ -0,0 +1,77 @@ +# 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_2_0/property-characteristic-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/property-characteristic-edges2boxmodel.sparql new file mode 100644 index 000000000..0f3a4bd72 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/property-characteristic-edges2boxmodel.sparql @@ -0,0 +1,41 @@ +# 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_2_0/property2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/property2boxmodel.sparql new file mode 100644 index 000000000..642ca61a5 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/property2boxmodel.sparql @@ -0,0 +1,92 @@ +# 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_2_0/quantifiable-unit-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/quantifiable-unit-edges2boxmodel.sparql new file mode 100644 index 000000000..9db7e0af4 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/quantifiable-unit-edges2boxmodel.sparql @@ -0,0 +1,40 @@ +# 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_2_0/quantitykind2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/quantitykind2boxmodel.sparql new file mode 100644 index 000000000..ac8ecfe78 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/quantitykind2boxmodel.sparql @@ -0,0 +1,32 @@ +# 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_2_0/structuredvalue-property-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/structuredvalue-property-edges2boxmodel.sparql new file mode 100644 index 000000000..feb50af10 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/structuredvalue-property-edges2boxmodel.sparql @@ -0,0 +1,40 @@ +# 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_2_0/structuredvalue2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/structuredvalue2boxmodel.sparql new file mode 100644 index 000000000..66c491776 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/structuredvalue2boxmodel.sparql @@ -0,0 +1,131 @@ +# 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_2_0/unit-quantitykind-edges2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/unit-quantitykind-edges2boxmodel.sparql new file mode 100644 index 000000000..2d35cf9dc --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/unit-quantitykind-edges2boxmodel.sparql @@ -0,0 +1,40 @@ +# 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_2_0/unit2boxmodel.sparql b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/unit2boxmodel.sparql new file mode 100644 index 000000000..879ca5c03 --- /dev/null +++ b/core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_2_2_0/unit2boxmodel.sparql @@ -0,0 +1,46 @@ +# 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 + } +}