Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for SAMM 2.2.0 #721

Merged
merged 9 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public static void cleanPrefixes( final Model model ) {
.map( Statement::getSubject )
.filter( Resource::isURIResource )
.map( Resource::getURI )
.map( uri -> uri.endsWith( "#" ) ? uri.replace( "#", "" ) : uri )
.map( AspectModelUrn::fromUrn )
.findAny()
.ifPresent( urn -> model.setNsPrefix( "", urn.getUrnPrefix() ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ private static Optional<AspectModelUrn> getUrn( final Resource modelElement ) {
}
return Optional.empty();
}
return Optional.of( AspectModelUrn.fromUrn( modelElement.getURI() ) );
return modelElement.getURI().endsWith( "#" )
? Optional.of( AspectModelUrn.fromUrn( modelElement.getURI().replace( "#", "" ) ) )
: Optional.of( AspectModelUrn.fromUrn( modelElement.getURI() ) );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ public Object visitLiteral( final Node_Literal it, final String lex, final Strin
public Object visitURI( final Node_URI it, final String uri ) {
final String suri = model.shortForm( uri );
if ( uri.equals( suri ) ) {
return "<" + uri + ">";
return uri.startsWith( "urn:samm:" ) && !uri.contains( "#" )
? "<" + uri + "#>"
: "<" + uri + ">";
} else {
return suri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private MetaModelVersionMigrator() {
}

private final List<Migrator> migrators = ImmutableList.<Migrator> builder()
.add( new SammMetaModelVersionUriRewriter( KnownVersion.SAMM_2_1_0, KnownVersion.SAMM_2_2_0 ) )
.add( new SammMetaModelVersionUriRewriter( KnownVersion.SAMM_2_0_0, KnownVersion.SAMM_2_1_0 ) )
.add( new SammMetaModelVersionUriRewriter( KnownVersion.SAMM_1_0_0, KnownVersion.SAMM_2_0_0 ) )
.add( new SammRemoveSammNameMigrator( KnownVersion.SAMM_1_0_0, KnownVersion.SAMM_2_0_0 ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package org.eclipse.esmf.test;

import static org.eclipse.esmf.metamodel.DataTypes.xsd;
import static org.eclipse.esmf.metamodel.DataTypes.*;
import static org.eclipse.esmf.metamodel.Elements.*;
import static org.eclipse.esmf.metamodel.builder.SammBuilder.*;
import static org.eclipse.esmf.test.shared.AspectModelAsserts.assertThat;
Expand All @@ -32,6 +32,7 @@
import org.eclipse.esmf.metamodel.Property;
import org.eclipse.esmf.metamodel.constraint.RangeConstraint;
import org.eclipse.esmf.metamodel.vocabulary.SammNs;
import org.eclipse.esmf.samm.KnownVersion;

import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -138,7 +139,7 @@ void testAssertionsWithBuilder() {
.characteristic()
.hasDataType( xsd.string )
.sourceFile()
.hasLocation( "urn:samm:org.eclipse.esmf.samm:characteristic:2.1.0" );
.hasLocation( "urn:samm:org.eclipse.esmf.samm:characteristic:" + KnownVersion.getLatest().toVersionString() );

final RangeConstraint rangeConstraint = rangeConstraint()
.minValue( value( 5, xsd.integer ) )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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: <urn:org.eclipse.esmf.samm:foo:1.0.0#> .

<urn:samm:org.eclipse.esmf.samm:aspect-model:TestAspect:1.0.0> a samm:Aspect ;
samm:preferredName "Test Aspect"@en ;
samm:properties ( ) ;
samm:operations ( ) .
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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: <urn:samm:foo:something:else#> .

<urn:samm:org.eclipse.esmf.samm:TestAspect:1.1.0> a samm:Aspect;
samm:preferredName "Test Aspect"@en;
samm:properties () ;
samm:operations () .
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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: <urn:foo:org.eclipse.esmf.samm:meta-model:2.0.0#> .

<urn:samm:org.eclipse.esmf.samm:aspect-model:TestAspect:1.1.0> a samm:Aspect ;
samm:preferredName "Test Aspect"@en ;
samm:properties ( ) ;
samm:operations ( ) .
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .

<urn:samm:org.eclipse.esmf.samm:aspect-model:TestAspect:1.1.0> a samm:Aspect ;
samm:preferredName "Test Aspect"@en ;
samm:properties ( ) ;
samm:operations ( ) .

<urn:samm:org.eclipse.esmf.samm:aspect-model:AnotherTestAspect:1.1.0> a samm:Aspect ;
samm:preferredName "Another Test Aspect"@en ;
samm:properties ( ) ;
samm:operations ( ) .
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix : <urn:samm:org.eclipse.esmf.test:1.0.0#> .

:AnotherTest a samm:Aspect ;
samm:preferredName "Another Test"@en ;
samm:properties ( :foo ) ;
samm:operations ( ) .

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix : <urn:samm:org.eclipse.esmf.test:1.0.0#> .

:AspectInPreviousNamespace a samm:Aspect ;
samm:properties ( :distinctProperty ) ;
samm:operations ( ) .

:distinctProperty a samm:Property ;
samm:characteristic samm-c:Text .
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
@prefix aux: <urn:bamm:io.openmanufacturing:aspect-model:aux#> .
@prefix ns: <urn:bamm:org.eclipse.esmf.test:1.0.0#BammAspectWithoutPrefixes> .
ns: a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Aspect> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Aspect for movement information"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"BammAspectWithoutPrefixes" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#operations>
() ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"BammAspectWithoutPrefixes"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#properties>
( <urn:bamm:org.eclipse.esmf.test:1.0.0#moving> <urn:bamm:org.eclipse.esmf.test:1.0.0#speedLimitWarning> <urn:bamm:org.eclipse.esmf.test:1.0.0#position> ) .
<urn:bamm:org.eclipse.esmf.test:1.0.0#moving>
a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Property> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#characteristic>
<urn:bamm:io.openmanufacturing:characteristic:1.0.0#Boolean> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Flag indicating if the position is changing"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"moving" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"Moving"@en .
<urn:bamm:org.eclipse.esmf.test:1.0.0#z>
a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Property> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#characteristic>
<urn:bamm:org.eclipse.esmf.test:1.0.0#Coordinate> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"z coordinate in space"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"z" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"z"@en .
<urn:bamm:org.eclipse.esmf.test:1.0.0#y>
a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Property> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#characteristic>
<urn:bamm:org.eclipse.esmf.test:1.0.0#Coordinate> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"y coordinate in space"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"y" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"y"@en .
<urn:bamm:org.eclipse.esmf.test:1.0.0#Coordinate>
a <urn:bamm:io.openmanufacturing:characteristic:1.0.0#Measurement> ;
<urn:bamm:io.openmanufacturing:characteristic:1.0.0#unit>
<urn:bamm:io.openmanufacturing:unit:1.0.0#metre> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#dataType>
<http://www.w3.org/2001/XMLSchema#float> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Represents a coordinate along an axis in space."@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"Coordinate" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"Coordinate"@en .
<urn:bamm:org.eclipse.esmf.test:1.0.0#speedLimitWarning>
a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Property> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#characteristic>
<urn:bamm:org.eclipse.esmf.test:1.0.0#WarningLevel> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Indicats if speed limit is adhered to."@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"speedLimitWarning" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"Speed Limit Warning"@en .
<urn:bamm:org.eclipse.esmf.test:1.0.0#SpatialPosition>
a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Entity> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Position in space, described along three axis, with the third axis optional, if all positions are in a plane."@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"SpatialPosition" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"Spatial Position"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#properties>
( <urn:bamm:org.eclipse.esmf.test:1.0.0#x> <urn:bamm:org.eclipse.esmf.test:1.0.0#y>
[ <urn:bamm:io.openmanufacturing:meta-model:1.0.0#optional>
true ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#property>
<urn:bamm:org.eclipse.esmf.test:1.0.0#z>
]
) .
<urn:bamm:org.eclipse.esmf.test:1.0.0#x>
a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Property> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#characteristic>
<urn:bamm:org.eclipse.esmf.test:1.0.0#Coordinate> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"x coordinate in space"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"x" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"x"@en .
<urn:bamm:org.eclipse.esmf.test:1.0.0#position>
a <urn:bamm:io.openmanufacturing:meta-model:1.0.0#Property> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#characteristic>
[ a <urn:bamm:io.openmanufacturing:characteristic:1.0.0#SingleEntity> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#dataType>
<urn:bamm:org.eclipse.esmf.test:1.0.0#SpatialPosition> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Represents a single location in space."@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"SpatialPositionCharacteristic" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"Spatial Position Characteristic"@en
] ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Indicates a position"@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"position" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"Position"@en .
<urn:bamm:org.eclipse.esmf.test:1.0.0#WarningLevel>
a <urn:bamm:io.openmanufacturing:characteristic:1.0.0#Enumeration> ;
<urn:bamm:io.openmanufacturing:characteristic:1.0.0#values>
( "green" "yellow" "red" ) ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#dataType>
<http://www.w3.org/2001/XMLSchema#string> ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#description>
"Represents if speed of position change is within specification (green), within tolerance (yellow), or outside specification (red)."@en ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#name>
"WarningLevel" ;
<urn:bamm:io.openmanufacturing:meta-model:1.0.0#preferredName>
"Warning Level"@en .
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix : <urn:samm:org.eclipse.esmf.test:1.0.0#> .

:FailingTest a samm:Aspect ;
samm:preferredName "Failing Test"@en ;
samm:properties ( :notExisting ) ;
samm:operations ( ) .
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <urn:samm:org.eclipse.esmf.test:1.0.0#> .

:ModelCode a samm-c:Code ;
samm:dataType xsd:string .

:ModelYear a samm-c:Code ;
samm:dataType xsd:nonNegativeInteger .

:SomeOtherNonRelatedEntity a samm:Entity ;
samm:properties ( :name ) .

:name a samm:Property ;
samm:characteristic samm-c:Text .
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#>.
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#>.
@prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:2.2.0#>.
@prefix unit: <urn:samm:org.eclipse.esmf.samm:unit:2.2.0#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix : <urn:samm:org.eclipse.esmf.test:1.0.0#>.

:PrimaryAspect a samm:Aspect ;
samm:properties ( :property1 ) ;
samm:operations () ;
samm:events () .

:property1 a samm:Property ;
samm:characteristic :MyChar .

:MyChar a samm-c:Enumeration ;
samm:dataType xsd:string ;
samm-c:values ( "true" "false" ) .
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
@prefix : <urn:samm:org.eclipse.esmf.test:1.0.0#> .

:ReferenceCharacteristicTest a samm:Aspect ;
samm:properties ( :foo ) ;
samm:operations ( ) .

:foo a samm:Property ;
samm:characteristic :TestCharacteristic .
Loading
Loading