Skip to content

Commit 993fe6d

Browse files
authored
Merge pull request #319 from eclipse-esmf/316-express-relationship-between-a-value-property-and-a-corresponding-unit-reference-property
Express relationship between a "value" Property and corresponding "unit reference" property
2 parents 286d873 + 042b415 commit 993fe6d

File tree

7 files changed

+136
-3
lines changed

7 files changed

+136
-3
lines changed

documentation/modules/ROOT/examples/aspect-sample.ttl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@
7575
) .
7676
# end::timeseries-declaration[]
7777

78+
# tag::quantity-declaration[]
79+
:Parameter a samm:Entity ;
80+
samm:extends samm-e:Quantity ;
81+
samm:properties (
82+
[ samm:extends samm-e:value ; samm:characteristic :ParameterValueCharacteristic ]
83+
) .
84+
:ParameterValueCharacteristic a samm:Characteristic ;
85+
samm:dataType xsd:integer .
86+
# end::quantity-declaration[]
87+
7888
# tag::enumeration-simple-declaration-string[]
7989
:Status a samm-c:Enumeration ;
8090
samm:dataType xsd:string ;

documentation/modules/ROOT/pages/entities.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,25 @@ Describes a resource with a relative or absolute location and a MIME type.
7373
| `samm-e:resource` | The location of the resource | xref:characteristics.adoc#resource-path-characteristic[Resource Path]
7474
| `samm-e:mimeType` | The MIME type of the resource | xref:characteristics.adoc#mime-typecharacteristic[MIME Type]
7575
|===
76+
77+
[[quantity-entity]]
78+
== Quantity Entity
79+
[.element-urn]
80+
--
81+
{samm-e}Quantity
82+
--
83+
84+
The Quantity Entity is used to represent a numeric value along with its corresponding physical unit.
85+
It ensures that values are always explicitly associated with their units, providing clarity and consistency
86+
in data representation.
87+
88+
This entity is particularly useful when working with dynamic units that are determined at runtime.
89+
90+
See xref:modeling-guidelines.adoc#declaring-quantities[declaring quantities] for usage in an Aspect Model.
91+
92+
[width="100%", options="header", cols="30,40,30"]
93+
|===
94+
| Property | Description | Characteristic
95+
| `samm-e:value` | The numeric value | This is an xref:modeling-guidelines.adoc#abstract-entities-with-abstract-properties[Abstract Property] without a Characteristic
96+
| `samm-e:unit` | The corresponding physical unit of the value | xref:characteristics.adoc#unit-reference-characteristic[Unit Reference]
97+
|===

documentation/modules/ROOT/pages/modeling-guidelines.adoc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,38 @@ related data is explicitly linked and contained in a single Collection. When mod
376376
two or more collections at root level which contain unrelated data, consider creating separate
377377
Aspects each containing a single Collection.
378378

379+
[[declaring-quantities]]
380+
==== Declaring Quantities
381+
382+
The `xref:characteristics.adoc#unit-reference-characteristic[UnitReference]` Characteristic is used
383+
to associate numeric values with their respective physical units in a structured and explicit way.
384+
The `Quantity` Entity is designed to represent such a pairing, ensuring that values are always
385+
interpreted correctly with their corresponding units.
386+
387+
A `Quantity` is defined as an entity that contains a numeric `value` and a corresponding `unit`,
388+
both of which are essential for properly interpreting the data.
389+
The `xref:entities.adoc#quantity-entity[QuantityEntity]` is declared as an Abstract Entity,
390+
providing a standard way to associate measurements with units.
391+
392+
To describe these semantics, the `Quantity` Entity defines the `value` Property as
393+
an `xref:modeling-guidelines.adoc#abstract-entities-with-abstract-properties[Abstract Property]`,
394+
meaning it does not have an inherent Characteristic and must be specialized based on the context.
395+
The `unit` Property is assigned the `xref:characteristics.adoc#unit-reference-characteristic[Unit Reference]`
396+
Characteristic, which ensures that it references a recognized unit of measurement.
397+
398+
To define a Quantity for a specific domain, the user should instantiate an Entity that extends
399+
the Abstract `Quantity` Entity and provide a specialized Characteristic for the `value` Property,
400+
specifying its data type and semantics according to the domain's needs. For details on how to extend
401+
an Abstract Entity, please refer
402+
to the `xref:modeling-guidelines.adoc#declaring-abstract-entities[Declaring Abstract Entities]` section.
403+
404+
Example:
405+
406+
[source,turtle,subs="attributes+"]
407+
----
408+
include::example$aspect-sample.ttl[tag=quantity-declaration]
409+
----
410+
379411
[[declaring-either]]
380412
==== Declaring Either
381413

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2025 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 samm-e: <urn:samm:org.eclipse.esmf.samm:entity:2.2.0#> .
15+
16+
samm-e:Quantity a samm:AbstractEntity ;
17+
samm:preferredName "Quantity"@en ;
18+
samm:description "A numeric value and the physical unit of the value."@en ;
19+
samm:properties ( samm-e:value samm-e:unit ) .
20+
21+
samm-e:unit a samm:Property ;
22+
samm:characteristic samm-c:UnitReference .
23+

esmf-semantic-aspect-meta-model/src/test/java/org/eclipse/esmf/samm/AbstractShapeTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616
import static org.assertj.core.api.Assertions.assertThat;
1717

1818
import java.io.StringWriter;
19+
import java.util.ArrayList;
1920
import java.util.HashMap;
2021
import java.util.List;
2122
import java.util.Map;
2223
import java.util.stream.Stream;
2324

24-
import org.apache.jena.rdf.model.Model;
25-
2625
import org.eclipse.esmf.samm.validation.ModelLoader;
2726
import org.eclipse.esmf.samm.validation.SemanticError;
2827
import org.eclipse.esmf.samm.validation.ValidationReport;
2928
import org.eclipse.esmf.samm.validation.Validator;
3029

30+
import org.apache.jena.rdf.model.Model;
31+
3132
public abstract class AbstractShapeTest {
3233
final static String TEST_NAMESPACE = "org.eclipse.esmf.test";
3334
final static String TEST_NAMESPACE_VERSION = "1.0.0";
@@ -134,7 +135,7 @@ protected static Stream<KnownVersion> versionsUpToIncluding1_0_0() {
134135
+ "Property's '{$this}' Characteristic's dataType.";
135136

136137
Model loadMetaModelDefinitions( final KnownVersion version ) {
137-
return ModelLoader.createModel( List.of(
138+
List<String> files = new ArrayList<>( List.of(
138139
"samm/meta-model/" + version.toVersionString() + "/aspect-meta-model-definitions.ttl",
139140
"samm/meta-model/" + version.toVersionString() + "/type-conversions.ttl",
140141
"samm/characteristic/" + version.toVersionString() + "/characteristic-definitions.ttl",
@@ -144,6 +145,12 @@ Model loadMetaModelDefinitions( final KnownVersion version ) {
144145
"samm/entity/" + version.toVersionString() + "/Point3d.ttl",
145146
"samm/unit/" + version.toVersionString() + "/units.ttl"
146147
) );
148+
149+
if ( version.isNewerThan( KnownVersion.SAMM_2_1_0 ) ) {
150+
files.add( "samm/entity/" + version.toVersionString() + "/Quantity.ttl" );
151+
}
152+
153+
return ModelLoader.createModel( files );
147154
}
148155

149156
protected void checkValidity( final String path, final String ttlDefinition, final KnownVersion testedVersion ) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.eclipse.esmf.samm;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.MethodSource;
5+
6+
class QuantityTest extends AbstractShapeTest {
7+
8+
@ParameterizedTest
9+
@MethodSource( value = "versionsStartingWith2_2_0" )
10+
void testQuantityValidationEntity( final KnownVersion metaModelVersion ) {
11+
checkValidity( "quantity", "QuantityTestEntity", metaModelVersion );
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Copyright (c) 2025 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+
@prefix : <urn:samm:org.eclipse.esmf.samm.test:1.0.0#> .
14+
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
15+
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
16+
@prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:2.2.0#> .
17+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
18+
19+
:Parameter a samm:Entity ;
20+
samm:extends samm-e:Quantity ;
21+
samm:properties (
22+
[ samm:extends samm-e:value ; samm:characteristic :ParameterValueCharacteristic ]
23+
) .
24+
25+
:ParameterValueCharacteristic a samm:Characteristic ;
26+
samm:dataType xsd:integer .

0 commit comments

Comments
 (0)