Search in sources :

Example 1 with SimpleCsvIoHandler

use of org.n52.io.handler.simple.SimpleCsvIoHandler in project series-rest-api by 52North.

the class QuantityIoFactory method createHandler.

@Override
public IoHandler<Data<QuantityValue>> createHandler(String outputMimeType) {
    IoParameters parameters = getParameters();
    Constants.MimeType mimeType = Constants.MimeType.toInstance(outputMimeType);
    if (mimeType == Constants.MimeType.IMAGE_PNG) {
        return createMultiChartRenderer(mimeType);
    } else if (mimeType == Constants.MimeType.APPLICATION_PDF) {
        ChartIoHandler imgRenderer = createMultiChartRenderer(mimeType);
        return new PDFReportGenerator(parameters, createProcessChain(), imgRenderer);
    } else if (isCsvOutput(mimeType)) {
        CsvIoHandler<QuantityValue> handler = new SimpleCsvIoHandler<>(parameters, createProcessChain(), getMetadatas());
        boolean zipOutput = parameters.getAsBoolean(Parameters.ZIP, false);
        handler.setZipOutput(zipOutput || mimeType == Constants.MimeType.APPLICATION_ZIP);
        return handler;
    }
    String msg = "The requested media type '" + outputMimeType + "' is not supported.";
    IllegalArgumentException exception = new IllegalArgumentException(msg);
    throw exception;
}
Also used : SimpleCsvIoHandler(org.n52.io.handler.simple.SimpleCsvIoHandler) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) ChartIoHandler(org.n52.io.type.quantity.handler.img.ChartIoHandler) Constants(org.n52.io.Constants) IoParameters(org.n52.io.request.IoParameters) PDFReportGenerator(org.n52.io.type.quantity.handler.report.PDFReportGenerator)

Aggregations

Constants (org.n52.io.Constants)1 SimpleCsvIoHandler (org.n52.io.handler.simple.SimpleCsvIoHandler)1 IoParameters (org.n52.io.request.IoParameters)1 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)1 ChartIoHandler (org.n52.io.type.quantity.handler.img.ChartIoHandler)1 PDFReportGenerator (org.n52.io.type.quantity.handler.report.PDFReportGenerator)1