Beispiel #1
0
    def from_dict(cls, hierarchy_as_dict: Dict) -> 'Hierarchy':
        # Build the Dictionary for the edges
        edges = CaseAndSpaceInsensitiveTuplesDict({
            (edge['ParentName'], edge['ComponentName']): edge['Weight']
            for edge in hierarchy_as_dict['Edges']
        })

        return cls(name=hierarchy_as_dict['Name'],
                   dimension_name=hierarchy_as_dict['UniqueName']
                   [1:hierarchy_as_dict['UniqueName'].find("].[")],
                   elements=[
                       Element.from_dict(elem)
                       for elem in hierarchy_as_dict['Elements']
                   ],
                   element_attributes=[
                       ElementAttribute(ea['Name'], ea['Type'])
                       for ea in hierarchy_as_dict['ElementAttributes']
                   ],
                   edges=edges,
                   subsets=[
                       subset['Name']
                       for subset in hierarchy_as_dict['Subsets']
                   ],
                   structure=hierarchy_as_dict['Structure']
                   if 'Structure' in hierarchy_as_dict else None,
                   default_member=hierarchy_as_dict['DefaultMember']['Name']
                   if hierarchy_as_dict['DefaultMember'] else None)
Beispiel #2
0
 def add_element_attribute(self, name: str, attribute_type: str):
     attribute = ElementAttribute(name, attribute_type)
     if attribute not in self.element_attributes:
         self.element_attributes.append(attribute)
Beispiel #3
0
 def add_element_attribute(self, name, attribute_type):
     if name not in self.element_attributes:
         self.element_attributes.append(
             ElementAttribute(name, attribute_type))