Search in sources :

Example 1 with OriginalFileI

use of omero.model.OriginalFileI in project imagej-omero by imagej.

the class ModuleAdapter method attachTablesToImages.

/**
 * Attaches the tables to the input images. This also adds the Table ids to
 * the omero client.
 */
private void attachTablesToImages(final List<ImageData> images, final HashMap<String, TableData> tables, final SecurityContext ctx, final DataManagerFacility dm) throws DSOutOfServiceException, DSAccessException, ExecutionException, ServerError {
    final TablesFacility tablesFacility = gateway.getFacility(TablesFacility.class);
    for (final String name : tables.keySet()) {
        final TableData t = tablesFacility.addTable(ctx, images.get(0), name, tables.get(name));
        client.setOutput(name, omero.rtypes.rlong(t.getOriginalFileId()));
    }
    // Adding tables again would create new tables on the server
    for (int i = 1; i < images.size(); i++) {
        for (final String name : tables.keySet()) {
            final OriginalFile file = new OriginalFileI(tables.get(name).getOriginalFileId(), false);
            final FileAnnotation anno = new FileAnnotationI();
            anno.setFile(file);
            FileAnnotationData annotation = new FileAnnotationData(anno);
            annotation.setDescription(name);
            annotation = (FileAnnotationData) dm.saveAndReturnObject(ctx, annotation);
            dm.attachAnnotation(ctx, annotation, images.get(i));
        }
    }
}
Also used : TablesFacility(omero.gateway.facility.TablesFacility) FileAnnotationI(omero.model.FileAnnotationI) OriginalFileI(omero.model.OriginalFileI) FileAnnotation(omero.model.FileAnnotation) TableData(omero.gateway.model.TableData) OriginalFile(omero.model.OriginalFile) FileAnnotationData(omero.gateway.model.FileAnnotationData)

Aggregations

TablesFacility (omero.gateway.facility.TablesFacility)1 FileAnnotationData (omero.gateway.model.FileAnnotationData)1 TableData (omero.gateway.model.TableData)1 FileAnnotation (omero.model.FileAnnotation)1 FileAnnotationI (omero.model.FileAnnotationI)1 OriginalFile (omero.model.OriginalFile)1 OriginalFileI (omero.model.OriginalFileI)1