json2graph.modules.decoder package
Submodules
json2graph.modules.decoder.decode_general module
General decoding functions.
- json2graph.modules.decoder.decode_general.clean_null_data(dictionary_data)
Removes all empty values (i.e., keys associated with None) from the received dictionary. If a value of the dictionary is another dictionary, this function recursively verify this sub-dictionary elements. I.e., all empty fields, from all dictionaries composing the main dictionary are also cleaned.
- Parameters:
dictionary_data (dict) – Dictionary to have its empty fields cleaned.
- Returns:
Dictionary without empty fields.
- Return type:
dict
- json2graph.modules.decoder.decode_general.count_elements_graph(ontouml_graph)
Returns a dictionary with all element types on graphs and their respective quantity.
- Parameters:
ontouml_graph (Graph) – Knowledge graph with loaded objects’ ids and types
- Returns:
Dictionary with types and respective quantities present on graph.
- Return type:
dict
- json2graph.modules.decoder.decode_general.create_point(point_id, x_coord, y_coord, ontouml_graph)
Creates a new instance of ontouml:Point with its ontouml:xCoordinate, and ontouml:yCoordinate properties.
- Parameters:
point_id (str) – ID of the new ontouml:Point instance to be created.
x_coord (int) – Horizontal coordinate of the new ontouml:Point.
y_coord (int) – Vertical coordinate of the new ontouml:Point.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
- json2graph.modules.decoder.decode_general.get_all_ids_of_specific_type(dictionary_data, wanted_type, list_ids_for_type=None)
Recursively access all objects in the dictionary and generates a list of all ids of objects for a given type.
- Parameters:
dictionary_data (dict) – Dictionary to have its fields decoded.
wanted_type (str) – Name of the type of the objects to have their IDs identified.
list_ids_for_type (list[str]) –
- Returns:
List of ids from all objects for a given type.
- Return type:
list[str]
- json2graph.modules.decoder.decode_general.get_list_subdictionaries_for_specific_type(dictionary_data, wanted_type, return_list=None)
Recursively access all objects in the dictionary until find an object of the desired type. When the type is found, adds a copy of its dictionaries to a list to be returned (containing all its sub-dictionaries).
- Parameters:
dictionary_data (dict) – Dictionary to have its fields decoded.
wanted_type (str) – ID of the object to have its dictionary (including sub-dictionaries) returned.
return_list (list[dict]) – Optional. Searched dictionary to be returned. Used for recursion only.
- Returns:
List of copy of the object’s dictionaries.
- Return type:
list[dict]
- json2graph.modules.decoder.decode_general.get_stereotype(object_dict)
For coding reasons (dictionary index error), it is necessary to check if an object has its stereotype not set. Returns the evaluated object’s stereotype or ‘null’ when the stereotype is absent.
- Parameters:
object_dict (dict) – Object loaded as a dictionary.
- Returns:
Evaluated object’s stereotype or ‘null’ when the stereotype is absent.
- Return type:
str
- json2graph.modules.decoder.decode_general.get_subdictionary_for_specific_id(dictionary_data, wanted_id, return_dict=None)
Recursively access all objects in the dictionary until find the desired ID. When the id is found, return a copy of its dictionary (containing all its sub-dictionaries).
- Parameters:
dictionary_data (dict) – Dictionary to have its fields decoded.
wanted_id (str) – ID of the object to have its dictionary (including sub-dictionaries) returned.
return_dict (dict) – Optional. Searched dictionary to be returned. Used for recursion only.
- Returns:
Copy of the object’s dictionary.
- Return type:
dict
json2graph.modules.decoder.decode_main module
JSON decode functions.
- json2graph.modules.decoder.decode_main.add_metadata(ontouml_graph)
- Adds basic metadata to the generated graph when not in test mode. The metadata added are:
dct:conformsTo METADATA[“conformsToBase”]
dct:created (creation date)
dct:language (when user argument available)
type owl:Ontology
Decoder information as rdfs:comment and rdfs:seeAlso
- Parameters:
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
- json2graph.modules.decoder.decode_main.decode_dictionary(dictionary_data, ontouml_graph, language)
Receives the full dictionary with the loaded JSON data and decode known allowed values to the OntoUML Graph. Recursively evaluates the dictionary to create all possible instances, setting their types and attributes.
- OntoUML-Vocabulary properties that are directly decoded in the general decoder:
description, height, isAbstract, isComplete, isDerived, isDisjoint, isOrdered, isReadOnly, name, text, width
Restricted properties (the ones in the restricted_fields list) are not treated in this function.
- Parameters:
dictionary_data (dict) – Dictionary to have its fields decoded.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
language (str) – Language tag to be added to the ontology’s concepts.
- Return type:
None
- json2graph.modules.decoder.decode_main.decode_json_to_graph(json_data, language, execution_mode)
Receives the loaded JSON data and decodes it into a graph that complies to the OntoUML Vocabulary.
- Parameters:
json_data (dict) – Input JSON data loaded as a dictionary.
language (str) – Language tag to be added to the ontology’s concepts.
execution_mode (str) – Information about execution mode. Valid values are ‘script’, ‘import’, and ‘test’.
- Returns:
Knowledge graph that complies with the OntoUML Vocabulary
- Return type:
Graph
json2graph.modules.decoder.decode_obj_class module
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.
- json2graph.modules.decoder.decode_obj_class.create_class_properties(json_data, ontouml_graph, element_counting)
Main function for decoding 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
- json2graph.modules.decoder.decode_obj_class.set_class_attribute_property(class_dict, ontouml_graph)
Sets 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.modules.decoder.decode_obj_class.set_class_attributes(class_dict, ontouml_graph)
Defines 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.modules.decoder.decode_obj_class.set_class_literal_literal(class_dict, ontouml_graph)
Sets 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.modules.decoder.decode_obj_class.set_class_order_nonnegativeinteger(class_dict, ontouml_graph)
Sets 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.modules.decoder.decode_obj_class.set_class_restrictedto_ontologicalnature(class_dict, ontouml_graph)
Sets 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.modules.decoder.decode_obj_class.set_class_stereotype(class_dict, ontouml_graph)
Sets 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.modules.decoder.decode_obj_class.set_defaults_class_attribute(class_dict, ontouml_graph)
Verifies a class dictionary and check if their non-nullable attributes isExtensional and isPowertype were set or not. If not, creates default values. 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.modules.decoder.decode_obj_class.set_defaults_class_order(class_dict, ontouml_graph)
Verifies 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.modules.decoder.decode_obj_class.validate_class_attribute_constraints(class_dict)
Verifies 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.modules.decoder.decode_obj_class.validate_class_order_constraints(class_dict)
Verifies 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.modules.decoder.decode_obj_diagram module
Functions to decode specificities of the object Diagram.
- 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.
- json2graph.modules.decoder.decode_obj_diagram.create_diagram_properties(json_data, ontouml_graph, element_counting)
Main function for decoding objects of type ‘Diagram’.
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 object properties:
ontouml:owner (range ontouml:ModelElement)
ontouml:containsView (range ontouml:ElementView)
- 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
- json2graph.modules.decoder.decode_obj_diagram.set_diagram_containsview_elementview(diagram_dict, ontouml_graph)
Set the ontouml:containsView property between an ontouml:Diagram and its related ontouml:ElementView.
- Parameters:
diagram_dict (dict) – Diagram object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
- json2graph.modules.decoder.decode_obj_diagram.set_diagram_owner_modelelement(diagram_dict, ontouml_graph)
Set the ontouml:owner property between an ontouml:Diagram and its related ontouml:Package.
- Parameters:
diagram_dict (dict) – Diagram object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_elementview module
Functions to decode specificities of the object ElementView.
- 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.
- json2graph.modules.decoder.decode_obj_elementview.create_elementview_properties(json_data, ontouml_graph)
Main function for decoding an object of type ElementView.
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:shape (domain ontouml:ElementView, range ontouml:Shape)
ontouml:isViewOf (domain ontouml:ElementView, range ontouml:ModelElement)
ontouml:sourceView (domain ontouml:ConnectorView, range ontouml:ElementView)
ontouml:targetView (domain ontouml:ConnectorView, range ontouml:ElementView)
- 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
- json2graph.modules.decoder.decode_obj_elementview.set_elementview_relations(elementview_dict, ontouml_graph)
Set an ontouml:ElementView’s ontouml:shape and ontouml:isViewOf object properties in the resulting graph.
- Parameters:
elementview_dict (dict) – ElementView object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_generalization module
Functions to decode specificities of the object Generalization.
- 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.
- json2graph.modules.decoder.decode_obj_generalization.create_generalization_properties(json_data, ontouml_graph)
Main function for decoding an object of type Generalization.
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:general (range ontouml:Classifier)
ontouml:specific (range ontouml:Classifier)
- 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
- json2graph.modules.decoder.decode_obj_generalization.set_generalization_relations(generalization_dict, ontouml_graph)
Set the ontouml:general and ontouml:specific properties in the resulting graph.
- Parameters:
generalization_dict (dict) – Generalization object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_generalizationset module
Functions to decode specificities of the object GeneralizationSet.
- 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.
- json2graph.modules.decoder.decode_obj_generalizationset.create_generalizationset_properties(json_data, ontouml_graph)
Main function for decoding an object of type GeneralizationSet.
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:generalization (range ontouml:Generalization)
ontouml:categorizer (range ontouml:Class)
- 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
- json2graph.modules.decoder.decode_obj_generalizationset.set_generalizationset_defaults(generalizationset_dict, ontouml_graph)
Sets the default values to ontouml:generalizationSets to the resulting graph.
Default isDisjoint: If isDisjoint is null, set as False.
Default isComplete: If isComplete is null, set as False.
- Parameters:
generalizationset_dict (dict) – GeneralizationSet object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
- json2graph.modules.decoder.decode_obj_generalizationset.set_generalizationset_relations(generalizationset_dict, ontouml_graph)
Sets the ontouml:generalization and ontouml:categorizer property to the resulting graph.
- Parameters:
generalizationset_dict (dict) – GeneralizationSet object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_package module
Functions to decode specificities of the object Package.
- 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.
- json2graph.modules.decoder.decode_obj_package.create_package_properties(json_data, ontouml_graph)
Main function for decoding an object of type Package.
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 object properties:
ontouml:containsModelElement (range:ModelElement)
- 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
- json2graph.modules.decoder.decode_obj_package.get_package_contents(package_dict, package_id, list_contents=[])
Receives the dictionary with all loaded JSON data and returns the value of the ‘contents’ field for a given object (defined by the received value of its ID).
- Parameters:
package_dict (dict) – Package’s data to have its fields decoded.
package_id (str) – ID of the Package to have its list of contents returned.
list_contents (list) – Optional. Used to identify if the desired value was already found and exit recursion.
- Returns:
List of contents for a given Package.
- Return type:
list[dict]
- json2graph.modules.decoder.decode_obj_package.set_package_containsmodelelement_modelelement(package_dict, ontouml_graph)
Set object property ontouml:containsModelElement between an ontouml:Package and an ontouml:ModelElement it contains.
- Parameters:
package_dict (dict) – Package’s data to have its fields decoded.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_path module
Functions to decode specificities of the object Path.
- 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.
- json2graph.modules.decoder.decode_obj_path.create_path_properties(json_data, ontouml_graph)
Main function for decoding an object of type Path.
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:
ontouml:Point
- Created properties:
ontouml:point (range ontouml:Point)
- 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
- json2graph.modules.decoder.decode_obj_path.set_path_path_point(path_dict, ontouml_graph)
Creates an ontouml:Point, their properties and the ontouml:point of an ontouml:Path.
- Parameters:
path_dict (dict) – Path object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_project module
Functions to decode specificities of the object Project.
- 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.
- json2graph.modules.decoder.decode_obj_project.create_project_properties(json_data, ontouml_graph, element_counting)
Main function for decoding objects of type ‘Project’.
Receives the whole JSON loaded data as a dictionary and manipulates it to create all properties in which the object’s type is domain (every case) or range of (when related to an abstract class).
This function considers that there may be multiple projects in the loaded JSON file.
- Created object properties:
ontouml:project (domain ontouml:OntoumlElement, range ontouml:Project)
ontouml:model (domain ontouml:Project, range ontouml:Package)
ontouml:diagram (domain ontouml:Project, range ontouml:Diagram)
- 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
- json2graph.modules.decoder.decode_obj_project.set_ontoumlelement_project_project(project_dict, ontouml_graph, element_counting)
Sets the ontouml:project object property between an ontouml:Project (obj) and all its related entities (subj).
- Parameters:
project_dict (dict) – Project’s data to have its fields decoded.
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
- json2graph.modules.decoder.decode_obj_project.set_project_diagram_diagram(project_dict, ontouml_graph)
Sets the ontouml:diagram object property between an ontouml:Project and its related ontouml:Diagram entities.
- Parameters:
project_dict (dict) – Project’s data to have its fields decoded.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
- json2graph.modules.decoder.decode_obj_project.set_project_model_package(project_dict, ontouml_graph)
Sets ontouml:model relation between an ontouml:Project and its related model.
- Parameters:
project_dict (dict) – Project’s data to have its fields decoded.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_property module
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.
- json2graph.modules.decoder.decode_obj_property.create_property_properties(json_data, ontouml_graph)
Main function for decoding an 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
- json2graph.modules.decoder.decode_obj_property.determine_cardinality_bounds(cardinalities, property_id)
Receives 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.modules.decoder.decode_obj_property.set_cardinality_relations(property_dict, ontouml_graph)
Creates 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.modules.decoder.decode_obj_property.set_property_defaults(property_dict, ontouml_graph)
Sets 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.modules.decoder.decode_obj_property.set_property_relations(property_dict, ontouml_graph)
Sets 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.modules.decoder.decode_obj_property.validate_property_stereotype(ontouml_graph)
Performs 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.modules.decoder.decode_obj_rectangularshape module
Functions to decode specificities of the object RectangularShare.
- 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.
- json2graph.modules.decoder.decode_obj_rectangularshape.create_rectangularshape_properties(json_data, ontouml_graph)
Main function for decoding an object of type RectangularShape.
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:
ontouml:Point
- Created properties:
ontouml:topLeftPosition (domain ontouml:RectangularShape, range ontouml:Point)
ontouml:xCoordinate (domain ontouml:Point, range xsd:integer)
ontouml:yCoordinate (domain ontouml:Point, range xsd:integer)
# The ontouml:height and ontouml:width data properties are not assigned in this function, as they can be directly obtained in the general decoding.
- 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
- json2graph.modules.decoder.decode_obj_rectangularshape.set_rectangularshape_coordinates(rectangularshape_dict, ontouml_graph)
Creates an ontouml:Point, their properties and the ontouml:topLeftPosition of an ontouml:RectangularShape.
- Parameters:
rectangularshape_dict (dict) – RectangularShape object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
json2graph.modules.decoder.decode_obj_relation module
Functions to decode specificities of the object Relation.
- 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.
- json2graph.modules.decoder.decode_obj_relation.create_relation_properties(json_data, ontouml_graph)
Main function for decoding an object of type Relation.
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:relationEnd (range ontouml:Property)
ontouml:sourceEnd (range ontouml:Property)
ontouml:targetEnd (range ontouml:Property)
ontouml:stereotype (range ontouml:RelationStereotype)
ontouml:isDerived (range xsd:boolean)
ontouml:isAbstract (range xsd:boolean)
- 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
- json2graph.modules.decoder.decode_obj_relation.set_relation_defaults(relation_dict, ontouml_graph)
Sets the following attribute’s default values for ontouml:Relation:
DRA1) ontouml:isDerived default value = False DRA2) ontouml:isAbstract default value = False
- Parameters:
relation_dict (dict) – Relation object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
- json2graph.modules.decoder.decode_obj_relation.set_relation_relations(relation_dict, ontouml_graph)
- Sets the following object properties to instances of ontouml:Relation:
ontouml:relationEnd (range ontouml:Property)
ontouml:sourceEnd (range ontouml:Property)
ontouml:targetEnd (range ontouml:Property)
- Parameters:
relation_dict (dict) – Relation object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None
- json2graph.modules.decoder.decode_obj_relation.set_relation_stereotype(relation_dict, ontouml_graph)
Sets ontouml:stereotype property between an instance of ontouml:Relation and an instance representing an ontouml:RelationStereotype.
- Warning messages:
VRS1: Relation has invalid stereotype associated to it. Result is invalid.
- Parameters:
relation_dict (dict) – Relation object loaded as a dictionary.
ontouml_graph (Graph) – Knowledge graph that complies with the OntoUML Vocabulary.
- Return type:
None