[ome-devel] Accessing OMERO.insight attachements via the API.
josh.moore at gmx.de
josh.moore at gmx.de
Wed Aug 12 09:10:47 BST 2009
Hi Jerome,
chiming in a bit late because of holidays, but if the
unloadCollections() helped solve the issue, then it points to a
non-managed (id==null) link being present in the image already. Then
each time you try to save, the server detects the link and tries to
create it again. Something like:
Image i = ....;
i.linkAnnotation( new TagAnnotationI(1, false) );
update.saveObject( i );
i.linkAnnotation( new TagAnnotationI(2, false) );
update.saveObject( i ); // Throws exception
The second call to saveObject will try to create a second link to tag
#1. One solution is to use an unloaded image (including just unloading
the collections). The other is to always replace the image instance:
i = update.saveAndReturnObject( i );
Cheers,
~Josh
Jerome Avondo writes:
>
> Hi Jmarie,
>
> I still have the problem I described below, I just can't seem to
> figure out how to take an existing fileannotaion and link it to
> another image. I always seem to generate the exception below.
>
> J.
>
> ----------------------------------------
> > From: jeromeavondo at msn.com
> > To: ome-devel at lists.openmicroscopy.org.uk
> > Date: Tue, 28 Jul 2009 15:55:04 +0000
> > Subject: Re: [ome-devel] Accessing OMERO.insight attachements via the API.
> >
> >
> > Hi Bernhard,
> >
> > Yes, I had tried the method you showed below as well. Shame
> > issue. Hadn't realised the log files were more verbose for error
> > messages. Great tip!
> >
> > Looking at the logs, it's complaining about duplicate keys for
> > the parent, ie: Image... So looks like it thinks the link
> > already exists...
> >
> > "
> > Could not synchronize database state with session
> >
> > Caused by: org.postgresql.util.PSQLException: ERROR: duplicate
> > key value violates unique constraint
> > "imageannotationlink_parent_key" "
> >
> > But definitely can't see anything in OMERO.insight.
> >
> > Going to try and look for all the ImageAnnotationLink objects in the database, maybe I when trying a million and one ways I did something to create a bad/corrupt link...
> >
> > J.
> >
> > ----------------------------------------
> >> From: bernhard.voigt at gmail.com
> >> Date: Tue, 28 Jul 2009 15:58:49 +0200
> >> Subject: Re: [ome-devel] Accessing OMERO.insight attachements via the API.
> >> To: jeromeavondo at msn.com
> >> CC: ome-devel at lists.openmicroscopy.org.uk
> >>
> >> Hi Jerome!
> >>
> >> Have you tried just creating the link and saving that (python example):
> >>
> >> link = ImageAnnotationLinkI()
> >> link.parent = ImageI(image_id, False)
> >> link.child = FileAnnotationI(annotation_id, False)
> >> update_service.saveObject(link)
> >>
> >> You would need to reload the image to get the updated annotation list.
> >>
> >> Also it's sometimes useful to look at the Blitz0.log file in the
> >> var/log folder of the server installation. The error messages are more
> >> verbose there and might give a hint what's going wrong in your
> >> example. It might not be correct to create the link via linkAnnotation
> >> and save the link. I would guess you rather have to save the modified
> >> image...
> >>
> >> Hope that helps! Bernhard
> >>
> >>
> >> On Tue, Jul 28, 2009 at 1:59 PM, Jerome Avondo wrote:
> >>>
> >>> Hi again,
> >>>
> >>> Thanks again for the help, I've managed to push forward with all this... But... :)
> >>>
> >>> I'm now trying to write some methods to copy annotations from one object to the other.
> >>> I have no problems with ratings and tags but I'm still finding fileannotations tricky.
> >>>
> >>> Say I have an image, which already has a fileannotation associated with it. Now I want another Image to have the same fileannotation attached to it as well... I don't want to duplicate the file. Just want the second Image pointing to the same file.
> >>>
> >>> so I tried,
> >>>
> >>> using the loadAnnotations() from the IMetadataPrx object, to get all annotations for my ImageID and of type ome.model.annotations.FileAnnotation. Which seems to work fine as I can get to the data that way.
> >>>
> >>> Then I try to set the retrieved FileAnnotation objects to my second Image object, using the Image member function, linkAnnotation(), to create a ImageAnnotationLink which I then save the new link to the database via the gateway saveObject(). But this doesn't work.
> >>>
> >>> When I try and save the link, I get, message = "could not insert: [ome.model.annotations.ImageAnnotationLink]; nested exception is org.hibernate.exception.ConstraintViolationException:"
> >>>
> >>> I also tried creating a new FileAnnotation object, and pointing it to the OriginalFile of the retrieved FileAnnotation. Still same error, when saving the link.
> >>>
> >>> And I also tried retrieving the FileAnnotation or OriginalFile objects by their ids via queries, thinking I might not have the full objects loaded, but same issue...
> >>>
> >>> Running out of ideas, any help welcome....
> >>>
> >>> Thanks,
> >>>
> >>> J.
> >>>
> >>> ________________________________
> >>>> CC: ome-devel at lists.openmicroscopy.org.uk
> >>>> From: j.burel at dundee.ac.uk
> >>>> Subject: Re: [ome-devel] Accessing OMERO.insight attachements via the API.
> >>>> Date: Wed, 22 Jul 2009 16:14:58 +0100
> >>>> To: jeromeavondo at msn.com
> >>>>
> >>>>
> >>>> Hi Jerome
> >>>>
> >>>> If you want to remove the tag, you need to delete the link.
> >>>> We should add some methods to the API to improve the usability
> >>>>
> >>>> Retrieve the link using the findByQuery of the IQuery service i.e.
> >>>> query =
> >>>> "select link from ImageAnnotationLink as link where " +
> >>>> "link.parent.id = :imageID and link.child.id =: tagID";
> >>>>
> >>>> then delete the link
> >>>> using the deleteObject method from the IUpdate service.
> >>>>
> >>>> Hope it helps
> >>>>
> >>>> Jmarie
> >>>
> >>> _________________________________________________________________
> >>> Windows Live Messenger: Happy 10-Year Anniversary$,1rt(Bget free winks and emoticons.
> >>> http://clk.atdmt.com/UKM/go/157562755/direct/01/
> >>> _______________________________________________
> >>> ome-devel mailing list
> >>> ome-devel at lists.openmicroscopy.org.uk
> >>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
> >>>
> >
> > _________________________________________________________________
> > Share your memories online with anyone you want.
> > http://clk.atdmt.com/UKM/go/134665338/direct/01/
> > _________________________________________________________________
> > Share your memories online with anyone you want.
> > http://clk.atdmt.com/UKM/go/134665338/direct/01/
> > _______________________________________________
> > ome-devel mailing list
> > ome-devel at lists.openmicroscopy.org.uk
> > http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
>
> _________________________________________________________________
> Celebrate a decade of Messenger with free winks, emoticons, display pics, and more.
> http://clk.atdmt.com/UKM/go/157562755/direct/01/
> _________________________________________________________________
> Windows Live Messenger: Thanks for 10 great years$,1rt(Benjoy free winks and emoticons.
> http://clk.atdmt.com/UKM/go/157562755/direct/01/
> _______________________________________________
> ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
More information about the ome-devel
mailing list