use of eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsTree in project selenium_java by sergueik.
the class JrdsDataAdapter method getBindingTree.
// region [DataAdapter Members]
@Override
public TreeItem<TimeSeriesBinding<Double>> getBindingTree() throws DataAdapterException {
Gson gson = new Gson();
try {
JsonJrdsTree t = gson.fromJson(getJsonTree(treeViewTab.getCommand(), treeViewTab.getArgument(), filter), JsonJrdsTree.class);
Map<String, JsonJrdsItem> m = Arrays.stream(t.items).collect(Collectors.toMap(o -> o.id, (o -> o)));
TreeItem<TimeSeriesBinding<Double>> tree = new TreeItem<>(bindingFactory.of("", getSourceName(), "/", this));
for (JsonJrdsItem branch : Arrays.stream(t.items).filter(jsonJrdsItem -> JRDS_TREE.equals(jsonJrdsItem.type) || JRDS_FILTER.equals(jsonJrdsItem.type)).collect(Collectors.toList())) {
attachNode(tree, branch.id, m);
}
return tree;
} catch (JsonParseException e) {
throw new DataAdapterException("An error occurred while parsing the json response to getBindingTree request", e);
} catch (URISyntaxException e) {
throw new SourceCommunicationException("Error building URI for request", e);
}
}
Aggregations