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] SAMM-CLI v2.2.1 assumes wrong default namespace for BAMM2.0.0 models #363

Closed bs-jokri closed 1 year ago

bs-jokri commented 1 year ago

Describe the bug I have a model

@prefix bamm: <urn:bamm:io.openmanufacturing:meta-model:2.0.0#>.
@prefix bamm-c: <urn:bamm:io.openmanufacturing:characteristic:2.0.0#>.
@prefix bamm-e: <urn:bamm:io.openmanufacturing:entity:2.0.0#>.
@prefix unit: <urn:bamm:io.openmanufacturing:unit:2.0.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:bamm:io.catenax.example_aspect:1.0.0#>.

:ExampleAspect a bamm:Aspect;
    bamm:properties (:property1);
    bamm:operations ();
    bamm:events ().
:property1 a bamm:Property;
    bamm:characteristic :Characteristic1.
:Characteristic1 a bamm:Characteristic;
    bamm:dataType xsd:string.

when I run the SAMM CLI v2.2.1 to validate the model

java -jar samm-cli-2.2.1.jar  aspect io.catenax.example_aspect/1.0.0/ExampleAspect.ttl validate

It does not validate the model but returns the error message

Validation failed:
Resolution strategy returned a model which does not contain element definition for urn:samm:io.catenax.example_aspect:1.0.0#ExampleAspect

As one can see it assumes another default namespace

urn:samm:io.catenax.example_aspect:1.0.0#ExampleAspect

as the one provided

urn:bamm:io.catenax.example_aspect:1.0.0#ExampleAspect

This prevents using the SAMM-CLI and SDK for already existing BAMM models, as the model's namespaces need to be adjusted, which effectively is the same as migrating the model.

Would be great if the SAMM SDK could process outdated BAMM models for a while, to allow a smooth migration procedure.

bs-jokri commented 1 year ago

One more thought: it might be that the validation rules are not properly applied

bs-jokri commented 1 year ago

Checked with Release 2.2.2 of the CLI. BAMM 2.0.0 models are now working. However, it still seems to have problems with BAMM 1.0.0 models. I have checked with the following model

called the validator as follows

java -jar  ~/Downloads/samm-cli-2.2.2.jar aspect ~/Desktop/migration/BAMM\ 1.0.0/io.catenax.example_aspect/1.0.0/ExampleAspect.ttl validate
@prefix bamm: <urn:bamm:io.openmanufacturing:meta-model:1.0.0#>.
@prefix bamm-c: <urn:bamm:io.openmanufacturing:characteristic:1.0.0#>.
@prefix bamm-e: <urn:bamm:io.openmanufacturing:entity:1.0.0#>.
@prefix unit: <urn:bamm:io.openmanufacturing:unit:1.0.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:bamm:io.catenax.example_aspect:1.0.0#>.

:ExampleAspect a bamm:Aspect;
    bamm:properties (:property1);
    bamm:operations ();
    bamm:events ().
:property1 a bamm:Property;
    bamm:characteristic :Characteristic1.
:Characteristic1 a bamm:Characteristic;
    bamm:dataType xsd:string.

and receive the following error message (similar to the one with BAMM 2.0.0 before)

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: Could not load urn:samm:io.catenax.example_aspect:1.0.0#ExampleAspect: Unknown type urn:samm:io.openmanufacturing:meta-model:1.0.0#Aspect