コード例 #1
0
def load(conn, filepath):
    """
    Import new tag(s) from json.
    """
    if filepath:
        fobj = open(filepath, "r")
    else:
        sys.stderr.write("Error: No file is given.\n")
        sys.exit(1)

    p = json.load(fobj)

    if fobj is not sys.stdin:
        fobj.close()

    update = conn.getUpdateService()
    tagList2 = []
    for tset in p:
        if "tag" in tset:
            tag = TagAnnotationI()
            tag.setTextValue(rstring(tset["tag"]))
            if tset["desc"]:
                tag.setDescription(rstring(tset["desc"]))
            tagList2.append(tag)
        #end if

        if "tagset" in tset:
            tagList = []
            for t in tset['tags']:
                tag = TagAnnotationI()

                tag.setTextValue(rstring(t["name"]))
                if t["desc"]:
                    tag.setDescription(rstring(t["desc"]))
                tagList.append(tag)
            #end for
            tagList = update.saveAndReturnArray(tagList)

            tag = TagAnnotationI()
            tag.setTextValue(rstring(tset["tagset"]))
            if tset["desc"]:
                tag.setDescription(rstring(tset["desc"]))
            tag.setNs(rstring(omero.constants.metadata.NSINSIGHTTAGSET))
            tag = update.saveAndReturnObject(tag)
            links = []
            for child in tagList:
                l = AnnotationAnnotationLinkI()
                l.setChild(child)
                l.setParent(tag)
                links.append(l)
            #end for
            update.saveAndReturnArray(links)
        #end if
    #end for
    update.saveAndReturnArray(tagList2)
コード例 #2
0
 def addTagAs(self, user, project):
     """ Adds and links a Tag. """
     tag = TagAnnotationI()
     tag.setTextValue(rstring(self.tag_text))
     tag.setNs(rstring(self.tag_ns))
     tag = self.updateServices[user].saveAndReturnObject(tag)
     self.linkTagAs(user, project, tag)
     return tag
コード例 #3
0
    def testBasicUsage(self):

        img = self.new_image(name="name")
        img.linkAnnotation(TagAnnotationI())
        img = self.update.saveAndReturnObject(img)

        img = self.query.findByQuery(
            "select img from Image img "
            "join fetch img.annotationLinksCountPerOwner "
            "where img.id = %s" % (img.id.val), None)
        assert img
        assert img.getAnnotationLinksCountPerOwner()[self.ctx.userId] > 0
コード例 #4
0
    def testBasicUsage(self):
        usr = self.client.sf.getAdminService().getEventContext().userId

        img = ImageI()
        img.name = rstring("name")
        img.acquisitionDate = rtime(0)
        tag = TagAnnotationI()
        img.linkAnnotation(tag)

        img = self.client.sf.getUpdateService().saveAndReturnObject(img)

        img = self.client.sf.getQueryService().findByQuery(
            """
        select img from Image img
        join fetch img.annotationLinksCountPerOwner
        where img.id = %s
        """ % (img.id.val), None)
        self.assert_(img)
        self.assert_(img.getAnnotationLinksCountPerOwner()[usr] > 0)
コード例 #5
0
    def testLoginToPublicGroupTicket1940(self):
        # As root create a new group
        uuid = self.uuid()
        g = ExperimenterGroupI()
        g.name = rstring(uuid)
        g.details.permissions = PermissionsI("rwrwrw")
        gid = self.root.sf.getAdminService().createGroup(g)

        # As a regular user, login to that group
        rv = self.root.getPropertyMap()
        ec = self.client.sf.getAdminService().getEventContext()
        public_client = omero.client(rv)
        public_client.getImplicitContext().put("omero.group", uuid)
        sf = public_client.createSession(ec.userName, "foo")
        ec = sf.getAdminService().getEventContext()
        self.assertEquals(uuid, ec.groupName)

        # But can the user write anything?
        tag = TagAnnotationI()
        sf.getUpdateService().saveObject(tag)
コード例 #6
0
    def testLoginToPublicGroupTicket1940(self):
        # As root create a new group
        uuid = self.uuid()
        g = ExperimenterGroupI()
        g.name = rstring(uuid)
        g.ldap = rbool(False)
        g.details.permissions = PermissionsI("rwrwrw")
        self.root.sf.getAdminService().createGroup(g)

        # As a regular user, login to that group
        rv = self.root.getPropertyMap()
        ec = self.client.sf.getAdminService().getEventContext()
        public_client = omero.client(rv)
        public_client.getImplicitContext().put("omero.group", uuid)
        sf = public_client.createSession(ec.userName, ec.userName)
        ec = sf.getAdminService().getEventContext()
        assert uuid == ec.groupName

        # But can the user write anything?
        tag = TagAnnotationI()
        tag = sf.getUpdateService().saveAndReturnObject(tag)
        # And link?
        # And edit? cF. READ-ONLY & READ-LINK
        sf.getUpdateService().deleteObject(tag)
コード例 #7
0
 def makeTag(self):
     tag = TagAnnotationI()
     tag.setTextValue(rstring(self.tag_text))
     tag.setNs(rstring(self.tag_ns))
     return tag