Skip to content

Commit

Permalink
retuen all containers if no query is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledk2 committed Nov 27, 2024
1 parent baddc02 commit 30d89d0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
20 changes: 20 additions & 0 deletions omero_search_engine/api/v1/resources/resource_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,3 +1051,23 @@ def get_resource_keys(resource, data_source):
json.loads(resource_keys_template.substitute(data_source=data_source)),
)
return res["aggregations"]["value_search"]["required_name"]["buckets"]


def get_containets_from_name(container_name=None, returned_data_source=None):
act_names =[]# {}
pr_names = get_resource_names("all")
for resourse, names_ in pr_names.items():
if len(names_)>0:
print (names_.keys())

for data_source, names in names_.items():
act_names.append( [
{"id": name["id"], "name": name["name"], "data_source":data_source, "image count":name["no_images"], "type":resourse}
for name in names
if not container_name or(name.get("name") and container_name.lower() in name.get("name").lower()) and (not returned_data_source or returned_data_source==data_source)
])
return act_names

def return_containes_images():
data = get_containets_from_name()
return {"Error": None, "results": {"results":data}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ A searchengine endpoint to accept complex query but it will return the container
API endpoint to search the annotation (key/value pair), the main difference between this endpoint and searchannotation is this one can be used to search different resources and return the container (screen or project) which includes the images which satisfy the search conditions.
The container can be used as a resource instead of a project or screen if the user is not sure about the container type.
The query data has a similar format to the query for searchannotation.
If no query is provided, it will return all the available containers.
Example:

{
Expand Down Expand Up @@ -60,7 +61,7 @@ parameters:
required: false
- name: data
in: body
required: true
required: false
#examples:
- name: data_source
in: query
Expand Down
20 changes: 13 additions & 7 deletions omero_search_engine/api/v1/resources/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
get_resource_names,
get_key_values_return_contents,
query_cashed_bucket_part_value_keys,
return_containes_images,
)
from omero_search_engine.api.v1.resources.utils import get_resource_annotation_table
from omero_search_engine.api.v1.resources.query_handler import (
Expand Down Expand Up @@ -363,8 +364,10 @@ def submit_query_return_containers():
except Exception:
query = None
if not query:
return jsonify(build_error_message("No query is provided"))
adjust_query_for_container(query)
query={}
#return jsonify(build_error_message("No query is provided"))
if len(query)>0:
adjust_query_for_container(query)
return_columns = request.args.get("return_columns")
data_source = request.args.get("data_source")
if data_source:
Expand All @@ -374,18 +377,21 @@ def submit_query_return_containers():
return_columns = json.loads(return_columns.lower())
except Exception:
return_columns = False
validation_results = query_validator(query)
if validation_results == "OK":
return jsonify(
determine_search_results_(
if len(query)>0:
validation_results = query_validator(query)
if validation_results == "OK":
return jsonify(
determine_search_results_(
query,
data_source=data_source,
return_columns=return_columns,
return_containers=True,
)
)
else:
return jsonify(build_error_message(validation_results))
else:
return jsonify(build_error_message(validation_results))
return jsonify(return_containes_images())


@resources.route("/submitquery/", methods=["POST"])
Expand Down

0 comments on commit 30d89d0

Please sign in to comment.