Skip to content

Commit

Permalink
add endpoint to return data_sources and develope to search by data so…
Browse files Browse the repository at this point in the history
…urce
  • Loading branch information
khaledk2 committed Aug 16, 2024
1 parent aa40427 commit 71b8a0d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions omero_search_engine/api/v1/resources/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
search_resource_annotation,
build_error_message,
adjust_query_for_container,
get_data_sources
)
from omero_search_engine.api.v1.resources.resource_analyser import (
search_value_for_resource,
Expand All @@ -45,6 +46,12 @@
def index():
return "OMERO search engine (API V1)"

@resources.route("/data_resources/", methods=["GET"])
def return_data_resources():
"""
used to return the available data resources
"""
return jsonify(get_data_sources())

@resources.route("/<resource_table>/searchannotation_page/", methods=["POST"])
def search_resource_page(resource_table):
Expand Down
23 changes: 23 additions & 0 deletions omero_search_engine/api/v1/resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ def search_resource_annotation(
bookmark=None,
pagination_dict=None,
return_containers=False,
data_source=None
):
"""
@table_: the resource table, e.g. image. project, etc.
Expand Down Expand Up @@ -1106,6 +1107,22 @@ def search_resource_annotation(
return build_error_message(
"{query} is not a valid query".format(query=query)
)
if data_source and data_source.lower()!= "all" :
clause={}
clause["name"]="data_source"
clause["value"]=data_source
clause["operator"]="equals"
#'resource': 'image'

if main_attributes and len(main_attributes) > 0:
if main_attributes.get("and_main_attributes"):
main_attributes.get("and_main_attributes").append(clause)
else:
main_attributes["and_main_attributes"]=[clause]
else:
main_attributes={}
main_attributes["and_main_attributes"] = [clause]

and_filters = query_details.get("and_filters")
or_filters = query_details.get("or_filters")
case_sensitive = query_details.get("case_sensitive")
Expand Down Expand Up @@ -1254,3 +1271,9 @@ def adjust_query_for_container(query):

for filter in new_or_filters:
or_filters.append(filter)

def get_data_sources():
data_sources=[]
for data_source in search_omero_app.config.database_connectors.keys():
data_sources.append(data_source)
return data_sources

0 comments on commit 71b8a0d

Please sign in to comment.