Skip to content

Commit a32d709

Browse files
committed
fixed issue with names collision during diagram generation for BAMM v1.0
1 parent 4244d60 commit a32d709

File tree

35 files changed

+133
-90
lines changed

35 files changed

+133
-90
lines changed

core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/GetNamespaceFunctionFactory.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
package io.openmanufacturing.sds.aspectmodel.generator.diagram;
1+
/*
2+
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
3+
*
4+
* See the AUTHORS file(s) distributed with this work for additional
5+
* information regarding authorship.
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
10+
*
11+
* SPDX-License-Identifier: MPL-2.0
12+
*/
13+
14+
package org.eclipse.esmf.aspectmodel.generator.diagram;
215

316
import org.apache.jena.graph.Node;
417
import org.apache.jena.rdf.model.Model;
518
import org.apache.jena.sparql.expr.NodeValue;
619
import org.apache.jena.sparql.function.Function;
720
import org.apache.jena.sparql.function.FunctionBase1;
821
import org.apache.jena.sparql.function.FunctionFactory;
9-
10-
import io.openmanufacturing.sds.aspectmodel.urn.AspectModelUrn;
22+
import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
1123

1224
/**
1325
* {@link FunctionFactory} for the {@link getNamespace} SPARQL function.
@@ -30,7 +42,7 @@ public Function create( String s ) {
3042
/**
3143
* A custom SPARQL function which provides the namespace of a model element.
3244
*/
33-
public static class getNamespace extends FunctionBase1 {
45+
private static class getNamespace extends FunctionBase1 {
3446

3547
private final String defaultNs;
3648

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-operation-edges2boxmodel.sparql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#>
1313
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1414
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
15+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1516

1617
# Generate edges between Aspects and Operations
1718
construct {
@@ -27,9 +28,9 @@ construct {
2728
filter( exists { ?aspect samm:operations/rdf:rest*/rdf:first ?operation } )
2829

2930
bind( concat( ?aspectName, "Aspect" ) as ?aspectBoxName )
30-
bind( iri( concat( str( : ), ?aspectBoxName ) ) as ?from )
31+
bind( iri( concat( func:getNamespace( ?aspect ), ?aspectBoxName ) ) as ?from )
3132
bind( concat( ?operationName, "Operation" ) as ?operationBoxName )
32-
bind( iri( concat( str( : ), ?operationBoxName ) ) as ?to )
33+
bind( iri( concat( func:getNamespace( ?operation ), ?operationBoxName ) ) as ?to )
3334

34-
bind( iri( concat( str( : ), ?aspectBoxName, "_To_", ?operationBoxName ) ) as ?edge )
35+
bind( iri( concat( func:getNamespace( ?aspect ), ?aspectBoxName, "_To_", ?operationBoxName ) ) as ?edge )
3536
}

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/aspect-property-edges2boxmodel.sparql

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:1.0.0#>
1414
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1515
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
1616
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
17+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1718

1819
# Generates edges between Aspects or Entites and Properties
1920
construct {
@@ -38,12 +39,12 @@ construct {
3839

3940
bind( if( ?class = samm:Aspect, "Aspect", "Entity" ) as ?typeName )
4041
bind( concat( ?aspectOrEntityName, ?typeName ) as ?aspectOrEntityBoxName )
41-
bind( iri( concat( str( : ), ?aspectOrEntityBoxName ) ) as ?from )
42+
bind( iri( concat( func:getNamespace( ?aspectOrEntity ), ?aspectOrEntityBoxName ) ) as ?from )
4243

4344
bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
44-
bind( iri( concat( str( : ), ?propertyBoxName ) ) as ?to )
45+
bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to )
4546

46-
bind( iri( concat( str( : ), ?aspectOrEntityBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
47+
bind( iri( concat( func:getNamespace( ?aspectOrEntity ), ?aspectOrEntityBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
4748

4849
optional {
4950
?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
@@ -75,8 +76,8 @@ construct {
7576
}
7677

7778
optional {
78-
?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
79-
bind( "property" as ?title )
79+
?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
80+
bind( "property" as ?title )
8081
}
8182
}
8283

@@ -94,12 +95,12 @@ construct {
9495
?refiningEntity samm:name ?entityName .
9596
?property samm:name ?propertyName .
9697
bind( concat( ?entityName, "Entity" ) as ?entityBoxName )
97-
bind( iri( concat( str( : ), ?entityBoxName ) ) as ?from )
98+
bind( iri( concat( func:getNamespace( ?refiningEntity ), ?entityBoxName ) ) as ?from )
9899

99100
bind( concat( ?propertyName, "Property" ) as ?propertyBoxName )
100-
bind( iri( concat( str( : ), ?propertyBoxName ) ) as ?to )
101+
bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to )
101102

102-
bind( iri( concat( str( : ), ?entityBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
103+
bind( iri( concat( func:getNamespace( ?refiningEntity ), ?entityBoxName, "_To_", ?propertyBoxName ) ) as ?edge )
103104

104105
optional {
105106
?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
@@ -131,8 +132,8 @@ construct {
131132
}
132133

133134
optional {
134-
?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
135-
bind( "property" as ?title )
135+
?aspectOrEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
136+
bind( "property" as ?title )
136137
}
137138
}
138139
}

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-characteristic-edges2boxmodel.sparql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#>
1313
prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:1.0.0#>
1414
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1515
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
16+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1617

1718
# Generates edges between Trait and other Characteristics (baseCharacteristic)
1819
construct {
@@ -25,11 +26,11 @@ construct {
2526
?characteristic samm-c:baseCharacteristic ?baseCharacteristic .
2627
?baseCharacteristic samm:name ?baseCharacteristicName .
2728
bind( concat( ?characteristicName, "Characteristic" ) as ?box1Name )
28-
bind( iri( concat( str( : ), ?box1Name ) ) as ?from )
29+
bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name ) ) as ?from )
2930

3031
bind( concat( ?baseCharacteristicName, "Characteristic" ) as ?box2Name )
31-
bind( iri( concat( str( : ), ?box2Name ) ) as ?to )
32+
bind( iri( concat( func:getNamespace( ?baseCharacteristic ), ?box2Name ) ) as ?to )
3233

33-
bind( iri( concat( str( : ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
34+
bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
3435
}
3536

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-constraint-edges2boxmodel.sparql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1616
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
1717
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
1818
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
19+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1920

2021
# Generates edges between Trait and Constraints (constraint)
2122
construct {
@@ -28,7 +29,7 @@ construct {
2829
?characteristic samm:name ?characteristicName .
2930

3031
bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
31-
bind( iri( concat( str( : ), ?characteristicBoxName ) ) as ?from )
32+
bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from )
3233

3334
optional {
3435
?constraint samm:name ?givenConstraintName .
@@ -59,8 +60,8 @@ construct {
5960
bind( coalesce( concat( ?givenConstraintName, "Constraint" ),
6061
concat( "Constraint", substr( md5( ?constraintPropertyValues ), 0, 11 ) ) ) as ?constraintBoxName )
6162

62-
bind( iri( concat( str( : ), ?constraintBoxName ) ) as ?to )
63+
bind( iri( concat( func:getNamespace( ?constraint ), ?constraintBoxName ) ) as ?to )
6364

64-
bind( iri( concat( str( : ), ?characteristicBoxName, "_To_", ?constraintBoxName ) ) as ?edge )
65+
bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?constraintBoxName ) ) as ?edge )
6566
}
6667

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic-entity-edges2boxmodel.sparql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:1.0.0#>
1414
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1515
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
1616
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
17+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1718

1819
# Generates edges between Characteristic and Entities (dataType)
1920
construct {
@@ -29,11 +30,11 @@ construct {
2930
?characteristic samm:name ?characteristicName .
3031
?entity samm:name ?entityName .
3132
bind( concat( ?characteristicName, "Characteristic" ) as ?characteristicBoxName )
32-
bind( iri( concat( str( : ), ?characteristicBoxName ) ) as ?from )
33+
bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName ) ) as ?from )
3334

3435
bind( concat( ?entityName, "Entity" ) as ?entityBoxName )
35-
bind( iri( concat( str( : ), ?entityBoxName ) ) as ?to )
36+
bind( iri( concat( func:getNamespace( ?characteristic ), ?entityBoxName ) ) as ?to )
3637

37-
bind( iri( concat( str( : ), ?characteristicBoxName, "_To_", ?entityBoxName ) ) as ?edge )
38+
bind( iri( concat( func:getNamespace( ?characteristic ), ?characteristicBoxName, "_To_", ?entityBoxName ) ) as ?edge )
3839
}
3940

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/characteristic2boxmodel.sparql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1515
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
1616
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
1717
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
18+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1819

1920
# Generates boxes for Characteristics that are not Collections, Constraints, Enumeration/State or StructuredValue
2021
construct {
@@ -67,7 +68,7 @@ construct {
6768

6869
?characteristic samm:name ?characteristicName .
6970
bind( concat( ?characteristicName, "Characteristic" ) as ?boxName )
70-
bind( iri( concat( str( : ), ?boxName ) ) as ?characteristicBox )
71+
bind( iri( concat( func:getNamespace( ?characteristic ), ?boxName ) ) as ?characteristicBox )
7172

7273
optional {
7374
?characteristic samm:preferredName ?preferredNameValue .

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection-elementcharacteristic-edges2boxmodel.sparql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0#>
1313
prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:1.0.0#>
1414
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1515
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
16+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1617

1718
# Generates edges between Collections and Element Characteristics
1819
construct {
@@ -25,11 +26,11 @@ construct {
2526
?characteristic samm-c:elementCharacteristic ?elementCharacteristic .
2627
?elementCharacteristic samm:name ?elementCharacteristicName .
2728
bind( concat( ?characteristicName, "Characteristic" ) as ?box1Name )
28-
bind( iri( concat( str( : ), ?box1Name ) ) as ?from )
29+
bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name ) ) as ?from )
2930

3031
bind( concat( ?elementCharacteristicName, "Characteristic" ) as ?box2Name )
31-
bind( iri( concat( str( : ), ?box2Name ) ) as ?to )
32+
bind( iri( concat( func:getNamespace( ?elementCharacteristic ), ?box2Name ) ) as ?to )
3233

33-
bind( iri( concat( str( : ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
34+
bind( iri( concat( func:getNamespace( ?characteristic ), ?box1Name, "_To_", ?box2Name ) ) as ?edge )
3435
}
3536

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/collection2boxmodel.sparql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
1717
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
1818
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
1919
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
20+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
2021

2122
# Generates boxes for Collection Characteristics
2223
construct {

core/esmf-aspect-model-document-generators/src/main/resources/diagram/samm_1_0_0/constraint2boxmodel.sparql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
1515
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
1616
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
1717
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:1.0.0/boxmodel#>
18+
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>
1819

1920
# Generates boxes for Constraints
2021
construct {
@@ -116,7 +117,7 @@ construct {
116117
?constraint a ?constraintType .
117118
bind( coalesce( ?givenConstraintName, strafter( str( ?constraintType ), "#" ) ) as ?constraintName )
118119

119-
bind( iri( concat( str( : ), ?boxName ) ) as ?constraintBox )
120+
bind( iri( concat( func:getNamespace( ?constraint ), ?boxName ) ) as ?constraintBox )
120121

121122
optional {
122123
?constraint samm:preferredName ?preferredNameValue .

0 commit comments

Comments
 (0)