use of net.imagej.table.GenericTable 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 net.imagej.table.GenericTable in project imagej-omero by imagej.
the class UploadTableTest method testReferenceTable.
@Test
public void testReferenceTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final GenericTable table = new DefaultGenericTable();
final OMERORefColumn rc0 = new OMERORefColumn(OMERORef.WELL);
final OMERORefColumn rc1 = new OMERORefColumn(OMERORef.WELL);
final OMERORefColumn rc2 = new OMERORefColumn(OMERORef.WELL);
rc0.fill(new long[] { 2314, 3141324, 1235 });
rc1.fill(new long[] { 1234, 18367, 82156 });
rc2.fill(new long[] { 3198, 968431, 5489 });
table.add(rc0);
table.add(rc1);
table.add(rc2);
final Object[][] wells = new Object[3][3];
for (int c = 0; c < table.getColumnCount(); c++) {
for (int r = 0; r < table.getRowCount(); r++) {
wells[c][r] = new WellSampleData(new WellSampleI((long) table.get(c, r), false));
}
((OMERORefColumn) table.get(c)).setOriginalData(wells[c]);
}
// 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, WellSampleData.class);
}
};
}
use of net.imagej.table.GenericTable in project imagej-omero by imagej.
the class DefaultOMEROService method downloadTable.
@Override
public Table<?, ?> downloadTable(final OMEROCredentials credentials, final long tableID) throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
try (final OMEROSession session = new DefaultOMEROSession(credentials)) {
final TablesFacility tableService = session.getGateway().getFacility(TablesFacility.class);
final TableData table = tableService.getTable(session.getSecurityContext(), tableID, 0, Integer.MAX_VALUE - 1);
final TableDataColumn[] omeroColumns = table.getColumns();
final Object[][] data = table.getData();
final Table<?, ?> imageJTable = TableUtils.createImageJTable(omeroColumns);
imageJTable.setRowCount((int) table.getNumberOfRows());
boolean colsCreated = false;
if (!(imageJTable instanceof GenericTable)) {
imageJTable.appendColumns(omeroColumns.length);
colsCreated = true;
}
for (int i = 0; i < omeroColumns.length; i++) {
if (!colsCreated) {
final Column<?> imageJCol = TableUtils.createImageJColumn(omeroColumns[i]);
TableUtils.populateImageJColumn(omeroColumns[i].getType(), data[omeroColumns[i].getIndex()], imageJCol);
((GenericTable) imageJTable).add(omeroColumns[i].getIndex(), imageJCol);
} else {
TableUtils.populateImageJColumn(omeroColumns[i].getType(), data[omeroColumns[i].getIndex()], imageJTable.get(i));
imageJTable.get(i).setHeader(omeroColumns[i].getName());
}
}
return imageJTable;
}
}
use of net.imagej.table.GenericTable in project imagej-omero by imagej.
the class UploadTableTest method testDoubleArrayTable.
@Test
public void testDoubleArrayTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final GenericTable table = new DefaultGenericTable();
final DefaultColumn<DoubleArray> ij0 = new DefaultColumn<>(DoubleArray.class, "H1");
final DefaultColumn<DoubleArray> ij1 = new DefaultColumn<>(DoubleArray.class, "H2");
ij0.add(new DoubleArray(new double[] { 0.5, 0.25, 0.125 }));
ij1.add(new DoubleArray(new double[] { -0.125, -0.0625, 0.03125 }));
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, Double[].class);
}
};
}
use of net.imagej.table.GenericTable in project imagej-omero by imagej.
the class UploadTableTest method testMixedTable.
@Test
public void testMixedTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final GenericTable table = new DefaultGenericTable();
final BoolColumn ijc0 = new BoolColumn("h0");
final DoubleColumn ijc1 = new DoubleColumn("h1");
final DefaultColumn<String> ijc2 = new DefaultColumn<>(String.class, "h2");
final DefaultColumn<IntArray> ijc3 = new DefaultColumn<>(IntArray.class, "h3");
final OMERORefColumn ijc4 = new OMERORefColumn("h4", OMERORef.ROI);
ijc0.fill(new boolean[] { true, false });
ijc1.fill(new double[] { 0.03125, -2134.5 });
ijc2.add("abc");
ijc2.add("123");
ijc3.add(new IntArray(new int[] { 9012, 1294 }));
ijc3.add(new IntArray(new int[] { -4123, -9 }));
ijc4.fill(new long[] { 2314, 1234 });
ijc4.setOriginalData(new Object[] { new ROIData(new RoiI(2314, true)), new ROIData(new RoiI(1234, true)) });
table.add(ijc0);
table.add(ijc1);
table.add(ijc2);
table.add(ijc3);
table.add(ijc4);
// 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, Boolean.class, Double.class, String.class, Long[].class, ROIData.class);
}
};
}
Aggregations