diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-11-09 12:09:12 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2014-11-09 12:09:12 +0200 |
| commit | 85feae0a74a97ad7bc04e13b511601e14be5f234 (patch) | |
| tree | 6ea694e11b582d061e9b5432273b87e9ad184b9d /src-py/db_controller.py | |
| parent | 223adad23867e19ba4d43e14104d40309c54280a (diff) | |
DBO_rz_clone - reconstruct links from link tuples
Diffstat (limited to 'src-py/db_controller.py')
| -rw-r--r-- | src-py/db_controller.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src-py/db_controller.py b/src-py/db_controller.py index 40038ed8..273686fd 100644 --- a/src-py/db_controller.py +++ b/src-py/db_controller.py @@ -370,7 +370,7 @@ class DBO_rz_clone(DB_op): 'order by n.id', 'skip %d' % (self.skip), 'limit %d' % (self.limit), - 'return n,collect([n.id, m.id, r])'] + 'return n,labels(n),collect([m.id, r, type(r)])'] q = ' '.join(q_arr) self.add_statement(q) @@ -380,17 +380,28 @@ class DBO_rz_clone(DB_op): ret_l_set = [] for _, _, row_set in self: for row in row_set: - itr = iter(row) - n = itr.next() + n, n_lbl_set, l_set = row.items() # see query return statement - l_set = itr.next() - for l in l_set: - assert 3 == len(l) # (n.id, m.id, r) tuples - if None == l[1]: + # reconstruct nodes + assert None != n['id'] + + n['__label_set'] = n_lbl_set + ret_n_set.append(n) + + # reconstruct links from link tuples + for l_tuple in l_set: + assert 3 == len(l_tuple) # see query return statement + + if None == l_tuple[0]: # check if link dst is None # as link matching is optional, collect may yield empty sets continue + + l = l_tuple[1] + l['__src'] = n['id'] + l['__dst'] = l_tuple[0] + l['__label_set'] = [l_tuple[2]] # box single value returned by type() + ret_l_set.append(l) - ret_n_set.append(n) return {'node_set': ret_n_set, 'link_set': ret_l_set } |
