def __init__(self, filter_label=None, filter_attr_map={}): """ load an id-set of links @param filter_label: link type filter @param filter_attr_map: is a filter_key to filter_value_set map of attributes to match link properties against @return: a set of loaded link ids """ super(DBO_match_link_id_set, self).__init__() q_arr = [ 'match ()-[r{filter_label} {filter_attr}]->()', 'return id(r)' ] q = ' '.join(q_arr) q = cfmt(q, filter_label="" if not filter_label else ":" + filter_label) q = cfmt( q, filter_attr=db_util.gen_clause_attr_filter_from_filter_attr_map( filter_attr_map)) q_params = {k: v[0] for (k, v) in filter_attr_map.items() } # pass on only first value from each value set self.add_statement(q, q_params)
def __init__(self, filter_label=None, filter_attr_map={}): """ match a set of nodes by type / attr_map @param filter_label: node type filter @param filter_attr_map: is a filter_key to filter_value_set map of possible attributes to match against, eg.: { 'id':[0,1], 'color: ['red','blue'] } @return: a set of node DB id's """ super(DBO_match_node_id_set, self).__init__() q = "match (n{filter_label}) {where_clause} return id(n)" q = cfmt(q, filter_label="" if not filter_label else ":" + filter_label) q = cfmt(q, where_clause=db_util.gen_clause_where_from_filter_attr_map(filter_attr_map)) q_params = filter_attr_map self.add_statement(q, q_params)
def __init__(self, filter_label=None, filter_attr_map={}): """ load an id-set of links @param filter_label: link type filter @param filter_attr_map: is a filter_key to filter_value_set map of attributes to match link properties against @return: a set of loaded link ids """ super(DBO_match_link_id_set, self).__init__() q_arr = ['match ()-[r{filter_label} {filter_attr}]->()', 'return id(r)' ] q = ' '.join(q_arr) q = cfmt(q, filter_label="" if not filter_label else ":" + filter_label) q = cfmt(q, filter_attr=db_util.gen_clause_attr_filter_from_filter_attr_map(filter_attr_map)) q_params = {k: v[0] for (k, v) in filter_attr_map.items()} # pass on only first value from each value set self.add_statement(q, q_params)
def __init__(self, filter_label=None, filter_attr_map={}): """ match a set of nodes by type / attr_map @param filter_label: node type filter @param filter_attr_map: is a filter_key to filter_value_set map of possible attributes to match against, eg.: { 'id':[0,1], 'color: ['red','blue'] } @return: a set of node DB id's """ super(DBO_match_node_id_set, self).__init__() q = "match (n{filter_label}) {where_clause} return id(n)" q = cfmt(q, filter_label="" if not filter_label else ":" + filter_label) q = cfmt(q, where_clause=db_util.gen_clause_where_from_filter_attr_map( filter_attr_map)) q_params = filter_attr_map self.add_statement(q, q_params)