use of com.infiniteautomation.mango.rest.latest.model.pointValue.PointValueTimeJsonWriter in project ma-modules-public by infiniteautomation.
the class MultiPointStatisticsStreamTest method generateOutput.
/**
* Generate a JsonNode from the query
*/
protected JsonNode generateOutput(ZonedDateTimeStatisticsQueryInfo info, Map<Integer, DataPointVO> voMap) throws QueryCancelledException, IOException {
MultiPointStatisticsStream stream = new MultiPointStatisticsStream(info, voMap, Common.getBean(PointValueDao.class));
JsonFactory factory = new JsonFactory();
ByteArrayOutputStream output = new ByteArrayOutputStream();
JsonGenerator jgen = factory.createGenerator(output);
PointValueTimeWriter writer = new PointValueTimeJsonWriter(stream.getQueryInfo(), jgen);
stream.setContentType(StreamContentType.JSON);
stream.start(writer);
stream.streamData(writer);
stream.finish(writer);
jgen.flush();
ObjectMapper mapper = new ObjectMapper();
return mapper.readTree(output.toString(StandardCharsets.UTF_8.name()));
}
use of com.infiniteautomation.mango.rest.latest.model.pointValue.PointValueTimeJsonWriter in project ma-modules-public by infiniteautomation.
the class PointValueTimeStreamJsonSerializer method serialize.
@Override
public void serialize(PointValueTimeStream<T, INFO> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
PointValueTimeWriter writer = new PointValueTimeJsonWriter(value.getQueryInfo(), jgen);
value.setContentType(StreamContentType.JSON);
try {
value.start(writer);
value.streamData(writer);
value.finish(writer);
jgen.flush();
} catch (QueryCancelledException e) {
LOG.info("Query cancelled.", e);
}
}
Aggregations