Page 2 of 2

Re: Thumbnail pixels and annotations/tag

PostPosted: Wed Feb 17, 2010 5:13 pm
by cxallan
First thing to note is that OMERO only provides IDs (and unloaded objects) for relations that are 1:1. So you must perform a query based on that Image ID to do what you want. Python examples follow.

Option 1, query against the Pixels set itself:

Code: Select all
>>> iquery = sf.getQueryService()
>>> image = iquery.find('Image', 1L)
>>> pixels = iquery.findByQuery('from Pixels as p where p.image = %d' \
...      % image.id.val, None)
>>> pixels.id
object #0 (::omero::RLong)
{
    _val = 1
}
>>> pixels.id
object #0 (::omero::RLong)
{
    _val = 1
}


Option 2, query with a fetch:

Code: Select all
>>> image = iquery.findByQuery('from Image as image join fetch image.pixels '
...                            'where image.id = %d' % 1L, None)
>>> image.id
object #0 (::omero::RLong)
{
    _val = 1
}
>>> image.getPrimaryPixels().id.val
1L


These are HQL queries, which is an object oriented query language included as part of Hibernate. You can read more about HQL here:

http://docs.jboss.org/hibernate/stable/ ... ryhql.html

Re: Thumbnail pixels and annotations/tag

PostPosted: Wed Feb 17, 2010 5:18 pm
by cxallan
If you don't like string comprehension you can also use a ParametersI object:

Code: Select all
...
>>> params = omero.sys.ParametersI()
>>> params.addId(1L)
object #0 (::omero::sys::Parameters)
{
    map =
    {
        key = id
        value = object #1 (::omero::RLong)
        {
            _val = 1
        }
    }
    theFilter = <nil>
    theOptions = <nil>
}
>>> image = iquery.findByQuery('from Image as image join fetch image.pixels '
...                            'where image.id = :id', params)
>>> image.id
object #0 (::omero::RLong)
{
    _val = 1
}