:py:mod:`json2graph.decoder.decode_obj_class` ============================================= .. py:module:: json2graph.decoder.decode_obj_class .. autoapi-nested-parse:: Functions to decode objects of type Class. Function's nomenclatures: - Functions that set one property are named: set___. - Functions that set multiple object properties are named: set__relations. - Functions that set multiple data properties are named: set__attributes. - Functions that set both object and data properties are named: set__properties. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: json2graph.decoder.decode_obj_class.validate_class_attribute_constraints json2graph.decoder.decode_obj_class.validate_class_order_constraints json2graph.decoder.decode_obj_class.set_defaults_class_attribute json2graph.decoder.decode_obj_class.set_defaults_class_order json2graph.decoder.decode_obj_class.set_class_stereotype json2graph.decoder.decode_obj_class.set_class_order_nonnegativeinteger json2graph.decoder.decode_obj_class.set_class_restrictedto_ontologicalnature json2graph.decoder.decode_obj_class.set_class_attributes json2graph.decoder.decode_obj_class.set_class_attribute_property json2graph.decoder.decode_obj_class.set_class_literal_literal json2graph.decoder.decode_obj_class.create_class_properties .. py:function:: 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. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict .. py:function:: 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. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict .. py:function:: 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 :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: 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. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: 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. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: 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). :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: set_class_restrictedto_ontologicalnature(class_dict, ontouml_graph) Set the ontouml:restrictedTo relation between a class and its related ontouml:OntologicalNature instance. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: 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. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: set_class_attribute_property(class_dict, ontouml_graph) Set ontouml:attribute relation between an ontouml:Class and an ontouml:Property. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: set_class_literal_literal(class_dict, ontouml_graph) Set ontouml:literal relation between an ontouml:Class and its related ontouml:Literal individuals. :param class_dict: Class object loaded as a dictionary. :type class_dict: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph .. py:function:: 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. :param json_data: JSON's data to have its fields decoded loaded into a dictionary. :type json_data: dict :param ontouml_graph: Knowledge graph that complies with the OntoUML Vocabulary. :type ontouml_graph: Graph :param element_counting: Dictionary with types and respective quantities present on graph. :type element_counting: dict