use of com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter in project ma-core-public by infiniteautomation.
the class CsvDataPageQueryStreamMessageConverter method writeInternal.
/* (non-Javadoc)
* @see org.springframework.http.converter.AbstractHttpMessageConverter#writeInternal(java.lang.Object, org.springframework.http.HttpOutputMessage)
*/
@SuppressWarnings({ "rawtypes" })
@Override
protected void writeInternal(QueryDataPageStream<?> stream, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
CSVPojoWriter out = new CSVPojoWriter(new CSVWriter(new OutputStreamWriter(outputMessage.getBody(), Common.UTF8_CS), separator, quote));
stream.streamData(out);
out.close();
}
use of com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter in project ma-modules-public by infiniteautomation.
the class AbstractPointValueRollupCalculator method createQuantizer.
/**
* Create the proper quantizer for csv generation
* @param vo
* @param startValue
* @param bc
* @param writer
* @return
*/
protected AbstractDataQuantizer createQuantizer(DataPointVO vo, DataValue startValue, BucketCalculator bc, CSVPojoWriter<T> writer, boolean writeXidColumn, boolean writeHeaders) {
if (vo.getPointLocator().getDataTypeId() == DataTypes.NUMERIC) {
return new AnalogStatisticsQuantizer(bc, startValue, new NumericPointValueStatisticsQuantizerCsvCallback(writer.getWriter(), vo, this.useRendered, this.unitConversion, this.rollup, writeXidColumn, writeHeaders, this.limit, this.dateTimeFormat, this.timezone));
} else {
if (!rollup.nonNumericSupport()) {
LOG.warn("Invalid non-numeric rollup type: " + rollup);
// Default to first
rollup = RollupEnum.FIRST;
}
return new ValueChangeCounterQuantizer(bc, startValue, new NonNumericPointValueStatisticsQuantizerCsvCallback(writer.getWriter(), vo, useRendered, unitConversion, this.rollup, writeXidColumn, writeHeaders, this.limit, this.dateTimeFormat, this.timezone));
}
}
use of com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter in project ma-modules-public by infiniteautomation.
the class XidPointValueTimeLatestPointFacadeStream method streamData.
/*
* (non-Javadoc)
* @see com.serotonin.m2m2.web.mvc.rest.v1.model.ObjectStream#streamData(com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter)
*/
@Override
public void streamData(CSVPojoWriter<Map<String, List<PointValueTime>>> writer) throws IOException {
Iterator<Integer> it = this.pointMap.keySet().iterator();
boolean writeHeaders = true;
while (it.hasNext()) {
DataPointVO vo = this.pointMap.get(it.next());
PointValueFacade pointValueFacade = new PointValueFacade(vo.getId(), useCache);
PointValueTimeCsvStreamCallback callback = new PointValueTimeCsvStreamCallback(writer.getWriter(), vo, useRendered, unitConversion, true, writeHeaders, null, dateTimeFormat, timezone);
List<PointValueTime> pvts = pointValueFacade.getLatestPointValues(limit);
for (int i = 0; i < pvts.size(); i++) callback.row(pvts.get(i), i);
writeHeaders = false;
}
}
use of com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter in project ma-modules-public by infiniteautomation.
the class XidPointValueTimeMapDatabaseStream method streamData.
/*
* (non-Javadoc)
* @see com.serotonin.m2m2.web.mvc.rest.v1.model.ObjectStream#streamData(com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter)
*/
@Override
public void streamData(CSVPojoWriter<Map<String, List<PointValueTime>>> writer) throws IOException {
Iterator<Integer> it = this.pointMap.keySet().iterator();
boolean writeHeaders = true;
while (it.hasNext()) {
DataPointVO vo = this.pointMap.get(it.next());
PointValueTimeCsvStreamCallback callback = new PointValueTimeCsvStreamCallback(writer.getWriter(), vo, useRendered, unitConversion, true, writeHeaders, limit, dateTimeFormat, timezone);
this.dao.getPointValuesBetween(vo.getId(), from, to, callback);
writeHeaders = false;
}
}
use of com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter in project ma-core-public by infiniteautomation.
the class CsvRowMessageConverter method writeInternal.
/*
* (non-Javadoc)
*
* @see
* org.springframework.http.converter.AbstractHttpMessageConverter#writeInternal
* (java.lang.Object, org.springframework.http.HttpOutputMessage)
*/
@SuppressWarnings({ "rawtypes" })
@Override
protected void writeInternal(AbstractRestModel<?> record, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
CSVPojoWriter out = new CSVPojoWriter(new CSVWriter(new OutputStreamWriter(outputMessage.getBody(), Common.UTF8_CS), separator, quote));
out.writeNext(record);
out.close();
}
Aggregations