Package omeroweb :: Package webclient :: Package controller :: Module container
[hide private]
[frames] | no frames]

Source Code for Module omeroweb.webclient.controller.container

   1  #!/usr/bin/env python 
   2  #  
   3  #  
   4  #  
   5  # Copyright (c) 2008-2011 University of Dundee. 
   6  #  
   7  # This program is free software: you can redistribute it and/or modify 
   8  # it under the terms of the GNU Affero General Public License as 
   9  # published by the Free Software Foundation, either version 3 of the 
  10  # License, or (at your option) any later version. 
  11  #  
  12  # This program is distributed in the hope that it will be useful, 
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  15  # GNU Affero General Public License for more details. 
  16  #  
  17  # You should have received a copy of the GNU Affero General Public License 
  18  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
  19  #  
  20  # Author: Aleksandra Tarkowska <A(dot)Tarkowska(at)dundee(dot)ac(dot)uk>, 2008. 
  21  #  
  22  # Version: 1.0 
  23  # 
  24   
  25  import omero 
  26  from omero.rtypes import * 
  27  from django.core.urlresolvers import reverse 
  28  from django.utils.encoding import smart_str 
  29  import logging 
  30   
  31  logger = logging.getLogger('web-container') 
  32   
  33  from webclient.controller import BaseController 
  34   
35 -class BaseContainer(BaseController):
36 37 project = None 38 screen = None 39 dataset = None 40 plate = None 41 acquisition = None 42 well = None 43 image = None 44 tag = None 45 file = None 46 comment = None 47 tags = None 48 49 index = None 50 containers = None 51 experimenter = None 52 53 c_size = 0 54 55 text_annotations = None 56 txannSize = 0 57 long_annotations = None 58 file_annotations = None 59 60 orphaned = False 61
62 - def __init__(self, conn, project=None, dataset=None, image=None, screen=None, plate=None, acquisition=None, well=None, tag=None, tagset=None, file=None, comment=None, annotation=None, index=None, orphaned=None, **kw):
63 BaseController.__init__(self, conn) 64 if project is not None: 65 self.project = self.conn.getObject("Project", project) 66 if self.project is None: 67 raise AttributeError("We are sorry, but that project (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(project)) 68 if self.project._obj is None: 69 raise AttributeError("We are sorry, but that project (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(project)) 70 if dataset is not None: 71 self.dataset = self.conn.getObject("Dataset", dataset) 72 if self.dataset is None: 73 raise AttributeError("We are sorry, but that dataset (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(dataset)) 74 if self.dataset._obj is None: 75 raise AttributeError("We are sorry, but that dataset (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(dataset)) 76 if screen is not None: 77 self.screen = self.conn.getObject("Screen", screen) 78 if self.screen is None: 79 raise AttributeError("We are sorry, but that screen (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(screen)) 80 if self.screen._obj is None: 81 raise AttributeError("We are sorry, but that screen (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(screen)) 82 if plate is not None: 83 self.plate = self.conn.getObject("Plate", plate) 84 if self.plate is None: 85 raise AttributeError("We are sorry, but that plate (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(plate)) 86 if self.plate._obj is None: 87 raise AttributeError("We are sorry, but that plate (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(plate)) 88 if acquisition is not None: 89 self.acquisition = self.conn.getObject("PlateAcquisition", acquisition) 90 if self.acquisition is None: 91 raise AttributeError("We are sorry, but that plate acquisition (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(acquisition)) 92 if self.acquisition._obj is None: 93 raise AttributeError("We are sorry, but that plate acquisition (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(acquisition)) 94 if image is not None: 95 self.image = self.conn.getObject("Image", image) 96 if self.image is None: 97 raise AttributeError("We are sorry, but that image (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(image)) 98 if self.image._obj is None: 99 raise AttributeError("We are sorry, but that image (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(image)) 100 if well is not None: 101 self.well = self.conn.getObject("Well", well) 102 if self.well is None: 103 raise AttributeError("We are sorry, but that well (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(well)) 104 if self.well._obj is None: 105 raise AttributeError("We are sorry, but that well (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(well)) 106 if index is not None: 107 self.well.index = index 108 if tag is not None: 109 self.tag = self.conn.getObject("Annotation", tag) 110 if self.tag is None: 111 raise AttributeError("We are sorry, but that tag (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(tag)) 112 if self.tag._obj is None: 113 raise AttributeError("We are sorry, but that tag (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(tag)) 114 if tagset is not None: 115 self.tag = self.conn.getObject("Annotation", tagset) 116 if self.tag is None: 117 raise AttributeError("We are sorry, but that tag (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(tag)) 118 if self.tag._obj is None: 119 raise AttributeError("We are sorry, but that tag (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(tag)) 120 if comment is not None: 121 self.comment = self.conn.getObject("Annotation", comment) 122 if self.comment is None: 123 raise AttributeError("We are sorry, but that comment (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(comment)) 124 if self.comment._obj is None: 125 raise AttributeError("We are sorry, but that comment (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(comment)) 126 if file is not None: 127 self.file = self.conn.getObject("Annotation", file) 128 if self.file is None: 129 raise AttributeError("We are sorry, but that file (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(file)) 130 if self.file._obj is None: 131 raise AttributeError("We are sorry, but that file (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(file)) 132 if annotation is not None: 133 self.annotation = self.conn.getObject("Annotation", annotation) 134 if self.annotation is None: 135 raise AttributeError("We are sorry, but that annotation (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(annotation)) 136 if self.annotation._obj is None: 137 raise AttributeError("We are sorry, but that annotation (id:%s) does not exist, or if it does, you have no permission to see it. Contact the user you think might share that data with you." % str(annotation)) 138 if orphaned: 139 self.orphaned = True
140
141 - def openAstexViewerCompatible(self):
142 """ 143 Is the image suitable to be viewed with the Volume viewer 'Open Astex Viewer' applet? 144 Image must be a 'volume' of suitable dimensions and not too big. 145 """ 146 from django.conf import settings 147 MAX_SIDE = settings.OPEN_ASTEX_MAX_SIDE # default is 400 148 MIN_SIDE = settings.OPEN_ASTEX_MIN_SIDE # default is 20 149 MAX_VOXELS = settings.OPEN_ASTEX_MAX_VOXELS # default is 15625000 (250 * 250 * 250) 150 151 print "Max side, min side, max voxels", MAX_SIDE, MIN_SIDE, MAX_VOXELS 152 if self.image is None: 153 return False 154 sizeZ = self.image.getSizeZ() 155 if self.image.getSizeC() > 1: return False 156 sizeX = self.image.getSizeX() 157 sizeY = self.image.getSizeY() 158 if sizeZ < MIN_SIDE or sizeX < MIN_SIDE or sizeY < MIN_SIDE: return False 159 if sizeX > MAX_SIDE or sizeY > MAX_SIDE or sizeZ > MAX_SIDE: return False 160 voxelCount = (sizeX * sizeY * sizeZ) 161 if voxelCount > MAX_VOXELS: return False 162 163 try: # if scipy ndimage is not available for interpolation, can only handle smaller images 164 import scipy.ndimage 165 except ImportError: 166 logger.debug("Failed to import scipy.ndimage - Open Astex Viewer limited to display of smaller images.") 167 MAX_VOXELS = (160 * 160 * 160) 168 if voxelCount > MAX_VOXELS: return False 169 170 return True
171
172 - def formatMetadataLine(self, l):
173 if len(l) < 1: 174 return None 175 return l.split("=")
176
177 - def originalMetadata(self):
178 # TODO: hardcoded values. 179 self.global_metadata = list() 180 self.series_metadata = list() 181 if self.image is not None: 182 om = self.image.loadOriginalMetadata() 183 elif self.well.getWellSample().image is not None: 184 om = self.well.getWellSample().image().loadOriginalMetadata() 185 if om is not None: 186 self.original_metadata = om[0] 187 self.global_metadata = om[1] 188 self.series_metadata = om[2]
189
190 - def channelMetadata(self):
191 self.channel_metadata = None 192 try: 193 if self.image is not None: 194 self.channel_metadata = self.image.getChannels() 195 elif self.well is not None: 196 self.channel_metadata = self.well.getWellSample().image().getChannels() 197 except: 198 pass 199 200 if self.channel_metadata is None: 201 self.channel_metadata = list()
202
203 - def loadTags(self, eid=None):
204 if eid is not None: 205 self.experimenter = self.conn.getObject("Experimenter", eid) 206 else: 207 eid = self.conn.getEventContext().userId 208 209 self.tags = list(self.conn.listTags(eid)) 210 self.t_size = len(self.tags)
211
212 - def loadDataByTag(self):
213 pr_list = list(self.conn.getObjectsByAnnotations('Project',[self.tag.id])) 214 ds_list = list(self.conn.getObjectsByAnnotations('Dataset',[self.tag.id])) 215 im_list = list(self.conn.getObjectsByAnnotations('Image',[self.tag.id])) 216 sc_list = list(self.conn.getObjectsByAnnotations('Screen',[self.tag.id])) 217 pl_list = list(self.conn.getObjectsByAnnotations('Plate',[self.tag.id])) 218 219 pr_list_with_counters = list() 220 ds_list_with_counters = list() 221 im_list_with_counters = list() 222 sc_list_with_counters = list() 223 pl_list_with_counters = list() 224 225 pr_ids = [pr.id for pr in pr_list] 226 if len(pr_ids) > 0: 227 pr_annotation_counter = self.conn.getCollectionCount("Project", "annotationLinks", pr_ids) 228 229 for pr in pr_list: 230 pr.annotation_counter = pr_annotation_counter.get(pr.id) 231 pr_list_with_counters.append(pr) 232 233 ds_ids = [ds.id for ds in ds_list] 234 if len(ds_ids) > 0: 235 ds_annotation_counter = self.conn.getCollectionCount("Dataset", "annotationLinks", ds_ids) 236 237 for ds in ds_list: 238 ds.annotation_counter = ds_annotation_counter.get(ds.id) 239 ds_list_with_counters.append(ds) 240 241 im_ids = [im.id for im in im_list] 242 if len(im_ids) > 0: 243 im_annotation_counter = self.conn.getCollectionCount("Image", "annotationLinks", im_ids) 244 245 for im in im_list: 246 im.annotation_counter = im_annotation_counter.get(im.id) 247 im_list_with_counters.append(im) 248 249 sc_ids = [sc.id for sc in sc_list] 250 if len(sc_ids) > 0: 251 sc_annotation_counter = self.conn.getCollectionCount("Screen", "annotationLinks", sc_ids) 252 253 for sc in sc_list: 254 sc.annotation_counter = sc_annotation_counter.get(sc.id) 255 sc_list_with_counters.append(sc) 256 257 pl_ids = [pl.id for pl in pl_list] 258 if len(pl_ids) > 0: 259 pl_annotation_counter = self.conn.getCollectionCount("Plate", "annotationLinks", pl_ids) 260 261 for pl in pl_list: 262 pl.annotation_counter = pl_annotation_counter.get(pl.id) 263 pl_list_with_counters.append(pl) 264 265 self.containers={'projects': pr_list_with_counters, 'datasets': ds_list_with_counters, 'images': im_list_with_counters, 'screens':sc_list_with_counters, 'plates':pl_list_with_counters} 266 self.c_size = len(pr_list_with_counters)+len(ds_list_with_counters)+len(im_list_with_counters)+len(sc_list_with_counters)+len(pl_list_with_counters)
267
268 - def listImagesInDataset(self, did, eid=None, page=None):
269 if eid is not None: 270 self.experimenter = self.conn.getObject("Experimenter", eid) 271 272 im_list = list(self.conn.listImagesInDataset(oid=did, eid=eid, page=page)) 273 # Not displaying annotation icons (same as Insight). #5514. 274 #im_list_with_counters = list() 275 276 #im_ids = [im.id for im in im_list] 277 #if len(im_ids) > 0: 278 # im_annotation_counter = self.conn.getCollectionCount("Image", "annotationLinks", im_ids) 279 280 # for im in im_list: 281 # im.annotation_counter = im_annotation_counter.get(im.id) 282 # im_list_with_counters.append(im) 283 284 im_list_with_counters = im_list 285 im_list_with_counters.sort(key=lambda x: x.getName().lower()) 286 self.containers = {'images': im_list_with_counters} 287 self.c_size = self.conn.getCollectionCount("Dataset", "imageLinks", [long(did)])[long(did)] 288 289 if page is not None: 290 self.paging = self.doPaging(page, len(im_list_with_counters), self.c_size)
291
292 - def listContainerHierarchy(self, eid=None):
293 if eid is not None: 294 self.experimenter = self.conn.getObject("Experimenter", eid) 295 else: 296 eid = self.conn.getEventContext().userId 297 298 pr_list = list(self.conn.listProjects(eid)) 299 ds_list = list(self.conn.listOrphans("Dataset", eid)) 300 sc_list = list(self.conn.listScreens(eid)) 301 pl_list = list(self.conn.listOrphans("Plate", eid)) 302 303 pr_list_with_counters = list() 304 ds_list_with_counters = list() 305 sc_list_with_counters = list() 306 pl_list_with_counters = list() 307 308 pr_ids = [pr.id for pr in pr_list] 309 if len(pr_ids) > 0: 310 pr_annotation_counter = self.conn.getCollectionCount("Project", "annotationLinks", pr_ids) 311 312 for pr in pr_list: 313 pr.annotation_counter = pr_annotation_counter.get(pr.id) 314 pr_list_with_counters.append(pr) 315 316 ds_ids = [ds.id for ds in ds_list] 317 if len(ds_ids) > 0: 318 ds_annotation_counter = self.conn.getCollectionCount("Dataset", "annotationLinks", ds_ids) 319 320 for ds in ds_list: 321 ds.annotation_counter = ds_annotation_counter.get(ds.id) 322 ds_list_with_counters.append(ds) 323 324 sc_ids = [sc.id for sc in sc_list] 325 if len(sc_ids) > 0: 326 sc_annotation_counter = self.conn.getCollectionCount("Screen", "annotationLinks", sc_ids) 327 328 for sc in sc_list: 329 sc.annotation_counter = sc_annotation_counter.get(sc.id) 330 sc_list_with_counters.append(sc) 331 332 pl_ids = [pl.id for pl in pl_list] 333 if len(pl_ids) > 0: 334 pl_annotation_counter = self.conn.getCollectionCount("Plate", "annotationLinks", ds_ids) 335 336 for pl in pl_list: 337 pl.annotation_counter = pl_annotation_counter.get(pl.id) 338 pl_list_with_counters.append(pl) 339 340 pr_list_with_counters.sort(key=lambda x: x.getName() and x.getName().lower()) 341 ds_list_with_counters.sort(key=lambda x: x.getName() and x.getName().lower()) 342 sc_list_with_counters.sort(key=lambda x: x.getName() and x.getName().lower()) 343 pl_list_with_counters.sort(key=lambda x: x.getName() and x.getName().lower()) 344 345 self.orphans = self.conn.countOrphans("Image", eid) 346 347 self.containers={'projects': pr_list_with_counters, 'datasets': ds_list_with_counters, 'screens': sc_list_with_counters, 'plates': pl_list_with_counters} 348 self.c_size = len(pr_list_with_counters)+len(ds_list_with_counters)+len(sc_list_with_counters)+len(pl_list_with_counters)
349
350 - def listOrphanedImages(self, eid=None, page=None):
351 if eid is not None: 352 self.experimenter = self.conn.getObject("Experimenter", eid) 353 else: 354 eid = self.conn.getEventContext().userId 355 356 im_list = list(self.conn.listOrphans("Image", eid=eid, page=page)) 357 # Not displaying annotation icons (same as Insight). #5514. 358 #im_list_with_counters = list() 359 360 #im_ids = [im.id for im in im_list] 361 #if len(im_ids) > 0: 362 #im_annotation_counter = self.conn.getCollectionCount("Image", "annotationLinks", im_ids) 363 364 #for im in im_list: 365 #im.annotation_counter = im_annotation_counter.get(im.id) 366 #im_list_with_counters.append(im) 367 368 im_list_with_counters = im_list 369 im_list_with_counters.sort(key=lambda x: x.getName().lower()) 370 self.containers = {'orphaned': True, 'images': im_list_with_counters} 371 self.c_size = self.conn.countOrphans("Image", eid=eid) 372 373 if page is not None: 374 self.paging = self.doPaging(page, len(im_list_with_counters), self.c_size)
375 376 # Annotation list
377 - def annotationList(self):
378 self.text_annotations = list() 379 self.rating_annotations = list() 380 self.file_annotations = list() 381 self.tag_annotations = list() 382 self.xml_annotations = list() 383 self.boolean_annotations = list() 384 self.double_annotations = list() 385 self.long_annotations = list() 386 self.term_annotations = list() 387 self.time_annotations = list() 388 self.companion_files = list() 389 390 annTypes = {omero.model.CommentAnnotationI: self.text_annotations, 391 omero.model.LongAnnotationI: self.long_annotations, 392 omero.model.FileAnnotationI: self.file_annotations, 393 omero.model.TagAnnotationI: self.tag_annotations, 394 omero.model.XmlAnnotationI: self.xml_annotations, 395 omero.model.BooleanAnnotationI: self.boolean_annotations, 396 omero.model.DoubleAnnotationI: self.double_annotations, 397 omero.model.TermAnnotationI: self.term_annotations, 398 omero.model.TimestampAnnotationI: self.time_annotations} 399 400 aList = list() 401 if self.image is not None: 402 aList = list(self.image.listAnnotations()) 403 elif self.dataset is not None: 404 aList = list(self.dataset.listAnnotations()) 405 elif self.project is not None: 406 aList = list(self.project.listAnnotations()) 407 elif self.screen is not None: 408 aList = list(self.screen.listAnnotations()) 409 elif self.plate is not None: 410 aList = list(self.plate.listAnnotations()) 411 elif self.acquisition is not None: 412 aList = list(self.acquisition.listAnnotations()) 413 elif self.well is not None: 414 aList = list(self.well.getWellSample().image().listAnnotations()) 415 416 for ann in aList: 417 annClass = ann._obj.__class__ 418 if annClass in annTypes: 419 if ann.ns == omero.constants.metadata.NSINSIGHTRATING: 420 self.rating_annotations.append(ann) 421 elif ann.ns == omero.constants.namespaces.NSCOMPANIONFILE: 422 if ann.getFileName != omero.constants.annotation.file.ORIGINALMETADATA: 423 self.companion_files.append(ann) 424 else: 425 annTypes[annClass].append(ann) 426 427 self.text_annotations.sort(key=lambda x: x.creationEventDate(), reverse=True) 428 self.file_annotations.sort(key=lambda x: x.creationEventDate()) 429 self.rating_annotations.sort(key=lambda x: x.creationEventDate()) 430 self.tag_annotations.sort(key=lambda x: x.textValue) 431 432 self.txannSize = len(self.text_annotations) 433 self.fileannSize = len(self.file_annotations) 434 self.tgannSize = len(self.tag_annotations)
435 436
437 - def getTagsByObject(self):
438 eid = self.conn.getGroupFromContext().isReadOnly() and self.conn.getEventContext().userId or None 439 440 if self.image is not None: 441 return list(self.image.listOrphanedAnnotations(eid=eid, anntype='Tag')) 442 elif self.dataset is not None: 443 return list(self.dataset.listOrphanedAnnotations(eid=eid, anntype='Tag')) 444 elif self.project is not None: 445 return list(self.project.listOrphanedAnnotations(eid=eid, anntype='Tag')) 446 elif self.well is not None: 447 return list(self.well.getWellSample().image().listOrphanedAnnotations(eid=eid, anntype='Tag')) 448 elif self.plate is not None: 449 return list(self.plate.listOrphanedAnnotations(eid=eid, anntype='Tag')) 450 elif self.screen is not None: 451 return list(self.screen.listOrphanedAnnotations(eid=eid, anntype='Tag')) 452 else: 453 eid = self.conn.getGroupFromContext().isReadOnly() and self.conn.getEventContext().userId or None 454 if eid is not None: 455 params = omero.sys.Parameters() 456 params.theFilter = omero.sys.Filter() 457 params.theFilter.ownerId = omero.rtypes.rlong(eid) 458 return list(self.conn.getObjects("TagAnnotation", params=params)) 459 return list(self.conn.getObjects("TagAnnotation"))
460
461 - def getFilesByObject(self):
462 eid = self.conn.getGroupFromContext().isReadOnly() and self.conn.getEventContext().userId or None 463 ns = [omero.constants.namespaces.NSCOMPANIONFILE, omero.constants.namespaces.NSEXPERIMENTERPHOTO] 464 465 if self.image is not None: 466 return list(self.image.listOrphanedAnnotations(eid=eid, ns=ns, anntype='File')) 467 elif self.dataset is not None: 468 return list(self.dataset.listOrphanedAnnotations(eid=eid, ns=ns, anntype='File')) 469 elif self.project is not None: 470 return list(self.project.listOrphanedAnnotations(eid=eid, ns=ns, anntype='File')) 471 elif self.well is not None: 472 return list(self.well.getWellSample().image().listOrphanedAnnotations(eid=eid, ns=ns, anntype='File')) 473 elif self.plate is not None: 474 return list(self.plate.listOrphanedAnnotations(eid=eid, ns=ns, anntype='File')) 475 elif self.screen is not None: 476 return list(self.screen.listOrphanedAnnotations(eid=eid, ns=ns, anntype='File')) 477 else: 478 eid = self.conn.getGroupFromContext().isReadOnly() and self.conn.getEventContext().userId or None 479 if eid is not None: 480 params = omero.sys.Parameters() 481 params.theFilter = omero.sys.Filter() 482 params.theFilter.ownerId = omero.rtypes.rlong(eid) 483 return list(self.conn.listFileAnnotations(params=params)) 484 return list(self.conn.listFileAnnotations())
485 #################################################################### 486 # Creation 487
488 - def createDataset(self, name, description=None):
489 ds = omero.model.DatasetI() 490 ds.name = rstring(str(name)) 491 if description is not None and description != "" : 492 ds.description = rstring(str(description)) 493 if self.project is not None: 494 l_ds = omero.model.ProjectDatasetLinkI() 495 l_ds.setParent(self.project._obj) 496 l_ds.setChild(ds) 497 ds.addProjectDatasetLink(l_ds) 498 return self.conn.saveAndReturnId(ds)
499
500 - def createProject(self, name, description=None):
501 pr = omero.model.ProjectI() 502 pr.name = rstring(str(name)) 503 if description is not None and description != "" : 504 pr.description = rstring(str(description)) 505 return self.conn.saveAndReturnId(pr)
506
507 - def createScreen(self, name, description=None):
508 sc = omero.model.ScreenI() 509 sc.name = rstring(str(name)) 510 if description is not None and description != "" : 511 sc.description = rstring(str(description)) 512 return self.conn.saveAndReturnId(sc)
513 514 # Comment annotation
515 - def createCommentAnnotation(self, otype, content):
516 otype = str(otype).lower() 517 if not otype in ("project", "dataset", "image", "screen", "plate", "acquisition", "well"): 518 raise AttributeError("Object type must be: project, dataset, image, screen, plate, acquisition, well. ") 519 if otype == 'well': 520 otype = 'Image' 521 selfobject = self.well.getWellSample().image() 522 elif otype == 'acquisition': 523 otype = 'PlateAcquisition' 524 selfobject = self.acquisition 525 else: 526 selfobject = getattr(self, otype) 527 otype = otype.title() 528 529 ann = omero.model.CommentAnnotationI() 530 ann.textValue = rstring(str(content)) 531 l_ann = getattr(omero.model, otype+"AnnotationLinkI")() 532 l_ann.setParent(selfobject._obj) 533 l_ann.setChild(ann) 534 self.conn.saveObject(l_ann)
535 536 # Tag annotation
537 - def createTagAnnotationOnly(self, tag, desc):
538 ann = None 539 try: 540 ann = self.conn.findTag(tag, desc)._obj 541 except: 542 pass 543 if ann is None: 544 ann = omero.model.TagAnnotationI() 545 ann.textValue = rstring(str(tag)) 546 ann.setDescription(rstring(str(desc))) 547 self.conn.saveObject(ann)
548
549 - def createTagAnnotation(self, otype, tag, desc):
550 otype = str(otype).lower() 551 if not otype in ("project", "dataset", "image", "screen", "plate", "acquisition", "well"): 552 raise AttributeError("Object type must be: project, dataset, image, screen, plate, acquisition, well. ") 553 if otype == 'well': 554 otype = 'Image' 555 selfobject = self.well.getWellSample().image() 556 elif otype == 'acquisition': 557 otype = 'PlateAcquisition' 558 selfobject = self.acquisition 559 else: 560 selfobject = getattr(self, otype) 561 otype = otype.title() 562 563 ann = None 564 try: 565 ann = self.conn.findTag(tag, desc)._obj 566 except: 567 pass 568 if ann is None: 569 ann = omero.model.TagAnnotationI() 570 ann.textValue = rstring(str(tag)) 571 ann.setDescription(rstring(str(desc))) 572 t_ann = getattr(omero.model, otype+"AnnotationLinkI")() 573 t_ann.setParent(selfobject._obj) 574 t_ann.setChild(ann) 575 self.conn.saveObject(t_ann) 576 else: 577 # Tag exists - check it isn't already linked to parent by this user 578 params = omero.sys.Parameters() 579 params.theFilter = omero.sys.Filter() 580 params.theFilter.ownerId = rlong(self.conn.getUser().id) # linked by current user 581 links = self.conn.getAnnotationLinks(otype, parent_ids=[selfobject.id], ann_ids=[ann.id.val], params=params) 582 links = list(links) 583 if len(links) == 0: # current user has not already tagged this object 584 t_ann = getattr(omero.model, otype+"AnnotationLinkI")() 585 t_ann.setParent(selfobject._obj) 586 t_ann.setChild(ann) 587 self.conn.saveObject(t_ann)
588
589 - def checkMimetype(self, file_type):
590 if file_type is None or len(file_type) == 0: 591 file_type = "application/octet-stream" 592 return file_type
593
594 - def createFileAnnotation(self, otype, newFile):
595 otype = str(otype).lower() 596 if not otype in ("project", "dataset", "image", "screen", "plate", "acquisition", "well"): 597 raise AttributeError("Object type must be: project, dataset, image, screen, plate, acquisition, well. ") 598 if otype == 'well': 599 otype = 'Image' 600 selfobject = self.well.getWellSample().image() 601 elif otype == 'acquisition': 602 otype = 'PlateAcquisition' 603 selfobject = self.acquisition 604 else: 605 selfobject = getattr(self, otype) 606 otype = otype.title() 607 608 format = self.checkMimetype(newFile.content_type) 609 610 oFile = omero.model.OriginalFileI() 611 oFile.setName(rstring(smart_str(newFile.name))); 612 oFile.setPath(rstring(smart_str(newFile.name))); 613 oFile.setSize(rlong(long(newFile.size))); 614 oFile.setSha1(rstring("pending")); 615 oFile.setMimetype(rstring(str(format))); 616 617 ofid = self.conn.saveAndReturnId(oFile); 618 of = self.conn.saveAndReturnFile(newFile, ofid) 619 620 fa = omero.model.FileAnnotationI() 621 fa.setFile(of) 622 l_ia = getattr(omero.model, otype+"AnnotationLinkI")() 623 l_ia.setParent(selfobject._obj) 624 l_ia.setChild(fa) 625 self.conn.saveObject(l_ia)
626
627 - def createCommentAnnotations(self, content, oids):
628 ann = omero.model.CommentAnnotationI() 629 ann.textValue = rstring(str(content)) 630 ann = self.conn.saveAndReturnObject(ann) 631 632 new_links = list() 633 for k in oids.keys(): 634 if len(oids[k]) > 0: 635 for ob in oids[k]: 636 if isinstance(ob._obj, omero.model.WellI): 637 t = 'Image' 638 obj = ob.getWellSample().image() 639 elif isinstance(ob._obj, omero.model.PlateAcquisitionI): 640 t = 'PlateAcquisition' 641 obj = ob 642 else: 643 t = k.lower().title() 644 obj = ob 645 l_ann = getattr(omero.model, t+"AnnotationLinkI")() 646 l_ann.setParent(obj._obj) 647 l_ann.setChild(ann._obj) 648 new_links.append(l_ann) 649 650 if len(new_links) > 0 : 651 self.conn.saveArray(new_links)
652
653 - def createTagAnnotations(self, tag, desc, oids):
654 ann = None 655 try: 656 ann = self.conn.findTag(tag, desc) 657 except: 658 pass 659 if ann is None: 660 ann = omero.model.TagAnnotationI() 661 ann.textValue = rstring(str(tag)) 662 ann.setDescription(rstring(str(desc))) 663 ann = self.conn.saveAndReturnObject(ann) 664 665 new_links = list() 666 for k in oids: 667 if len(oids[k]) > 0: 668 for ob in oids[k]: 669 if isinstance(ob._obj, omero.model.WellI): 670 t = 'Image' 671 obj = ob.getWellSample().image() 672 elif isinstance(ob._obj, omero.model.PlateAcquisitionI): 673 t = 'PlateAcquisition' 674 obj = ob 675 else: 676 t = k.lower().title() 677 obj = ob 678 l_ann = getattr(omero.model, t+"AnnotationLinkI")() 679 l_ann.setParent(obj._obj) 680 l_ann.setChild(ann._obj) 681 new_links.append(l_ann) 682 if len(new_links) > 0 : 683 self.conn.saveArray(new_links)
684
685 - def createFileAnnotations(self, newFile, oids):
686 format = self.checkMimetype(newFile.content_type) 687 688 oFile = omero.model.OriginalFileI() 689 oFile.setName(rstring(smart_str(newFile.name))); 690 oFile.setPath(rstring(smart_str(newFile.name))); 691 oFile.setSize(rlong(long(newFile.size))); 692 oFile.setSha1(rstring("pending")); 693 oFile.setMimetype(rstring(str(format))); 694 695 ofid = self.conn.saveAndReturnId(oFile); 696 of = self.conn.saveAndReturnFile(newFile, ofid) 697 698 fa = omero.model.FileAnnotationI() 699 fa.setFile(of) 700 fa = self.conn.saveAndReturnObject(fa) 701 702 new_links = list() 703 for k in oids: 704 if len(oids[k]) > 0: 705 for ob in oids[k]: 706 if isinstance(ob._obj, omero.model.WellI): 707 t = 'Image' 708 obj = ob.getWellSample().image() 709 elif isinstance(ob._obj, omero.model.PlateAcquisitionI): 710 t = 'PlateAcquisition' 711 obj = ob 712 else: 713 t = k.lower().title() 714 obj = ob 715 l_ann = getattr(omero.model, t+"AnnotationLinkI")() 716 l_ann.setParent(obj._obj) 717 l_ann.setChild(fa._obj) 718 new_links.append(l_ann) 719 if len(new_links) > 0 : 720 self.conn.saveArray(new_links)
721 722 # Create links 757 792 793 ################################################################ 794 # Update 795
796 - def updateDescription(self, o_type, o_id, description=None):
797 obj = getattr(self, o_type)._obj 798 if description is not None and description != "" : 799 obj.description = rstring(str(description)) 800 else: 801 obj.description = None 802 self.conn.saveObject(obj)
803
804 - def updateName(self, o_type, o_id, name):
805 obj = getattr(self, o_type)._obj 806 if o_type not in ('tag', 'tagset'): 807 obj.name = rstring(str(name)) 808 else: 809 obj.textValue = rstring(str(name)) 810 self.conn.saveObject(obj)
811
812 - def updateImage(self, name, description=None):
813 img = self.image._obj 814 img.name = rstring(str(name)) 815 if description is not None and description != "" : 816 img.description = rstring(str(description)) 817 else: 818 img.description = None 819 self.conn.saveObject(img)
820
821 - def updateDataset(self, name, description=None):
822 container = self.dataset._obj 823 container.name = rstring(str(name)) 824 if description is not None and description != "" : 825 container.description = rstring(str(description)) 826 else: 827 container.description = None 828 self.conn.saveObject(container)
829
830 - def updatePlate(self, name, description=None):
831 container = self.plate._obj 832 container.name = rstring(str(name)) 833 if description is not None and description != "" : 834 container.description = rstring(str(description)) 835 else: 836 container.description = None 837 self.conn.saveObject(container)
838
839 - def updateProject(self, name, description=None):
840 container = self.project._obj 841 container.name = rstring(str(name)) 842 if description is not None and description != "" : 843 container.description = rstring(str(description)) 844 else: 845 container.description = None 846 self.conn.saveObject(container)
847
848 - def updateScreen(self, name, description=None):
849 container = self.screen._obj 850 container.name = rstring(str(name)) 851 if description is not None and description != "" : 852 container.description = rstring(str(description)) 853 else: 854 container.description = None 855 self.conn.saveObject(container)
856
857 - def saveCommentAnnotation(self, content):
858 ann = self.comment._obj 859 ann.textValue = rstring(str(content)) 860 self.conn.saveObject(ann)
861
862 - def saveTagAnnotation(self, tag, description=None):
863 ann = self.tag._obj 864 ann.textValue = rstring(str(tag)) 865 if description is not None and description != "" : 866 ann.description = rstring(str(description)) 867 else: 868 ann.description = None 869 self.conn.saveObject(ann)
870
871 - def move(self, parent, destination):
872 if self.project is not None: 873 return 'Cannot move project.' 874 elif self.dataset is not None: 875 if destination[0] == 'dataset': 876 return 'Cannot move dataset to dataset' 877 elif destination[0] == 'project': 878 up_pdl = None 879 pdls = self.dataset.getParentLinks() 880 already_there = None 881 882 for pdl in pdls: 883 if pdl.parent.id.val == long(destination[1]): 884 already_there = True 885 if pdl.parent.id.val == long(parent[1]): 886 up_pdl = pdl 887 if already_there: 888 if long(parent[1]) != long(destination[1]): 889 self.conn.deleteObjectDirect(up_pdl._obj) 890 else: 891 new_pr = self.conn.getObject("Project", destination[1]) 892 if parent[0] not in ('experimenter', 'orphaned'): 893 up_pdl.setParent(new_pr._obj) 894 self.conn.saveObject(up_pdl._obj) 895 else: 896 up_pdl = omero.model.ProjectDatasetLinkI() 897 up_pdl.setChild(self.dataset._obj) 898 up_pdl.setParent(new_pr._obj) 899 self.conn.saveObject(up_pdl) 900 elif destination[0] == 'experimenter': 901 up_pdl = None 902 for p in self.dataset.getParentLinks(): 903 if p.parent.id.val == long(parent[1]): 904 up_pdl = p 905 self.conn.deleteObjectDirect(up_pdl._obj) 906 elif destination[0] == 'orphaned': 907 return 'Cannot move dataset to orphaned images.' 908 else: 909 return 'Destination not supported.' 910 elif self.image is not None: 911 if destination[0] == 'dataset': 912 up_dsl = None 913 dsls = self.image.getParentLinks() #gets every links for child 914 already_there = None 915 916 #checks links 917 for dsl in dsls: 918 #if is already linked to destination 919 if dsl.parent.id.val == long(destination[1]): 920 already_there = True 921 # gets old parent to update or delete 922 if dsl.parent.id.val == long(parent[1]): 923 up_dsl = dsl 924 if already_there: 925 # delete link to not duplicate 926 if long(parent[1]) != long(destination[1]): 927 self.conn.deleteObjectDirect(up_dsl._obj) 928 else: 929 # update link to new destination 930 new_ds = self.conn.getObject("Dataset", destination[1]) 931 if parent[0] not in ('experimenter', 'orphaned'): 932 up_dsl.setParent(new_ds._obj) 933 self.conn.saveObject(up_dsl._obj) 934 else: 935 up_dsl = omero.model.DatasetImageLinkI() 936 up_dsl.setChild(self.image._obj) 937 up_dsl.setParent(new_ds._obj) 938 self.conn.saveObject(up_dsl) 939 elif destination[0] == 'project': 940 return 'Cannot move image to project.' 941 elif destination[0] == 'experimenter' or destination[0] == 'orphaned': 942 if parent[0] != destination[0]: 943 up_dsl = None 944 dsls = list(self.image.getParentLinks()) #gets every links for child 945 if len(dsls) == 1: 946 # gets old parent to delete 947 if dsls[0].parent.id.val == long(parent[1]): 948 up_dsl = dsls[0] 949 self.conn.deleteObjectDirect(up_dsl._obj) 950 else: 951 return 'This image is linked in multiple places. Please unlink the image first.' 952 else: 953 return 'Destination not supported.' 954 elif self.screen is not None: 955 return 'Cannot move screen.' 956 elif self.plate is not None: 957 if destination[0] == 'plate': 958 return 'Cannot move plate to plate' 959 elif destination[0] == 'screen': 960 up_spl = None 961 spls = self.plate.getParentLinks() 962 already_there = None 963 964 for spl in spls: 965 if spl.parent.id.val == long(destination[1]): 966 already_there = True 967 if spl.parent.id.val == long(parent[1]): 968 up_spl = spl 969 if already_there: 970 if long(parent[1]) != long(destination[1]): 971 self.conn.deleteObjectDirect(up_spl._obj) 972 else: 973 new_sc = self.conn.getObject("Screen", destination[1]) 974 if parent[0] not in ('experimenter', 'orphaned'): 975 up_spl.setParent(new_sc._obj) 976 self.conn.saveObject(up_spl._obj) 977 else: 978 up_spl = omero.model.ScreenPlateLinkI() 979 up_spl.setChild(self.plate._obj) 980 up_spl.setParent(new_sc._obj) 981 self.conn.saveObject(up_spl) 982 elif destination[0] == 'experimenter' or destination[0] == 'orphaned': 983 if parent[0] != destination[0]: 984 up_spl = None 985 spls = list(self.plate.getParentLinks()) #gets every links for child 986 if len(spls) == 1: 987 # gets old parent to delete 988 if spls[0].parent.id.val == long(parent[1]): 989 up_spl = spls[0] 990 self.conn.deleteObjectDirect(up_spl._obj) 991 else: 992 return 'This plate is linked in multiple places. Please unlink the plate first.' 993 else: 994 return 'Destination not supported.' 995 else: 996 return 'No data was choosen.' 997 return
998
999 - def remove(self, parent):
1000 if self.tag: 1001 for al in self.tag.getParentLinks(str(parent[0]), [long(parent[1])]): 1002 if al is not None and al.details.owner.id.val == self.conn.getUser().id: 1003 self.conn.deleteObjectDirect(al._obj) 1004 elif self.file: 1005 for al in self.file.getParentLinks(str(parent[0]), [long(parent[1])]): 1006 if al is not None and al.details.owner.id.val == self.conn.getUser().id: 1007 self.conn.deleteObjectDirect(al._obj) 1008 elif self.comment: 1009 # remove the comment from specified parent 1010 for al in self.comment.getParentLinks(str(parent[0]), [long(parent[1])]): 1011 if al is not None and al.details.owner.id.val == self.conn.getUser().id: 1012 self.conn.deleteObjectDirect(al._obj) 1013 # if comment is orphan, delete it directly 1014 orphan = True 1015 for parentType in ["Project", "Dataset", "Image", "Screen", "Plate"]: 1016 annLinks = list(self.conn.getAnnotationLinks(parentType, ann_ids=[self.comment.id])) 1017 if len(annLinks) > 0: 1018 orphan = False 1019 break 1020 if orphan: 1021 self.conn.deleteObjectDirect(self.comment._obj) 1022 1023 elif self.dataset is not None: 1024 if parent[0] == 'project': 1025 for pdl in self.dataset.getParentLinks([parent[1]]): 1026 if pdl is not None: 1027 self.conn.deleteObjectDirect(pdl._obj) 1028 elif self.plate is not None: 1029 if parent[0] == 'screen': 1030 for spl in self.plate.getParentLinks([parent[1]]): 1031 if spl is not None: 1032 self.conn.deleteObjectDirect(spl._obj) 1033 elif self.image is not None: 1034 if parent[0] == 'dataset': 1035 for dil in self.image.getParentLinks([parent[1]]): 1036 if dil is not None: 1037 self.conn.deleteObjectDirect(dil._obj) 1038 else: 1039 raise AttributeError("Attribute not specified. Cannot be removed.")
1040
1041 - def removemany(self, images):
1042 if self.dataset is not None: 1043 dil = self.dataset.getParentLinks('image', images) 1044 if dil is not None: 1045 self.conn.deleteObjectDirect(dil._obj) 1046 else: 1047 raise AttributeError("Attribute not specified. Cannot be removed.")
1048 1049 ########################################################## 1050 # Copy 1051
1052 - def paste(self, destination):
1053 if self.project is not None: 1054 return 'Cannot paste project.' 1055 elif self.dataset is not None: 1056 if destination[0] == 'dataset': 1057 return 'Cannot paste dataset to dataset' 1058 elif destination[0] == 'project': 1059 pdls = self.dataset.getParentLinks() 1060 already_there = None 1061 1062 for pdl in pdls: 1063 if pdl.parent.id.val == long(destination[1]): 1064 already_there = True 1065 if already_there: 1066 return 'Dataset is already there.' 1067 else: 1068 new_pr = self.conn.getObject("Project", destination[1]) 1069 up_pdl = omero.model.ProjectDatasetLinkI() 1070 up_pdl.setChild(self.dataset._obj) 1071 up_pdl.setParent(new_pr._obj) 1072 self.conn.saveObject(up_pdl) 1073 else: 1074 return 'Destination not supported.' 1075 elif self.image is not None: 1076 if destination[0] == 'dataset': 1077 dsls = self.image.getParentLinks() #gets every links for child 1078 already_there = None 1079 1080 #checks links 1081 for dsl in dsls: 1082 #if is already linked to destination 1083 if dsl.parent.id.val == long(destination[1]): 1084 already_there = True 1085 if already_there: 1086 return 'Image is already there.' 1087 else: 1088 # update link to new destination 1089 new_ds = self.conn.getObject("Dataset", destination[1]) 1090 up_dsl = omero.model.DatasetImageLinkI() 1091 up_dsl.setChild(self.image._obj) 1092 up_dsl.setParent(new_ds._obj) 1093 self.conn.saveObject(up_dsl) 1094 elif destination[0] == 'project': 1095 return 'Cannot copy image to project.' 1096 else: 1097 return 'Destination not supported.' 1098 elif self.screen is not None: 1099 return 'Cannot paste screen.' 1100 elif self.plate is not None: 1101 if destination[0] == 'plate': 1102 return 'Cannot move plate to plate' 1103 elif destination[0] == 'screen': 1104 spls = self.plate.getParentLinks() 1105 already_there = None 1106 1107 for spl in spls: 1108 if spl.parent.id.val == long(destination[1]): 1109 already_there = True 1110 if already_there: 1111 return 'Plate is already there.' 1112 else: 1113 new_sc = self.conn.getObject("Screen", destination[1]) 1114 up_spl = omero.model.ScreenPlateLinkI() 1115 up_spl.setChild(self.plate._obj) 1116 up_spl.setParent(new_sc._obj) 1117 self.conn.saveObject(up_spl) 1118 else: 1119 return 'Destination not supported.' 1120 else: 1121 return 'No data was choosen.'
1122
1123 - def copyImageToDataset(self, source, destination=None):
1124 if destination is None: 1125 dsls = self.conn.getDatasetImageLinks(source[1]) #gets every links for child 1126 for dsl in dsls: 1127 self.conn.deleteObjectDirect(dsl._obj) 1128 else: 1129 im = self.conn.getObject("Image", source[1]) 1130 ds = self.conn.getObject("Dataset", destination[1]) 1131 new_dsl = omero.model.DatasetImageLinkI() 1132 new_dsl.setChild(im._obj) 1133 new_dsl.setParent(ds._obj) 1134 self.conn.saveObject(new_dsl)
1135
1136 - def copyImagesToDataset(self, images, dataset):
1137 if dataset is not None and dataset[0] is not "dataset": 1138 ims = self.conn.getObjects("Image", images) 1139 ds = self.conn.getObject("Dataset", dataset[1]) 1140 link_array = list() 1141 for im in ims: 1142 new_dsl = omero.model.DatasetImageLinkI() 1143 new_dsl.setChild(im._obj) 1144 new_dsl.setParent(ds._obj) 1145 link_array.append(new_dsl) 1146 self.conn.saveArray(link_array) 1147 raise AttributeError("Destination not supported")
1148
1149 - def copyDatasetToProject(self, source, destination=None):
1150 if destination is not None and destination[0] is not "project": 1151 ds = self.conn.getObject("Dataset", source[1]) 1152 pr = self.conn.getObject("Project", destination[1]) 1153 new_pdl = omero.model.ProjectDatasetLinkI() 1154 new_pdl.setChild(ds._obj) 1155 new_pdl.setParent(pr._obj) 1156 self.conn.saveObject(new_pdl) 1157 raise AttributeError("Destination not supported")
1158
1159 - def copyDatasetsToProject(self, datasets, project):
1160 if project is not None and project[0] is not "project": 1161 dss = self.conn.getObjects("Dataset", datasets) 1162 pr = self.conn.getObject("Project", project[1]) 1163 link_array = list() 1164 for ds in dss: 1165 new_pdl = omero.model.ProjectDatasetLinkI() 1166 new_pdl.setChild(ds._obj) 1167 new_pdl.setParent(pr._obj) 1168 link_array.append(new_pdl) 1169 self.conn.saveArray(link_array) 1170 raise AttributeError("Destination not supported")
1171
1172 - def copyPlateToScreen(self, source, destination=None):
1173 if destination is not None and destination[0] is not "screen": 1174 pl = self.conn.getObject("Plate", source[1]) 1175 sc = self.conn.getObject("Screen", destination[1]) 1176 new_spl = omero.model.ScreenPlateLinkI() 1177 new_spl.setChild(pl._obj) 1178 new_spl.setParent(sc._obj) 1179 self.conn.saveObject(new_spl) 1180 raise AttributeError("Destination not supported")
1181
1182 - def copyPlatesToScreen(self, plates, screen):
1183 if screen is not None and screen[0] is not "screen": 1184 pls = self.conn.getObjects("Plate", plates) 1185 sc = self.conn.getObject("Screen", screen[1]) 1186 link_array = list() 1187 for pl in pls: 1188 new_spl = omero.model.ScreenPlateLinkI() 1189 new_spl.setChild(pl._obj) 1190 new_spl.setParent(sc._obj) 1191 link_array.append(new_spl) 1192 self.conn.saveArray(link_array) 1193 raise AttributeError("Destination not supported")
1194 1195 1196 ########################################################## 1197 # Delete 1198
1199 - def deleteItem(self, child=False, anns=False):
1200 handle = None 1201 if self.image: 1202 handle = self.conn.deleteObjects("Image", [self.image.id], deleteAnns=anns) 1203 elif self.dataset: 1204 handle = self.conn.deleteObjects("Dataset", [self.dataset.id], deleteChildren=child, deleteAnns=anns) 1205 elif self.project: 1206 handle = self.conn.deleteObjects("Project", [self.project.id], deleteChildren=child, deleteAnns=anns) 1207 elif self.screen: 1208 handle = self.conn.deleteObjects("Screen", [self.screen.id], deleteChildren=child, deleteAnns=anns) 1209 elif self.plate: 1210 handle = self.conn.deleteObjects("Plate", [self.plate.id], deleteAnns=anns) 1211 elif self.comment: 1212 handle = self.conn.deleteObjects("Annotation", [self.comment.id], deleteAnns=anns) 1213 elif self.tag: 1214 handle = self.conn.deleteObjects("Annotation", [self.tag.id], deleteAnns=anns) 1215 elif self.file: 1216 handle = self.conn.deleteObjects("Annotation", [self.file.id], deleteAnns=anns) 1217 return handle
1218
1219 - def deleteObjects(self, otype, ids, child=False, anns=False):
1220 return self.conn.deleteObjects(otype, ids, deleteChildren=child, deleteAnns=anns)
1221