Search in sources :

Example 6 with CSVPojoWriter

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();
}
Also used : CSVPojoWriter(com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter) CSVWriter(au.com.bytecode.opencsv.CSVWriter) OutputStreamWriter(java.io.OutputStreamWriter)

Example 7 with CSVPojoWriter

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));
    }
}
Also used : NonNumericPointValueStatisticsQuantizerCsvCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NonNumericPointValueStatisticsQuantizerCsvCallback) NumericPointValueStatisticsQuantizerCsvCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NumericPointValueStatisticsQuantizerCsvCallback) NonNumericPointValueStatisticsQuantizerCsvCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NonNumericPointValueStatisticsQuantizerCsvCallback) ValueChangeCounterQuantizer(com.serotonin.m2m2.view.quantize2.ValueChangeCounterQuantizer) AnalogStatisticsQuantizer(com.serotonin.m2m2.view.quantize2.AnalogStatisticsQuantizer)

Example 8 with CSVPojoWriter

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;
    }
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) PointValueFacade(com.serotonin.m2m2.rt.dataImage.PointValueFacade) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime)

Example 9 with CSVPojoWriter

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;
    }
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO)

Example 10 with CSVPojoWriter

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();
}
Also used : CSVPojoWriter(com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter) CSVWriter(au.com.bytecode.opencsv.CSVWriter) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

CSVWriter (au.com.bytecode.opencsv.CSVWriter)5 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)5 CSVPojoWriter (com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter)5 OutputStreamWriter (java.io.OutputStreamWriter)5 DataValue (com.serotonin.m2m2.rt.dataImage.types.DataValue)3 BucketCalculator (com.serotonin.m2m2.view.quantize2.BucketCalculator)3 PointValueFacade (com.serotonin.m2m2.rt.dataImage.PointValueFacade)2 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)2 AbstractDataQuantizer (com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer)2 IdPointValueTime (com.serotonin.m2m2.rt.dataImage.IdPointValueTime)1 AnalogStatisticsQuantizer (com.serotonin.m2m2.view.quantize2.AnalogStatisticsQuantizer)1 ValueChangeCounterQuantizer (com.serotonin.m2m2.view.quantize2.ValueChangeCounterQuantizer)1 IdPointValueStatisticsQuantizerCsvCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.IdPointValueStatisticsQuantizerCsvCallback)1 NonNumericPointValueStatisticsQuantizerCsvCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NonNumericPointValueStatisticsQuantizerCsvCallback)1 NumericPointValueStatisticsQuantizerCsvCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NumericPointValueStatisticsQuantizerCsvCallback)1 AnalogStatisticsChildQuantizer (com.serotonin.m2m2.web.mvc.rest.v1.statistics.AnalogStatisticsChildQuantizer)1 ParentDataQuantizer (com.serotonin.m2m2.web.mvc.rest.v1.statistics.ParentDataQuantizer)1 ValueChangeCounterChildQuantizer (com.serotonin.m2m2.web.mvc.rest.v1.statistics.ValueChangeCounterChildQuantizer)1 ArrayList (java.util.ArrayList)1