Ejemplo n.º 1
0
    def testCreatesCompositionInGraphSomeRestriction(self):
        # Prepare data

        # Build First Graph with the method
        graph = rdflib.Graph()
        # Bind the OWL and Digital Buildings name spaces
        namespace_manager = namespace.NamespaceManager(rdflib.Graph())
        namespace_manager.bind('owl', rdflib.OWL)
        namespace_manager.bind('db', constants.DIGITAL_BUILDINGS_NS)
        graph.namespace_manager = namespace_manager
        list_standard_field_name = [
            'cooling_air_flowrate_sensor_1', 'run_command'
        ]
        uses_property = infixowl.Property(
            identifier=constants.DIGITAL_BUILDINGS_NS['uses'],
            baseType=infixowl.OWL_NS.ObjectProperty,
            graph=graph)
        class_owl = infixowl.Class(
            identifier=constants.DIGITAL_BUILDINGS_NS['DFSS'], graph=graph)

        graph = rdf_helper.CreateCompositionInGraph(
            composition_operator='|',
            list_standard_field_names=list_standard_field_name,
            restriction=infixowl.some,
            composition_property=uses_property,
            class_owl=class_owl,
            graph=graph)

        # Build a second graph that is expected
        expected_graph = rdflib.Graph()
        # Bind the OWL and Digital Buildings name spaces
        namespace_manager_expected = namespace.NamespaceManager(rdflib.Graph())
        namespace_manager_expected.bind('owl', rdflib.OWL)
        namespace_manager_expected.bind('db', constants.DIGITAL_BUILDINGS_NS)
        expected_graph.namespace_manager = namespace_manager_expected
        class_owl_expected = infixowl.Class(
            identifier=constants.DIGITAL_BUILDINGS_NS['DFSS'],
            graph=expected_graph)

        sfn1_expected = infixowl.Class(
            identifier=constants.
            DIGITAL_BUILDINGS_NS['Cooling_air_flowrate_sensor_1'],
            graph=expected_graph)
        sfn2_expected = infixowl.Class(
            identifier=constants.DIGITAL_BUILDINGS_NS['Run_command'],
            graph=expected_graph)
        uses_property_expected = infixowl.Property(
            identifier=constants.DIGITAL_BUILDINGS_NS['uses'],
            baseType=infixowl.OWL_NS.ObjectProperty,
            graph=expected_graph)

        concat = sfn1_expected | sfn2_expected
        class_owl_expected.subClassOf = [
            uses_property_expected | infixowl.some | concat
        ]

        # Check if they are similar
        self.assertTrue(compare.similar(graph, expected_graph))
Ejemplo n.º 2
0
    def testAbstractGraphGeneration(self):

        fake_abstract = 'fake_resources/Abstract.yaml'

        file_contents = rdf_helper.ReadFile(fake_abstract)

        yaml_abstract = yaml_handler.ImportYamlFiles(file_contents)

        # Create global graph
        graph = rdflib.Graph()
        # Generate the graph by the function handler
        graph = rdflib_function_handler.GenerateGraph(yaml_abstract, graph)

        # Build a second graph manually in order to compare it with the one above:
        # DD:
        # description: "Dual duct flow control (hot deck, cold deck)."
        # is_abstract: true
        # opt_uses:
        # - discharge_air_temperature_sensor
        # - run_command
        # uses:
        # - heating_air_flowrate_sensor
        # - heating_air_flowrate_setpoint
        # implements:
        # - CONTROL

        expected_graph = rdflib.Graph()
        # Main Types
        functionality = rdflib.URIRef(constants.HVAC_NS['Functionality'])
        entity_type = rdflib.URIRef(
            constants.DIGITAL_BUILDINGS_NS['EntityType'])
        dd_description = 'Dual duct flow control (hot deck, cold deck).'
        # Main Classes
        dd_expected = infixowl.Class(identifier=constants.HVAC_NS['Dd'],
                                     graph=expected_graph,
                                     subClassOf=[functionality])
        expected_graph, _ = rdf_helper.CreateClassInGraph(
            graph=expected_graph,
            class_name='Dd',
            class_description=dd_description,
            parent_clazz=functionality,
            entity_namespace=constants.HVAC_NS)
        infixowl.Class(identifier=constants.SUBFIELDS_NS['Point_type'],
                       graph=expected_graph)

        uses_property = infixowl.Property(
            identifier=constants.DIGITAL_BUILDINGS_NS['uses'],
            baseType=infixowl.OWL_NS.ObjectProperty,
            graph=expected_graph)

        is_composed_of_property = infixowl.Property(
            identifier=constants.DIGITAL_BUILDINGS_NS['isComposedOf'],
            baseType=infixowl.OWL_NS.ObjectProperty,
            graph=expected_graph)
        uses_property_optionally = infixowl.Property(
            identifier=constants.DIGITAL_BUILDINGS_NS['usesOptional'],
            baseType=infixowl.OWL_NS.ObjectProperty,
            graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Air'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Flowrate'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Heating'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Run'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Command'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Discharge'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Temperature'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Sensor'],
                       graph=expected_graph)

        infixowl.Class(identifier=constants.FIELDS_NS['Field'],
                       graph=expected_graph)

        heating_air_flowrate_sensor = infixowl.Class(
            identifier=constants.FIELDS_NS['Heating_air_flowrate_sensor'],
            graph=expected_graph,
            subClassOf=[constants.FIELDS_NS['Field']])
        heating_air_flowrate_setpoint = infixowl.Class(
            identifier=constants.FIELDS_NS['Heating_air_flowrate_setpoint'],
            graph=expected_graph,
            subClassOf=[constants.FIELDS_NS['Field']])

        concat = heating_air_flowrate_sensor & heating_air_flowrate_setpoint
        dd_expected.subClassOf = [uses_property | infixowl.only | concat]

        discharge_air_temperature_sensor = infixowl.Class(
            identifier=constants.FIELDS_NS['Discharge_air_temperature_sensor'],
            graph=expected_graph,
            subClassOf=[constants.FIELDS_NS['Field']])
        run_command = infixowl.Class(
            identifier=constants.FIELDS_NS['Run_command'],
            graph=expected_graph,
            subClassOf=[constants.FIELDS_NS['Field']])

        concat2 = discharge_air_temperature_sensor | run_command
        dd_expected.subClassOf = [
            uses_property_optionally | infixowl.some | concat2
        ]

        list_composition = rdf_helper.DecomposeStandardFieldName(
            'Discharge_air_temperature_sensor')
        expected_graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
            graph=expected_graph,
            list_composition=list_composition,
            standard_field_name='Discharge_air_temperature_sensor',
            is_composed_of_property=is_composed_of_property)

        list_composition = rdf_helper.DecomposeStandardFieldName('Run_command')
        expected_graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
            graph=expected_graph,
            list_composition=list_composition,
            standard_field_name='Run_command',
            is_composed_of_property=is_composed_of_property)

        list_composition = rdf_helper.DecomposeStandardFieldName(
            'Heating_air_flowrate_sensor')
        expected_graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
            graph=expected_graph,
            list_composition=list_composition,
            standard_field_name='Heating_air_flowrate_sensor',
            is_composed_of_property=is_composed_of_property)

        list_composition = rdf_helper.DecomposeStandardFieldName(
            'Heating_air_flowrate_setpoint')
        expected_graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
            graph=expected_graph,
            list_composition=list_composition,
            standard_field_name='Heating_air_flowrate_setpoint',
            is_composed_of_property=is_composed_of_property)

        expected_graph, functionality_class = rdf_helper.CreateClassInGraph(
            graph=expected_graph,
            class_name='Functionality',
            class_description=None,
            parent_clazz=entity_type,
            entity_namespace=constants.HVAC_NS)

        expected_graph, application = rdf_helper.CreateClassInGraph(
            graph=expected_graph,
            class_name='Application',
            class_description=None,
            parent_clazz=entity_type)

        expected_graph, control = rdf_helper.CreateClassInGraph(
            graph=expected_graph,
            class_name='Control',
            class_description=None,
            parent_clazz=application[0])

        expected_graph, _ = rdf_helper.CreateClassInGraph(
            graph=expected_graph,
            class_name='Dd',
            class_description=dd_description,
            parent_clazz=functionality_class[0],
            entity_namespace=constants.HVAC_NS)

        expected_graph, _ = rdf_helper.CreateClassInGraph(
            graph=expected_graph,
            class_name='Dd',
            class_description=dd_description,
            parent_clazz=control[0],
            entity_namespace=constants.HVAC_NS)

        # Check if they are similar
        self.assertTrue(compare.similar(graph, expected_graph))
def GenerateGraph(yaml_object, graph, entity_namespace):
    """Utility function updates an RDF graph with the yaml content.

  Updates an RDF graph with the yaml content

  Args:
    yaml_object: the yaml content.
    graph: the global graph where the ontology is being built in RDF.
    entity_namespace: the namespace to be attributed to the given types

  Returns:
    a graph with the contents of the yaml file merged
  """

    # Ignore entities implementing the following keywords in their definition
    ignore_generation_set = {
        "DEPRECATED", "INCOMPLETE", "IGNORE", "REMAP_REQUIRED"
    }
    field = rdflib.URIRef(constants.FIELDS_NS["Field"])
    # Prepare properties to be added to the graph and not in the yaml
    uses_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["uses"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)
    uses_property_optionally = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["usesOptional"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)
    is_composed_of_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["isComposedOf"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)
    infixowl.Class(identifier=constants.SUBFIELDS_NS["Point_type"],
                   graph=graph)

    # Traverse the yaml content
    for clazz, clazz_content in yaml_object.items():
        class_name = clazz.capitalize()
        implements = clazz_content.get("implements")
        # implements content will decide if the class is added to the graph or not
        ignore_class = False
        if implements is not None:
            for implements_item in implements:
                if implements_item in ignore_generation_set:
                    ignore_class = True

        # Generate the class if it does not have implements field
        #   or no (DEPRECATED or INCOMPLETE)
        if ignore_class:
            continue

        # Create the class
        parent = (entity_namespace[implements[0].capitalize()]
                  if implements is not None else namespace.OWL.Thing)
        graph, _ = rdf_helper.CreateClassInGraph(
            graph=graph,
            class_name=class_name,
            class_description=clazz_content.get("description"),
            parent_clazz=parent,
            entity_namespace=entity_namespace)
        # update parents only if implements is not None
        if implements is not None:
            for implements_item in implements[1:]:
                graph.add((entity_namespace[class_name.capitalize()],
                           rdflib.RDFS.subClassOf,
                           entity_namespace[implements_item.capitalize()]))

        # check the mandatory fields
        uses = clazz_content.get("uses")
        if uses is not None and isinstance(uses, list):
            for each_item in uses:
                list_composition = rdf_helper.DecomposeStandardFieldName(
                    each_item)
                graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
                    graph=graph,
                    list_composition=list_composition,
                    standard_field_name=each_item,
                    is_composed_of_property=is_composed_of_property)
                class_owl = infixowl.Class(
                    identifier=entity_namespace[class_name],
                    graph=graph,
                    subClassOf=[parent])
                graph = rdf_helper.CreateCompositionInGraph(
                    list_standard_field_names=uses,
                    composition_operator="&",
                    composition_property=uses_property,
                    restriction=infixowl.only,
                    class_owl=class_owl,
                    graph=graph,
                    entity_namespace=constants.FIELDS_NS,
                    sub_class_of=[field])

        # check the optional fields
        opt_uses = clazz_content.get("opt_uses")
        if opt_uses is not None and isinstance(opt_uses, list):
            for each_item in opt_uses:
                list_composition = rdf_helper.DecomposeStandardFieldName(
                    each_item)
                graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
                    graph=graph,
                    list_composition=list_composition,
                    standard_field_name=each_item,
                    is_composed_of_property=is_composed_of_property)
                class_owl = infixowl.Class(
                    identifier=entity_namespace[class_name],
                    graph=graph,
                    subClassOf=[parent])
                graph = rdf_helper.CreateCompositionInGraph(
                    list_standard_field_names=opt_uses,
                    composition_operator="|",
                    composition_property=uses_property_optionally,
                    restriction=infixowl.some,
                    class_owl=class_owl,
                    graph=graph,
                    entity_namespace=constants.FIELDS_NS,
                    sub_class_of=[field])
    return graph
Ejemplo n.º 4
0
def GenerateGraph(yaml_object, graph):
    """Utility function updates an RDF graph with the yaml content of the GeneralTypes.yaml.

  The content of each object is similar to the following:
   CHL:
    id: "9950288448474578944"
    description: "Tag for chillers."
    is_abstract: true
    implements:
    - EQUIPMENT
    opt_uses:
    - cooling_thermal_power_capacity
    - power_capacity
    - efficiency_percentage_specification
    - flowrate_requirement

  Updates an RDF graph with the yaml content.

  Args:
    yaml_object: the yaml content.
    graph: the global graph where the ontology is being built in RDF.

  Returns:
    a graph with the contents of the yaml file merged
  """
    # Applications Set used to avoid recreating applications again in the graph
    applications_set = {"Equipment"}
    # Prepare classes to be added to the graph and not in the yaml
    equipment = rdflib.URIRef(constants.DIGITAL_BUILDINGS_NS["Equipment"])
    entity_type = rdflib.URIRef(constants.DIGITAL_BUILDINGS_NS["EntityType"])
    field = rdflib.URIRef(constants.FIELDS_NS["Field"])
    infixowl.Class(identifier=constants.FIELDS_NS["Field"], graph=graph)
    infixowl.Class(identifier=constants.SUBFIELDS_NS["Point_type"],
                   graph=graph)
    graph, application_class = rdf_helper.CreateClassInGraph(
        graph=graph,
        class_name="Application",
        class_description=None,
        parent_clazz=entity_type)
    graph, _ = rdf_helper.CreateClassInGraph(graph=graph,
                                             class_name="Equipment",
                                             class_description=None,
                                             parent_clazz=entity_type)
    # Prepare properties to be added to the graph and not in the yaml
    uses_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["uses"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)
    uses_property_optionally = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["usesOptional"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)
    is_composed_of_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["isComposedOf"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)

    # Traverse the yaml content
    for clazz in yaml_object.keys():
        clazz_content = yaml_object.get(clazz)
        class_name = clazz.capitalize()
        implements = clazz_content.get("implements")
        # implements will decide if the entity gets generated in the graph,
        # for now the mother class is equipment, this might change in the near
        # future due to changes in the ontology, keeping the implementation as it is
        if implements is None:
            continue
        else:
            mother_class = equipment

        # Create the class
        graph, clazz_object = rdf_helper.CreateClassInGraph(
            graph=graph,
            class_name=class_name,
            class_description=clazz_content.get("description"),
            parent_clazz=mother_class,
            entity_namespace=constants.HVAC_NS)

        if implements is not None:
            graph, applications_set = rdf_helper.CreatesImplementsInGraph(
                graph=graph,
                implements_list=implements,
                applications_set=applications_set,
                application_class=application_class,
                class_object=clazz_object)

        uses = clazz_content.get("uses")
        if uses is not None:
            if isinstance(uses, list):
                for each_item in uses:
                    list_composition = rdf_helper.DecomposeStandardFieldName(
                        each_item)
                    graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
                        graph=graph,
                        list_composition=list_composition,
                        standard_field_name=each_item,
                        is_composed_of_property=is_composed_of_property)
                class_owl = infixowl.Class(
                    identifier=constants.HVAC_NS[class_name],
                    graph=graph,
                    sub_class_of=[equipment])
                graph = rdf_helper.CreateCompositionInGraph(
                    list_standard_field_names=uses,
                    composition_operator="&",
                    composition_property=uses_property,
                    restriction=infixowl.only,
                    class_owl=class_owl,
                    graph=graph,
                    entity_namespace=constants.FIELDS_NS,
                    sub_class_of=[field])

        opt_uses = clazz_content.get("opt_uses")
        if opt_uses is not None:
            if isinstance(opt_uses, list):
                for each_item in opt_uses:
                    list_composition = rdf_helper.DecomposeStandardFieldName(
                        each_item)
                    graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
                        graph=graph,
                        list_composition=list_composition,
                        standard_field_name=each_item,
                        is_composed_of_property=is_composed_of_property)
                class_owl = infixowl.Class(
                    identifier=constants.HVAC_NS[class_name],
                    graph=graph,
                    subClassOf=[equipment])
                graph = rdf_helper.CreateCompositionInGraph(
                    list_standard_field_names=opt_uses,
                    composition_operator="|",
                    composition_property=uses_property_optionally,
                    restriction=infixowl.some,
                    class_owl=class_owl,
                    graph=graph,
                    entity_namespace=constants.FIELDS_NS,
                    sub_class_of=[field])

    return graph
Ejemplo n.º 5
0
    def testCreatesStandardFieldNameCompositionInGraph(self):
        # Prepare data

        # Build First Graph with the method
        graph = rdflib.Graph()
        # Bind the OWL and Digital Buildings name spaces
        namespace_manager = namespace.NamespaceManager(graph)
        namespace_manager.bind('owl', rdflib.OWL)
        namespace_manager.bind('db', constants.DIGITAL_BUILDINGS_NS)
        graph.namespace_manager = namespace_manager
        list_composition = ['Cooling', 'Air', 'Flowrate', 'Sensor']
        standard_field_name = 'cooling_air_flowrate_sensor_1'
        is_composed_of_property = infixowl.Property(
            identifier=constants.DIGITAL_BUILDINGS_NS['isComposedOf'],
            baseType=infixowl.OWL_NS.ObjectProperty,
            graph=graph)
        point_type = infixowl.Class(
            identifier=constants.SUBFIELDS_NS['Point_type'], graph=graph)

        infixowl.Class(identifier=constants.SUBFIELDS_NS['Sensor'],
                       graph=graph,
                       subClassOf=[point_type])

        field = infixowl.Class(identifier=constants.FIELDS_NS['Field'],
                               graph=graph)

        infixowl.Class(
            identifier=constants.FIELDS_NS['Cooling_air_flowrate_sensor_1'],
            graph=graph,
            subClassOf=[field])
        graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
            list_composition=list_composition,
            standard_field_name=standard_field_name,
            is_composed_of_property=is_composed_of_property,
            graph=graph)

        # Build a second graph that is expected
        expected_graph = rdflib.Graph()
        # Bind the OWL and Digital Buildings name spaces
        namespace_manager_expected = namespace.NamespaceManager(expected_graph)
        namespace_manager_expected.bind('owl', rdflib.OWL)
        namespace_manager_expected.bind('db', constants.DIGITAL_BUILDINGS_NS)
        expected_graph.namespace_manager = namespace_manager_expected
        field_expected = infixowl.Class(
            identifier=constants.FIELDS_NS['Field'], graph=expected_graph)
        point_type_expected = infixowl.Class(
            identifier=constants.SUBFIELDS_NS['Point_type'],
            graph=expected_graph)
        cooling_expected = infixowl.Class(
            identifier=constants.SUBFIELDS_NS['Cooling'], graph=expected_graph)
        air_expected = infixowl.Class(identifier=constants.SUBFIELDS_NS['Air'],
                                      graph=expected_graph)
        flowrate_expected = infixowl.Class(
            identifier=constants.SUBFIELDS_NS['Flowrate'],
            graph=expected_graph)
        sensor_expected = infixowl.Class(
            identifier=constants.SUBFIELDS_NS['Sensor'],
            graph=expected_graph,
            subClassOf=[point_type_expected])
        sfn_expected = infixowl.Class(
            identifier=constants.FIELDS_NS['Cooling_air_flowrate_sensor_1'],
            graph=expected_graph,
            subClassOf=[field_expected])
        is_composed_of_property_expected = infixowl.Property(
            identifier=constants.DIGITAL_BUILDINGS_NS['isComposedOf'],
            baseType=infixowl.OWL_NS.ObjectProperty,
            graph=expected_graph)

        concat = sensor_expected & flowrate_expected
        concat += air_expected
        concat += cooling_expected
        sfn_expected.subClassOf = [
            is_composed_of_property_expected | infixowl.only | concat
        ]

        # Check if they are similar
        self.assertTrue(compare.similar(graph, expected_graph))
Ejemplo n.º 6
0
def GenerateGraph(yaml_object, graph):
    """Utility function updates an RDF graph with the yaml content of the Abstract.yaml.

  The content of each object is similar to the following:
    DXRC:
      description: "Compressor run control on return air side (RC)."
      opt_uses:
        discharge_air_temperature_sensor
        leaving_cooling_coil_temperature_sensor
        cooling_thermal_power_capacity
      uses:
        return_air_temperature_setpoint
        return_air_temperature_sensor
        compressor_run_command
        compressor_run_status
      implements:
        CONTROL

  Updates an RDF graph with the yaml content.

  Args:
    yaml_object: the yaml content.
    graph: the global graph where the ontology is being built in RDF.

  Returns:
    a graph with the contents of the yaml file merged
  """
    # Applications Set used to avoid recreating applications again in the graph
    applications_set = set()
    # Prepare classes to be added to the graph and not in the yaml
    functionality = rdflib.URIRef(constants.HVAC_NS["Functionality"])
    entity_type = rdflib.URIRef(constants.DIGITAL_BUILDINGS_NS["EntityType"])
    field = rdflib.URIRef(constants.FIELDS_NS["Field"])
    infixowl.Class(identifier=constants.FIELDS_NS["Field"], graph=graph)
    infixowl.Class(identifier=constants.SUBFIELDS_NS["Point_type"],
                   graph=graph)
    graph, _ = rdf_helper.CreateClassInGraph(
        graph=graph,
        class_name="Functionality",
        class_description=None,
        parent_clazz=entity_type,
        entity_namespace=constants.HVAC_NS)

    graph, application_class = rdf_helper.CreateClassInGraph(
        graph=graph,
        class_name="Application",
        class_description=None,
        parent_clazz=entity_type)

    # Prepare properties to be added to the graph and not in the yaml
    uses_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["uses"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)
    uses_property_optionally = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["usesOptional"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)
    is_composed_of_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["isComposedOf"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)

    # Traverse the yaml content
    for clazz, clazz_content in yaml_object.items():
        class_name = clazz.capitalize()
        graph, clazz_object = rdf_helper.CreateClassInGraph(
            graph=graph,
            class_name=class_name,
            class_description=clazz_content.get("description"),
            parent_clazz=functionality,
            entity_namespace=constants.HVAC_NS)

        implements = clazz_content.get("implements")
        if implements is not None:
            graph, applications_set = rdf_helper.CreatesImplementsInGraph(
                graph=graph,
                implements_list=implements,
                applications_set=applications_set,
                application_class=application_class,
                class_object=clazz_object)

        uses = clazz_content.get("uses")
        if uses is not None:
            if isinstance(uses, list):
                for each_item in uses:
                    list_composition = rdf_helper.DecomposeStandardFieldName(
                        each_item)
                    graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
                        graph=graph,
                        list_composition=list_composition,
                        standard_field_name=each_item,
                        is_composed_of_property=is_composed_of_property)
                class_owl = infixowl.Class(
                    identifier=constants.HVAC_NS[class_name],
                    graph=graph,
                    subClassOf=[functionality])
                graph = rdf_helper.CreateCompositionInGraph(
                    list_standard_field_names=uses,
                    composition_operator="&",
                    composition_property=uses_property,
                    restriction=infixowl.only,
                    class_owl=class_owl,
                    graph=graph,
                    entity_namespace=constants.FIELDS_NS,
                    sub_class_of=[field])

        opt_uses = clazz_content.get("opt_uses")
        if opt_uses is not None:
            if isinstance(opt_uses, list):
                for each_item in opt_uses:
                    list_composition = rdf_helper.DecomposeStandardFieldName(
                        each_item)
                    graph = rdf_helper.CreatesStandardFieldNameCompositionInGraph(
                        graph=graph,
                        list_composition=list_composition,
                        standard_field_name=each_item,
                        is_composed_of_property=is_composed_of_property)
                class_owl = infixowl.Class(
                    identifier=constants.HVAC_NS[class_name],
                    graph=graph,
                    subClassOf=[functionality])
                graph = rdf_helper.CreateCompositionInGraph(
                    list_standard_field_names=opt_uses,
                    composition_operator="|",
                    composition_property=uses_property_optionally,
                    restriction=infixowl.some,
                    class_owl=class_owl,
                    graph=graph,
                    entity_namespace=constants.FIELDS_NS,
                    sub_class_of=[field])

    return graph
def GenerateGraph(yaml_object, graph):
    """Utility function updates an RDF graph with the yaml content.

  Updates an RDF graph with the yaml content

  Args:
    yaml_object: the yaml content.
    graph: the global graph where the ontology is being built in RDF.

  Returns:
    a graph with the contents of the yaml file merged
  """
    # Create the node to add to the Graph
    physical_location = rdflib.URIRef(
        constants.FACILITIES_NS["PhysicalLocation"])
    entity_type = rdflib.URIRef(constants.DIGITAL_BUILDINGS_NS["EntityType"])
    has_physical_location = rdflib.URIRef(
        constants.DIGITAL_BUILDINGS_NS["hasPhysicalLocation"])
    has_floor = rdflib.URIRef(constants.DIGITAL_BUILDINGS_NS["hasFloor"])
    has_room = rdflib.URIRef(constants.DIGITAL_BUILDINGS_NS["hasRoom"])

    has_room_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["hasRoom"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)

    has_floor_property = infixowl.Property(
        identifier=constants.DIGITAL_BUILDINGS_NS["hasFloor"],
        baseType=infixowl.OWL_NS.ObjectProperty,
        graph=graph)

    # Add the OWL data to the graph
    graph.add((physical_location, rdflib.RDF.type, rdflib.OWL.Class))
    graph.add((physical_location, rdflib.RDFS.subClassOf, entity_type))
    graph.add((physical_location, rdflib.RDFS.label,
               rdflib.Literal("PhysicalLocation")))
    graph.add((physical_location, rdflib.RDFS.comment,
               rdflib.Literal("The class of all physical locations")))

    # Construct the classes and the subclasses
    map_name_object = {}
    for clazz in yaml_object.keys():
        clazz_content = yaml_object.get(clazz)
        description = clazz_content.get("description")
        clazz_object = rdf_helper.CreateClassInGraph(
            graph,
            clazz.capitalize(),
            description,
            physical_location,
            entity_namespace=constants.FACILITIES_NS)
        map_name_object[clazz.capitalize()] = clazz_object

    # Construct the object properties
    graph.add(
        (has_physical_location, rdflib.RDF.type, rdflib.OWL.ObjectProperty))
    graph.add((has_physical_location, rdflib.RDF.type,
               rdflib.OWL.TransitiveProperty))
    graph.add((has_floor, rdflib.RDF.type, rdflib.OWL.ObjectProperty))
    graph.add((has_room, rdflib.RDF.type, rdflib.OWL.ObjectProperty))

    # Construct the sub object properties
    graph.add((has_floor, rdflib.RDFS.subPropertyOf, has_physical_location))
    graph.add((has_room, rdflib.RDFS.subPropertyOf, has_physical_location))

    # Link the graph together, done manually until the yaml evolves
    class_floor = infixowl.Class(identifier=constants.FACILITIES_NS["Floor"],
                                 graph=graph)
    class_room = infixowl.Class(identifier=constants.FACILITIES_NS["Room"],
                                graph=graph)
    class_building = infixowl.Class(
        identifier=constants.FACILITIES_NS["Building"], graph=graph)
    class_building.subClassOf = [
        has_floor_property | infixowl.only | class_floor
    ]
    class_floor.subClassOf = [has_room_property | infixowl.only | class_room]

    return graph