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));
}
}
Aggregations