json2graph.decoder.decode_obj_class

Functions to decode objects of type Class.

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.

Module Contents

Functions

validate_class_attribute_constraints(class_dict)

Verify all Class dictionaries and check if the constraints related to classes were correctly considered and fixes them when they are not.

validate_class_order_constraints(class_dict)

Verify all Class dictionaries and check if the constraints related to classes were correctly considered and fixes them when they are not.

set_defaults_class_attribute(class_dict, ontouml_graph)

Verify a class dictionary and check if their non-nullable attributes isExtensional and isPowertype were set or not. If not, creates default values.

set_defaults_class_order(class_dict, ontouml_graph)

Verify a class dictionary and check if their non-nullable attribute order was set or not. If not, creates default values.

set_class_stereotype(class_dict, ontouml_graph)

Set ontouml:stereotype property between an instance of ontouml:Class and an instance representing an ontouml:ClassStereotype.

set_class_order_nonnegativeinteger(class_dict, ...)

Set an ontouml:Class's ontouml:order property based on the received value of the object's field 'order'.

set_class_restrictedto_ontologicalnature(class_dict, ...)

Set the ontouml:restrictedTo relation between a class and its related ontouml:OntologicalNature instance.

set_class_attributes(class_dict, ontouml_graph)

Define the ontouml:isPowertype and ontouml:isExtensional data properties of an ontouml:Class in the graph.

set_class_attribute_property(class_dict, ontouml_graph)

Set ontouml:attribute relation between an ontouml:Class and an ontouml:Property.

set_class_literal_literal(class_dict, ontouml_graph)

Set ontouml:literal relation between an ontouml:Class and its related ontouml:Literal individuals.

create_class_properties(json_data, ontouml_graph, ...)

Decode an object of type 'Class'.

json2graph.decoder.decode_obj_class.validate_class_attribute_constraints(class_dict)

Verify all Class dictionaries and check if the constraints related to classes were correctly considered and fixes them when they are not.

The pair of attribute/stereotype: isExtensional/collective and isPowertype/type checked constraints are:

VCA1) If class is not type and has isExtensional True and isPowertype True, then do nothing and report error. VCA2a) If class has no stereotype and isExtensional is not null, set as ontouml:collective. VCA2b) If class has no stereotype and isPowertype is True, set as ontouml: type. VCA3a) If class has stereotype different from ‘collective’ and isExtensional is not null, remove isExtensional. VCA3b) If class has stereotype different from ‘type’ and isPowertype is True, set isPowertype as False.

Parameters:

class_dict (dict) – Class object loaded as a dictionary.

Return type:

None

json2graph.decoder.decode_obj_class.validate_class_order_constraints(class_dict)

Verify all Class dictionaries and check if the constraints related to classes were correctly considered and fixes them when they are not.

The checked constraints are:

VCO1) ‘order’ property must be greater than 1 when class’s stereotype is ‘type’ VCO2) class’s ‘order’ property must be 1 when class’s stereotype is not ‘type’

The above codes are used to display warning/error messages when necessary.

Parameters:

class_dict (dict) – Class object loaded as a dictionary.

Return type:

None

json2graph.decoder.decode_obj_class.set_defaults_class_attribute(class_dict, ontouml_graph)

Verify a class dictionary and check if their non-nullable attributes isExtensional and isPowertype were set or not. If not, creates default values.

The default values checked are:

DCA1) ontouml:isExtensional default value = False when class’s stereotype ‘collective’ DCA2) ontouml:isPowertype default value = False DCA3) ontouml:isDerived default value = False DCA4) ontouml:isAbstract default value = False

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.set_defaults_class_order(class_dict, ontouml_graph)

Verify a class dictionary and check if their non-nullable attribute order was set or not. If not, creates default values.

Default values checked are:

DCO1) order default value = 1 when class’s stereotype is not ‘type’ DCO2) order default value = 2 when class’s stereotype ‘type’

The above codes are used to display warning/error messages when necessary.

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.set_class_stereotype(class_dict, ontouml_graph)

Set ontouml:stereotype property between an instance of ontouml:Class and an instance representing an ontouml:ClassStereotype.

Warning messages:
  • VCS1: Mandatory stereotype not assigned to a class. Result is invalid.

  • VCS2: Class has invalid stereotype associated to it. Result is invalid.

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.set_class_order_nonnegativeinteger(class_dict, ontouml_graph)

Set an ontouml:Class’s ontouml:order property based on the received value of the object’s field ‘order’.

The treated possibilities are: A) invalid value (null, non integers, integers <= 0) —> is converted to the default value of the class B) positive integers —> directly converted C) * (representing an orderless type) —> converted to 0 (representation of orderless in the OntoUML Vocabulary).

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.set_class_restrictedto_ontologicalnature(class_dict, ontouml_graph)

Set the ontouml:restrictedTo relation between a class and its related ontouml:OntologicalNature instance.

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.set_class_attributes(class_dict, ontouml_graph)

Define the ontouml:isPowertype and ontouml:isExtensional data properties of an ontouml:Class in the graph.

This function must be called after the function set_class_defaults, as the received value may change because of identified problems.

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.set_class_attribute_property(class_dict, ontouml_graph)

Set ontouml:attribute relation between an ontouml:Class and an ontouml:Property.

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.set_class_literal_literal(class_dict, ontouml_graph)

Set ontouml:literal relation between an ontouml:Class and its related ontouml:Literal individuals.

Parameters:
  • class_dict (dict) – Class object loaded as a dictionary.

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

Return type:

None

json2graph.decoder.decode_obj_class.create_class_properties(json_data, ontouml_graph, element_counting)

Decode an object of type ‘Class’.

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 properties:
  • ontouml:order (range xsd:nonNegativeInteger)

  • ontouml:stereotype (range ontouml:ClassStereotype)

  • ontouml:restrictedTo (range ontouml:OntologicalNature)

  • ontouml:isPowertype (range xsd:boolean)

  • ontouml:isExtensional (range xsd:boolean)

  • ontouml:isDerived (range xsd:boolean)

  • ontouml:isAbstract (range xsd:boolean)

  • ontouml:attribute (range ontouml:Property)

  • ontouml:literal (range ontouml:Literal)

Dictionaries containing classes IDs are used for reference. One of its characteristics is that they do not have the field ‘name’. These are not Classes dictionaries and, hence, are not treated here.

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.

  • element_counting (dict) – Dictionary with types and respective quantities present on graph.

Return type:

None