Skip to content

Commit 034fbbf

Browse files
authored
Merge pull request #802 from hubmapconsortium/karlburke/CorrectProvMetadataEndpoint
Fix for prov-metadata generation to filter entity exclusions regardle…
2 parents c0dd0f1 + 253bfcf commit 034fbbf

File tree

1 file changed

+32
-35
lines changed

1 file changed

+32
-35
lines changed

src/app.py

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -699,30 +699,30 @@ def get_provenance_metadata_by_id_for_auth_level(id):
699699
# Identify fields to exclude from non-authorized responses for the entity type.
700700
fields_to_exclude = schema_manager.get_fields_to_exclude(normalized_entity_type)
701701

702-
# Response with the dict
703-
if public_entity and not user_authorized:
704-
final_result = schema_manager.exclude_properties_from_response(fields_to_exclude, final_result)
702+
# Remove fields which do not belong in provenance metadata, regardless of
703+
# entity scope or user authorization.
704+
final_result = schema_manager.exclude_properties_from_response(fields_to_exclude, final_result)
705705

706706
# Retrieve the associated data for the entity, and add it to the expanded dictionary.
707-
associated_organ_list = _get_dataset_associated_data( dataset_dict=final_result
708-
, dataset_visibility=entity_scope
709-
, valid_user_token=user_token
710-
, request=request
711-
, associated_data='Organs')
707+
associated_organ_list = _get_dataset_associated_metadata( dataset_dict=final_result
708+
, dataset_visibility=entity_scope
709+
, valid_user_token=user_token
710+
, request=request
711+
, associated_data='Organs')
712712
final_result['organs'] = associated_organ_list
713713

714-
associated_sample_list = _get_dataset_associated_data( dataset_dict=final_result
715-
, dataset_visibility=entity_scope
716-
, valid_user_token=user_token
717-
, request=request
718-
, associated_data='Samples')
714+
associated_sample_list = _get_dataset_associated_metadata( dataset_dict=final_result
715+
, dataset_visibility=entity_scope
716+
, valid_user_token=user_token
717+
, request=request
718+
, associated_data='Samples')
719719
final_result['samples'] = associated_sample_list
720720

721-
associated_donor_list = _get_dataset_associated_data( dataset_dict=final_result
722-
, dataset_visibility=entity_scope
723-
, valid_user_token=user_token
724-
, request=request
725-
, associated_data='Donors')
721+
associated_donor_list = _get_dataset_associated_metadata( dataset_dict=final_result
722+
, dataset_visibility=entity_scope
723+
, valid_user_token=user_token
724+
, request=request
725+
, associated_data='Donors')
726726

727727
final_result['donors'] = associated_donor_list
728728

@@ -5019,12 +5019,9 @@ def _get_entity_visibility(normalized_entity_type, entity_dict):
50195019
return entity_visibility
50205020

50215021

5022-
"""
5023-
Retrieve the metadata information for certain data associated with entity. This method supports
5024-
Dataset entities, and can get the associated data for organs, samples, or donors.
5025-
5026-
Get associated data dict based upon the user's authorization. The associated data may be
5027-
filtered down if credentials were not presented for full access.
5022+
'''
5023+
Retrieve the organ, donor, or sample metadata information associated with a Dataset, based
5024+
up the user's authorization to access the Dataset.
50285025
50295026
Parameters
50305027
----------
@@ -5044,9 +5041,9 @@ def _get_entity_visibility(normalized_entity_type, entity_dict):
50445041
Returns
50455042
-------
50465043
list
5047-
A dictionary containing all the properties the target entity.
5048-
"""
5049-
def _get_dataset_associated_data(dataset_dict, dataset_visibility, valid_user_token, request, associated_data: str):
5044+
A dictionary containing the metadata properties the Dataset associated data.
5045+
'''
5046+
def _get_dataset_associated_metadata(dataset_dict, dataset_visibility, valid_user_token, request, associated_data: str):
50505047

50515048
# Confirm the associated data requested is supported by this method.
50525049
retrievable_associations = ['organs', 'samples', 'donors']
@@ -5115,17 +5112,17 @@ def _get_dataset_associated_data(dataset_dict, dataset_visibility, valid_user_to
51155112

51165113
# For public entities, limit the fields in the response unless the authorization presented in the
51175114
# Request allows the user to see all properties.
5118-
if public_entity and not user_authorized:
5119-
filtered_entities_list = []
5120-
for entity in final_result:
5121-
final_entity_dict = schema_manager.exclude_properties_from_response(excluded_fields=fields_to_exclude
5122-
, output_dict=entity)
5123-
filtered_entities_list.append(final_entity_dict)
5124-
final_result = filtered_entities_list
5115+
# Remove fields which do not belong in provenance metadata, regardless of
5116+
# entity scope or user authorization.
5117+
filtered_entities_list = []
5118+
for entity in final_result:
5119+
final_entity_dict = schema_manager.exclude_properties_from_response(excluded_fields=fields_to_exclude
5120+
, output_dict=entity)
5121+
filtered_entities_list.append(final_entity_dict)
5122+
final_result = filtered_entities_list
51255123

51265124
return final_result
51275125

5128-
51295126
"""
51305127
Generate 'before_create_triiger' data and create the entity details in Neo4j
51315128

0 commit comments

Comments
 (0)