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);
}
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();
}
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();
}
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();
}
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);
}
Aggregations