@@ -164,7 +164,7 @@ def filter_ancestors_by_type(neo4j_driver, direct_ancestor_uuids, entity_type):
164164"""
165165def get_children (neo4j_driver , uuid , property_key = None ):
166166 results = []
167-
167+ fields_to_omit = SchemaConstants . OMITTED_FIELDS
168168 if property_key :
169169 query = (f"MATCH (e:Entity)-[:ACTIVITY_INPUT]->(:Activity)-[:ACTIVITY_OUTPUT]->(child:Entity) "
170170 # The target entity can't be a Lab
@@ -178,7 +178,7 @@ def get_children(neo4j_driver, uuid, property_key = None):
178178 f"WHERE e.uuid='{ uuid } ' AND e.entity_type <> 'Lab' "
179179 # COLLECT() returns a list
180180 # apoc.coll.toSet() reruns a set containing unique nodes
181- f"RETURN apoc.coll.toSet(COLLECT(child)) AS { record_field_name } " )
181+ f"RETURN apoc.coll.toSet(COLLECT(apoc.create.vNode(labels( child), apoc.map.removeKeys(properties(child), { fields_to_omit } )) )) AS { record_field_name } " )
182182
183183 logger .info ("======get_children() query======" )
184184 logger .info (query )
@@ -193,7 +193,7 @@ def get_children(neo4j_driver, uuid, property_key = None):
193193 else :
194194 # Convert the list of nodes to a list of dicts
195195 results = nodes_to_dicts (record [record_field_name ])
196-
196+
197197 return results
198198
199199
@@ -216,7 +216,7 @@ def get_children(neo4j_driver, uuid, property_key = None):
216216"""
217217def get_parents (neo4j_driver , uuid , property_key = None ):
218218 results = []
219-
219+ fields_to_omit = SchemaConstants . OMITTED_FIELDS
220220 if property_key :
221221 query = (f"MATCH (e:Entity)<-[:ACTIVITY_OUTPUT]-(:Activity)<-[:ACTIVITY_INPUT]-(parent:Entity) "
222222 # Filter out the Lab entities
@@ -230,7 +230,7 @@ def get_parents(neo4j_driver, uuid, property_key = None):
230230 f"WHERE e.uuid='{ uuid } ' AND parent.entity_type <> 'Lab' "
231231 # COLLECT() returns a list
232232 # apoc.coll.toSet() reruns a set containing unique nodes
233- f"RETURN apoc.coll.toSet(COLLECT(parent)) AS { record_field_name } " )
233+ f"RETURN apoc.coll.toSet(COLLECT(apoc.create.vNode(labels( parent), apoc.map.removeKeys(properties(parent), { fields_to_omit } )) )) AS { record_field_name } " )
234234
235235 logger .info ("======get_parents() query======" )
236236 logger .info (query )
@@ -380,7 +380,7 @@ def get_tuplets(neo4j_driver, uuid, property_key=None):
380380"""
381381def get_ancestors (neo4j_driver , uuid , property_key = None ):
382382 results = []
383-
383+ fields_to_omit = SchemaConstants . OMITTED_FIELDS
384384 if property_key :
385385 query = (f"MATCH (e:Entity)<-[:ACTIVITY_INPUT|ACTIVITY_OUTPUT*]-(ancestor:Entity) "
386386 # Filter out the Lab entities
@@ -394,7 +394,7 @@ def get_ancestors(neo4j_driver, uuid, property_key = None):
394394 f"WHERE e.uuid='{ uuid } ' AND ancestor.entity_type <> 'Lab' "
395395 # COLLECT() returns a list
396396 # apoc.coll.toSet() reruns a set containing unique nodes
397- f"RETURN apoc.coll.toSet(COLLECT(ancestor)) AS { record_field_name } " )
397+ f"RETURN apoc.coll.toSet(COLLECT(apoc.create.vNode(labels( ancestor), apoc.map.removeKeys(properties(ancestor), { fields_to_omit } )) )) AS { record_field_name } " )
398398
399399 logger .info ("======get_ancestors() query======" )
400400 logger .info (query )
@@ -431,7 +431,7 @@ def get_ancestors(neo4j_driver, uuid, property_key = None):
431431"""
432432def get_descendants (neo4j_driver , uuid , property_key = None ):
433433 results = []
434-
434+ fields_to_omit = SchemaConstants . OMITTED_FIELDS
435435 if property_key :
436436 query = (f"MATCH (e:Entity)-[:ACTIVITY_INPUT|ACTIVITY_OUTPUT*]->(descendant:Entity) "
437437 # The target entity can't be a Lab
@@ -445,7 +445,7 @@ def get_descendants(neo4j_driver, uuid, property_key = None):
445445 f"WHERE e.uuid='{ uuid } ' AND e.entity_type <> 'Lab' "
446446 # COLLECT() returns a list
447447 # apoc.coll.toSet() reruns a set containing unique nodes
448- f"RETURN apoc.coll.toSet(COLLECT(descendant)) AS { record_field_name } " )
448+ f"RETURN apoc.coll.toSet(COLLECT(apoc.create.vNode(labels( descendant), apoc.map.removeKeys(properties(descendant), { fields_to_omit } )) )) AS { record_field_name } " )
449449
450450 logger .info ("======get_descendants() query======" )
451451 logger .info (query )
@@ -460,7 +460,7 @@ def get_descendants(neo4j_driver, uuid, property_key = None):
460460 else :
461461 # Convert the list of nodes to a list of dicts
462462 results = nodes_to_dicts (record [record_field_name ])
463-
463+
464464 return results
465465
466466
@@ -1185,7 +1185,7 @@ def get_dataset_upload(neo4j_driver, uuid):
11851185def get_collection_datasets (neo4j_driver , uuid ):
11861186 results = []
11871187
1188- fields_to_omit = SchemaConstants .DATASETS_OMITTED_FIELDS
1188+ fields_to_omit = SchemaConstants .OMITTED_FIELDS
11891189 query = (f"MATCH (e:Dataset)-[:IN_COLLECTION]->(c:Collection) "
11901190 f"WHERE c.uuid = '{ uuid } ' "
11911191 f"RETURN COLLECT(apoc.create.vNode(labels(e), apoc.map.removeKeys(properties(e), { fields_to_omit } ))) AS { record_field_name } " )
@@ -1391,7 +1391,7 @@ def unlink_datasets_from_upload(neo4j_driver, upload_uuid, dataset_uuids_list):
13911391"""
13921392def get_upload_datasets (neo4j_driver , uuid , property_key = None ):
13931393 results = []
1394- fields_to_omit = SchemaConstants .DATASETS_OMITTED_FIELDS
1394+ fields_to_omit = SchemaConstants .OMITTED_FIELDS
13951395 if property_key :
13961396 query = (f"MATCH (e:Dataset)-[:IN_UPLOAD]->(s:Upload) "
13971397 f"WHERE s.uuid = '{ uuid } ' "
0 commit comments