예제 #1
0
    def testWrappers(self):
        image = ImageI()
        info = image._field_info

        assert info.name.wrapper == rstring
        assert info.acquisitionDate.wrapper == rtime

        assert not info.name.nullable
        assert not info.acquisitionDate.nullable

        image.setAcquisitionDate("1", wrap=True)
        assert type(image.acquisitionDate) == type(rtime(0))

        # The following causes pytest to fail!
        # image.setAcquisitionDate("", wrap=True)

        # Note: collections still don't work well
        if False:
            image.addPixels(PixelsI())
            image.setPixels(0, "Pixels:1", wrap=True)
            assert type(image.pixels) == omero.model.PixelsI

            image.setPixels(0, "Pixels", wrap=True)
            image.setPixels(0, "Unknown", wrap=True)

        link = DatasetImageLinkI()
        link.setParent("Dataset:1")
        link.setChild("Image:1")
예제 #2
0
    def testWrappers(self):
        image = ImageI()
        info = image._field_info

        assert info.name.wrapper == rstring
        assert info.acquisitionDate.wrapper == rtime

        assert not info.name.nullable
        assert info.acquisitionDate.nullable

        image.setAcquisitionDate("1", wrap=True)
        assert type(image.acquisitionDate) == type(rtime(0))

        # The following causes pytest to fail!
        # image.setAcquisitionDate("", wrap=True)

        # Note: collections still don't work well
        if False:
            image.addPixels(PixelsI())
            image.setPixels(0, "Pixels:1", wrap=True)
            assert type(image.pixels) == omero.model.PixelsI

            image.setPixels(0, "Pixels", wrap=True)
            image.setPixels(0, "Unknown", wrap=True)

        link = DatasetImageLinkI()
        link.setParent("Dataset:1")
        link.setChild("Image:1")
예제 #3
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        assert d.sizeOfImageLinks() == 1
        d.unlinkImage(i)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        assert i.sizeOfDatasetLinks() == 1
        i.unlinkDataset(d)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d, i)
        d.addDatasetImageLink(dil, False)
        assert d.sizeOfImageLinks() == 1
        assert i.sizeOfDatasetLinks() == 0
예제 #4
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        self.assert_(d.sizeOfImageLinks() == 1)
        d.unlinkImage(i)
        self.assert_(d.sizeOfImageLinks() == 0)

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        self.assert_(i.sizeOfDatasetLinks() == 1)
        i.unlinkDataset(d)
        self.assert_(d.sizeOfImageLinks() == 0)

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d, i)
        d.addDatasetImageLink(dil, False)
        self.assert_(d.sizeOfImageLinks() == 1)
        self.assert_(i.sizeOfDatasetLinks() == 0)
예제 #5
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        assert d.sizeOfImageLinks() == 1
        d.unlinkImage(i)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        assert i.sizeOfDatasetLinks() == 1
        i.unlinkDataset(d)
        assert d.sizeOfImageLinks() == 0

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d, i)
        d.addDatasetImageLink(dil, False)
        assert d.sizeOfImageLinks() == 1
        assert i.sizeOfDatasetLinks() == 0
예제 #6
0
    def testLinkingAndUnlinking(self):
        d = DatasetI()
        i = ImageI()

        d.linkImage(i)
        self.assert_( d.sizeOfImageLinks() == 1 )
        d.unlinkImage(i)
        self.assert_( d.sizeOfImageLinks() == 0 )

        d = DatasetI()
        i = ImageI()
        d.linkImage(i)
        self.assert_( i.sizeOfDatasetLinks() == 1 )
        i.unlinkDataset(d)
        self.assert_( d.sizeOfImageLinks() == 0 )

        d = DatasetI()
        i = ImageI()
        dil = DatasetImageLinkI()
        dil.link(d,i)
        d.addDatasetImageLink(dil, False)
        self.assert_( d.sizeOfImageLinks() == 1 )
        self.assert_( i.sizeOfDatasetLinks() == 0 )
    def test1071(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        pojos = self.root.sf.getContainerService()
        query = self.root.sf.getQueryService()
        update = self.root.sf.getUpdateService()

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (uuid)))
        pr1 = update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (uuid)))
        pr2 = update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (uuid)))
        ds1 = update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (uuid)))
        ds2 = update.saveAndReturnObject(ds2)
        ds2.unload()

        ds3 = DatasetI()
        ds3.setName(rstring('test1071-ds3-%s' % (uuid)))
        ds3 = update.saveAndReturnObject(ds3)
        ds3.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = update.saveAndReturnObject(im2)
        im2.unload()

        #links
        #
        # im2 -> ds3
        #    +-> ds2 --> pr2
        #    |       \
        #    \-> ds1 --> pr1
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr1)
        pdl2.setChild(ds2)
        update.saveObject(pdl2)

        pdl3 = ProjectDatasetLinkI()
        pdl3.setParent(pr2)
        pdl3.setChild(ds2)
        update.saveObject(pdl3)

        dil4 = DatasetImageLinkI()
        dil4.setParent(ds1)
        dil4.setChild(im2)
        update.saveObject(dil4)

        dil5 = DatasetImageLinkI()
        dil5.setParent(ds2)
        dil5.setChild(im2)
        update.saveObject(dil5)

        dil6 = DatasetImageLinkI()
        dil6.setParent(ds3)
        dil6.setChild(im2)
        update.saveObject(dil6)

        #test:
        hier = pojos.findContainerHierarchies("Project", [long(im2.id.val)], None)

        assert 3 ==  len(hier), "len of hier != 3: %s" % [type(x) for x in hier]
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                assert c.sizeOfDatasetLinks() == 2, "length 2 != " + str(c.sizeOfDatasetLinks())
                for pdl in c.copyDatasetLinks():
                    assert pdl.child.sizeOfImageLinks() == 1
                    for dil in pdl.child.copyImageLinks():
                        assert dil.child.id.val == im2.id.val
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                assert  c.sizeOfDatasetLinks() == 1
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                assert  c.sizeOfImageLinks() == 1
    def test1071_1(self):
        admin = self.root.sf.getAdminService()

        common_group = self.new_group(perms="rwrw--")
        c1 = self.new_client(common_group)
        c2 = self.new_client(common_group)

        c1_pojos = c1.sf.getContainerService()
        c1_query = c1.sf.getQueryService()
        c1_update = c1.sf.getUpdateService()
        c1_uuid = c1.sf.getAdminService().getEventContext().sessionUuid

        c2_pojos = c2.sf.getContainerService()
        c2_query = c2.sf.getQueryService()
        c2_update = c2.sf.getUpdateService()
        c2_uuid = c2.sf.getAdminService().getEventContext().sessionUuid

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (c1_uuid)))
        pr1 = c1_update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (c2_uuid)))
        pr2 = c2_update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (c1_uuid)))
        ds1 = c1_update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (c2_uuid)))
        ds2 = c2_update.saveAndReturnObject(ds2)
        ds2.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (c2_uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = c2_update.saveAndReturnObject(im2)
        im2.unload()

        #links
        # im2 owned by u2
        #
        # im2   -> ds2 --> pr2 (owned by u2)
        #      |
        #      \-> ds1 --> pr1 (owned by u1)
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        c1_update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr2)
        pdl2.setChild(ds2)
        c2_update.saveObject(pdl2)

        dil2 = DatasetImageLinkI()
        dil2.setParent(ds2)
        dil2.setChild(im2)
        c2_update.saveObject(dil2)

        dil1 = DatasetImageLinkI()
        dil1.setParent(ds1)
        dil1.setChild(im2)
        c1_update.saveObject(dil1)

        #test:
        hier = c2_pojos.findContainerHierarchies("Project", [long(im2.id.val)], None)

        assert 2 ==  len(hier), "size of hier != 2: %s" % [type(x) for x in hier]
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                assert 1 ==  c.sizeOfDatasetLinks()
                for pdl in c.copyDatasetLinks():
                    assert 1 ==  pdl.child.sizeOfImageLinks()
                    for dil in pdl.child.copyImageLinks():
                        assert dil.child.id.val == im2.id.val
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                assert 1 ==  c.sizeOfDatasetLinks()
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                assert 1 ==  c.sizeOfImageLinks()
예제 #9
0
    def test1071_1(self):
        admin = self.root.sf.getAdminService()

        common_group = self.new_group(perms="rwrw--")
        c1 = self.new_client(common_group)
        c2 = self.new_client(common_group)

        c1_pojos = c1.sf.getContainerService()
        c1_query = c1.sf.getQueryService()
        c1_update = c1.sf.getUpdateService()
        c1_uuid = c1.sf.getAdminService().getEventContext().sessionUuid

        c2_pojos = c2.sf.getContainerService()
        c2_query = c2.sf.getQueryService()
        c2_update = c2.sf.getUpdateService()
        c2_uuid = c2.sf.getAdminService().getEventContext().sessionUuid

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (c1_uuid)))
        pr1 = c1_update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (c2_uuid)))
        pr2 = c2_update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (c1_uuid)))
        ds1 = c1_update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (c2_uuid)))
        ds2 = c2_update.saveAndReturnObject(ds2)
        ds2.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (c2_uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = c2_update.saveAndReturnObject(im2)
        im2.unload()

        #links
        # im2 owned by u2
        #
        # im2   -> ds2 --> pr2 (owned by u2)
        #      |
        #      \-> ds1 --> pr1 (owned by u1)
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        c1_update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr2)
        pdl2.setChild(ds2)
        c2_update.saveObject(pdl2)

        dil2 = DatasetImageLinkI()
        dil2.setParent(ds2)
        dil2.setChild(im2)
        c2_update.saveObject(dil2)

        dil1 = DatasetImageLinkI()
        dil1.setParent(ds1)
        dil1.setChild(im2)
        c1_update.saveObject(dil1)

        #test:
        hier = c2_pojos.findContainerHierarchies("Project", [long(im2.id.val)],
                                                 None)

        self.assertEquals(2, len(hier),
                          "size of hier != 2: %s" % [type(x) for x in hier])
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                self.assertEquals(1, c.sizeOfDatasetLinks())
                for pdl in c.copyDatasetLinks():
                    self.assertEquals(1, pdl.child.sizeOfImageLinks())
                    for dil in pdl.child.copyImageLinks():
                        self.assert_(dil.child.id.val == im2.id.val)
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                self.assertEquals(1, c.sizeOfDatasetLinks())
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                self.assertEquals(1, c.sizeOfImageLinks())
예제 #10
0
    def test1071(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        pojos = self.root.sf.getContainerService()
        query = self.root.sf.getQueryService()
        update = self.root.sf.getUpdateService()

        #projects
        pr1 = ProjectI()
        pr1.setName(rstring('test1071-pr1-%s' % (uuid)))
        pr1 = update.saveAndReturnObject(pr1)
        pr1.unload()

        pr2 = ProjectI()
        pr2.setName(rstring('test1071-pr2-%s' % (uuid)))
        pr2 = update.saveAndReturnObject(pr2)
        pr2.unload()

        #datasets
        ds1 = DatasetI()
        ds1.setName(rstring('test1071-ds1-%s' % (uuid)))
        ds1 = update.saveAndReturnObject(ds1)
        ds1.unload()

        ds2 = DatasetI()
        ds2.setName(rstring('test1071-ds2-%s' % (uuid)))
        ds2 = update.saveAndReturnObject(ds2)
        ds2.unload()

        ds3 = DatasetI()
        ds3.setName(rstring('test1071-ds3-%s' % (uuid)))
        ds3 = update.saveAndReturnObject(ds3)
        ds3.unload()

        #images
        im2 = ImageI()
        im2.setName(rstring('test1071-im2-%s' % (uuid)))
        im2.acquisitionDate = rtime(0)
        im2 = update.saveAndReturnObject(im2)
        im2.unload()

        #links
        #
        # im2 -> ds3
        #    +-> ds2 --> pr2
        #    |       \
        #    \-> ds1 --> pr1
        #
        pdl1 = ProjectDatasetLinkI()
        pdl1.setParent(pr1)
        pdl1.setChild(ds1)
        update.saveObject(pdl1)

        pdl2 = ProjectDatasetLinkI()
        pdl2.setParent(pr1)
        pdl2.setChild(ds2)
        update.saveObject(pdl2)

        pdl3 = ProjectDatasetLinkI()
        pdl3.setParent(pr2)
        pdl3.setChild(ds2)
        update.saveObject(pdl3)

        dil4 = DatasetImageLinkI()
        dil4.setParent(ds1)
        dil4.setChild(im2)
        update.saveObject(dil4)

        dil5 = DatasetImageLinkI()
        dil5.setParent(ds2)
        dil5.setChild(im2)
        update.saveObject(dil5)

        dil6 = DatasetImageLinkI()
        dil6.setParent(ds3)
        dil6.setChild(im2)
        update.saveObject(dil6)

        #test:
        hier = pojos.findContainerHierarchies("Project", [long(im2.id.val)],
                                              None)

        self.assertEquals(3, len(hier),
                          "len of hier != 3: %s" % [type(x) for x in hier])
        for c in hier:
            if c.id.val == pr1.id.val and isinstance(c, ProjectI):
                self.assert_(c.sizeOfDatasetLinks() == 2,
                             "length 2 != " + str(c.sizeOfDatasetLinks()))
                for pdl in c.copyDatasetLinks():
                    self.assert_(pdl.child.sizeOfImageLinks() == 1)
                    for dil in pdl.child.copyImageLinks():
                        self.assert_(dil.child.id.val == im2.id.val)
            elif c.id.val == pr2.id.val and isinstance(c, ProjectI):
                self.assert_(c.sizeOfDatasetLinks() == 1)
            elif c.id.val == ds3.id.val and isinstance(c, DatasetI):
                self.assert_(c.sizeOfImageLinks() == 1)
예제 #11
0
    def test1172(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        share = self.root.sf.getShareService()
        query = self.root.sf.getQueryService()
        update = self.root.sf.getUpdateService()
        
        ### create user
        client_share1, user1 = self.new_client_and_user()
        
        #create dataset with image
        #dataset with image
        ds = omero.model.DatasetI()
        ds.setName(rstring("dataset-%s" % (uuid)))
        ds = update.saveAndReturnObject(ds)
        ds.unload()
        
        # create image
        img = ImageI()
        img.setName(rstring('test-img in dataset-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update.saveAndReturnObject(img)
        img.unload()
        
        dil = DatasetImageLinkI()
        dil.setParent(ds)
        dil.setChild(img)
        dil = update.saveAndReturnObject(dil)
        dil.unload()
        
        # create share by root
        items = list()
        ms = list()
        
        p = omero.sys.Parameters()
        p.map = {}
        p.map["oid"] = ds.id
        sql = "select ds from Dataset ds join fetch ds.details.owner join fetch ds.details.group " \
              "left outer join fetch ds.imageLinks dil left outer join fetch dil.child i " \
              "where ds.id=:oid"
        items.extend(query.findAllByQuery(sql, p))
        self.assertEquals(1, len(items))
        
        #members
        p.map["eid"] = rlong(user1.id.val)
        sql = "select e from Experimenter e where e.id =:eid order by e.omeName"
        ms = query.findAllByQuery(sql, p)
        sid = share.createShare(("test-share-%s" % uuid), rtime(long(time.time()*1000 + 86400)) , items, ms, [], True)
        
        # USER RETRIEVAL
        ## login as user1
        share1 = client_share1.sf.getShareService()
        query1 = client_share1.sf.getQueryService()
        cntar1 = client_share1.sf.getContainerService()
        
        content = share1.getContents(sid)
        # Content now contains just the dataset with nothing loaded
        self.assertEquals(1, len(content))

        # get shared dataset and image when share is activated
        share1.activate(sid)

        #retrieve dataset
        p = omero.sys.Parameters()
        p.map = {}
        p.map["ids"] = rlist([ds.id])
        sql = "select ds from Dataset ds join fetch ds.details.owner join fetch ds.details.group " \
              "left outer join fetch ds.imageLinks dil left outer join fetch dil.child i " \
              "where ds.id in (:ids) order by ds.name"
        try:
            res1 = query1.findAllByQuery(sql, p)
            self.fail("This should throw an exception")
        except:
            pass

        #
        # Now we add all the other elements to the share to prevent
        # the security violation
        #
        # Not working imgs = cntar.getImages("Dataset",[ds.id.val], None)
        img = query.findByQuery("select i from Image i join fetch i.datasetLinks dil join dil.parent d where d.id = %s " % ds.id.val, None)
        self.assert_(img)
        share.addObject(sid, img)
        share.addObjects(sid, img.copyDatasetLinks())
        self.assertEquals(3, len(share.getContents(sid)))

        #
        # And try again to load them
        #
        share1.activate(sid)
        res1 = query1.findAllByQuery(sql, p)
        self.assert_(len(res1) == 1)
        for e in res1:
            self.assert_(e.id.val == ds.id.val)

        # retrieve only image
        p = omero.sys.Parameters()
        p.map = {}
        p.map["oid"] = rlong(img.id)
        sql = "select im from Image im " \
              "where im.id=:oid order by im.name"
        res2 = query1.findByQuery(sql, p)
        self.assert_(res2.id.val == img.id.val)
예제 #12
0
    def test1172(self):
        uuid = self.root.sf.getAdminService().getEventContext().sessionUuid
        share = self.root.sf.getShareService()
        query = self.root.sf.getQueryService()
        update = self.root.sf.getUpdateService()

        ### create user
        client_share1, user1 = self.new_client_and_user()

        #create dataset with image
        #dataset with image
        ds = omero.model.DatasetI()
        ds.setName(rstring("dataset-%s" % (uuid)))
        ds = update.saveAndReturnObject(ds)
        ds.unload()

        # create image
        img = ImageI()
        img.setName(rstring('test-img in dataset-%s' % (uuid)))
        img.setAcquisitionDate(rtime(0))
        img = update.saveAndReturnObject(img)
        img.unload()

        dil = DatasetImageLinkI()
        dil.setParent(ds)
        dil.setChild(img)
        dil = update.saveAndReturnObject(dil)
        dil.unload()

        # create share by root
        items = list()
        ms = list()

        p = omero.sys.Parameters()
        p.map = {}
        p.map["oid"] = ds.id
        sql = "select ds from Dataset ds join fetch ds.details.owner join fetch ds.details.group " \
              "left outer join fetch ds.imageLinks dil left outer join fetch dil.child i " \
              "where ds.id=:oid"
        items.extend(query.findAllByQuery(sql, p))
        self.assertEquals(1, len(items))

        #members
        p.map["eid"] = rlong(user1.id.val)
        sql = "select e from Experimenter e where e.id =:eid order by e.omeName"
        ms = query.findAllByQuery(sql, p)
        sid = share.createShare(("test-share-%s" % uuid),
                                rtime(long(time.time() * 1000 + 86400)), items,
                                ms, [], True)

        # USER RETRIEVAL
        ## login as user1
        share1 = client_share1.sf.getShareService()
        query1 = client_share1.sf.getQueryService()
        cntar1 = client_share1.sf.getContainerService()

        content = share1.getContents(sid)
        # Content now contains just the dataset with nothing loaded
        self.assertEquals(1, len(content))

        # get shared dataset and image when share is activated
        share1.activate(sid)

        #retrieve dataset
        p = omero.sys.Parameters()
        p.map = {}
        p.map["ids"] = rlist([ds.id])
        sql = "select ds from Dataset ds join fetch ds.details.owner join fetch ds.details.group " \
              "left outer join fetch ds.imageLinks dil left outer join fetch dil.child i " \
              "where ds.id in (:ids) order by ds.name"
        try:
            res1 = query1.findAllByQuery(sql, p)
            self.fail("This should throw an exception")
        except:
            pass

        #
        # Now we add all the other elements to the share to prevent
        # the security violation
        #
        # Not working imgs = cntar.getImages("Dataset",[ds.id.val], None)
        img = query.findByQuery(
            "select i from Image i join fetch i.datasetLinks dil join dil.parent d where d.id = %s "
            % ds.id.val, None)
        self.assert_(img)
        share.addObject(sid, img)
        share.addObjects(sid, img.copyDatasetLinks())
        self.assertEquals(3, len(share.getContents(sid)))

        #
        # And try again to load them
        #
        share1.activate(sid)
        res1 = query1.findAllByQuery(sql, p)
        self.assert_(len(res1) == 1)
        for e in res1:
            self.assert_(e.id.val == ds.id.val)

        # retrieve only image
        p = omero.sys.Parameters()
        p.map = {}
        p.map["oid"] = rlong(img.id)
        sql = "select im from Image im " \
              "where im.id=:oid order by im.name"
        res2 = query1.findByQuery(sql, p)
        self.assert_(res2.id.val == img.id.val)