def marshal_projects(conn, mapann_value, query=False, mapann_ns=[], mapann_names=[], group_id=-1, experimenter_id=-1, page=1, limit=settings.PAGE): ''' Marshals projects @param conn OMERO gateway. @type conn L{omero.gateway.BlitzGateway} @param mapann_ns The Map annotation namespace to filter by. @type mapann_ns L{string} @param mapann_names The Map annotation names to filter by. @type mapann_names L{string} @param mapann_value The Map annotation value to filter by. @type mapann_value L{string} @param query Flag allowing to search for value patters. @type query L{boolean} @param group_id The Group ID to filter by or -1 for all groups, defaults to -1 @type group_id L{long} @param experimenter_id The Experimenter (user) ID to filter by or -1 for all experimenters @type experimenter_id L{long} @param page Page number of results to get. `None` or 0 for no paging defaults to 1 @type page L{long} @param limit The limit of results per page to get defaults to the value set in settings.PAGE @type page L{long} ''' projects = [] params, where_clause = _set_parameters(mapann_ns=mapann_ns, mapann_names=mapann_names, query=query, mapann_value=mapann_value, params=None, experimenter_id=experimenter_id, page=page, limit=limit) service_opts = deepcopy(conn.SERVICE_OPTS) # Set the desired group context if group_id is None: group_id = -1 service_opts.setOmeroGroup(group_id) qs = conn.getQueryService() q = """ select new map(mv.value as value, project.id as id, project.name as name, project.details.owner.id as ownerId, project as project_details_permissions, count(distinct dataset.id) as childCount, count(distinct i.id) as imgCount) from ImageAnnotationLink ial join ial.child a join a.mapValue mv join ial.parent i join i.datasetLinks dil join dil.parent dataset join dataset.projectLinks pl join pl.parent project where %s group by project.id, project.name, mv.value order by lower(project.name), project.id """ % (" and ".join(where_clause)) logger.debug("HQL QUERY: %s\nPARAMS: %r" % (q, params)) for e in qs.projection(q, params, service_opts): e = unwrap(e) v = e[0]['value'] c = e[0]['imgCount'] e = [ e[0]['id'], "%s (%d)" % (e[0]["name"], c), e[0]['ownerId'], e[0]['project_details_permissions'], e[0]['childCount'] ] ms = _marshal_screen(conn, e[0:5]) extra = {'extra': {'counter': c}} if mapann_value is not None: extra['extra']['value'] = v ms.update(extra) projects.append(ms) return projects
def marshal_screens(conn, mapann_value, query=False, mapann_ns=[], mapann_names=[], group_id=-1, experimenter_id=-1, page=1, limit=settings.PAGE): ''' Marshals screens @param conn OMERO gateway. @type conn L{omero.gateway.BlitzGateway} @param mapann_ns The Map annotation namespace to filter by. @type mapann_ns L{string} @param mapann_names The Map annotation names to filter by. @type mapann_names L{string} @param mapann_value The Map annotation value to filter by. @type mapann_value L{string} @param query Flag allowing to search for value patters. @type query L{boolean} @param group_id The Group ID to filter by or -1 for all groups, defaults to -1 @type group_id L{long} @param experimenter_id The Experimenter (user) ID to filter by or -1 for all experimenters @type experimenter_id L{long} @param page Page number of results to get. `None` or 0 for no paging defaults to 1 @type page L{long} @param limit The limit of results per page to get defaults to the value set in settings.PAGE @type page L{long} ''' screens = [] params, where_clause = _set_parameters(mapann_ns=mapann_ns, mapann_names=mapann_names, query=query, mapann_value=mapann_value, params=None, experimenter_id=experimenter_id, page=page, limit=limit) service_opts = deepcopy(conn.SERVICE_OPTS) # Set the desired group context if group_id is None: group_id = -1 service_opts.setOmeroGroup(group_id) # TODO: Joining wellsample should be enough since wells are annotated # with the same annotations as images. In the future if that changes, # query has to be restored to: # - count(distinct i.id) as imgCount) # - from ImageAnnotationLink ial join ial.child a join a.mapValue mv # - join ial.parent i join i.wellSamples ws join ws.well w # - join w.plate pl join pl.screenLinks sl join sl.parent screen qs = conn.getQueryService() q = """ select new map(mv.value as value, screen.id as id, screen.name as name, screen.details.owner.id as ownerId, screen as screen_details_permissions, count(distinct pl.id) as childCount, count(distinct ws.id) as imgCount) from WellAnnotationLink wal join wal.child a join a.mapValue mv join wal.parent w join w.wellSamples ws join w.plate pl join pl.screenLinks sl join sl.parent screen where %s group by screen.id, screen.name, mv.value order by lower(screen.name), screen.id """ % (" and ".join(where_clause)) logger.debug("HQL QUERY: %s\nPARAMS: %r" % (q, params)) for e in qs.projection(q, params, service_opts): e = unwrap(e) v = e[0]['value'] c = e[0]['imgCount'] e = [ e[0]['id'], "%s (%d)" % (e[0]['name'], c), e[0]['ownerId'], e[0]['screen_details_permissions'], e[0]['childCount'] ] ms = _marshal_screen(conn, e[0:5]) extra = {'extra': {'counter': c}} if mapann_value is not None: extra['extra']['value'] = v ms.update(extra) screens.append(ms) return screens
def marshal_screens(conn, mapann_value, query=False, mapann_ns=[], mapann_names=[], group_id=-1, experimenter_id=-1, page=1, limit=settings.PAGE): ''' Marshals screens @param conn OMERO gateway. @type conn L{omero.gateway.BlitzGateway} @param mapann_ns The Map annotation namespace to filter by. @type mapann_ns L{string} @param mapann_names The Map annotation names to filter by. @type mapann_names L{string} @param mapann_value The Map annotation value to filter by. @type mapann_value L{string} @param query Flag allowing to search for value patters. @type query L{boolean} @param group_id The Group ID to filter by or -1 for all groups, defaults to -1 @type group_id L{long} @param experimenter_id The Experimenter (user) ID to filter by or -1 for all experimenters @type experimenter_id L{long} @param page Page number of results to get. `None` or 0 for no paging defaults to 1 @type page L{long} @param limit The limit of results per page to get defaults to the value set in settings.PAGE @type page L{long} ''' screens = [] params, where_clause = _set_parameters( mapann_ns=mapann_ns, mapann_names=mapann_names, query=query, mapann_value=mapann_value, params=None, experimenter_id=experimenter_id, page=page, limit=limit) service_opts = deepcopy(conn.SERVICE_OPTS) # Set the desired group context if group_id is None: group_id = -1 service_opts.setOmeroGroup(group_id) # TODO: Joining wellsample should be enough since wells are annotated # with the same annotations as images. In the future if that changes, # query has to be restored to: # - count(distinct i.id) as imgCount) # - from ImageAnnotationLink ial join ial.child a join a.mapValue mv # - join ial.parent i join i.wellSamples ws join ws.well w # - join w.plate pl join pl.screenLinks sl join sl.parent screen qs = conn.getQueryService() q = """ select new map(mv.value as value, screen.id as id, screen.name as name, screen.details.owner.id as ownerId, screen as screen_details_permissions, count(distinct pl.id) as childCount, count(distinct ws.id) as imgCount) from WellAnnotationLink wal join wal.child a join a.mapValue mv join wal.parent w join w.wellSamples ws join w.plate pl join pl.screenLinks sl join sl.parent screen where %s group by screen.id, screen.name, mv.value order by lower(screen.name), screen.id """ % (" and ".join(where_clause)) logger.debug("HQL QUERY: %s\nPARAMS: %r" % (q, params)) for e in qs.projection(q, params, service_opts): e = unwrap(e) v = e[0]['value'] c = e[0]['imgCount'] e = [e[0]['id'], "%s (%d)" % (e[0]['name'], c), e[0]['ownerId'], e[0]['screen_details_permissions'], e[0]['childCount']] ms = _marshal_screen(conn, e[0:5]) extra = {'extra': {'counter': c}} if mapann_value is not None: extra['extra']['value'] = v ms.update(extra) screens.append(ms) return screens
def marshal_projects(conn, mapann_value, query=False, mapann_ns=[], mapann_names=[], group_id=-1, experimenter_id=-1, page=1, limit=settings.PAGE): ''' Marshals projects @param conn OMERO gateway. @type conn L{omero.gateway.BlitzGateway} @param mapann_ns The Map annotation namespace to filter by. @type mapann_ns L{string} @param mapann_names The Map annotation names to filter by. @type mapann_names L{string} @param mapann_value The Map annotation value to filter by. @type mapann_value L{string} @param query Flag allowing to search for value patters. @type query L{boolean} @param group_id The Group ID to filter by or -1 for all groups, defaults to -1 @type group_id L{long} @param experimenter_id The Experimenter (user) ID to filter by or -1 for all experimenters @type experimenter_id L{long} @param page Page number of results to get. `None` or 0 for no paging defaults to 1 @type page L{long} @param limit The limit of results per page to get defaults to the value set in settings.PAGE @type page L{long} ''' projects = [] params, where_clause = _set_parameters( mapann_ns=mapann_ns, mapann_names=mapann_names, query=query, mapann_value=mapann_value, params=None, experimenter_id=experimenter_id, page=page, limit=limit) service_opts = deepcopy(conn.SERVICE_OPTS) # Set the desired group context if group_id is None: group_id = -1 service_opts.setOmeroGroup(group_id) qs = conn.getQueryService() q = """ select new map(mv.value as value, project.id as id, project.name as name, project.details.owner.id as ownerId, project as project_details_permissions, count(distinct dataset.id) as childCount, count(distinct i.id) as imgCount) from ImageAnnotationLink ial join ial.child a join a.mapValue mv join ial.parent i join i.datasetLinks dil join dil.parent dataset join dataset.projectLinks pl join pl.parent project where %s group by project.id, project.name, mv.value order by lower(project.name), project.id """ % (" and ".join(where_clause)) logger.debug("HQL QUERY: %s\nPARAMS: %r" % (q, params)) for e in qs.projection(q, params, service_opts): e = unwrap(e) v = e[0]['value'] c = e[0]['imgCount'] e = [e[0]['id'], "%s (%d)" % (e[0]["name"], c), e[0]['ownerId'], e[0]['project_details_permissions'], e[0]['childCount']] ms = _marshal_screen(conn, e[0:5]) extra = {'extra': {'counter': c}} if mapann_value is not None: extra['extra']['value'] = v ms.update(extra) projects.append(ms) return projects
def marshal_screens(conn, mapann_ns=[], mapann_names=[], mapann_value=None, mapann_query=None, group_id=-1, experimenter_id=-1, page=1, limit=settings.PAGE): ''' Marshals screens @param conn OMERO gateway. @type conn L{omero.gateway.BlitzGateway} @param mapann_names The Map annotation names to filter by. @type mapann_names L{string} @param mapann_value The Map annotation value to filter by. @type mapann_value L{string} @param group_id The Group ID to filter by or -1 for all groups, defaults to -1 @type group_id L{long} @param experimenter_id The Experimenter (user) ID to filter by or -1 for all experimenters @type experimenter_id L{long} @param page Page number of results to get. `None` or 0 for no paging defaults to 1 @type page L{long} @param limit The limit of results per page to get defaults to the value set in settings.PAGE @type page L{long} ''' screens = [] params, where_clause = _set_parameters(mapann_ns=mapann_ns, mapann_names=mapann_names, mapann_query=mapann_query, mapann_value=mapann_value, params=None, experimenter_id=experimenter_id, page=page, limit=limit) service_opts = deepcopy(conn.SERVICE_OPTS) # Set the desired group context if group_id is None: group_id = -1 service_opts.setOmeroGroup(group_id) qs = conn.getQueryService() q = """ select new map(screen.id as id, screen.name as name, screen.details.owner.id as ownerId, screen as screen_details_permissions, count(distinct p.id) as childCount, count(distinct i.id) as imgCount) from ImageAnnotationLink ial join ial.child a join a.mapValue mv join ial.parent i join i.wellSamples ws join ws.well w join w.plate p join p.screenLinks sl join sl.parent screen where %s group by screen.id, screen.name order by lower(screen.name), screen.id """ % (" and ".join(where_clause)) logger.debug("HQL QUERY: %s\nPARAMS: %r" % (q, params)) for e in qs.projection(q, params, service_opts): e = unwrap(e) e = [ e[0]["id"], "%s (%d)" % (e[0]["name"], e[0]["imgCount"]), e[0]["ownerId"], e[0]["screen_details_permissions"], e[0]["childCount"] ] ms = _marshal_screen(conn, e[0:5]) ms.update({'extra': {'value': mapann_value}}) screens.append(ms) return screens