Get all the attributes for the nodes, links and groups of a network.
        Return these attributes as a dictionary, keyed on type (NODE, LINK, GROUP)
        then by ID of the node or link.
484709
def _get_all_resource_attributes(network_id, template_id=None):
    
    base_qry = db.DBSession.query(
                               ResourceAttr.id.label('id'),
                               ResourceAttr.ref_key.label('ref_key'),
                               ResourceAttr.cr_date.label('cr_date'),
                               ResourceAttr.attr_is_var.label('attr_is_var'),
                               ResourceAttr.node_id.label('node_id'),
                               ResourceAttr.link_id.label('link_id'),
                               ResourceAttr.group_id.label('group_id'),
                               ResourceAttr.network_id.label('network_id'),
                               ResourceAttr.attr_id.label('attr_id'),
                               Attr.name.label('name'),
                               Attr.dimension_id.label('dimension_id'),
                              ).filter(Attr.id==ResourceAttr.attr_id)


    all_node_attribute_qry = base_qry.join(Node).filter(Node.network_id==network_id)

    all_link_attribute_qry = base_qry.join(Link).filter(Link.network_id==network_id)

    all_group_attribute_qry = base_qry.join(ResourceGroup).filter(ResourceGroup.network_id==network_id)
    network_attribute_qry = base_qry.filter(ResourceAttr.network_id==network_id)


    #Filter the group attributes by template
    if template_id is not None:
        all_node_attribute_qry = all_node_attribute_qry.join(ResourceType).join(TemplateType).join(TypeAttr).filter(TemplateType.template_id==template_id).filter(ResourceAttr.attr_id==TypeAttr.attr_id)
        all_link_attribute_qry = all_link_attribute_qry.join(ResourceType).join(TemplateType).join(TypeAttr).filter(TemplateType.template_id==template_id).filter(ResourceAttr.attr_id==TypeAttr.attr_id)
        all_group_attribute_qry = all_group_attribute_qry.join(ResourceType).join(TemplateType).join(TypeAttr).filter(TemplateType.template_id==template_id).filter(ResourceAttr.attr_id==TypeAttr.attr_id)
        network_attribute_qry = network_attribute_qry.join(ResourceType, ResourceAttr.network_id==ResourceType.network_id).join(TemplateType).join(TypeAttr).filter(TemplateType.template_id==template_id).filter(ResourceAttr.attr_id==TypeAttr.attr_id)

    x = time.time()
    logging.info("Getting all attributes using execute")
    attribute_qry = all_node_attribute_qry.union(all_link_attribute_qry, all_group_attribute_qry, network_attribute_qry)
    all_attributes = db.DBSession.execute(attribute_qry.statement).fetchall()
    log.info("%s attrs retrieved in %s", len(all_attributes), time.time()-x)

    logging.info("Attributes retrieved. Processing results...")
    x = time.time()
    node_attr_dict = dict()
    link_attr_dict = dict()
    group_attr_dict = dict()
    network_attr_dict = dict()

    for attr in all_attributes:
        if attr.ref_key == 'NODE':
            nodeattr = node_attr_dict.get(attr.node_id, [])
            nodeattr.append(attr)
            node_attr_dict[attr.node_id] = nodeattr
        elif attr.ref_key == 'LINK':
            linkattr = link_attr_dict.get(attr.link_id, [])
            linkattr.append(attr)
            link_attr_dict[attr.link_id] = linkattr
        elif attr.ref_key == 'GROUP':
            groupattr = group_attr_dict.get(attr.group_id, [])
            groupattr.append(attr)
            group_attr_dict[attr.group_id] = groupattr
        elif attr.ref_key == 'NETWORK':
            networkattr = network_attr_dict.get(attr.network_id, [])
            networkattr.append(attr)
            network_attr_dict[attr.network_id] = networkattr

    all_attributes = {
        'NODE' : node_attr_dict,
        'LINK' : link_attr_dict,
        'GROUP': group_attr_dict,
        'NETWORK': network_attr_dict,
    }

    logging.info("Attributes processed in %s", time.time()-x)
    return all_attributes
581367
def data_nodes(self):
        

        return {k: v for k, v in self.nodes.items() if v['type'] == 'data'}
714005
def networks(self, role="all", full="all"):
        """"""
        if full not in ["all", True, False]:
            raise ValueError(
                "full must be boolean or all, it cannot be {}".format(full)
            )

        if full == "all":
            if role == "all":
                return Network.query.all()
            else:
                return Network.query.filter_by(role=role).all()
        else:
            if role == "all":
                return Network.query.filter_by(full=full).all()
            else:
                return Network.query.filter(
                    and_(Network.role == role, Network.full == full)
                ).all()
256115
def get_nodes(self, node_id=None, **kwargs):
        
        return self.get_elements(Node, elem_id=node_id, **kwargs)
948445
def get_network_extents(network_id,**kwargs):
    
    rs = db.DBSession.query(Node.x, Node.y).filter(Node.network_id==network_id).all()
    if len(rs) == 0:
        return dict(
            network_id = network_id,
            min_x=None,
            max_x=None,
            min_y=None,
            max_y=None,
        )

    # Compute min/max extent of the network.
    x = [r.x for r in rs if r.x is not None]
    if len(x) > 0:
        x_min = min(x)
        x_max = max(x)
    else:
        # Default x extent if all None values
        x_min, x_max = 0, 1

    y = [r.y for r in rs if r.y is not None]
    if len(y) > 0:
        y_min = min(y)
        y_max = max(y)
    else:
        # Default y extent if all None values
        y_min, y_max = 0, 1

    ne = JSONObject(dict(
        network_id = network_id,
        min_x=x_min,
        max_x=x_max,
        min_y=y_min,
        max_y=y_max,
    ))
    return ne
214218
def get_name_type_dict(self):
        
        attrs = self.get_attributes()
        types = self.get_types()
        d = dict()
        for i,a in enumerate(attrs):
            d[a] = types[i]

        return d
330138
def _get_links(self,):
        
        res = ''
        if self.links:
            for l in self.links:
                res += ' links = ' + str(l[0]) + '\n'
                if l[0].child_nodes:
                    for chld in l[0].child_nodes:
                        res += '   child = ' + str(chld) + '\n'
                if l[0].links:
                    for lnk in l[0].links:
                        res += '   sublink = ' + str(lnk[0]) + '\n'
        else:
            res += ' links = None\n'
            
        return res
1288460
def get_degrees(self):
        '''
        
        '''
        degree = {}
        if self.attr['type'] is not DIRECTED_GRAPH:
            for n in self.get_node_list():
                degree[n] = len(self.get_neighbors(n))
            return degree
        else:
            for n in self.get_node_list():
                degree[n] = (len(self.get_in_neighbors(n)) +
                             len(self.get_out_neighbors(n)))
1037820
def nodes(self):
        
        if not hasattr(self, '_nodes'):
            base_url = "{}/{}".format(NodeBalancerConfig.api_endpoint, NodeBalancerNode.derived_url_path)
            result = self._client._get_objects(base_url, NodeBalancerNode, model=self, parent_id=(self.id, self.nodebalancer_id))

            self._set('_nodes', result)

        return self._nodes
1259483
def get_network_attributegroup_items(network_id, **kwargs):
    

    user_id=kwargs.get('user_id')


    net_i = _get_network(network_id)

    net_i.check_read_permission(user_id)

    group_items_i = db.DBSession.query(AttrGroupItem).filter(
                                    AttrGroupItem.network_id==network_id).all()

    return group_items_i
934502
def keys(self):
		
		if hasattr(self._nodes, 'iterkeys'):
			return self._nodes.keys()
		else:
			return tuple(self._nodes.keys())
839619
def get_networks(self):
        
        networks = self.c_resources["networks"]
        result = []
        for net in networks:
            _c_network = net.get("_c_network")
            if _c_network is None:
                continue
            roles = utils.get_roles_as_list(net)
            result.append((roles, _c_network))
        return result
292229
def get_attributes(**kwargs):
    

    attrs = db.DBSession.query(Attr).order_by(Attr.name).all()

    return attrs
628056
def node_link_data(graph: BELGraph) -> Mapping[str, Any]:
    
    nodes = sorted(graph, key=methodcaller('as_bel'))

    mapping = dict(zip(nodes, count()))

    return {
        'directed': True,
        'multigraph': True,
        'graph': graph.graph.copy(),
        'nodes': [
            _augment_node(node)
            for node in nodes
        ],
        'links': [
            dict(chain(
                data.copy().items(),
                [('source', mapping[u]), ('target', mapping[v]), ('key', key)]
            ))
            for u, v, key, data in graph.edges(keys=True, data=True)
        ]
    }
374393
def getConfig(self):
        
        return {'graph': self._graphAttrDict,
                'fields': [(field_name, self._fieldAttrDict.get(field_name))
                           for field_name in self._fieldNameList]}
589862
def get_links(self, **kw):
        

        links = [a for a in dir(self) if isinstance(getattr(self, a), Model)
                 and not a.startswith('_model')]

        return [
            {
                'field': l,
                'mdl': getattr(self, l).__class__,
            } for l in links
        ]
1024763
def list_nodes():
    
    token = session.get('token')
    node = nago.core.get_node(token)
    if not node.get('access') == 'master':
        return jsonify(status='error', error="You need master access to view this page")

    nodes = nago.core.get_nodes().values()
    return render_template('nodes.html', **locals())