⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.10
2.6.11
22 changes: 22 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4319,6 +4319,28 @@ def entity_bulk_update():
return jsonify(list(uuids)), 202


"""
Retrieve ids (uuid, hubmap_id) for a given id

Parameters
----------
id : str
The HuBMAP ID (e.g. HBM123.ABCD.456) or UUID of target entity (Dataset/Sample)

Returns
-------
json array
Each item in the array is a json object containing the uuid and hubmap_id for the given entity.
"""
@app.route('/entities/batch-ids', methods = ['POST'])
def get_batch_ids():
validate_token_if_auth_header_exists(request)
require_json(request)
json_data_dict = request.get_json()
ids = app_neo4j_queries.get_batch_ids(neo4j_driver_instance, json_data_dict)
return jsonify(ids)


####################################################################################################
## Internal Functions
####################################################################################################
Expand Down
33 changes: 33 additions & 0 deletions src/app_neo4j_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,3 +1181,36 @@ def get_entities_by_uuid(neo4j_driver,
return None

return records

"""
Get the uuid and hubmap_id for each entity in a list of ids.

Parameters
----------
neo4j_driver : neo4j.Driver object
The neo4j database connection pool
id_list : list
The list of ids

Returns
-------
Dictionary containing the uuid and hubmap_id of each entity in the list, keyed by that entities original id given
"""
def get_batch_ids(neo4j_driver, id_list):
query = """
MATCH (e)
WHERE e.uuid IN $id_list OR e.hubmap_id IN $id_list
WITH e, [id IN $id_list WHERE id = e.uuid OR id = e.hubmap_id][0] AS original_id
RETURN original_id, e.uuid AS uuid, e.hubmap_id AS hubmap_id
"""

result_map = {}

with neo4j_driver.session() as session:
result = session.run(query, id_list=id_list)
for record in result:
result_map[record['original_id']] = {
"uuid": record['uuid'],
"hubmap_id": record['hubmap_id']
}
return result_map