We're Hiring!

change group via blitz

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.

change group via blitz

Postby derekeh » Mon May 06, 2019 9:48 am

Hi,
Can you tell me the correct way to invoke Chgrp2() from my java app using the blitz API?

I have the securityContext of the user and from that the groupIDs for the groups that the user belongs to.
The user belongs to a private and a public group.
I want to be able to move a user's Project (including datasets and annotations) from public to private and vice versa.

Thanks
Derek
derekeh
 
Posts: 31
Joined: Mon Feb 12, 2018 12:00 pm

Re: change group via blitz

Postby derekeh » Tue May 07, 2019 8:45 am

Omero 5.4.0

I've got this far:

Code: Select all
long ProjectId=503;
long toGroupId=53;
Chgrp2 chgrp2 = Requests.chgrp().target("Project").id(ProjectId).toGroup(toGroupId).build();


Do I need to now run the request?? or what?
derekeh
 
Posts: 31
Joined: Mon Feb 12, 2018 12:00 pm

Re: change group via blitz

Postby Dominik » Tue May 07, 2019 9:33 am

You're pretty close. Just have to submit the chgrp2 request and wait for its execution:
Code: Select all
Chgrp2 chgrp2 = Requests.chgrp().target("Project").id(ProjectId).toGroup(toGroupId).build();
CmdCallbackI cb = gw.submit(ctx, chgrp2);
Response res = cb.loop(5, 500);

(gw is the Java Gateway omero.gateway.Gateway)

The group of the SecurityContext ctx doesn't matter in that case.

There should definitely be an easier way in the Java Gateway to do things like that, I'll add that to
the ToDo board.

Regards,
Dominik
User avatar
Dominik
Team Member
 
Posts: 149
Joined: Mon Feb 10, 2014 11:26 am

Re: change group via blitz

Postby derekeh » Tue May 07, 2019 9:52 am

Many thanks for the magic lines Dominik.
All good now.

Derek
derekeh
 
Posts: 31
Joined: Mon Feb 12, 2018 12:00 pm


Return to Developer Discussion

Who is online

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

cron