use of com.twosigma.beakerx.table.TableDisplay in project beakerx by twosigma.
the class ScalaListOfPrimitiveTypeMapsSerializer method writeObject.
@Override
public boolean writeObject(Object obj, JsonGenerator jgen, boolean expand) throws JsonProcessingException, IOException {
logger.debug("list of maps");
// convert this 'on the fly' to a datatable
Collection<?> col = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) obj);
List<Map<String, Object>> tab = new ArrayList<Map<String, Object>>();
for (Object o : col) {
Map<String, Object> row = scala.collection.JavaConversions.mapAsJavaMap((scala.collection.Map<String, Object>) o);
tab.add(row);
}
TableDisplay t = new TableDisplay(tab, parent);
jgen.writeObject(t);
return true;
}
use of com.twosigma.beakerx.table.TableDisplay in project beakerx by twosigma.
the class SQLEvaluatorTest method verifyResult.
private void verifyResult(TryResult seo) {
assertThat(seo.result() instanceof TableDisplay).isTrue();
TableDisplay result = (TableDisplay) seo.result();
assertThat(result.getValues().size()).isEqualTo(3);
}
use of com.twosigma.beakerx.table.TableDisplay in project beakerx by twosigma.
the class MIMEContainerFactory method createMIMEContainersFromObject.
private static List<MIMEContainer> createMIMEContainersFromObject(final Object data) {
Object input = DisplayerDataMapper.convert(data);
if (input instanceof DisplayableWidget) {
((DisplayableWidget) input).display();
return HIDDEN_MIME;
}
TableDisplay table = getTableDisplay(input);
if (table != null) {
table.display();
return HIDDEN_MIME;
}
if (input instanceof Collection) {
return singletonList(MIMEContainer.Text(collectionToString((Collection<?>) input)));
}
if (input instanceof XYGraphics) {
new Plot().add((XYGraphics) input).display();
return HIDDEN_MIME;
}
if (input instanceof MIMEContainer) {
return singletonList((MIMEContainer) input);
}
return Displayers.display(input).entrySet().stream().map(item -> new MIMEContainer(item.getKey(), item.getValue())).collect(Collectors.toList());
}
use of com.twosigma.beakerx.table.TableDisplay in project beakerx by twosigma.
the class MIMEContainerFactory method getTableDisplay.
public static TableDisplay getTableDisplay(final Object input) {
TableDisplay ret = null;
if (input instanceof Map) {
Map map = (Map) input;
ret = new TableDisplay(map);
} else if (input instanceof Collection) {
Collection items = (Collection) input;
if (!items.isEmpty()) {
Object item = items.iterator().next();
if (item instanceof Map) {
if (((Map) item).keySet().stream().allMatch(o -> o instanceof String)) {
ret = new TableDisplay(items);
}
}
}
} else if (input instanceof Map[]) {
Map[] items = (Map[]) input;
if (items.length > 0) {
ret = new TableDisplay(items);
}
}
return ret;
}
use of com.twosigma.beakerx.table.TableDisplay in project beakerx by twosigma.
the class TableDisplaySerializerTest method setUp.
@Before
public void setUp() throws Exception {
KernelManager.register(new KernelTest());
tableDisplay = new TableDisplay(ObservableTableDisplayTest.getListOfMapsData());
}
Aggregations