Search in sources :

Example 6 with ImageData

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

the class ModuleAdapter method getInputImages.

/**
 * Loops over the input items, and checks for Datasets, and if so gets the
 * corresponding omero ImageData.
 */
private List<ImageData> getInputImages(final HashMap<String, Object> inputMap, final BrowseFacility browse, final SecurityContext ctx) throws ServerError, DSOutOfServiceException, DSAccessException {
    if (imageInput != null) {
        final RLong id = (RLong) client.getInput(IMAGE_NAME);
        return Collections.singletonList(browse.getImage(ctx, id.getValue()));
    }
    final List<ImageData> images = new ArrayList<>();
    for (String key : inputMap.keySet()) {
        if (inputMap.get(key) instanceof Dataset) {
            final RLong id = (RLong) client.getInput(key);
            images.add(browse.getImage(ctx, id.getValue()));
        }
    }
    return images;
}
Also used : ImageData(omero.gateway.model.ImageData) Dataset(net.imagej.Dataset) ArrayList(java.util.ArrayList) RLong(omero.RLong)

Example 7 with ImageData

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

the class ModuleAdapter method getOutputImages.

/**
 * Loops over all the orphaned images, and grabs the ones which have IDs that
 * match the omero client outputs.
 */
private List<ImageData> getOutputImages(final long userId, final BrowseFacility browse, final SecurityContext ctx) throws ServerError {
    final Collection<ImageData> orphans = browse.getOrphanedImages(ctx, userId);
    final HashMap<Long, ImageData> mappedOrphans = new HashMap<>();
    for (ImageData i : orphans) mappedOrphans.put(i.getId(), i);
    final List<ImageData> images = new ArrayList<>();
    for (String key : client.getOutputKeys()) {
        final omero.RType type = client.getOutput(key);
        if (type instanceof RLong) {
            if (mappedOrphans.containsKey(((RLong) type).getValue()))
                images.add(mappedOrphans.get(((RLong) type).getValue()));
        }
    }
    return images;
}
Also used : HashMap(java.util.HashMap) ImageData(omero.gateway.model.ImageData) RLong(omero.RLong) ArrayList(java.util.ArrayList) RLong(omero.RLong)

Example 8 with ImageData

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

the class UploadTableTest method setUpMethodCalls.

// -- Helper methods --
private void setUpMethodCalls() throws ServerError, PermissionDeniedException, CannotCreateSessionException, DSOutOfServiceException, ExecutionException, DSAccessException {
    new Expectations() {

        {
            new DefaultOMEROSession(credentials);
            gateway.getFacility(BrowseFacility.class);
            result = browseFacility;
            browseFacility.getImage((SecurityContext) any, anyLong);
            result = new ImageData();
            gateway.getFacility(TablesFacility.class);
            result = tablesFacility;
            tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, (TableData) any);
            result = new TableData((TableDataColumn[]) any, (Object[][]) any);
        }
    };
}
Also used : Expectations(mockit.Expectations) ImageData(omero.gateway.model.ImageData) DataObject(omero.gateway.model.DataObject) TableData(omero.gateway.model.TableData)

Example 9 with ImageData

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

the class DownloadTableTest method downloadRefTable.

@Test
public void downloadRefTable() throws PermissionDeniedException, CannotCreateSessionException, ServerError, DSOutOfServiceException, ExecutionException, DSAccessException {
    final TableDataColumn[] tdc = new TableDataColumn[] { new TableDataColumn("Header 1", 0, ImageData.class), new TableDataColumn("Header 2", 1, ImageData.class), new TableDataColumn("Header 3", 2, ImageData.class) };
    final Object[][] data = new Object[3][3];
    final long[][] ids = new long[][] { { 101, 102, 103 }, { 201, 202, 203 }, { 301, 302, 303 } };
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            data[i][j] = new ImageData(new ImageI(ids[i][j], false));
        }
    }
    final TableData table = new TableData(tdc, data);
    table.setNumberOfRows(3);
    // Create expectations
    setUpMethodCalls(table);
    final Table<?, ?> imageJTable = ((DefaultOMEROService) service).downloadTable(credentials, 0);
    // Tests
    assertTrue(GenericTable.class.isInstance(imageJTable));
    assertEquals(imageJTable.getColumnCount(), 3);
    assertEquals(imageJTable.getRowCount(), 3);
    assertEquals(imageJTable.getColumnHeader(0), "Header 1");
    assertEquals(imageJTable.getColumnHeader(1), "Header 2");
    assertEquals(imageJTable.getColumnHeader(2), "Header 3");
    for (int r = 0; r < imageJTable.getRowCount(); r++) {
        for (int c = 0; c < imageJTable.getColumnCount(); c++) {
            assertTrue(OMERORefColumn.class.isInstance(imageJTable.get(c)));
            assertTrue(imageJTable.get(c).getType() == Long.class);
            assertEquals(((OMERORefColumn) imageJTable.get(c)).getOMERORef(), OMERORef.IMAGE);
            assertEquals(ids[c][r], ((OMERORefColumn) imageJTable.get(c)).get(r).longValue());
        }
    }
}
Also used : GenericTable(net.imagej.table.GenericTable) ImageI(omero.model.ImageI) ImageData(omero.gateway.model.ImageData) TableDataColumn(omero.gateway.model.TableDataColumn) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Aggregations

ImageData (omero.gateway.model.ImageData)9 RLong (omero.RLong)4 ArrayList (java.util.ArrayList)3 TableData (omero.gateway.model.TableData)3 HashMap (java.util.HashMap)2 BrowseFacility (omero.gateway.facility.BrowseFacility)2 FormatException (io.scif.FormatException)1 ImageMetadata (io.scif.ImageMetadata)1 Expectations (mockit.Expectations)1 Dataset (net.imagej.Dataset)1 GenericTable (net.imagej.table.GenericTable)1 RawPixelsStorePrx (omero.api.RawPixelsStorePrx)1 SecurityContext (omero.gateway.SecurityContext)1 DataManagerFacility (omero.gateway.facility.DataManagerFacility)1 TablesFacility (omero.gateway.facility.TablesFacility)1 DataObject (omero.gateway.model.DataObject)1 DatasetData (omero.gateway.model.DatasetData)1 ExperimenterData (omero.gateway.model.ExperimenterData)1 TableDataColumn (omero.gateway.model.TableDataColumn)1 Image (omero.model.Image)1