Page 1 of 1

change group via blitz

PostPosted: Mon May 06, 2019 9:48 am
by derekeh
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

Re: change group via blitz

PostPosted: Tue May 07, 2019 8:45 am
by derekeh
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?

Re: change group via blitz

PostPosted: Tue May 07, 2019 9:33 am
by Dominik
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

Re: change group via blitz

PostPosted: Tue May 07, 2019 9:52 am
by derekeh
Many thanks for the magic lines Dominik.
All good now.

Derek