summaryrefslogtreecommitdiff
path: root/src-py/db_controller.py
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2014-12-10 15:06:43 +0200
committerLV-426 <lv-426@taproot.org.il>2014-12-10 15:06:43 +0200
commit1391f30e366df1c14487f5c21f037258a1e219bd (patch)
tree3496af4512310b2efac79534bd71dd2f73926f4d /src-py/db_controller.py
parent3ed7eae2d984493e1b295f853780556a0d4a93e4 (diff)
DBO_rm_link_set
Diffstat (limited to 'src-py/db_controller.py')
-rw-r--r--src-py/db_controller.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/src-py/db_controller.py b/src-py/db_controller.py
index 66bc5a47..00043d04 100644
--- a/src-py/db_controller.py
+++ b/src-py/db_controller.py
@@ -130,13 +130,9 @@ class DBO_topo_diff_commit(DB_composed_op):
def __init__(self, topo_diff):
super(DBO_topo_diff_commit, self).__init__()
- # TODO rm link set
- # TODO rm node set
- assert 0 == len(topo_diff.link_set_rm), 'unsupported'
-
n_add_map = db_util.meta_attr_list_to_meta_attr_map(topo_diff.node_set_add)
l_add_map = db_util.meta_attr_list_to_meta_attr_map(topo_diff.link_set_add)
- l_rm_set = []
+ l_rm_set = topo_diff.link_set_rm
n_rm_set = topo_diff.node_set_rm
#
@@ -151,7 +147,8 @@ class DBO_topo_diff_commit(DB_composed_op):
self.add_sub_op(op)
if len(l_rm_set) > 0:
- pass
+ op = DBO_rm_link_set(l_rm_set)
+ self.add_sub_op(op)
if len(n_rm_set) > 0:
op = DBO_rm_node_set(n_rm_set)
@@ -351,6 +348,25 @@ class DBO_rm_node_set(DB_op):
]
q = ' '.join(q_arr) # TODO: use id param upon neo4j support: q_params = {'id_set': id_set}
+class DBO_rm_link_set(DB_op):
+ def __init__(self, id_set):
+ """
+ remove link set
+
+ [!] when removing as a result of node removal, use DBO_rm_node_set
+ along with rm_links=True
+ """
+ assert len(id_set) > 0, __name__ + ': empty id set'
+
+ super(DBO_rm_link_set, self).__init__()
+
+ q_arr = ['match ()-[r]->()',
+ 'where r.id in {id_set}',
+ 'delete r',
+ 'return {id_set}'
+ ]
+
+ q = ' '.join(q_arr)
q_params = {'id_set': id_set}
self.add_statement(q, q_params)