Commit 786ba61e authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Include dataset responses correctly implemented

parent 567410a9
......@@ -31,6 +31,22 @@ class Beacon(object):
info_for_user = self.datasources_manager.update_authorization_info(info, user_groups)
return info_for_user
def handle_include_dataset_responses(self, response: List[dict], responses, flag: str):
flag = flag.upper()
if len(flag) == 0 or flag == "NONE":
return
if flag != "HIT" and flag != "MISS" and flag != "ALL":
return
response['datasetAlleleResponses'] = []
for r in responses:
exists = bool(r[1])
if flag == "ALL" or (flag == "MISS" and not exists) or (flag == "HIT" and exists):
allele_response = create_beacon_dataset_allele_response_ok(datasetId=r[0], exists=exists)
response['datasetAlleleResponses'].append(allele_response)
def dispatch_query(self, query: dict, user_groups: List[str]):
dataset_ids = query.get('datasetIds', [])
beacon_id = self.settings.get_beacon_information().get('id')
......@@ -61,12 +77,10 @@ class Beacon(object):
alleleRequest=query
)
should_include_dataset_responses = query.get('includeDatasetResponses', "")
if len(should_include_dataset_responses) and should_include_dataset_responses != "NONE":
response['datasetAlleleResponses'] = []
for r in responses:
allele_response = create_beacon_dataset_allele_response_ok(datasetId=r[0], exists=bool(r[1]))
response['datasetAlleleResponses'].append(allele_response)
self.handle_include_dataset_responses(response,
responses,
query.get('includeDatasetResponses', ""))
except (NotImplementedError, Exception) as error:
response = create_beacon_allele_response_error(
beaconId=beacon_id,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment