json2graph.decoder.decode_obj_property

Functions to decode specificities of the object Property.

Function’s nomenclatures:
  • Functions that set one property are named: set_<subject>_<predicate>_<object>.

  • Functions that set multiple object properties are named: set_<subject>_relations.

  • Functions that set multiple data properties are named: set_<subject>_attributes.

  • Functions that set both object and data properties are named: set_<subject>_properties.

  • Functions that set default values: set_<subject>_defaults.

Module Contents

Functions

validate_property_stereotype(ontouml_graph)

Perform syntactical and semantic validations on an ontouml:Property's stereotype.

set_property_defaults(property_dict, ontouml_graph)

Set default values for ontouml:Property elements that do not present them.

set_property_relations(property_dict, ontouml_graph)

Set the ontouml:aggregationKind and ontouml:propertyType object properties between an ontouml:Property and its related elements.

determine_cardinality_bounds(cardinalities, property_id)

Receive a string with an ontouml:Cardinality's ontouml:cardinalityValue, fix its format and decouple it into its ontouml:lowerBound and ontouml:upperBound. Checks and displays warning if the obtained values are not valid.

set_cardinality_relations(property_dict, ontouml_graph)

Create the ontouml:Cardinality instance and sets its properties.

create_property_properties(json_data, ontouml_graph)

Decode object of type Property.

Attributes

LOGGER

json2graph.decoder.decode_obj_property.LOGGER
json2graph.decoder.decode_obj_property.validate_property_stereotype(ontouml_graph)

Perform syntactical and semantic validations on an ontouml:Property’s stereotype.

Differently from what is used in the validation of other JSON objects, this function manipulates the graph itself, not the JSON object. This is because it is much straightforward to access all the necessary property elements.

Validations performed: VPS1) Reports invalid property stereotypes (i.e., stereotypes different from ontouml:begin or ontouml:end). VPS2) Reports if a property stereotype is used in association with an invalid class stereotype. I.e., a class stereotype that is known and different from ‘event’. VPS3) Sets class stereotype as ‘event’ when it is associated to a property that has an assigned valid stereotype.

Parameters:

ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.

Return type:

None

json2graph.decoder.decode_obj_property.set_property_defaults(property_dict, ontouml_graph)

Set default values for ontouml:Property elements that do not present them.

The defaults are:

DPA1) ontouml:isDerived default value = False DPA2) ontouml:isOrdered default value = False DPA3) ontouml:isReadOnly default value = False

Parameters:
  • property_dict (dict) – Property object loaded as a dictionary.

  • ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.

Return type:

None

json2graph.decoder.decode_obj_property.set_property_relations(property_dict, ontouml_graph)

Set the ontouml:aggregationKind and ontouml:propertyType object properties between an ontouml:Property and its related elements.

Parameters:
  • property_dict (dict) – Property object loaded as a dictionary.

  • ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.

Return type:

None

json2graph.decoder.decode_obj_property.determine_cardinality_bounds(cardinalities, property_id)

Receive a string with an ontouml:Cardinality’s ontouml:cardinalityValue, fix its format and decouple it into its ontouml:lowerBound and ontouml:upperBound. Checks and displays warning if the obtained values are not valid.

Parameters:
  • cardinalities (str) – String containing the value of the cardinality to be decoupled into lower and upper bounds.

  • property_id (str) – ID of the Property that owns the cardinality being treated. Used in case of invalid cardinality.

Returns:

Tuple of three elements: full cardinality, cardinality’s lower bound, and cardinality’s upper bound.

Return type:

(str, str, str)

json2graph.decoder.decode_obj_property.set_cardinality_relations(property_dict, ontouml_graph)

Create the ontouml:Cardinality instance and sets its properties.

Parameters:
  • property_dict (dict) – Property object loaded as a dictionary.

  • ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.

Return type:

None

json2graph.decoder.decode_obj_property.create_property_properties(json_data, ontouml_graph)

Decode object of type Property.

Receives the whole JSON loaded data as a dictionary and manipulates it to create all properties in which the object’s type is domain of.

Created instances of class:
  • ontouml:Cardinality

Created properties:
  • ontouml:aggregationKind (domain ontouml:Property, range ontouml:AggregationKind)

  • ontouml:propertyType (domain ontouml:Property, range ontouml:Classifier)

  • ontouml:stereotype (domain ontouml:Property, range ontouml:PropertyStereotype)

  • ontouml:cardinality (domain ontouml:Property, range ontouml:Cardinality)

  • ontouml:cardinalityValue (domain ontouml:Cardinality, range xsd:string)

  • ontouml:lowerBound (domain ontouml:Cardinality, range xsd:nonNegativeInteger)

  • ontouml:upperBound (domain ontouml:Cardinality)

  • ontouml:subsetsProperty (range ontouml:Property)

  • ontouml:redefinesProperty (range ontouml:Property)

  • ontouml:isDerived (range xsd:boolean)

  • ontouml:isOrdered (range xsd:boolean)

  • ontouml:isReadOnly (range xsd:boolean)

Performs validation for ontouml:stereotype.

Parameters:
  • json_data (dict) – JSON’s data to have its fields decoded loaded into a dictionary.

  • ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.

Return type:

None