private void logGeneralizationAmount(DataCollection<Data<QuantityValue>> ungeneralizedData, DataCollection<Data<QuantityValue>> generalizedData) { for (String timeseriesId : ungeneralizedData.getAllSeries() .keySet()) { Data<QuantityValue> originalTimeseries = ungeneralizedData.getSeries(timeseriesId); Data<QuantityValue> generalizedTimeseries = generalizedData.getSeries(timeseriesId); int originalAmount = originalTimeseries.getValues() .size(); int generalizedAmount = generalizedTimeseries.getValues() .size(); LOGGER.debug("Generalized timeseries: {} (#{} --> #{}).", timeseriesId, originalAmount, generalizedAmount); } }
private void writeData(DataCollection<Data<QuantityValue>> data, OutputStream stream) throws IOException { for (DatasetOutput metadata : seriesMetadatas) { Data<QuantityValue> series = data.getSeries(metadata.getId()); writeData(metadata, series, stream); } }
@Override public FlotDataCollection format(DataCollection<Data<QuantityValue>> toFormat) { FlotDataCollection flotDataCollection = new FlotDataCollection(); for (String timeseriesId : toFormat.getAllSeries().keySet()) { Data<QuantityValue> seriesToFormat = toFormat.getSeries(timeseriesId); FlotData series = createFlotSeries(seriesToFormat); flotDataCollection.addNewSeries(timeseriesId, series); } return flotDataCollection; }
@Override public DataCollection<Data<QuantityValue>> generalize( DataCollection<Data<QuantityValue>> data) throws GeneralizerException { TvpDataCollection<Data<QuantityValue>> generalizedDataCollection = new TvpDataCollection<>(); for (String timeseriesId : data.getAllSeries().keySet()) { Data<QuantityValue> timeseries = data.getSeries(timeseriesId); Data<QuantityValue> generalizedTimeseries = generalize(timeseries); generalizedDataCollection.addNewSeries(timeseriesId, generalizedTimeseries); } return generalizedDataCollection; }
@Override public DataCollection<Data<QuantityValue>> generalize(DataCollection<Data<QuantityValue>> data) throws GeneralizerException { TvpDataCollection<Data<QuantityValue>> generalizedDataCollection = new TvpDataCollection<>(); for (String timeseriesId : data.getAllSeries().keySet()) { Data<QuantityValue> timeseries = data.getSeries(timeseriesId); generalizedDataCollection.addNewSeries(timeseriesId, generalize(timeseries)); } return generalizedDataCollection; }
@Override public HighchartDataCollection format(DataCollection<Data<QuantityValue>> toFormat) { HighchartDataCollection dataCollection = new HighchartDataCollection(); for (String timeseriesId : toFormat.getAllSeries().keySet()) { Data<QuantityValue> seriesToFormat = toFormat.getSeries(timeseriesId); HighchartData series = createHighchartSeries(timeseriesId, seriesToFormat); dataCollection.addNewSeries(timeseriesId, series); if (seriesToFormat.hasMetadata()) { DatasetMetadata<QuantityValue> metadata = seriesToFormat.getMetadata(); if (metadata.hasReferenceValues()) { Map<String, Data<QuantityValue>> referenceValues = metadata.getReferenceValues(); for (String referenceValueId : referenceValues.keySet()) { Data<QuantityValue> timeseriesData = metadata.getReferenceValues().get(referenceValueId); HighchartData referenceSeries = createHighchartSeries(referenceValueId, timeseriesData); dataCollection.addNewSeries(referenceValueId, referenceSeries); } } series.setValueBeforeTimespan(formatValue(metadata.getValueBeforeTimespan())); series.setValueAfterTimespan(formatValue(metadata.getValueAfterTimespan())); } } return dataCollection; }