Search in sources :

Example 1 with ByteTable

use of net.imagej.table.ByteTable in project imagej-omero by imagej.

the class OmeroIT method testUploadTable.

@Test
public void testUploadTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final byte[][] d = new byte[][] { { 127, 0, -128 }, { -1, -6, -23 }, { 100, 87, 4 } };
    final ByteTable table = new DefaultByteTable(3, 3);
    for (int c = 0; c < table.getColumnCount(); c++) {
        table.setColumnHeader(c, "Heading " + (c + 1));
        for (int r = 0; r < table.getRowCount(); r++) table.set(c, r, d[c][r]);
    }
    final long tableId = omero.uploadTable(cred, "test-table-upload", table, 1);
    // When upload table was called it created a session, which cleared out
    // the username and password from the credentials. The credentials must
    // have a username and password to create security contexts.
    final OMEROCredentials tc = new OMEROCredentials();
    tc.setServer(OMERO_SERVER);
    tc.setPort(OMERO_PORT);
    tc.setUser(OMERO_USER);
    tc.setPassword(OMERO_PASSWORD);
    try (final OMEROSession session = new DefaultOMEROSession(tc)) {
        final TablesFacility tablesFacility = session.getGateway().getFacility(TablesFacility.class);
        final TableData td = tablesFacility.getTableInfo(session.getSecurityContext(), tableId);
        assertEquals(td.getColumns().length, 3);
        assertEquals(td.getColumns()[0].getName(), "Heading 1");
        assertEquals(td.getColumns()[1].getName(), "Heading 2");
        assertEquals(td.getColumns()[2].getName(), "Heading 3");
        assertEquals(td.getNumberOfRows(), 3);
    }
}
Also used : TablesFacility(omero.gateway.facility.TablesFacility) DefaultByteTable(net.imagej.table.DefaultByteTable) DefaultOMEROSession(net.imagej.omero.DefaultOMEROSession) ByteTable(net.imagej.table.ByteTable) DefaultByteTable(net.imagej.table.DefaultByteTable) OMEROSession(net.imagej.omero.OMEROSession) DefaultOMEROSession(net.imagej.omero.DefaultOMEROSession) TableData(omero.gateway.model.TableData) OMEROCredentials(net.imagej.omero.OMEROCredentials) Test(org.junit.Test)

Aggregations

DefaultOMEROSession (net.imagej.omero.DefaultOMEROSession)1 OMEROCredentials (net.imagej.omero.OMEROCredentials)1 OMEROSession (net.imagej.omero.OMEROSession)1 ByteTable (net.imagej.table.ByteTable)1 DefaultByteTable (net.imagej.table.DefaultByteTable)1 TablesFacility (omero.gateway.facility.TablesFacility)1 TableData (omero.gateway.model.TableData)1 Test (org.junit.Test)1