use of eu.fthevenet.binjr.data.adapters.DataAdapter 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);
}
}
use of eu.fthevenet.binjr.data.adapters.DataAdapter in project selenium_java by sergueik.
the class MainViewController method loadWorkspace.
private void loadWorkspace(File file) {
if (confirmAndClearWorkspace()) {
sourceMaskerPane.setVisible(true);
AsyncTaskManager.getInstance().submit(() -> {
Workspace wsFromfile = Workspace.from(file);
for (Source source : wsFromfile.getSources()) {
DataAdapter da = DataAdapterFactory.getInstance().newAdapter(source.getAdapterClassName());
da.loadParams(source.getAdapterParams());
da.setId(source.getAdapterId());
source.setAdapter(da);
loadSource(source);
}
return wsFromfile;
}, event -> {
workspace.setPath(file.toPath());
sourceMaskerPane.setVisible(false);
loadWorksheets((Workspace) event.getSource().getValue());
}, event -> {
sourceMaskerPane.setVisible(false);
Dialogs.notifyException("An error occurred while loading workspace from file " + (file != null ? file.getName() : "null"), event.getSource().getException(), root);
});
}
}
Aggregations