We're Hiring!

Retrieve NamedValue from MapAnnotation

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.

Retrieve NamedValue from MapAnnotation

Postby derekeh » Wed May 16, 2018 1:12 pm

Hi,
I've got the CommentAnnotations and the TagAnnotations returning from my Java app but I can't seem to get the key/value pairs for the MapAnnotation.
Using OMERO 5.4.0 on Linux Centos 7.
In the following code I've split out each assign to separate lines and used the get(i) function instead of an iterator at present.
The NamedValue: nv_0.getClass.getName() returns omero.model.NamedValue@16c069df
but nv_0.getValue() is not a valid function.
How do I get the value of the current NamedValue, nv_0 ?
Thanks in advance
Derek

Code: Select all
List mapTypes = new ArrayList();
mapTypes.add("ome.model.annotations.MapAnnotation");
Map <Long,Set<Annotation>> mapSetMap = proxy.loadAnnotations("Image", imageIds, mapTypes, annotatorIds, param);
            Iterator mit = mapSetMap.entrySet().iterator();
            while (mit.hasNext()) {
                Map.Entry pair = (Map.Entry)mit.next();
                ArrayList ret = (ArrayList)pair.getValue();
                MapAnnotation mapannot = (MapAnnotation)ret.get(0);
                List<NamedValue> nv = mapannot.getMapValue();
                NamedValue nv_0 = (NamedValue)nv.get(0);

                System.out.println("Named Value type: " + nv_0.getClass().getName());
                System.out.println("Named Value Value: " + nv_0);

                mit.remove();
            }


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

Re: Retrieve NamedValue from MapAnnotation

Postby mtbc » Wed May 16, 2018 1:27 pm

Dear Derek,

You should find that nv_0.name and nv_0.value are simple strings containing what you need.

Cheers,
Mark
User avatar
mtbc
Team Member
 
Posts: 282
Joined: Tue Oct 23, 2012 10:59 am
Location: Dundee, Scotland

Re: Retrieve NamedValue from MapAnnotation

Postby derekeh » Wed May 16, 2018 1:42 pm

Mark,
Thanks for that.
I spent way too much time trying to find that simple answer !

Still, why does the getValue() method not return the same as the API suggests.
What am I missing?

Anyway, thanks to your reply I now have the data back that I want.

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

Re: Retrieve NamedValue from MapAnnotation

Postby mtbc » Wed May 16, 2018 2:27 pm

Dear Derek,

I am glad that that works for you now. You might want to try out different IDEs for developing in Java as some make it easy to see what various object classes offer.

I suspect that the class that you read about offering getValue() is not in the package of the class that you are actually using. :) Many of the classes from the omero.model package appear not to be in any published documentation that I see online. I've made a note that we should look at including them.

Cheers,
Mark
User avatar
mtbc
Team Member
 
Posts: 282
Joined: Tue Oct 23, 2012 10:59 am
Location: Dundee, Scotland


Return to Developer Discussion

Who is online

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

cron