OntoUML / ontouml-js

Javascript library for manipulating OntoUML models.
Apache License 2.0
12 stars 8 forks source link

Datatypes with attributes generate inconsistent OWL model #21

Closed tgoprince closed 4 years ago

tgoprince commented 4 years ago

Consider the OntoUML model fragment below:

Schermata 2020-03-20 alle 21 16 41

The serialization of this model is at the end of this issue.

This generates inconsistencies on the three attributes of the RGB datatype, namely red, green, and blue.

This is the code that is generated for them:

:red rdf:type owl:DatatypeProperty;
    rdfs:subPropertyOf gufo:hasQualityValue;
    rdfs:domain :Rgb;
    rdfs:range xsd:int;
    rdfs:label "red".
:green rdf:type owl:DatatypeProperty;
    rdfs:subPropertyOf gufo:hasQualityValue;
    rdfs:domain :Rgb;
    rdfs:range xsd:int;
    rdfs:label "green".
:blue rdf:type owl:DatatypeProperty;
    rdfs:subPropertyOf gufo:hasQualityValue;
    rdfs:domain :Rgb;
    rdfs:range xsd:int;
    rdfs:label "blue".

Note that :red, :green, and :blue are sub-properties of gufo:hasQualityValue that have :Rgb as their domain.

This is an issue because gufo:hasQualityValue has gufo:ConcreteIndividual as its domain, and :Rgb is a subtype of gufo:AbstractIndividual.

The solution is to transform datatype attributes simply as datatype properties that DO NOT specialize gufo:hasQualityValue.

{
  "type": "Package",
  "id": "dvqJnw6GAqACBAj5",
  "name": "AttributeDatatype",
  "description": null,
  "contents": [
    {
      "type": "Class",
      "id": "7vqJnw6GAqACBAj_",
      "name": "int",
      "description": null,
      "properties": null,
      "literals": null,
      "propertyAssignments": null,
      "stereotypes": [
        "datatype"
      ],
      "isAbstract": false,
      "isDerived": false
    },
    {
      "type": "Class",
      "id": "qCGJnw6GAqACBAyA",
      "name": "Object with Quality",
      "description": null,
      "properties": null,
      "literals": null,
      "propertyAssignments": null,
      "stereotypes": [
        "kind"
      ],
      "isAbstract": false,
      "isDerived": false
    },
    {
      "type": "Class",
      "id": "xpOJnw6GAqACBAyf",
      "name": "Color",
      "description": null,
      "properties": [
        {
          "type": "Property",
          "id": ".W5Jnw6GAqACBAzV",
          "name": "valueInRGB",
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "O5VJnw6GAqACBAz1"
          },
          "cardinality": null,
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        }
      ],
      "literals": null,
      "propertyAssignments": null,
      "stereotypes": [
        "quality"
      ],
      "isAbstract": false,
      "isDerived": false
    },
    {
      "type": "Class",
      "id": "O5VJnw6GAqACBAz1",
      "name": "RGB",
      "description": null,
      "properties": [
        {
          "type": "Property",
          "id": "ePdJnw6GAqACBA0G",
          "name": "red",
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "7vqJnw6GAqACBAj_"
          },
          "cardinality": null,
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        },
        {
          "type": "Property",
          "id": "os9Jnw6GAqACBA0K",
          "name": "green",
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "7vqJnw6GAqACBAj_"
          },
          "cardinality": null,
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        },
        {
          "type": "Property",
          "id": "wx9Jnw6GAqACBA0O",
          "name": "blue",
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "7vqJnw6GAqACBAj_"
          },
          "cardinality": null,
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        }
      ],
      "literals": null,
      "propertyAssignments": null,
      "stereotypes": [
        "datatype"
      ],
      "isAbstract": false,
      "isDerived": false
    },
    {
      "type": "Class",
      "id": "tQopnw6GAqACBA2x",
      "name": "Object with Attribute",
      "description": null,
      "properties": [
        {
          "type": "Property",
          "id": "qacpnw6GAqACBA3T",
          "name": "colorInRGB",
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "O5VJnw6GAqACBAz1"
          },
          "cardinality": null,
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        }
      ],
      "literals": null,
      "propertyAssignments": null,
      "stereotypes": [
        "kind"
      ],
      "isAbstract": false,
      "isDerived": false
    },
    {
      "type": "Class",
      "id": "gEOpnw6GAqACBA4q",
      "name": "Object with Association",
      "description": null,
      "properties": null,
      "literals": null,
      "propertyAssignments": null,
      "stereotypes": [
        "kind"
      ],
      "isAbstract": false,
      "isDerived": false
    },
    {
      "type": "Relation",
      "id": "uVXJnw6GAqACBA1G",
      "name": null,
      "description": null,
      "properties": [
        {
          "type": "Property",
          "id": "uVXJnw6GAqACBA1H",
          "name": null,
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "xpOJnw6GAqACBAyf"
          },
          "cardinality": "1",
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        },
        {
          "type": "Property",
          "id": "uVXJnw6GAqACBA1J",
          "name": null,
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "qCGJnw6GAqACBAyA"
          },
          "cardinality": "1",
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": true,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        }
      ],
      "propertyAssignments": null,
      "stereotypes": [
        "characterization"
      ],
      "isAbstract": false,
      "isDerived": false
    },
    {
      "type": "Relation",
      "id": "5zhpnw6GAqACBA5U",
      "name": null,
      "description": null,
      "properties": [
        {
          "type": "Property",
          "id": "5zhpnw6GAqACBA5V",
          "name": null,
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "gEOpnw6GAqACBA4q"
          },
          "cardinality": "0..*",
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        },
        {
          "type": "Property",
          "id": "5zhpnw6GAqACBA5X",
          "name": "hasValueInRGB",
          "description": null,
          "propertyType": {
            "type": "Class",
            "id": "O5VJnw6GAqACBAz1"
          },
          "cardinality": "1",
          "isDerived": false,
          "isOrdered": false,
          "isReadOnly": false,
          "stereotypes": null,
          "propertyAssignments": null,
          "subsettedProperties": null,
          "redefinedProperties": null,
          "aggregationKind": "NONE"
        }
      ],
      "propertyAssignments": null,
      "stereotypes": null,
      "isAbstract": false,
      "isDerived": false
    }
  ],
  "propertyAssignments": null
}