Search in sources :

Example 31 with Data

use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.

the class ParameterController method getExtras.

@Override
public Map<String, Object> getExtras(HttpServletResponse response, String resourceId, String locale, MultiValueMap<String, String> query) {
    IoParameters map = createParameters(query, locale, response);
    LOGGER.debug("getExtras() with id '{}' and query '{}'", resourceId, map);
    Map<String, Object> extras = new HashMap<>();
    T from = parameterService.getParameter(resourceId, map);
    for (MetadataExtension<T> extension : metadataExtensions) {
        final Map<String, Object> furtherExtras = extension.getExtras(from, map);
        Collection<String> overridableKeys = checkForOverridingData(extras, furtherExtras);
        if (!overridableKeys.isEmpty()) {
            String[] keys = overridableKeys.toArray(new String[0]);
            LOGGER.warn("Metadata extension overrides existing extra data: {}", Arrays.toString(keys));
        }
        extras.putAll(furtherExtras);
    }
    return extras;
}
Also used : HashMap(java.util.HashMap) IoParameters(org.n52.io.request.IoParameters)

Example 32 with Data

use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.

the class ParameterController method getRawData.

@Override
public void getRawData(HttpServletResponse response, String id, String locale, MultiValueMap<String, String> query) {
    if (!parameterService.supportsRawData()) {
        throw new BadRequestException("Querying raw procedure data is not supported!");
    }
    IoParameters queryMap = createParameters(query, locale, response);
    LOGGER.debug("getRawData() with id '{}' and query '{}'", id, queryMap);
    try (InputStream inputStream = parameterService.getRawDataService().getRawData(id, queryMap)) {
        IOUtils.copyLarge(inputStream, response.getOutputStream());
    } catch (IOException e) {
        throw new InternalServerException("Error while querying raw data", e);
    }
}
Also used : InputStream(java.io.InputStream) InternalServerException(org.n52.web.exception.InternalServerException) BadRequestException(org.n52.web.exception.BadRequestException) IoParameters(org.n52.io.request.IoParameters) IOException(java.io.IOException)

Example 33 with Data

use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.

the class CountIoProcessChain method formatValueOutputs.

private DataCollection<?> formatValueOutputs() {
    FormatterFactory factory = FormatterFactory.createFormatterFactory(parameters);
    DataCollection<Data<CountValue>> data = getData();
    return factory.create().format(data);
}
Also used : FormatterFactory(org.n52.io.type.count.format.FormatterFactory) ResultTimeClassifiedData(org.n52.io.format.ResultTimeClassifiedData) Data(org.n52.io.response.dataset.Data)

Example 34 with Data

use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.

the class ProfileIoFactory method createHandler.

@Override
public IoHandler<Data<ProfileValue<?>>> createHandler(String outputMimeType) {
    IoParameters parameters = getParameters();
    Constants.MimeType mimeType = Constants.MimeType.toInstance(outputMimeType);
    if (mimeType == Constants.MimeType.APPLICATION_ZIP || mimeType == Constants.MimeType.TEXT_CSV) {
        ProfileCsvIoHandler handler = new ProfileCsvIoHandler(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 : Constants(org.n52.io.Constants) IoParameters(org.n52.io.request.IoParameters) ProfileCsvIoHandler(org.n52.io.handler.profile.ProfileCsvIoHandler)

Example 35 with Data

use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.

the class QuantityIoProcessChain method formatValueOutputs.

private DataCollection<?> formatValueOutputs() {
    FormatterFactory factory = FormatterFactory.createFormatterFactory(parameters);
    DataCollection<Data<QuantityValue>> data = getData();
    return factory.create().format(data);
}
Also used : FormatterFactory(org.n52.io.type.quantity.format.FormatterFactory) ResultTimeClassifiedData(org.n52.io.format.ResultTimeClassifiedData) Data(org.n52.io.response.dataset.Data)

Aggregations

IoParameters (org.n52.io.request.IoParameters)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 Data (org.n52.io.response.dataset.Data)13 IOException (java.io.IOException)12 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)11 HashMap (java.util.HashMap)6 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)6 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)6 InputStream (java.io.InputStream)5 XmlObject (org.apache.xmlbeans.XmlObject)5 IoParseException (org.n52.io.IoParseException)5 File (java.io.File)4 Test (org.junit.Test)4 InternalServerException (org.n52.web.exception.InternalServerException)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 BigDecimal (java.math.BigDecimal)3 ElasticsearchAwareTest (org.n52.iceland.statistics.basetests.ElasticsearchAwareTest)3 ResultTimeClassifiedData (org.n52.io.format.ResultTimeClassifiedData)3 RawDataService (org.n52.series.spi.srv.RawDataService)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3