Search in sources :

Example 1 with BrowseFacility

use of omero.gateway.facility.BrowseFacility in project imagej-omero by imagej.

the class DefaultOMEROService method uploadTable.

@Override
public long uploadTable(final OMEROCredentials credentials, final String name, final Table<?, ?> imageJTable, final long imageID) throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final TableData omeroTable = convertOMEROTable(imageJTable);
    long id = -1;
    try (final OMEROSession session = new DefaultOMEROSession(credentials)) {
        // Get image
        final BrowseFacility browseFacility = session.getGateway().getFacility(BrowseFacility.class);
        final ImageData image = browseFacility.getImage(session.getSecurityContext(), imageID);
        // attach table to image
        final TablesFacility tablesFacility = session.getGateway().getFacility(TablesFacility.class);
        final TableData stored = tablesFacility.addTable(session.getSecurityContext(), image, name, omeroTable);
        id = stored.getOriginalFileId();
    }
    return id;
}
Also used : TablesFacility(omero.gateway.facility.TablesFacility) ImageData(omero.gateway.model.ImageData) TableData(omero.gateway.model.TableData) BrowseFacility(omero.gateway.facility.BrowseFacility)

Example 2 with BrowseFacility

use of omero.gateway.facility.BrowseFacility in project imagej-omero by imagej.

the class ModuleAdapter method createOutputLinks.

/**
 * Attempts to attach the outputs to the appropriate items.
 */
private void createOutputLinks(final HashMap<String, Object> inputMap, final HashMap<String, TableData> tables) throws ExecutionException, ServerError, DSOutOfServiceException, DSAccessException {
    final ExperimenterData user = createUser();
    final BrowseFacility browse = gateway.getFacility(BrowseFacility.class);
    final DataManagerFacility dm = gateway.getFacility(DataManagerFacility.class);
    final SecurityContext ctx = new SecurityContext(user.getGroupId());
    final List<ImageData> outImages = getOutputImages(user.getId(), browse, ctx);
    final List<ImageData> inputImages = getInputImages(inputMap, browse, ctx);
    if (!outImages.isEmpty()) {
        attachImagesToDatasets(inputImages, outImages, dm, browse, ctx);
    }
    if (!tables.isEmpty()) {
        if (inputImages.isEmpty())
            throw new IllegalArgumentException("Input image(s) required to upload table to OMERO");
        attachTablesToImages(inputImages, tables, ctx, dm);
    }
}
Also used : ExperimenterData(omero.gateway.model.ExperimenterData) ImageData(omero.gateway.model.ImageData) SecurityContext(omero.gateway.SecurityContext) DataManagerFacility(omero.gateway.facility.DataManagerFacility) BrowseFacility(omero.gateway.facility.BrowseFacility)

Aggregations

BrowseFacility (omero.gateway.facility.BrowseFacility)2 ImageData (omero.gateway.model.ImageData)2 SecurityContext (omero.gateway.SecurityContext)1 DataManagerFacility (omero.gateway.facility.DataManagerFacility)1 TablesFacility (omero.gateway.facility.TablesFacility)1 ExperimenterData (omero.gateway.model.ExperimenterData)1 TableData (omero.gateway.model.TableData)1