@@ -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
@@ -193,7 +193,10 @@ 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+ if fields_to_omit :
197+ for node_dict in results :
198+ for field in fields_to_omit :
199+ node_dict .pop (field , None )
197200 return results
198201
199202
@@ -216,7 +219,7 @@ def get_children(neo4j_driver, uuid, property_key = None):
216219"""
217220def get_parents (neo4j_driver , uuid , property_key = None ):
218221 results = []
219-
222+ fields_to_omit = SchemaConstants . OMITTED_FIELDS
220223 if property_key :
221224 query = (f"MATCH (e:Entity)<-[:ACTIVITY_OUTPUT]-(:Activity)<-[:ACTIVITY_INPUT]-(parent:Entity) "
222225 # Filter out the Lab entities
@@ -245,6 +248,10 @@ def get_parents(neo4j_driver, uuid, property_key = None):
245248 else :
246249 # Convert the list of nodes to a list of dicts
247250 results = nodes_to_dicts (record [record_field_name ])
251+ if fields_to_omit :
252+ for node_dict in results :
253+ for field in fields_to_omit :
254+ node_dict .pop (field , None )
248255
249256 return results
250257
@@ -380,7 +387,7 @@ def get_tuplets(neo4j_driver, uuid, property_key=None):
380387"""
381388def get_ancestors (neo4j_driver , uuid , property_key = None ):
382389 results = []
383-
390+ fields_to_omit = SchemaConstants . OMITTED_FIELDS
384391 if property_key :
385392 query = (f"MATCH (e:Entity)<-[:ACTIVITY_INPUT|ACTIVITY_OUTPUT*]-(ancestor:Entity) "
386393 # Filter out the Lab entities
@@ -410,6 +417,11 @@ def get_ancestors(neo4j_driver, uuid, property_key = None):
410417 # Convert the list of nodes to a list of dicts
411418 results = nodes_to_dicts (record [record_field_name ])
412419
420+ if fields_to_omit :
421+ for node_dict in results :
422+ for field in fields_to_omit :
423+ node_dict .pop (field , None )
424+
413425 return results
414426
415427"""
@@ -431,7 +443,7 @@ def get_ancestors(neo4j_driver, uuid, property_key = None):
431443"""
432444def get_descendants (neo4j_driver , uuid , property_key = None ):
433445 results = []
434-
446+ fields_to_omit = SchemaConstants . OMITTED_FIELDS
435447 if property_key :
436448 query = (f"MATCH (e:Entity)-[:ACTIVITY_INPUT|ACTIVITY_OUTPUT*]->(descendant:Entity) "
437449 # The target entity can't be a Lab
@@ -460,7 +472,10 @@ def get_descendants(neo4j_driver, uuid, property_key = None):
460472 else :
461473 # Convert the list of nodes to a list of dicts
462474 results = nodes_to_dicts (record [record_field_name ])
463-
475+ if fields_to_omit :
476+ for node_dict in results :
477+ for field in fields_to_omit :
478+ node_dict .pop (field , None )
464479 return results
465480
466481
@@ -1185,7 +1200,7 @@ def get_dataset_upload(neo4j_driver, uuid):
11851200def get_collection_datasets (neo4j_driver , uuid ):
11861201 results = []
11871202
1188- fields_to_omit = SchemaConstants .DATASETS_OMITTED_FIELDS
1203+ fields_to_omit = SchemaConstants .OMITTED_FIELDS
11891204 query = (f"MATCH (e:Dataset)-[:IN_COLLECTION]->(c:Collection) "
11901205 f"WHERE c.uuid = '{ uuid } ' "
11911206 f"RETURN COLLECT(apoc.create.vNode(labels(e), apoc.map.removeKeys(properties(e), { fields_to_omit } ))) AS { record_field_name } " )
@@ -1391,7 +1406,7 @@ def unlink_datasets_from_upload(neo4j_driver, upload_uuid, dataset_uuids_list):
13911406"""
13921407def get_upload_datasets (neo4j_driver , uuid , property_key = None ):
13931408 results = []
1394- fields_to_omit = SchemaConstants .DATASETS_OMITTED_FIELDS
1409+ fields_to_omit = SchemaConstants .OMITTED_FIELDS
13951410 if property_key :
13961411 query = (f"MATCH (e:Dataset)-[:IN_UPLOAD]->(s:Upload) "
13971412 f"WHERE s.uuid = '{ uuid } ' "
0 commit comments