use of omero.gateway.model.TableData 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;
}
use of omero.gateway.model.TableData in project imagej-omero by imagej.
the class ModuleAdapter method launch.
/**
* Executes the associated ImageJ module as an OMERO script.
*
* @throws IOException
* @throws ServerError
* @throws ExecutionException
* @throws CannotCreateSessionException
* @throws PermissionDeniedException
* @throws DSAccessException
* @throws DSOutOfServiceException
*/
public void launch() throws ServerError, IOException, ExecutionException, PermissionDeniedException, CannotCreateSessionException, DSOutOfServiceException, DSAccessException {
// populate inputs
log.debug(info.getTitle() + ": populating inputs");
final HashMap<String, Object> inputMap = new HashMap<>();
for (final String name : client.getInputKeys()) {
final ModuleItem<?> input = getInput(name);
final Class<?> type = input.getType();
final Object value = omeroService.toImageJ(client, client.getInput(name), type);
inputMap.put(input.getName(), value);
}
// execute ImageJ module
log.debug(info.getTitle() + ": executing module");
final Future<Module> future = moduleService.run(info, true, inputMap);
final Module module = moduleService.waitFor(future);
final HashMap<String, TableData> tables = new HashMap<>();
// populate outputs, except tables
log.debug(info.getTitle() + ": populating outputs");
for (final ModuleItem<?> item : module.getInfo().outputs()) {
final Object value = omeroService.toOMERO(client, item.getValue(module));
final String name = getOutputName(item);
if (value == null) {
log.warn(info.getTitle() + ": output '" + name + "' is null");
}
if (value instanceof omero.RType)
client.setOutput(name, (omero.RType) value);
if (value instanceof TableData)
tables.put(name, (TableData) value);
}
createOutputLinks(inputMap, tables);
gateway.disconnect();
log.debug(info.getTitle() + ": completed execution");
}
use of omero.gateway.model.TableData in project imagej-omero by imagej.
the class UploadTableTest method testFloatTable.
@Test
public void testFloatTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final FloatTable table = new DefaultFloatTable(4, 2);
table.get(0).fill(new float[] { -380129.125f, 0.25f });
table.get(1).fill(new float[] { 9871234.0f, -12.5f });
table.get(2).fill(new float[] { 0.0625f, 13208.03125f });
table.get(3).fill(new float[] { -0.0625f, 1908471790.5f });
final String[] headers = new String[] { "H1", "H2", "H3", "H4" };
for (int i = 0; i < table.getColumnCount(); i++) {
table.get(i).setHeader(headers[i]);
}
// Create expectations
setUpMethodCalls();
final long id = service.uploadTable(credentials, "table", table, 0);
assertEquals(id, -1);
// NB: Can only capture in a Verifications block
new Verifications() {
{
TableData td;
tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, td = withCapture());
tableEquals(table, td, Double.class);
}
};
}
use of omero.gateway.model.TableData in project imagej-omero by imagej.
the class UploadTableTest method testByteArrayTable.
@Test
public void testByteArrayTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final GenericTable table = new DefaultGenericTable();
final DefaultColumn<ByteArray> ij0 = new DefaultColumn<>(ByteArray.class);
final DefaultColumn<ByteArray> ij1 = new DefaultColumn<>(ByteArray.class);
ij0.add(new ByteArray(new byte[] { -128, 127 }));
ij0.add(new ByteArray(new byte[] { 0, 10 }));
ij1.add(new ByteArray(new byte[] { 112, 42 }));
ij1.add(new ByteArray(new byte[] { -13, -84 }));
table.add(ij0);
table.add(ij1);
// Create expectations
setUpMethodCalls();
final long id = service.uploadTable(credentials, "table", table, 0);
assertEquals(id, -1);
// NB: Can only capture in a Verifications block
new Verifications() {
{
TableData td;
tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, td = withCapture());
tableEquals(table, td, Long[].class);
}
};
}
use of omero.gateway.model.TableData in project imagej-omero by imagej.
the class UploadTableTest method testCharTable.
@Test
public void testCharTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final CharTable table = new DefaultCharTable(5, 2);
table.get(0).fill(new char[] { 'q', 'V' });
table.get(1).fill(new char[] { '2', '$' });
table.get(2).fill(new char[] { 'b', 'a' });
table.get(3).fill(new char[] { '\t', '\n' });
table.get(4).fill(new char[] { '.', ' ' });
// Create expectations
setUpMethodCalls();
final long id = service.uploadTable(credentials, "table", table, 0);
assertEquals(id, -1);
// NB: Can only capture in a Verifications block
new Verifications() {
{
TableData td;
tablesFacility.addTable((SecurityContext) any, (ImageData) any, anyString, td = withCapture());
tableEquals(table, td, String.class);
}
};
}
Aggregations