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