Esempio n. 1
0
  /**
   * Uses bulk update
   *
   * @see <a href="http://trac.openmicroscopy.org.uk/ome/ticket/1654">ticket:1654</a>
   */
  private void clearRois(Session session, Image i) {

    int shapeCount =
        execute(
            session,
            i.getId(),
            "delete from Shape where roi.id in "
                + "(select id from Roi roi where roi.image.id = :id)");
    int roiAnnCount =
        execute(
            session,
            i.getId(),
            "delete from RoiAnnotationLink where parent.id in "
                + "(select id from Roi roi where roi.image.id = :id)");
    int roiCount = execute(session, i.getId(), "delete from Roi where image.id = :id");

    if (shapeCount > 0 || roiAnnCount > 0 || roiCount > 0) {
      log.info(
          String.format(
              "Roi delete for image %s :" + " %s rois, %s shapes, %s annotations",
              i.getId(), roiCount, shapeCount, roiAnnCount));
    }
  }
Esempio n. 2
0
  /**
   * Walks the {@link Image} graph collecting unloaded instances of all entities for later delete.
   */
  protected void collect(final UnloadedCollector delete, final Image i) {

    i.collectPixels(
        new CBlock<Pixels>() {

          public Pixels call(IObject object) {

            if (object == null) {
              return null; // EARLY EXIT. Happening due to image_index=1
            }

            Pixels p = (Pixels) object;

            p.eachLinkedOriginalFile(delete);
            p.collectPlaneInfo(delete);

            for (RenderingDef rdef : p.collectSettings((CBlock<RenderingDef>) null)) {

              for (ChannelBinding binding : rdef.unmodifiableWaveRendering()) {
                delete.call(binding);
              }
              delete.call(rdef);
              delete.call(rdef.getQuantization());
            }

            p.collectThumbnails(delete);

            // Why do we set channel to null here and not waveRendering
            // above?
            List<Channel> channels = p.collectChannels((CBlock<Channel>) null);
            for (int i = 0; i < channels.size(); i++) {
              Channel channel = channels.set(i, null);
              delete.call(channel);
              delete.call(channel.getStatsInfo());

              LogicalChannel lc = channel.getLogicalChannel();
              if (lc.sizeOfChannels() < 2) {
                delete.call(lc);
              }
              // delete.call(lc.getLightSource());
              // // TODO lightsource
              // delete.call(lc.getAuxLightSource());
              // // TODO lightsource
              // delete.call(lc.getOtf());
              // delete.call(lc.getDetectorSettings());
              // DetectorSettings ds = lc.getDetectorSettings();
              // delete.call(ds.getDetector());
            }

            delete.call(p);

            return null;
          }
        });

    for (DatasetImageLink link : i.collectDatasetLinks((CBlock<DatasetImageLink>) null)) {
      i.removeDatasetImageLink(link, true);
      delete.call(link);
    }

    for (ImageAnnotationLink link : i.collectAnnotationLinks((CBlock<ImageAnnotationLink>) null)) {
      i.removeImageAnnotationLink(link, true);
      delete.call(link);
    }

    delete.call(i);
  }