def _get_top(proj_ctx: 'ProjectionContext',
                 attr_name: str) -> List['ProjectionAttributeState']:
        """Get top node of the projection state tree for non-polymorphic scenarios"""
        result = SearchResult()
        for top in proj_ctx._current_attribute_state_set._values:
            st = SearchStructure()
            st = SearchStructure._build_structure(top, top, attr_name, st,
                                                  False, 0)
            if st and st._result.found_flag == True:
                result = st._result

        return result.top if result else None
Esempio n. 2
0
    def _get_leaf_list(proj_ctx: 'ProjectionContext',
                       attr_name: str) -> List['ProjectionAttributeState']:
        """Get leaf nodes of the projection state tree for polymorphic scenarios"""
        result = None

        for top in proj_ctx._current_attribute_state_set._states:
            st = SearchStructure()
            st = SearchStructure._build_structure(top, top, attr_name, st,
                                                  False, 0)
            if st and st._result.found_flag == True and len(
                    st._result.leaf) > 0:
                result = st._result

        return result.leaf if result else None
    def _search_tree_traversal(self, pc: 'ProjectionContext', val: str) -> str:
        result = SearchResult()
        for top in pc._current_attribute_state_set._states:
            st = SearchStructure()
            st = SearchStructure._build_structure(top, top, val, st, False, 0)
            if st:
                if st._result.found_flag == True:
                    if result.found_flag == False:
                        result = st._result
                    elif result.found_depth > st._result.found_depth:
                        result = st._result
                    elif result.found_depth == st._result.found_depth:
                        for new_tops in st._result.top:
                            result.top.append(new_tops)

        return self._get_result(val, result) if result.found_flag else ''
Esempio n. 4
0
    def _get_top_list(proj_ctx: 'ProjectionContext',
                      attr_names: List[str]) -> Dict[str, str]:
        """Gets the names of the top-level nodes in the projection state tree (for non-polymorphic scenarios) that match a set of attribute names """
        # This dictionary contains a mapping from the top-level name of an attribute
        # to the attribute name the top-level name was derived from (the name contained in the given list)
        top_level_attribute_names = {}

        # Iterate through each attribute name in the list and search for their top-level names
        for attr_name in attr_names:
            # Iterate through each projection attribute state in the current set and check if its
            # current resolved attribute's name is the top-level name of the current attrName
            for top in proj_ctx._current_attribute_state_set._states:
                st = SearchStructure()
                st = SearchStructure._build_structure(top, top, attr_name, st,
                                                      False, 0)
                # Found the top-level name
                if st and st._result.found_flag:
                    # Create a mapping from the top-level name of the attribute to the name it has in the list
                    top_level_attribute_names[top._current_resolved_attribute.
                                              resolved_name] = attr_name

        return top_level_attribute_names