We're Hiring!

getting the list of all dataset IDs

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

getting the list of all dataset IDs

Postby bhcho » Fri Jun 10, 2011 3:53 pm

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
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: getting the list of all dataset IDs

Postby jmoore » Fri Jun 10, 2011 5:59 pm

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
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: getting the list of all dataset IDs

Postby bhcho » Fri Jun 10, 2011 6:25 pm

Thanks Josh,

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

BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: getting the list of all dataset IDs

Postby jmoore » Fri Jun 10, 2011 6:45 pm

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
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany


Return to Developer Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest