Search in sources :

Example 1 with JsonJrdsTree

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);
    }
}
Also used : JsonParseException(com.google.gson.JsonParseException) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) java.util(java.util) JsonJrdsTree(eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsTree) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Dialogs(eu.fthevenet.binjr.dialogs.Dialogs) TreeItem(javafx.scene.control.TreeItem) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) ZonedDateTime(java.time.ZonedDateTime) JsonJrdsItem(eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsItem) StatusLine(org.apache.http.StatusLine) EntityUtils(org.apache.http.util.EntityUtils) Gson(com.google.gson.Gson) HttpDataAdapterBase(eu.fthevenet.binjr.data.adapters.HttpDataAdapterBase) BasicResponseHandler(org.apache.http.impl.client.BasicResponseHandler) AbstractResponseHandler(org.apache.http.impl.client.AbstractResponseHandler) URI(java.net.URI) JAXB(javax.xml.bind.JAXB) CsvDecoder(eu.fthevenet.binjr.data.codec.CsvDecoder) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) MalformedURLException(java.net.MalformedURLException) XmlUtils(eu.fthevenet.util.xml.XmlUtils) HttpEntity(org.apache.http.HttpEntity) HttpResponseException(org.apache.http.client.HttpResponseException) eu.fthevenet.binjr.data.exceptions(eu.fthevenet.binjr.data.exceptions) IOException(java.io.IOException) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) DataAdapter(eu.fthevenet.binjr.data.adapters.DataAdapter) Logger(org.apache.logging.log4j.Logger) TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) DateTimeFormatter(java.time.format.DateTimeFormatter) ObservableValue(javafx.beans.value.ObservableValue) Pattern(java.util.regex.Pattern) ChangeListener(javafx.beans.value.ChangeListener) NameValuePair(org.apache.http.NameValuePair) LogManager(org.apache.logging.log4j.LogManager) DoubleTimeSeriesProcessor(eu.fthevenet.binjr.data.timeseries.DoubleTimeSeriesProcessor) InputStream(java.io.InputStream) TreeItem(javafx.scene.control.TreeItem) Gson(com.google.gson.Gson) JsonJrdsTree(eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsTree) URISyntaxException(java.net.URISyntaxException) JsonParseException(com.google.gson.JsonParseException) TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) JsonJrdsItem(eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsItem)

Aggregations

Gson (com.google.gson.Gson)1 JsonParseException (com.google.gson.JsonParseException)1 DataAdapter (eu.fthevenet.binjr.data.adapters.DataAdapter)1 HttpDataAdapterBase (eu.fthevenet.binjr.data.adapters.HttpDataAdapterBase)1 TimeSeriesBinding (eu.fthevenet.binjr.data.adapters.TimeSeriesBinding)1 CsvDecoder (eu.fthevenet.binjr.data.codec.CsvDecoder)1 eu.fthevenet.binjr.data.exceptions (eu.fthevenet.binjr.data.exceptions)1 DoubleTimeSeriesProcessor (eu.fthevenet.binjr.data.timeseries.DoubleTimeSeriesProcessor)1 Dialogs (eu.fthevenet.binjr.dialogs.Dialogs)1 JsonJrdsItem (eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsItem)1 JsonJrdsTree (eu.fthevenet.binjr.sources.jrds.adapters.json.JsonJrdsTree)1 XmlUtils (eu.fthevenet.util.xml.XmlUtils)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 Instant (java.time.Instant)1