@Override
protected void writeJsonForChunks(final JsonGenerator generator, final Collection<? extends TimelineChunk> chunksForSourceAndMetric) throws IOException {
for (final TimelineChunk chunk : chunksForSourceAndMetric) {
if (withBinaryData) {
writer.writeValue(generator, new TimelineChunkDecoded(chunk, sampleCoder));
} else {
final String source = timelineDao.getSource(chunk.getSourceId(), context);
final CategoryRecordIdAndMetric categoryIdAndMetric = timelineDao.getCategoryIdAndMetric(chunk.getMetricId(), context);
final String category = timelineDao.getEventCategory(categoryIdAndMetric.getEventCategoryId(), context);
final String metric = categoryIdAndMetric.getMetric();
final String samples = CSVConsumer.getSamplesAsCSV(sampleCoder, chunk);
if (!Strings.isNullOrEmpty(samples)) {
generator.writeObject(new SamplesForMetricAndSource(source, category, metric, samples));
}
}
}
}
}