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] Invalidly modelled TimeSeries passes validation (BAMM v1 and BAMM v2) #194

Closed LukasHeimann closed 1 year ago

LukasHeimann commented 2 years ago

Describe the bug In BAMM v1, there is a specific way in which time series data must be modelled: https://openmanufacturingplatform.github.io/sds-bamm-aspect-meta-model/bamm-specification/v1.0.0/modeling-guidelines.html#declaring-time-series

However, an invalid time series definition can still pass validation:

@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 xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix : <urn:bamm:test:0.0.1#>.

:Test a bamm:Aspect;
    bamm:name "Test";
    bamm:properties (:timeseries);
    bamm:operations ();
    bamm:events ().
:timeseries a bamm:Property;
    bamm:name "timeseries";
    bamm:characteristic :TimeSeries.
:TimeSeries a bamm-c:TimeSeries;
    bamm:name "TimeSeries";
    bamm:dataType :TimeSeriesEntry.

######## Invalidly modelled:
:TimeSeriesEntry a bamm:Entity;
    bamm:name "TimeSeriesEntry";
    bamm:properties (:quantity).
:quantity a bamm:Property;
    bamm:name "quantity";
    bamm:characteristic :Quantity.

######## Should be:
# :TimeSeriesEntry bamm:refines bamm-e:TimeSeriesEntity;
#     bamm:name "TimeSeriesEntry";
#     bamm:properties (:quantity).
# :quantity bamm:refines bamm-e:value;
#     bamm:name "quantity";
#     bamm:characteristic :Quantity.

:Quantity a bamm:Characteristic;
    bamm:name "Quantity";
    bamm:dataType xsd:positiveInteger.

Where bamm aspect Test.ttl validate

Additional Context: I am using BAMM CLI v2.0.1.

This bug is also valid for v2's TimeSeries modelling as described here: https://openmanufacturingplatform.github.io/sds-bamm-aspect-meta-model/bamm-specification/2.0.0/modeling-guidelines.html#declaring-time-series. bamm aspect Test.ttl migrate doesn't do a good job of updating time series modelling to the latest version, unfortunately, but this freshly created minimal example passes as well, even though it should only do so with the commented out line properly in pace:

@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 xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix : <urn:bamm:test:0.0.1#>.

:Test a bamm:Aspect;
    bamm:properties (:timeseries).

:timeseries a bamm:Property;
    bamm:characteristic :TimeSeries.

:TimeSeries a bamm-c:TimeSeries;
    bamm:dataType :TimeSeriesEntry.

:TimeSeriesEntry a bamm:Entity;
    # bamm:extends bamm-e:TimeSeriesEntity;
    bamm:properties (:quantity).
:quantity a bamm:Property;
    bamm:characteristic :Quantity.

:Quantity a bamm:Characteristic;
    bamm:dataType xsd:positiveInteger.
atextor commented 1 year ago

Fixed by https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/pull/233.