Skip to content
Open
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
4 changes: 4 additions & 0 deletions idr_gallery/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
re_path(r'^gallery-api/thumbnails/$', views.api_thumbnails,
name='idr_gallery_api_thumbnails'),

# Find annotations by namespace ?ns=idr.gallery.etc
path("gallery_api/annotations/", views.api_annotations,
name='idr_gallery_annotations'),

# handle mapr URLs and redirect to search e.g. /mapr/gene/?value=PAX7
# First URL is matched by mapr itself, so not used while mapr istalled...
# we want a regex that matches mapr_key but not favicon
Expand Down
35 changes: 34 additions & 1 deletion idr_gallery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from omeroweb.webclient.decorators import login_required, render_response
from omeroweb.api.decorators import login_required as api_login_required
from omeroweb.api.api_settings import API_MAX_LIMIT
from omeroweb.webclient.tree import marshal_annotations
from omeroweb.webclient.tree import marshal_annotations, _marshal_annotation

import requests

Expand Down Expand Up @@ -519,6 +519,39 @@ def api_thumbnails(request, conn=None, **kwargs):
return rv


@render_response()
@api_login_required() # 403 JsonResponse if not logged in
def api_annotations(request, conn=None, **kwargs):
"""
Return annotations for a given namespace e.g.
?ns=idr.gallery.etc
"""
ns = request.GET.get("ns")
if not ns:
return HttpResponseBadRequest("Missing 'ns' query parameter")
dtypes = request.GET.getlist("type")
if len(dtypes) == 0:
return HttpResponseBadRequest("Missing e.g. ?type=project")

query_service = conn.getQueryService()
params = omero.sys.ParametersI()
params.addString("ns", ns)
anns = []
for dtype in dtypes:
query = """select oal from %sAnnotationLink as oal
join fetch oal.details.creationEvent
join fetch oal.details.owner
left outer join fetch oal.child as ch
left outer join fetch oal.parent as pa
join fetch ch.details.creationEvent
where ch.ns = :ns""" % dtype.capitalize()
result = query_service.findAllByQuery(query, params, conn.SERVICE_OPTS)
for link in result:
if link.child is not None and link.parent is not None:
anns.append(_marshal_annotation(conn, link.child, link))
return {"annotations": anns}


def get_bff_url(request, data_url, fname, ext="csv"):
"""
We build config into query params for the BFF app
Expand Down
Loading