eclipse-esmf / esmf-sdk

Load Aspect Models and their artifacts as Java code; share components to realize SAMM as code
https://eclipse-esmf.github.io/esmf-developer-guide/index.html
Mozilla Public License 2.0
25 stars 12 forks source link

[BUG] Validation fails for value type bamm:curie for bamm-c:UnitReference characteristic in SAMM-CLI 2.2.2 #382

Closed bs-jokri closed 1 year ago

bs-jokri commented 1 year ago

Describe the bug Trying to validate a model with the following snippet with bamm-cli-2.1.3 is correct but with SAMM-CLI 2.2.2 not.

:measurementUnit a bamm:Property;
    bamm:preferredName "Measurement Unit"@en;
    bamm:description "Unit of measurement for the quantity of serialized objects."@en;
    bamm:characteristic bamm-c:UnitReference;
    bamm:exampleValue "kW"^^bamm:curie.

which validated. With the new SAMM-CLI the following validation error appears: https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_bom_as_specified/1.0.0

java -jar samm-cli-2.2.2.jar  aspect io.catenax.single_level_bom_as_specified/1.0.0/SingleLevelBomAsSpecified.ttl validate
Semantic violations were found:

> :measurementUnit :

  The datatype 'bamm:curie' of the exampleValue neither matches nor can be cast to the Property's ':measurementUnit' Characteristic's dataType.

switching to the SAMM 2.0.0 meta model resolves the problem. However, this is not possible for released models.

Where SAMM-CLI 2.2.2

Screenshots na

Additional context Add any other context about the problem here.

RaMisess commented 1 year ago

Validating the given model with the samm-cli built from the current "main" branch works. It looks like the bug has been fixed through some of the recent updates.

bs-jokri commented 1 year ago

The problem seem still to exist as can be verified with model https://github.com/eclipse-tractusx/sldt-semantic-models/pull/257

ysrbo commented 1 year ago
:TimeUnitEnum a samm-c:Enumeration ;
   samm:preferredName "Time Unit Enum"@en ;
   samm:description "Enumerates all time units"@en ;
   samm:dataType samm:curie ;
   samm-c:values ( "unit:secondUnitOfTime"^^samm:curie "unit:minuteUnitOfTime"^^samm:curie "unit:hour"^^samm:curie "unit:day"^^samm:curie "unit:week"^^samm:curie "unit:month"^^samm:curie "unit:year"^^samm:curie ) .

leads to

Validation failed:
Validation succeeded, but an error was found while processing the model. This indicates an error in the model validation; please consider reporting this issue including the model at https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/issues -- Could not load Aspect model, please make sure the model is valid: Literal can not be parsed: unit:secondUnitOfTime^^urn:samm:org.eclipse.esmf.samm:meta-model:2.0.0#curie
bs-jokri commented 1 year ago

A similar problem occurs also for same-cli 2.3.1 when validating model https://github.com/eclipse-tractusx/sldt-semantic-models/pull/283/files

which results in

java -Dpolyglot.engine.WarnInterpreterOnly=false -jar samm-cli-2.3.1.jar aspect io.catenax.generic.digital_product_passport/2.0.0/DigitalProductPassport.ttl validate

Validation failed:
Validation succeeded, but an error was found while processing the model. This indicates an error in the model validation; please consider reporting this issue including the model at https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/issues -- Could not load Aspect model, please make sure the model is valid: Literal can not be parsed: unit:day^^urn:samm:org.eclipse.esmf.samm:meta-model:2.0.0#curie
bs-jokri commented 1 year ago

we had this issue in the past and it was fixed with https://github.com/eclipse-esmf/esmf-sdk/issues/303

probably this is a regression of this bug?

bs-jokri commented 1 year ago

Hi @chris-volk, @RaMisess, what @ysrbo identified in his comment affects us at several models. Do you have an idea, why this happens?

RaMisess commented 1 year ago

Yes, the problem was that the literals with data type "curie", like "unit:day"^^samm:curie, were not properly migrated to the current version of the metamodel. This resulted in failure of the validation, where the model is instantiated as a last step of the process. As long as the latest version of the metamodel was 2.0.0, which matched the version of the model, there was no migration and everything was fine. With the introduction of metamodel 2.1.0 the migrator kicks in, which surfaced this problem.

github-actions[bot] commented 1 year ago

Release v2.3.2 addresses this.

github-actions[bot] commented 1 year ago

Release v2.4.0 addresses this.