img2.clearAnnotationLinks did work.
- Code: Select all
img_id2 = 18683;
ma2 = getObjectAnnotations(session, 'map', 'image', img_id2);
images2 = session.getQueryService().findAllByQuery(...
['select img from Image as img left outer join fetch img.annotationLinks as link join fetch link.child as annotation where img.id = ', ...
num2str(img_id2)], []);
img2 = images2.get(0)
img2.clearAnnotationLinks
img2 = session.getUpdateService().saveAndReturnObject(img2);
ma3 = getObjectAnnotations(session, 'map', 'image', img_id2);
% ma3 is empty
However, img2.unlinkAnnotation(ma2) did not work. It's shame because it can be more useful if I can unlink annotations specifically. I'm wondering why this does not work. Again, API documentation doesn't really help, so I need to ask you.
- Code: Select all
img_id2 = 18683;
ma2 = getObjectAnnotations(session, 'map', 'image', img_id2);
images2 = session.getQueryService().findAllByQuery(...
['select img from Image as img left outer join fetch img.annotationLinks as link join fetch link.child as annotation where img.id = ', ...
num2str(img_id2)], []);
img2 = images2.get(0)
img2.unlinkAnnotation(ma2)
img2 = session.getUpdateService().saveAndReturnObject(img2);
ma3 = getObjectAnnotations(session, 'map', 'image', img_id2);
% ma3 is not empty