diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-09-28 14:31:25 +0300 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2014-09-28 14:31:25 +0300 |
| commit | f93e7846097e73d5f021594af16264fe7ebdf9d0 (patch) | |
| tree | 62e4a83f8673ed5dc9436e72c11143ef01792082 /src-py/db_controller.py | |
| parent | dd1966972b41e7fd3492f8db07b286647f39b02d (diff) | |
DBO_load_node_set_by_DB_id & test
Diffstat (limited to 'src-py/db_controller.py')
| -rw-r--r-- | src-py/db_controller.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src-py/db_controller.py b/src-py/db_controller.py index c9305fb9..a6f738bd 100644 --- a/src-py/db_controller.py +++ b/src-py/db_controller.py @@ -93,7 +93,6 @@ class DBO_add_node_set(DB_op): @param node_map: node-type to node list map @input_to_DB_property_map: optional function which takes a map of input properties and returns a map of DB properties - use to map input schemas to DB schemas - """ super(DBO_add_node_set, self).__init__() self.node_map = node_map @@ -152,6 +151,21 @@ class DBO_load_node_id_set(DB_op): log.debug('loaded node id set: ' + str(id_set)) return id_set +class DBO_load_node_set_by_DB_id(DB_op): + def __init__(self, id_set): + """ + load a set of nodes whose DB id is in id_set + + @return: loaded node set or an empty set if no match was found + """ + super(DBO_load_node_set_by_DB_id, self).__init__() + q = "match (n) where id(n) in {id_set} return n" + self.add_statement(q, { 'id_set': id_set}) + + def on_success(self, data): + log.debug('loaded node set: ' + str(data)) + return self.parse_single_query_response_data(self.statement_set[0], data) + class DBO_load_node_set_by_attribute(DB_op): def __init__(self, attr_name, attr_set): @@ -161,8 +175,8 @@ class DBO_load_node_set_by_attribute(DB_op): @return: loaded node set or an empty set if no match was found """ super(DBO_load_node_set_by_attribute, self).__init__() - q = "match (n) where n.{0} in {{attr_list}} return n".format(attr_name) - self.add_statement(q, { 'attr_list': attr_set}) + q = "match (n) where n.{0} in {{attr_set}} return n".format(attr_name) + self.add_statement(q, { 'attr_set': attr_set}) def on_success(self, data): log.debug('loaded node set: ' + str(data)) @@ -213,4 +227,6 @@ class DB_Controller: """ @deprecated: use transaction based api """ - self.post_neo4j('/db/data/cypher', {"query" : q}) + + # call post and not dbu.post_neo4j to avoid response key errors + dbu.post(self.config.db_base_url + '/db/data/cypher', {"query" : q}) |
