Search in sources :

Example 1 with ChartIoHandler

use of org.n52.io.quantity.img.ChartIoHandler in project series-rest-api by 52North.

the class QuantityIoFactory method createHandler.

@Override
public IoHandler<QuantityData> createHandler(String outputMimeType) {
    IoParameters parameters = getParameters();
    MimeType mimeType = MimeType.toInstance(outputMimeType);
    if (mimeType == MimeType.IMAGE_PNG) {
        return createMultiChartRenderer(mimeType);
    } else if (mimeType == MimeType.APPLICATION_PDF) {
        ChartIoHandler imgRenderer = createMultiChartRenderer(mimeType);
        PDFReportGenerator reportGenerator = new PDFReportGenerator(getRequestParameters(), createProcessChain(), imgRenderer);
        reportGenerator.setBaseURI(getBasePath());
        return reportGenerator;
    } else if (mimeType == MimeType.TEXT_CSV || mimeType == MimeType.APPLICATION_ZIP) {
        QuantityCsvIoHandler handler = new QuantityCsvIoHandler(getRequestParameters(), createProcessChain(), getMetadatas());
        handler.setTokenSeparator(parameters.getOther("tokenSeparator"));
        boolean zipOutput = parameters.getAsBoolean(MimeType.APPLICATION_ZIP.name());
        handler.setZipOutput(zipOutput || mimeType == MimeType.APPLICATION_ZIP);
        boolean byteOderMark = Boolean.parseBoolean(parameters.getOther("bom"));
        handler.setIncludeByteOrderMark(byteOderMark);
        return handler;
    }
    String msg = "The requested media type '" + outputMimeType + "' is not supported.";
    IllegalArgumentException exception = new IllegalArgumentException(msg);
    throw exception;
}
Also used : QuantityCsvIoHandler(org.n52.io.quantity.csv.QuantityCsvIoHandler) ChartIoHandler(org.n52.io.quantity.img.ChartIoHandler) IoParameters(org.n52.io.request.IoParameters) PDFReportGenerator(org.n52.io.quantity.report.PDFReportGenerator) MimeType(org.n52.io.MimeType)

Aggregations

MimeType (org.n52.io.MimeType)1 QuantityCsvIoHandler (org.n52.io.quantity.csv.QuantityCsvIoHandler)1 ChartIoHandler (org.n52.io.quantity.img.ChartIoHandler)1 PDFReportGenerator (org.n52.io.quantity.report.PDFReportGenerator)1 IoParameters (org.n52.io.request.IoParameters)1