Skip to content

Commit

Permalink
adjust web to delete ns-anns via their links only
Browse files Browse the repository at this point in the history
  • Loading branch information
mtbc committed Apr 18, 2016
1 parent 67a71ca commit eab13c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
Expand Up @@ -28,7 +28,6 @@
from django.conf import settings
from django.utils.encoding import smart_str
import logging
from omero.cmd import Delete2

from webclient.controller import BaseController

Expand Down Expand Up @@ -1238,29 +1237,10 @@ def remove(self, parents, index, tag_owner_id=None):
self.conn.deleteObject(al._obj)
elif self.comment:
# remove the comment from specified parent
# the comment is automatically deleted when orphaned
for al in self.comment.getParentLinks(dtype, [parentId]):
if al is not None and al.canDelete():
self.conn.deleteObject(al._obj)
# if comment is orphan, delete it directly
orphan = True

# Use delete Dry Run...
cid = self.comment.getId()
command = Delete2(targetObjects={"CommentAnnotation": [cid]},
dryRun=True)
cb = self.conn.c.submit(command)
# ...to check for any remaining links
rsp = cb.getResponse()
cb.close(True)
for parentType in ["Project", "Dataset", "Image", "Screen",
"Plate", "PlateAcquisition", "Well"]:
key = 'ome.model.annotations.%sAnnotationLink' % parentType
if key in rsp.deletedObjects:
orphan = False
break
if orphan:
self.conn.deleteObject(self.comment._obj)

elif self.dataset is not None:
if dtype == 'project':
for pdl in self.dataset.getParentLinks([parentId]):
Expand Down
Expand Up @@ -2145,7 +2145,7 @@ def addRating(value):
ratingAnn.save()
else:
self._conn.deleteObject(ratingLink._obj)
self._conn.deleteObject(ratingAnn._obj)
# ratingAnn was automatically deleted if orphaned
# otherwise, unlink and create a new rating
else:
self._conn.deleteObject(ratingLink._obj)
Expand Down

0 comments on commit eab13c5

Please sign in to comment.