Beispiel #1
0
def listMostRecentAnnotations(conn, limit, eid=None):
    """
    Retrieve most recent annotations available
    
    @return:    Generator yielding BlitzObjectWrapper
    @rtype:     L{BlitzObjectWrapper} generator
    """

    tm = conn.getTimelineService()
    p = omero.sys.Parameters()
    p.map = {}
    f = omero.sys.Filter()
    if eid:
        f.ownerId = rlong(eid)
    else:
        f.groupId = rlong(conn.getEventContext().groupId)
    f.limit = rint(limit)
    p.theFilter = f
    anns = []

    # get ALL parent-types, child-types, namespaces:
    annTypes = ['LongAnnotation', 'TagAnnotation',
                'CommentAnnotation']  # etc. Only query 1 at at time!
    for at in annTypes:
        for a in tm.getMostRecentAnnotationLinks(None, [at], None, p):
            # TODO: maybe load parent for each link here
            wrapper = AnnotationWrapper._wrap(conn, a.child, a)
            anns.append(wrapper)
    return anns
Beispiel #2
0
def listCollabAnnotations(conn, myData=True, limit=10):
    """
    Lists the most recent annotations BY other users on YOUR images etc. 
    """

    eid = conn.getEventContext().userId
    queryService = conn.getQueryService()
    params = omero.sys.ParametersI()
    params.addLong("eid", eid)
    f = omero.sys.Filter()
    f.limit = rint(limit)
    params.theFilter = f

    if myData:  # want annotation links NOT owned, where parent IS owned
        selection = "where owner.id = :eid and linkOwner.id != :eid "
    else:  # want annotation links owned by me, on data NOT owned by me
        selection = "where owner.id != :eid and linkOwner.id = :eid "

    query = "select al from ImageAnnotationLink as al " \
                    "join fetch al.child as annot " \
                    "join fetch al.parent as parent " \
                    "join fetch parent.details.owner as owner " \
                    "join fetch al.details.owner as linkOwner " \
                    "join fetch al.details.creationEvent as event %s" \
                    "order by event desc" % selection
    imageLinks = queryService.findAllByQuery(query, params)

    return [
        RecentEvent(AnnotationWrapper._wrap(conn, a.child, a))
        for a in imageLinks
    ]
def listMostRecentAnnotations (conn, limit, eid=None):
    """
    Retrieve most recent annotations available
    
    @return:    Generator yielding BlitzObjectWrapper
    @rtype:     L{BlitzObjectWrapper} generator
    """
    
    tm = conn.getTimelineService()
    p = omero.sys.Parameters()
    p.map = {}
    f = omero.sys.Filter()
    if eid:
        f.ownerId = rlong(eid)
    else:
        f.groupId = rlong(conn.getEventContext().groupId)
    f.limit = rint(limit)
    p.theFilter = f
    anns = []
    
    # get ALL parent-types, child-types, namespaces:
    annTypes = ['LongAnnotation', 'TagAnnotation', 'CommentAnnotation'] # etc. Only query 1 at at time! 
    for at in annTypes:
        for a in tm.getMostRecentAnnotationLinks(None, [at], None, p):
            # TODO: maybe load parent for each link here
            wrapper = AnnotationWrapper._wrap(conn, a.child, a)
            anns.append(wrapper)
    return anns
def listCollabAnnotations(conn, myData=True, limit=10):
    """
    Lists the most recent annotations BY other users on YOUR images etc. 
    """
    
    eid = conn.getEventContext().userId
    queryService = conn.getQueryService()
    params = omero.sys.ParametersI()
    params.addLong("eid", eid);
    f = omero.sys.Filter()
    f.limit = rint(limit)
    params.theFilter = f
    
    if myData:  # want annotation links NOT owned, where parent IS owned
        selection = "where owner.id = :eid and linkOwner.id != :eid "
    else:   # want annotation links owned by me, on data NOT owned by me
        selection = "where owner.id != :eid and linkOwner.id = :eid "
        
    query = "select al from ImageAnnotationLink as al " \
                    "join fetch al.child as annot " \
                    "join fetch al.parent as parent " \
                    "join fetch parent.details.owner as owner " \
                    "join fetch al.details.owner as linkOwner " \
                    "join fetch al.details.creationEvent as event %s" \
                    "order by event desc" % selection
    print query
    imageLinks = queryService.findAllByQuery(query, params)
                        
    return [RecentEvent (AnnotationWrapper._wrap(conn, a.child, a) ) for a in imageLinks]
Beispiel #5
0
def listMostRecentObjects(conn, limit, obj_types=None, eid=None):
    """
    Get the most recent objects supported by the timeline service: obj_types are 
    ['Project', 'Dataset', 'Image', 'Annotation'), Specifying the 
    number of each you want 'limit', belonging to the specified experimenter 'eid'
    or current Group if 'eid' is None.
    """

    from datetime import datetime
    now = datetime.now()

    tm = conn.getTimelineService()
    p = omero.sys.Parameters()
    p.map = {}
    f = omero.sys.Filter()
    if eid:
        f.ownerId = rlong(eid)
    else:
        f.groupId = rlong(conn.getEventContext().groupId)
    f.limit = rint(limit)
    p.theFilter = f

    types = {
        'Image': ImageWrapper,
        'Project': ProjectWrapper,
        'Dataset': DatasetWrapper
    }
    recent = tm.getMostRecentObjects(None, p, False)

    recentItems = []
    for r in recent:  # 'Image', 'Project', 'Dataset', 'Annotation', 'RenderingSettings'
        if obj_types and r not in obj_types:
            continue
        for value in recent[r]:
            if r == 'Annotation':
                recentItems.append(AnnotationWrapper._wrap(conn, value))
            elif r in types:
                recentItems.append(types[r](conn, value))
            else:
                pass  # RenderingSettings
                # recentItems.append( BlitzObjectWrapper(conn, value) )

    if obj_types == None or 'Annotation' in obj_types:
        anns = listMostRecentAnnotations(conn, limit, eid)
        recentItems.extend(anns)

    recentItems.sort(key=lambda x: x.updateEventDate())
    recentItems.reverse()
    return recentItems
def listMostRecentObjects(conn, limit, obj_types=None, eid=None):
    """
    Get the most recent objects supported by the timeline service: obj_types are 
    ['Project', 'Dataset', 'Image', 'Annotation'), Specifying the 
    number of each you want 'limit', belonging to the specified experimenter 'eid'
    or current Group if 'eid' is None.
    """
    
    from datetime import datetime
    now = datetime.now()
    
    tm = conn.getTimelineService()
    p = omero.sys.Parameters()
    p.map = {}
    f = omero.sys.Filter()
    if eid:
        f.ownerId = rlong(eid)
    else:
        f.groupId = rlong(conn.getEventContext().groupId)
    f.limit = rint(limit)
    p.theFilter = f

    types = {'Image':ImageWrapper, 'Project':ProjectWrapper, 'Dataset':DatasetWrapper}
    recent = tm.getMostRecentObjects(None, p, False)

    recentItems = []
    for r in recent: # 'Image', 'Project', 'Dataset', 'Annotation', 'RenderingSettings'
        if obj_types and r not in obj_types:
            continue
        for value in recent[r]:
            if r == 'Annotation':
                recentItems.append(AnnotationWrapper._wrap(conn, value))
            elif r in types:
                recentItems.append( types[r](conn, value) )
            else:
                pass    # RenderingSettings
                # recentItems.append( BlitzObjectWrapper(conn, value) )  
    
    if obj_types == None or 'Annotation' in obj_types:
        anns = listMostRecentAnnotations(conn, limit, eid)
        recentItems.extend(anns)
        
    recentItems.sort(key = lambda x: x.updateEventDate())
    recentItems.reverse()
    return recentItems
    """

    OMERO_TYPE = omero.model.MapAnnotationI

    def _getQueryString(self):
        """
        Used for building queries in generic methods such as
        getObjects("MapAnnotation")
        """
        return ("select obj from MapAnnotation obj "
                "join fetch obj.details.owner as owner "
                "join fetch obj.details.group "
                "join fetch obj.details.creationEvent "
                "join fetch obj.mapValue")

    def getValue(self):
        """
        Gets map value
        """
        return unwrap(self._obj.mapValue)

    def setValue(self, val):
        """
        Sets map value
        """
        self._obj.mapValue = wrap(val)

AnnotationWrapper._register(MapAnnotationWrapper)
omero.gateway.KNOWN_WRAPPERS['mapannotation'] = MapAnnotationWrapper
omero.gateway.refreshWrappers()