We're Hiring!

Accept Gateway objects in all MATLAB functions

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.

Accept Gateway objects in all MATLAB functions

Postby Kouichi_C_Nakamura » Tue Jan 29, 2019 11:03 am

Now thanks to this topic (http://www.openmicroscopy.org/community ... f=6&t=8593), with a dependency on Bio-Formats, you can use Jave Gateway from MATLAB. See loadOmeroGateway.m https://gist.github.com/kouichi-c-nakam ... 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.
Posts: 165
Joined: Thu Oct 19, 2017 1:35 pm

Re: Accept Gateway objects in all MATLAB functions

Postby Dominik » Tue Feb 05, 2019 11:15 am

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,
User avatar
Team Member
Posts: 149
Joined: Mon Feb 10, 2014 11:26 am

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest