xtuml/load.py
def populate_connections(self, metamodel):
        '''
        Populate links in a *metamodel* with connections between them.
        '''
        storage = dict()
        for ass in metamodel.associations:
            source_class = ass.source_link.to_metaclass
            target_class = ass.target_link.to_metaclass

            if target_class not in storage:
                storage[target_class] = dict()
            
            link_key = frozenset(ass.source_link.key_map.values())
            if link_key not in storage[target_class]:
                storage[target_class][link_key] = dict()
                for other_inst in target_class.storage:
                    inst_key = ass.source_link.compute_index_key(other_inst)
                    if inst_key is None:
                        continue
                    
                    if inst_key not in storage[target_class][link_key]:
                        storage[target_class][link_key][inst_key] = xtuml.OrderedSet()

                    storage[target_class][link_key][inst_key].add(other_inst)

            for inst in source_class.storage:
                inst_key = ass.source_link.compute_lookup_key(inst)
                if inst_key is None:
                    continue
                
                if inst_key not in storage[target_class][link_key]:
                    continue
                
                for other_inst in storage[target_class][link_key][inst_key]:
                    ass.source_link.connect(other_inst, inst, check=False)
                    ass.target_link.connect(inst, other_inst, check=False)

        for inst in metamodel.instances:
            metaclass = xtuml.get_metaclass(inst)
            for attr in metaclass.referential_attributes:
                if attr in inst.__dict__:
                    delattr(inst, attr)
def populate_connections(self, metamodel):
        '''
        Populate links in a *metamodel* with connections between them.
        '''
        storage = dict()
        for ass in metamodel.associations:
            source_class = ass.source_link.to_metaclass
            target_class = ass.target_link.to_metaclass

            if target_class not in storage:
                storage[target_class] = dict()
            
            link_key = frozenset(ass.source_link.key_map.values())
            if link_key not in storage[target_class]:
                storage[target_class][link_key] = dict()
                for other_inst in target_class.storage:
                    inst_key = ass.source_link.compute_index_key(other_inst)
                    if inst_key is None:
                        continue
                    
                    if inst_key not in storage[target_class][link_key]:
                        storage[target_class][link_key][inst_key] = xtuml.OrderedSet()

                    storage[target_class][link_key][inst_key].add(other_inst)

            for inst in source_class.storage:
                inst_key = ass.source_link.compute_lookup_key(inst)
                if inst_key is None:
                    continue
                
                if inst_key not in storage[target_class][link_key]:
                    continue
                
                for other_inst in storage[target_class][link_key][inst_key]:
                    ass.source_link.connect(other_inst, inst, check=False)
                    ass.target_link.connect(inst, other_inst, check=False)

        for inst in metamodel.instances:
            metaclass = xtuml.get_metaclass(inst)
            for attr in metaclass.referential_attributes:
                if attr in inst.__dict__:
                    delattr(inst, attr)
def populate_connections ( self , metamodel ) : storage = dict ( ) for ass in metamodel . associations : source_class = ass . source_link . to_metaclass target_class = ass . target_link . to_metaclass if target_class not in storage : storage [ target_class ] = dict ( ) link_key = frozenset ( ass . source_link . key_map . values ( ) ) if link_key not in storage [ target_class ] : storage [ target_class ] [ link_key ] = dict ( ) for other_inst in target_class . storage : inst_key = ass . source_link . compute_index_key ( other_inst ) if inst_key is None : continue if inst_key not in storage [ target_class ] [ link_key ] : storage [ target_class ] [ link_key ] [ inst_key ] = xtuml . OrderedSet ( ) storage [ target_class ] [ link_key ] [ inst_key ] . add ( other_inst ) for inst in source_class . storage : inst_key = ass . source_link . compute_lookup_key ( inst ) if inst_key is None : continue if inst_key not in storage [ target_class ] [ link_key ] : continue for other_inst in storage [ target_class ] [ link_key ] [ inst_key ] : ass . source_link . connect ( other_inst , inst , check = False ) ass . target_link . connect ( inst , other_inst , check = False ) for inst in metamodel . instances : metaclass = xtuml . get_metaclass ( inst ) for attr in metaclass . referential_attributes : if attr in inst . __dict__ : delattr ( inst , attr )
Populate links in a *metamodel* with connections between them.
Populate links in a * metamodel * with connections between them .