Page 1 of 1

getting the list of all dataset IDs

PostPosted: Fri Jun 10, 2011 3:53 pm
by bhcho
Hi all,

can someone tell me how to get the list of all dataset IDs from entire OMERO DB? (I'm doing python now)

I need to get all datasets for all users (assuming that I'm executing it with the administrative user account)
But if it is not possible for the security reason, then can I get the list for the shared datasets?

thanks in advance,

BK

Re: getting the list of all dataset IDs

PostPosted: Fri Jun 10, 2011 5:59 pm
by jmoore
Hi BK,

take a look at the integration/permission.py test (line 303). The parameter you need is {"omero.group":"-1"}, which only works as an administrator. Please be aware that you should keep this data separate from any loaded without this parameter, since any updates which mix two such data graphs will fail.

Cheers,
~Josh

Re: getting the list of all dataset IDs

PostPosted: Fri Jun 10, 2011 6:25 pm
by bhcho
Thanks Josh,

then what is the hsql query to select all the datasets in the DB?

BK

Re: getting the list of all dataset IDs

PostPosted: Fri Jun 10, 2011 6:45 pm
by jmoore
The HQL is
Code: Select all
select d from Dataset d
.

Note, though, that you may want to do this via paging:

Code: Select all
queryService = client.sf.getQueryService()
count = queryService.projection("select count(d) from Dataset d", None)[0][0].val
for x in range(0, count/5):
    params.page(x*5, 5)
    results = queryService.findAllByQuery("select d from Dataset d order by d.id desc", params)
    print [d.id.val for d in results]


The ordering is important to make sure that each page view is unique, though if someone deletes a project between calls, you could still possibly miss some.

Cheers,
~Josh