Search in sources :

Example 1 with DatasetData

use of omero.gateway.model.DatasetData in project imagej-omero by imagej.

the class ModuleAdapter method attachImagesToDatasets.

/**
 * Attaches the given output images to the datasets of the given input images.
 */
private void attachImagesToDatasets(final List<ImageData> inputImages, final List<ImageData> outputImages, final DataManagerFacility dm, final BrowseFacility browse, SecurityContext ctx) throws DSOutOfServiceException, DSAccessException {
    final HashMap<Long, DatasetData> datasets = new HashMap<>();
    // Get all datasets related to the input images
    // FIXME: ImageData has a getDatasets() method, but it is null since the
    // underlying ImageI is unloaded.
    final Collection<DatasetData> allDatasets = browse.getDatasets(ctx);
    for (DatasetData d : allDatasets) {
        Collection<ImageData> allImages = browse.getImagesForDatasets(ctx, Collections.singleton(d.getId()));
        for (ImageData image : allImages) {
            for (ImageData input : inputImages) {
                if (input.getId() == image.getId())
                    datasets.put(d.getId(), d);
            }
        }
    }
    // attach all output images to these datasets
    if (!datasets.isEmpty()) {
        for (Long id : datasets.keySet()) dm.addImagesToDataset(ctx, outputImages, datasets.get(id));
    }
}
Also used : DatasetData(omero.gateway.model.DatasetData) HashMap(java.util.HashMap) ImageData(omero.gateway.model.ImageData) RLong(omero.RLong)

Aggregations

HashMap (java.util.HashMap)1 RLong (omero.RLong)1 DatasetData (omero.gateway.model.DatasetData)1 ImageData (omero.gateway.model.ImageData)1