summaryrefslogtreecommitdiff
path: root/src-py
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2014-10-20 19:30:34 +0200
committerLV-426 <lv-426@taproot.org.il>2014-10-20 19:30:34 +0200
commitf821ead8d1697702917817ce916e50f1c9e0cc3c (patch)
tree70c2187d848dc7f5449354b3fb5ad64a37f92a9d /src-py
parent00321278f858ec36fa4c799363bbcc508164f13c (diff)
DBO_match_node_id_set query generation
Diffstat (limited to 'src-py')
-rw-r--r--src-py/db_controller.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/src-py/db_controller.py b/src-py/db_controller.py
index 0ef70f3b..875eb0bc 100644
--- a/src-py/db_controller.py
+++ b/src-py/db_controller.py
@@ -234,22 +234,23 @@ class DBO_load_node_set_by_DB_id(DB_op):
class DBO_match_node_id_set(DB_op):
- def __init__(self, filter_type=None, filter_attr_map=None):
+ def __init__(self, filter_type=None, filter_attr_map={}):
"""
- load a set of nodes according to filter_attr_map
+ match a set of nodes by type / attr_map
+ @param filter_type: node type filter
@param filter_attr_map: is a filter_key to filter_value_set map of
- attributes to match against, eg.:
+ possible attributes to match against, eg.:
{ 'id':[0,1], 'color: ['red','blue'] }
- @param filter_type: node type filter
- @return: loaded node set or an empty set if no match was found
+ @return: a set of node DB id's
"""
+ super(DBO_match_node_id_set, self).__init__()
- filter_str = dbu.where_clause_from_filter_attr_map()
+ q = "match (n{filter_type}) {where_clause} return id(n)"
+ q = cfmt(q, filter_type="" if not filter_type else ":" + filter_type)
+ q = cfmt(q, where_clause=db_util.gen_clause_where_from_filter_attr_map(filter_attr_map))
- super(DBO_load_node_set, self).__init__()
- q = "match (n) {0} return n".format(filter_str)
- self.add_statement(q, params=filter_attr_map)
+ q_params = filter_attr_map
self.add_statement(q, q_params)