Skip to content

Commit c1a1a8f

Browse files
authored
Merge pull request #721 from bci-oss/720-initial-support-for-samm-2.2.0
Add initial support for SAMM 2.2.0
2 parents b0aa0c5 + 975429d commit c1a1a8f

File tree

252 files changed

+1201
-557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+1201
-557
lines changed

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/RdfUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public static void cleanPrefixes( final Model model ) {
118118
.map( Statement::getSubject )
119119
.filter( Resource::isURIResource )
120120
.map( Resource::getURI )
121+
.map( uri -> uri.endsWith( "#" ) ? uri.replace( "#", "" ) : uri )
121122
.map( AspectModelUrn::fromUrn )
122123
.findAny()
123124
.ifPresent( urn -> model.setNsPrefix( "", urn.getUrnPrefix() ) );

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/loader/ModelElementFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ private static Optional<AspectModelUrn> getUrn( final Resource modelElement ) {
257257
}
258258
return Optional.empty();
259259
}
260-
return Optional.of( AspectModelUrn.fromUrn( modelElement.getURI() ) );
260+
return modelElement.getURI().endsWith( "#" )
261+
? Optional.of( AspectModelUrn.fromUrn( modelElement.getURI().replace( "#", "" ) ) )
262+
: Optional.of( AspectModelUrn.fromUrn( modelElement.getURI() ) );
261263
}
262264

263265
/**

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/serializer/PrettyPrinter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ public Object visitLiteral( final Node_Literal it, final String lex, final Strin
481481
public Object visitURI( final Node_URI it, final String uri ) {
482482
final String suri = model.shortForm( uri );
483483
if ( uri.equals( suri ) ) {
484-
return "<" + uri + ">";
484+
return uri.startsWith( "urn:samm:" ) && !uri.contains( "#" )
485+
? "<" + uri + "#>"
486+
: "<" + uri + ">";
485487
} else {
486488
return suri;
487489
}

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/versionupdate/MetaModelVersionMigrator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ private MetaModelVersionMigrator() {
4545
}
4646

4747
private final List<Migrator> migrators = ImmutableList.<Migrator> builder()
48+
.add( new SammMetaModelVersionUriRewriter( KnownVersion.SAMM_2_1_0, KnownVersion.SAMM_2_2_0 ) )
4849
.add( new SammMetaModelVersionUriRewriter( KnownVersion.SAMM_2_0_0, KnownVersion.SAMM_2_1_0 ) )
4950
.add( new SammMetaModelVersionUriRewriter( KnownVersion.SAMM_1_0_0, KnownVersion.SAMM_2_0_0 ) )
5051
.add( new SammRemoveSammNameMigrator( KnownVersion.SAMM_1_0_0, KnownVersion.SAMM_2_0_0 ) )

core/esmf-aspect-meta-model-java/src/test-shared/java/org/eclipse/esmf/test/AssertTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
package org.eclipse.esmf.test;
1515

16-
import static org.eclipse.esmf.metamodel.DataTypes.xsd;
16+
import static org.eclipse.esmf.metamodel.DataTypes.*;
1717
import static org.eclipse.esmf.metamodel.Elements.*;
1818
import static org.eclipse.esmf.metamodel.builder.SammBuilder.*;
1919
import static org.eclipse.esmf.test.shared.AspectModelAsserts.assertThat;
@@ -32,6 +32,7 @@
3232
import org.eclipse.esmf.metamodel.Property;
3333
import org.eclipse.esmf.metamodel.constraint.RangeConstraint;
3434
import org.eclipse.esmf.metamodel.vocabulary.SammNs;
35+
import org.eclipse.esmf.samm.KnownVersion;
3536

3637
import org.apache.jena.datatypes.xsd.XSDDatatype;
3738
import org.junit.jupiter.api.Test;
@@ -138,7 +139,7 @@ void testAssertionsWithBuilder() {
138139
.characteristic()
139140
.hasDataType( xsd.string )
140141
.sourceFile()
141-
.hasLocation( "urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0" );
142+
.hasLocation( "urn:samm:org.eclipse.esmf.samm:characteristic:" + KnownVersion.getLatest().toVersionString() );
142143

143144
final RangeConstraint rangeConstraint = rangeConstraint()
144145
.minValue( value( 5, xsd.integer ) )
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
2+
#
3+
# See the AUTHORS file(s) distributed with this work for additional
4+
# information regarding authorship.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
#
10+
# SPDX-License-Identifier: MPL-2.0
11+
12+
@prefix samm: <urn:org.eclipse.esmf.samm:foo:1.0.0#> .
13+
14+
<urn:samm:org.eclipse.esmf.samm:aspect-model:TestAspect:1.0.0> a samm:Aspect ;
15+
samm:preferredName "Test Aspect"@en ;
16+
samm:properties ( ) ;
17+
samm:operations ( ) .
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
2+
#
3+
# See the AUTHORS file(s) distributed with this work for additional
4+
# information regarding authorship.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
#
10+
# SPDX-License-Identifier: MPL-2.0
11+
12+
@prefix samm: <urn:samm:foo:something:else#> .
13+
14+
<urn:samm:org.eclipse.esmf.samm:TestAspect:1.1.0> a samm:Aspect;
15+
samm:preferredName "Test Aspect"@en;
16+
samm:properties () ;
17+
samm:operations () .
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
2+
#
3+
# See the AUTHORS file(s) distributed with this work for additional
4+
# information regarding authorship.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
#
10+
# SPDX-License-Identifier: MPL-2.0
11+
12+
@prefix samm: <urn:foo:org.eclipse.esmf.samm:meta-model:2.0.0#> .
13+
14+
<urn:samm:org.eclipse.esmf.samm:aspect-model:TestAspect:1.1.0> a samm:Aspect ;
15+
samm:preferredName "Test Aspect"@en ;
16+
samm:properties ( ) ;
17+
samm:operations ( ) .
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
2+
#
3+
# See the AUTHORS file(s) distributed with this work for additional
4+
# information regarding authorship.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
#
10+
# SPDX-License-Identifier: MPL-2.0
11+
12+
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
13+
14+
<urn:samm:org.eclipse.esmf.samm:aspect-model:TestAspect:1.1.0> a samm:Aspect ;
15+
samm:preferredName "Test Aspect"@en ;
16+
samm:properties ( ) ;
17+
samm:operations ( ) .
18+
19+
<urn:samm:org.eclipse.esmf.samm:aspect-model:AnotherTestAspect:1.1.0> a samm:Aspect ;
20+
samm:preferredName "Another Test Aspect"@en ;
21+
samm:properties ( ) ;
22+
samm:operations ( ) .
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
2+
#
3+
# See the AUTHORS file(s) distributed with this work for additional
4+
# information regarding authorship.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
#
10+
# SPDX-License-Identifier: MPL-2.0
11+
12+
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
13+
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
14+
@prefix : <urn:samm:org.eclipse.esmf.test:1.0.0#> .
15+
16+
:AnotherTest a samm:Aspect ;
17+
samm:preferredName "Another Test"@en ;
18+
samm:properties ( :foo ) ;
19+
samm:operations ( ) .
20+

0 commit comments

Comments
 (0)