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;
}
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);
}
}
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);
}
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;
}
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);
}
Aggregations