Last active
June 9, 2016 10:36
-
-
Save atarkowska/ace091135c97ce0027eb9e0211d58ad4 to your computer and use it in GitHub Desktop.
MapAnnotation vs NamedValue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import omero, os | |
import omero.gateway | |
from omero.rtypes import * | |
from omero.rtypes import unwrap | |
host = "localhost" | |
port = 4064 | |
pass = "ome" | |
user = "test" | |
c = omero.client(host=host, port=port) | |
s = c.createSession(user, pass) | |
query = s.getQueryService() | |
expId = 2 #s.getAdminService().getEventContext().userId | |
sql = """ | |
select count(distinct a.id) as counter | |
from MapAnnotation a | |
where a.ns = :ns and a.details.owner.id = :id | |
""" | |
sql2 = """ | |
select count(a.id) as counter | |
from MapAnnotation a | |
where a.ns = :ns and a.details.owner.id = :id | |
""" | |
sql3 = """ | |
select count(distinct a.id) as counter | |
from MapAnnotation a join a.mapValue mv | |
where a.ns = :ns and a.details.owner.id = :id | |
""" | |
sql4 = """ | |
select count(a.id) as counter | |
from MapAnnotation a join a.mapValue mv | |
where a.ns = :ns and a.details.owner.id = :id | |
""" | |
p = omero.sys.ParametersI() | |
p.addString("ns", "openmicroscopy.org/omero/bulk_annotations") | |
p.addId(expId) | |
rv = unwrap(query.projection(sql, p)) | |
rv2 = unwrap(query.projection(sql2, p)) | |
rv3 = unwrap(query.projection(sql3, p)) | |
rv4 = unwrap(query.projection(sql4, p)) | |
print rv, rv2, rv3, rv4 # will give different values [[200995L]] [[200995L]] [[191181L]] [[815711L]] | |
assert rv == rv2 == rv3 == rv4 | |
s.closeOnDestroy() | |
c.closeSession() | |
c.__del__() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment