import omero from omero.rtypes import * from omero_sys_ParametersI import ParametersI c = omero.client("localhost") s = c.createSession("root","ome") q = s.getQueryService() u = s.getUpdateService() screen = omero.model.ScreenI() screen.name = rstring("screen") plate = omero.model.PlateI() plate.name = rstring("plate") well = omero.model.WellI() well.plate = plate acquisition = omero.model.ScreenAcquisitionI() acquisition.screen = screen annotation = omero.model.CommentAnnotationI() well.linkAnnotation(annotation) acquisition.linkAnnotation(annotation) rv = u.saveAndReturnArray([acquisition,well]) said = rv[0].id.getValue() wid = rv[1].id.getValue() print "Well:%s Acquisition:%s" % (wid, said) rv = q.findAllByQuery(""" SELECT sann FROM ScreenAcquisition sa, Well w JOIN sa.annotationLinks sal JOIN sal.child sann JOIN w.annotationLinks wl WHERE w.id = :wid AND sa.id = :said AND sann.id = wl.child.id """, ParametersI().addLong("wid", wid).addLong("said",said)) print "Annotations count:%s (id=%s)" % (len(rv), rv[0].id.val)