Search in sources :

Example 1 with GenericTable

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);
        }
    };
}
Also used : DefaultGenericTable(net.imagej.table.DefaultGenericTable) DefaultColumn(net.imagej.table.DefaultColumn) GenericTable(net.imagej.table.GenericTable) DefaultGenericTable(net.imagej.table.DefaultGenericTable) ByteArray(org.scijava.util.ByteArray) Verifications(mockit.Verifications) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Example 2 with GenericTable

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);
        }
    };
}
Also used : DefaultGenericTable(net.imagej.table.DefaultGenericTable) WellSampleData(omero.gateway.model.WellSampleData) GenericTable(net.imagej.table.GenericTable) DefaultGenericTable(net.imagej.table.DefaultGenericTable) DataObject(omero.gateway.model.DataObject) Verifications(mockit.Verifications) TableData(omero.gateway.model.TableData) WellSampleI(omero.model.WellSampleI) Test(org.junit.Test)

Example 3 with GenericTable

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;
    }
}
Also used : TablesFacility(omero.gateway.facility.TablesFacility) GenericTable(net.imagej.table.GenericTable) TableDataColumn(omero.gateway.model.TableDataColumn) TableData(omero.gateway.model.TableData)

Example 4 with GenericTable

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);
        }
    };
}
Also used : DefaultGenericTable(net.imagej.table.DefaultGenericTable) DefaultColumn(net.imagej.table.DefaultColumn) GenericTable(net.imagej.table.GenericTable) DefaultGenericTable(net.imagej.table.DefaultGenericTable) Verifications(mockit.Verifications) TableData(omero.gateway.model.TableData) DoubleArray(org.scijava.util.DoubleArray) Test(org.junit.Test)

Example 5 with GenericTable

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);
        }
    };
}
Also used : DefaultGenericTable(net.imagej.table.DefaultGenericTable) BoolColumn(net.imagej.table.BoolColumn) DefaultColumn(net.imagej.table.DefaultColumn) ROIData(omero.gateway.model.ROIData) GenericTable(net.imagej.table.GenericTable) DefaultGenericTable(net.imagej.table.DefaultGenericTable) Verifications(mockit.Verifications) DoubleColumn(net.imagej.table.DoubleColumn) IntArray(org.scijava.util.IntArray) RoiI(omero.model.RoiI) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Aggregations

GenericTable (net.imagej.table.GenericTable)5 TableData (omero.gateway.model.TableData)5 Verifications (mockit.Verifications)4 DefaultGenericTable (net.imagej.table.DefaultGenericTable)4 Test (org.junit.Test)4 DefaultColumn (net.imagej.table.DefaultColumn)3 BoolColumn (net.imagej.table.BoolColumn)1 DoubleColumn (net.imagej.table.DoubleColumn)1 TablesFacility (omero.gateway.facility.TablesFacility)1 DataObject (omero.gateway.model.DataObject)1 ROIData (omero.gateway.model.ROIData)1 TableDataColumn (omero.gateway.model.TableDataColumn)1 WellSampleData (omero.gateway.model.WellSampleData)1 RoiI (omero.model.RoiI)1 WellSampleI (omero.model.WellSampleI)1 ByteArray (org.scijava.util.ByteArray)1 DoubleArray (org.scijava.util.DoubleArray)1 IntArray (org.scijava.util.IntArray)1