Example #1
0
    def validate_relationships_definitions_with_includes(
            cls, template_includes, def_templates, entities_index,
            relationships_index):

        for include in template_includes:

            name = include[TemplateFields.NAME]
            def_template = \
                evaluator_utils.find_def_template(name, def_templates)

            if def_template:
                defs = def_template[TemplateFields.DEFINITIONS]
                relationships = defs[TemplateFields.RELATIONSHIPS]

                for relationship in relationships:
                    relationship_dict = \
                        relationship[TemplateFields.RELATIONSHIP]
                    template_id = relationship_dict[TemplateFields.TEMPLATE_ID]
                    if template_id not in relationships_index:
                        result = cls._validate_def_template_relationship(
                            relationship_dict, entities_index)

                        if not result.is_valid_config:
                            return result

                        relationships_index[template_id] = relationship_dict

        return get_content_correct_result()
Example #2
0
    def _build_entities_from_def_templates(self, includes, def_templates,
                                           entities):

        for def_template_dict in includes:

            name = def_template_dict[TFields.NAME]
            def_template = evaluator_utils.find_def_template(
                name, def_templates)
            defs = def_template[TFields.DEFINITIONS]
            entities_defs = defs[TFields.ENTITIES]

            for entity_def in entities_defs:

                entity_dict = entity_def[TFields.ENTITY]
                template_id = entity_dict[TFields.TEMPLATE_ID]
                if template_id not in entities:

                    properties = self._convert_properties_with_dictionary(
                        self._extract_properties(entity_dict))
                    entities[template_id] = Vertex(template_id, properties)
Example #3
0
    def _build_relationships_with_def_templates(
            self, includes, def_templates, relationships):

        for def_template_dict in includes:

            name = def_template_dict[TFields.NAME]
            def_template = evaluator_utils.find_def_template(
                name, def_templates)

            if TFields.RELATIONSHIPS in def_template[TFields.DEFINITIONS]:
                defs = def_template[TFields.DEFINITIONS]
                relationship_defs = defs[TFields.RELATIONSHIPS]

                for relationship_def in relationship_defs:
                    relationship_dict = relationship_def[TFields.RELATIONSHIP]
                    template_id = relationship_dict[TFields.TEMPLATE_ID]

                    if template_id not in relationships:
                        relationship = self._extract_relationship_info(
                            relationship_dict)
                        relationships[template_id] = relationship
def _validate_definitions_with_includes(template_includes, def_templates,
                                        entities_index):

    for include in template_includes:

        name = include[TemplateFields.NAME]
        def_template = evaluator_utils.find_def_template(name, def_templates)

        if not def_template:

            LOG.error('%s status code: %s' % (status_msgs[142], 142))
            return get_content_fault_result(142)

        def_template_definitions = def_template[TemplateFields.DEFINITIONS]
        def_template_entities = \
            def_template_definitions[TemplateFields.ENTITIES]
        result = _validate_include_entities_definition(def_template_entities,
                                                       entities_index)

        if not result.is_valid_config:
            return result

    return get_content_correct_result()