Page 1 of 1

Accept Gateway objects in all MATLAB functions

PostPosted: Tue Jan 29, 2019 11:03 am
by Kouichi_C_Nakamura
Now thanks to this topic ( ... f=6&t=8593), with a dependency on Bio-Formats, you can use Jave Gateway from MATLAB. See loadOmeroGateway.m ... 71a8578596

Accept Gateway objects in all (MATLAB) functions

Following the proposal above, I tried to make a MATLAB function``writeMapAnnotation.m`` support Gateway object as well. For that, however, you'll need ExperimenterData (user), a group ID, or SecurityContext (ctx) alongside with Gateway object, because many of omeo.gateway.Facility subclasses require a SecurityContext (ctx) prepared as below:

Code: Select all
ctx = omero.gateway.SecurityContext(user.getGroupId());

In modifying ``writeMapAnnotation.m``, I think the syntaxes like

1. ma = writeMapAnnotation({gateway, user}, keys, values)
2. ma = writeMapAnnotation(gateway, keys, values, user)
3. ma = writeMapAnnotation(gateway, user, keys, values)

are awkward, because they differ from the syntax for the session-client approach.

Do you think one of the examples below is good?

4. ma = writeMapAnnotation(gateway, keys, values, 'user',user)
5. ma = writeMapAnnotation(gateway, keys, values, 'group',groupId)
6. ma = writeMapAnnotation(gateway, keys, values, 'context',ctx)

Or we need to think of something else?

Option 4 is the simplest.

But because writeMapAnnotation already accepts `group` parameter, option 5 can be implemented with the smallest changes in the syntax.

I'd love to hear your thoughts on this.

Re: Accept Gateway objects in all MATLAB functions

PostPosted: Tue Feb 05, 2019 11:15 am
by Dominik
Hi Kouichi,

I don't think you have to pass the user around. The Gateway methods usually need a SecurityContext to determine in which user/group context an action should happen. Typically creating SecurityContext with a group ID is enough. The user is only needed for 'sudo' actions. So I think the easiest way is to simply pass the SecurityContext around, or the group ID in which case you'd have to create a SecurityContext within the method.

Kind Regards,