Search in sources :

Example 1 with TableCell

use of com.palantir.atlasdb.api.TableCell in project atlasdb by palantir.

the class TableCellDeserializer method deserialize.

@Override
public TableCell deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode node = jp.readValueAsTree();
    String tableName = node.get("table").textValue();
    TableMetadata metadata = metadataCache.getMetadata(tableName);
    Iterable<Cell> cells = AtlasDeserializers.deserializeCells(metadata, node.get("data"));
    return new TableCell(tableName, cells);
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) TableCell(com.palantir.atlasdb.api.TableCell) JsonNode(com.fasterxml.jackson.databind.JsonNode) Cell(com.palantir.atlasdb.keyvalue.api.Cell) TableCell(com.palantir.atlasdb.api.TableCell)

Example 2 with TableCell

use of com.palantir.atlasdb.api.TableCell in project atlasdb by palantir.

the class TableCellSerializer method serialize.

@Override
public void serialize(TableCell value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    TableMetadata metadata = metadataCache.getMetadata(value.getTableName());
    Preconditions.checkNotNull(metadata, "Unknown table %s", value.getTableName());
    jgen.writeStartObject();
    jgen.writeStringField("table", value.getTableName());
    jgen.writeArrayFieldStart("data");
    for (Cell cell : value.getCells()) {
        serialize(jgen, metadata, cell);
    }
    jgen.writeEndArray();
    jgen.writeEndObject();
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) Cell(com.palantir.atlasdb.keyvalue.api.Cell) TableCell(com.palantir.atlasdb.api.TableCell)

Example 3 with TableCell

use of com.palantir.atlasdb.api.TableCell in project atlasdb by palantir.

the class AtlasConsoleServiceTest method testGetCells.

@Test
public void testGetCells() throws IOException {
    final TableCell input = context.mock(TableCell.class);
    final TableCellVal output = context.mock(TableCellVal.class);
    context.checking(fromJson(input, TableCell.class));
    context.checking(new Expectations() {

        {
            oneOf(delegate).getCells(token, input);
            will(returnValue(output));
        }
    });
    context.checking(toJson(output, TableCellVal.class));
    assertEquals(service.getCells(token, QUERY), RESULT);
    context.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) TableCell(com.palantir.atlasdb.api.TableCell) TableCellVal(com.palantir.atlasdb.api.TableCellVal) Test(org.junit.Test)

Example 4 with TableCell

use of com.palantir.atlasdb.api.TableCell in project atlasdb by palantir.

the class AtlasConsoleServiceTest method testDelete.

@Test
public void testDelete() throws IOException {
    final TableCell input = context.mock(TableCell.class);
    context.checking(fromJson(input, TableCell.class));
    context.checking(new Expectations() {

        {
            oneOf(delegate).delete(token, input);
        }
    });
    service.delete(token, QUERY);
    context.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) TableCell(com.palantir.atlasdb.api.TableCell) Test(org.junit.Test)

Example 5 with TableCell

use of com.palantir.atlasdb.api.TableCell in project atlasdb by palantir.

the class AtlasConsoleServiceImpl method getCells.

@Override
public String getCells(TransactionToken token, String data) throws IOException {
    TableCell cells = fromJson(data, TableCell.class);
    TableCellVal result = service.getCells(token, cells);
    return toJson(result, TableCellVal.class);
}
Also used : TableCell(com.palantir.atlasdb.api.TableCell) TableCellVal(com.palantir.atlasdb.api.TableCellVal)

Aggregations

TableCell (com.palantir.atlasdb.api.TableCell)10 Test (org.junit.Test)6 TableCellVal (com.palantir.atlasdb.api.TableCellVal)5 Cell (com.palantir.atlasdb.keyvalue.api.Cell)5 TransactionToken (com.palantir.atlasdb.api.TransactionToken)4 TableMetadata (com.palantir.atlasdb.table.description.TableMetadata)2 Expectations (org.jmock.Expectations)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 RangeToken (com.palantir.atlasdb.api.RangeToken)1 TableRange (com.palantir.atlasdb.api.TableRange)1