Skip to content

Commit b23b4e5

Browse files
committed
Add new Value type
1 parent 993fe6d commit b23b4e5

File tree

14 files changed

+380
-39
lines changed

14 files changed

+380
-39
lines changed

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,79 @@
109109
samm-c:values ( "2010-01-01"^^xsd:date "2012-05-07"^^xsd:date "2018-03-08"^^xsd:date ) .
110110
# end::enumeration-simple-declaration-date[]
111111

112+
# tag::value-declaration[]
113+
:ValueOne a samm:Value ;
114+
samm:value 1;
115+
samm:preferredName "ValueOne Preferred Name"@en ;
116+
samm:description "The value one description"@en ;
117+
samm:see <https://en.wikipedia.org/wiki/One> .
118+
# end::value-declaration[]
119+
120+
# tag::value-in-example-value-additional[]
121+
:valueWithProperty a samm:Property ;
122+
samm:exampleValue :ValueOne ;
123+
samm:characteristic [
124+
a samm:Characteristic ;
125+
samm:dataType xsd:integer ;
126+
] .
127+
128+
:ValueOne a samm:Value ;
129+
samm:value 1;
130+
samm:preferredName "ValueOne Preferred Name"@en ;
131+
samm:description "The value one description"@en ;
132+
samm:see <https://en.wikipedia.org/wiki/One> .
133+
# end::value-in-example-value-additional[]
134+
135+
# tag::value-in-example-value-anonymous[]
136+
:propertyWithExampleValue a samm:Property ;
137+
samm:exampleValue [
138+
a samm:Value ;
139+
samm:description "Some Description"@en ;
140+
samm:value 2 ;
141+
] ;
142+
samm:characteristic [
143+
a samm:Characteristic ;
144+
samm:dataType xsd:integer ;
145+
] .
146+
# end::value-in-example-value-anonymous[]
147+
148+
# tag::enumeration-value-type-in-value-single-instance[]
149+
:SomeValueEnum a samm-c:Enumeration ;
150+
samm:name "SomeValueEnum" ;
151+
samm:preferredName "Some Value Enum"@en ;
152+
samm:description "An enumeration of integers"@en ;
153+
samm:dataType xsd:integer ;
154+
samm-c:values ( :ValueOne ) .
155+
156+
:ValueOne a samm:Value ;
157+
samm:value 1 ;
158+
samm:preferredName "ValueOne Preferred Name"@en ;
159+
samm:description "The value one description"@en ;
160+
samm:see <https://en.wikipedia.org/wiki/One> .
161+
# end::enumeration-value-type-in-value-single-instance[]
162+
163+
# tag::enumeration-value-type-in-value-mixed-instance[]
164+
:SomeValueEnum a samm-c:Enumeration ;
165+
samm:name "SomeValueEnum" ;
166+
samm:preferredName "Some Value Enum"@en ;
167+
samm:description "An enumeration of integers"@en ;
168+
samm:dataType xsd:integer ;
169+
samm-c:values (
170+
:ValueOne # A reference to a globally defined samm:Value
171+
2 # A direct literal value
172+
[
173+
a samm:Value ; # An inline complex value with additional metadata
174+
samm:value 3
175+
]
176+
) .
177+
178+
:ValueOne a samm:Value ;
179+
samm:value 1 ;
180+
samm:preferredName "ValueOne Preferred Name"@en ;
181+
samm:description "The value one description"@en ;
182+
samm:see <https://en.wikipedia.org/wiki/One> .
183+
# end::enumeration-value-type-in-value-mixed-instance[]
184+
112185
# tag::enumeration-complex-declaration[]
113186
:Results a samm-c:Enumeration ;
114187
samm:dataType :Result ;

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

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,30 @@ that all model elements have], Properties have the following attributes:
163163
| `samm:characteristic` | The xref:characteristics.adoc#characteristics[Characteristic] describing
164164
this Property. | {ok}
165165
| `samm:exampleValue` | An exemplary value the Property can take on that helps to understand the
166-
intended meaning of the property better. This can only be set for Properties with scalar data types
167-
(e.g., `xsd:string` or `xsd:float`, but not Entities). The data type of the `samm:exampleValue` must
168-
be convertible to the effective data type of the Property's Characteristic. For example, if the
169-
Characteristic's `samm:dataType` is `xsd:int`, `xsd:short` is also a valid type for the
170-
`samm:exampleValue`. Refer to section xref:datatypes.adoc#implicit-conversions[Implicit Conversions]
166+
intended meaning of the property better. This attribute supports both scalar literal values
167+
(e.g., `xsd:string`, `xsd:float`) and entity-based example values (i.e., references to instances of
168+
xref:modeling-guidelines.adoc#value-type[samm:Value]
169+
enriched with semantic metadata). In either case, the data type of the `samm:exampleValue` must be convertible to
170+
the effective data type defined by the Property's Characteristic. For example, if the Characteristic's `samm:dataType`
171+
is `xsd:int`, a value with the type `xsd:short` is also acceptable. Refer to section xref:datatypes.adoc#implicit-conversions[Implicit Conversions]
171172
for more details. | {nok}
172173
|===
173174

174-
Example:
175+
Example with Literal type:
175176

176177
[source,turtle,subs="attributes+"]
177178
----
178179
include::example$aspect-sample.ttl[tags=property-declaration]
179180
----
180181

182+
Example with entity-based type:
183+
184+
[source,turtle,subs="attributes+"]
185+
----
186+
include::example$aspect-sample.ttl[tags=value-in-example-value-additional]
187+
----
188+
189+
181190
[[declaring-characteristics]]
182191
=== Declaring Characteristics
183192

@@ -304,6 +313,28 @@ Example with literal `xsd:date` values:
304313
include::example$aspect-sample.ttl[tags=enumeration-simple-declaration-date]
305314
----
306315

316+
[[enumeration-with-value-type-in-value]]
317+
Example Using Value in an Enumeration:
318+
319+
An Enumeration can include complex values to enrich the semantic description of the enumeration items.
320+
This is especially useful when you want to provide additional metadata—such as a preferred name, description,
321+
or external reference—for a specific value.
322+
323+
There are several ways to define values in an Enumeration:
324+
325+
- Single Global Instance:
326+
[source,turtle,subs="attributes+"]
327+
----
328+
include::example$aspect-sample.ttl[tags=enumeration-value-type-in-value-single-instance]
329+
----
330+
331+
- Mixed Value Definitions:
332+
[source,turtle,subs="attributes+"]
333+
----
334+
include::example$aspect-sample.ttl[tags=enumeration-value-type-in-value-mixed-instance]
335+
----
336+
337+
307338
[[enumeration-with-complex-value]]
308339
Example with complex values:
309340

@@ -742,6 +773,34 @@ for example:
742773
include::example$aspect-sample.ttl[tags=see-dontuse]
743774
----
744775

776+
[[value-type]]
777+
=== Declaring Value
778+
779+
The `samm:Value` type is designed to represent a value enriched with semantic metadata.
780+
It encapsulates the actual data (which can be a literal or a reference) along with additional descriptive information.
781+
This type is used to enhance clarity in Enumerations and Properties by allowing you to attach a human-readable label,
782+
a detailed description, and an external reference to the value.
783+
784+
[source,turtle,subs="attributes+"]
785+
----
786+
include::example$aspect-sample.ttl[tags=value-declaration]
787+
----
788+
789+
Also, as an ExampleValue in Property:
790+
791+
- Additional Value:
792+
[source,turtle,subs="attributes+"]
793+
----
794+
include::example$aspect-sample.ttl[tags=value-in-example-value-additional]
795+
----
796+
797+
- Anonymous ExampleValue:
798+
[source,turtle,subs="attributes+"]
799+
----
800+
include::example$aspect-sample.ttl[tags=value-in-example-value-anonymous]
801+
----
802+
803+
745804
[[optional-properties]]
746805
=== Optional Properties
747806

esmf-semantic-aspect-meta-model/src/main/resources/samm/characteristic/2.2.0/characteristic-shapes.ttl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,10 @@ samm-c:EnumerationShape
514514
$this samm-c:values ?values .
515515
$this samm:dataType ?definedDataType .
516516
?values rdf:rest*/rdf:first ?item .
517-
bind( datatype( ?item ) as ?literalDataType ) .
518-
bind( strlen( str( ?literalDataType ) ) as ?literalDataTypeLength ) .
519-
filter( ( ?literalDataType != ?definedDataType ) && ( ?literalDataTypeLength > 0 ) ) .
517+
optional { ?item a samm:Value ; samm:value ?innerValue . }
518+
bind( coalesce( datatype(?innerValue), datatype(?item) ) AS ?literalDataType ) .
519+
filter( strlen(str(?literalDataType)) > 0 ) .
520+
filter( ?literalDataType != ?definedDataType ) .
520521
bind( 'ERR_WRONG_DATATYPE' as ?code )
521522
bind( ?item as ?highlight )
522523
}

esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-definitions.ttl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ samm:Namespace rdfs:subClassOf mmm:NamedConcept ;
7777
rdfs:label "Namespace" ;
7878
rdfs:comment "A Namespace can provide a human-readable name and a description for namespaces." .
7979

80+
samm:Value rdfs:subClassOf mmm:ConceptWithProperties ;
81+
rdfs:label: "Value" ;
82+
rdfs:comment "A type is designed to represent a value enriched with semantic metadata.".
83+
8084
# Meta meta model attributes used in Shapes
8185
mmm:listType a rdf:Property ;
8286
rdfs:label "listType" ;
@@ -152,7 +156,7 @@ samm:parameters a mmm:Attribute ;
152156

153157
samm:exampleValue a mmm:Attribute ;
154158
rdfs:label "exampleValue" ;
155-
rdfs:comment "An exemplary value the Property can take on that helps to understand the intended meaning of the property better. This can only be set for Properties with scalar data types (e.g. xsd:string or xsd:float, but not Entities). The data type of the samm:exampleValue must be convertable to the effective data type of the Property’s Characteristic." ;
159+
rdfs:comment "An exemplary value the Property can take on that helps to understand the intended meaning of the property better. This attribute supports both scalar literal values (e.g., xsd:string or xsd:float) and entity-based example values (i.e., references to instances of samm:Value enriched with semantic metadata). The data type of the samm:exampleValue must be convertable to the effective data type of the Property’s Characteristic." ;
156160
rdfs:domain samm:Property ;
157161
rdfs:range rdfs:Resource .
158162

esmf-semantic-aspect-meta-model/src/main/resources/samm/meta-model/2.2.0/aspect-meta-model-shapes.ttl

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,24 +290,24 @@ samm:PropertyShape
290290
sh:minCount 1 ;
291291
sh:maxCount 1 ;
292292
sh:class samm:Characteristic ;
293-
sh:maxCount 1 ;
294293
sh:name "characteristic" ;
295294
sh:description "The Characteristic describing the semantics of the Property." ;
296295
] ;
297296
sh:property [
298297
sh:order 4 ;
299298
sh:path samm:exampleValue ;
300-
sh:nodeKind sh:Literal ;
301299
sh:sparql [
302300
a sh:SPARQLConstraint ;
303301
sh:message "The datatype '{?value}' of the exampleValue neither matches nor can be cast to the Property's '{$this}' Characteristic's dataType." ;
304302
sh:prefixes samm:prefixDeclarations ;
305303
sh:select """
306-
select $this ?value ?code ?highlight
304+
select $this ?value ?exampleValue ?providedType ?characteristicDataType ?code ?highlight
307305
where {
308306
$this samm:exampleValue ?exampleValue .
309307
$this samm:characteristic/samm-c:baseCharacteristic*/samm:dataType ?characteristicDataType .
310-
bind( datatype( ?exampleValue ) as ?providedType )
308+
optional { ?exampleValue a samm:Value ; samm:value ?innerValue . }
309+
bind( coalesce(?innerValue, ?exampleValue) as ?actualValue )
310+
bind( datatype(?actualValue) as ?providedType )
311311
filter( ?providedType not in (
312312
xsd:string,
313313
xsd:boolean,
@@ -374,8 +374,10 @@ samm:PropertyShape
374374
select $this ?exampleValue ?code
375375
where {
376376
$this samm:exampleValue ?exampleValue .
377-
bind( datatype( ?exampleValue ) as ?providedType )
378-
filter ( ?providedType = xsd:boolean && ( str( ?exampleValue ) != "true" && str( ?exampleValue ) != "false" ) )
377+
optional { ?exampleValue a samm:Value ; samm:value ?innerValue . }
378+
bind( coalesce(?innerValue, ?exampleValue) as ?actualValue )
379+
bind( datatype(?actualValue) as ?providedType )
380+
filter ( ?providedType = xsd:boolean && ( str(?actualValue) != "true" && str(?actualValue) != "false" ) )
379381
bind('ERR_EXAMPLE_VALUE_NOT_ALLOWED' AS ?code)
380382
}
381383
"""
@@ -1024,3 +1026,14 @@ samm:ConstrainListTypeUsageShape
10241026
"""
10251027
]
10261028
] .
1029+
1030+
samm:ValueShape
1031+
a sh:NodeShape ;
1032+
sh:targetClass samm:Value ;
1033+
sh:property [
1034+
sh:path samm:value ;
1035+
sh:minCount 0 ;
1036+
sh:maxCount 1 ;
1037+
sh:name "value" ;
1038+
sh:description "A single constant value or link to another resource." ;
1039+
] .

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ protected static Stream<KnownVersion> versionsUpToIncluding1_0_0() {
6868
return versionsUpToIncluding( KnownVersion.SAMM_1_0_0 );
6969
}
7070

71+
protected static Stream<KnownVersion> versionsUpToIncluding2_1_0() {
72+
return versionsUpToIncluding( KnownVersion.SAMM_2_1_0 );
73+
}
74+
7175
final String violationUrn = "http://www.w3.org/ns/shacl#Violation";
7276
final String warningUrn = "http://www.w3.org/ns/shacl#Warning";
7377

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818

1919
import org.eclipse.esmf.samm.validation.SemanticError;
2020

21-
public class EnumerationShapeTest extends AbstractShapeTest {
21+
class EnumerationShapeTest extends AbstractShapeTest {
2222

2323
@ParameterizedTest
2424
@MethodSource( value = "allVersions" )
25-
public void testEnumerationValidationExpectSuccess( final KnownVersion metaModelVersion ) {
25+
void testEnumerationValidationExpectSuccess( final KnownVersion metaModelVersion ) {
2626
checkValidity( "enumeration-shape", "TestEnumeration", metaModelVersion );
2727
}
2828

2929
@ParameterizedTest
3030
@MethodSource( value = "allVersions" )
31-
public void testMissingRequiredPropertiesExpectFailure2( final KnownVersion metaModelVersion ) {
31+
void testMissingRequiredPropertiesExpectFailure2( final KnownVersion metaModelVersion ) {
3232
final SammUrns sammUrns = new SammUrns( metaModelVersion );
3333
final String focusNode = testNamespacePrefix + "TestEnumerationMissingRequiredProperties";
3434

@@ -42,7 +42,7 @@ public void testMissingRequiredPropertiesExpectFailure2( final KnownVersion meta
4242

4343
@ParameterizedTest
4444
@MethodSource( value = "allVersions" )
45-
public void testValueIsNotOfDefinedDataTypeExpectFailure( final KnownVersion metaModelVersion ) {
45+
void testValueIsNotOfDefinedDataTypeExpectFailure( final KnownVersion metaModelVersion ) {
4646
final SammUrns sammUrns = new SammUrns( metaModelVersion );
4747
final String focusNode = testNamespacePrefix + "TestEnumerationValueIsNotOfDefinedDataType";
4848

@@ -56,7 +56,7 @@ public void testValueIsNotOfDefinedDataTypeExpectFailure( final KnownVersion met
5656

5757
@ParameterizedTest
5858
@MethodSource( value = "allVersions" )
59-
public void testValueIsNotALiteralTypeExpectFailure( final KnownVersion metaModelVersion ) {
59+
void testValueIsNotALiteralTypeExpectFailure( final KnownVersion metaModelVersion ) {
6060
final SammUrns sammUrns = new SammUrns( metaModelVersion );
6161
final String focusNode = testNamespacePrefix + "TestEnumerationValueIsNotALiteralType";
6262

0 commit comments

Comments
 (0)