Search in sources :

Example 61 with Data

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

the class TimeseriesDataController method getSeriesCollectionChart.

@RequestMapping(value = "/observations", produces = { Constants.IMAGE_PNG }, method = RequestMethod.POST)
public void getSeriesCollectionChart(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE, required = false) String httpLocale, @RequestBody RequestStyledParameterSet simpleParameters) throws Exception {
    IoParameters parameters = createParameters(simpleParameters, httpLocale, response);
    LOGGER.debug("get data collection chart with query: {}", parameters);
    checkForUnknownDatasetIds(parameters, parameters.getDatasets());
    // final String datasetType = getValueType(parameters);
    final String valueType = getValueType(parameters, request.getRequestURI());
    String outputFormat = Constants.IMAGE_PNG;
    response.setContentType(outputFormat);
    createIoFactory(valueType).setParameters(parameters).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
Also used : IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 62 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class ElasticsearchAdminHandler method initEmbeddedMode.

private void initEmbeddedMode() {
    embeddedServer = new EmbeddedElasticsearch();
    embeddedServer.setHomePath(context.getRealPath("/WEB-INF").concat("/elasticsearch"));
    embeddedServer.init();
    client = embeddedServer.getClient();
    logger.info("ElasticSearch data handler starting in EMBEDDED mode");
}
Also used : EmbeddedElasticsearch(org.n52.iceland.statistics.impl.server.EmbeddedElasticsearch)

Example 63 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class ElasticSearchDataHandlerIT method persistBasicData.

@Test
public void persistBasicData() throws InterruptedException {
    Thread.sleep(2500);
    Map<String, Object> data = new HashMap<>();
    data.put("alma", "korte");
    dataHandler.persist(data);
    logger.debug("Waiting 3s");
    Thread.sleep(2500);
    SearchResponse response = getEmbeddedClient().prepareSearch(clientSettings.getIndexId()).setTypes(clientSettings.getTypeId()).get();
    Assert.assertEquals("korte", response.getHits().getHits()[0].getSource().get("alma"));
}
Also used : HashMap(java.util.HashMap) SearchResponse(org.elasticsearch.action.search.SearchResponse) ElasticsearchAwareTest(org.n52.iceland.statistics.basetests.ElasticsearchAwareTest) Test(org.junit.Test)

Example 64 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class ElasticsearchAdminHandlerIT method connectTransportMode.

@Test
public void connectTransportMode() throws InterruptedException {
    settings.setNodeConnectionMode(ElasticsearchSettingsKeys.CONNECTION_MODE_TRANSPORT_CLIENT);
    adminHandler.init();
    Map<String, Object> data = new HashMap<>();
    data.put("test", "test-string");
    IndexResponse idx = dataHandler.persist(data);
    Thread.sleep(2000);
    String ret = getEmbeddedClient().prepareGet(idx.getIndex(), idx.getType(), idx.getId()).get().getSourceAsString();
    Assert.assertNotNull(ret);
}
Also used : HashMap(java.util.HashMap) IndexResponse(org.elasticsearch.action.index.IndexResponse) ElasticsearchAwareTest(org.n52.iceland.statistics.basetests.ElasticsearchAwareTest) Test(org.junit.Test)

Example 65 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class ElasticsearchAdminHandlerIT method connectNodeMode.

@Test
public void connectNodeMode() throws Exception {
    settings.setNodeConnectionMode(ElasticsearchSettingsKeys.CONNECTION_MODE_NODE);
    adminHandler.init();
    Map<String, Object> data = new HashMap<>();
    data.put("test", "test-string");
    IndexResponse idx = dataHandler.persist(data);
    Thread.sleep(2000);
    String ret = getEmbeddedClient().prepareGet(idx.getIndex(), idx.getType(), idx.getId()).get().getSourceAsString();
    Assert.assertNotNull(ret);
}
Also used : HashMap(java.util.HashMap) IndexResponse(org.elasticsearch.action.index.IndexResponse) ElasticsearchAwareTest(org.n52.iceland.statistics.basetests.ElasticsearchAwareTest) Test(org.junit.Test)

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