Merge remote-tracking branch 'origin/master' into ATEST-304

This commit is contained in:
Fabian Märki
2016-01-25 17:06:07 +01:00
2 changed files with 25 additions and 1 deletions

View File

@ -8,7 +8,7 @@ This project requires Java 8 or greater.
# Deployment # Deployment
Use the instructions provided by [ch.psi.daq.install](https://github.psi.ch/projects/ST/repos/ch.psi.daq.install/browse#query_rest) to install the application on a server. Use the instructions provided by [ch.psi.daq.install](https://git.psi.ch/sf_daq/ch.psi.daq.install#query_rest) to install the application on a server.
## Application Properties ## Application Properties

View File

@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -45,6 +46,7 @@ import ch.psi.daq.query.request.ChannelsRequest;
import ch.psi.daq.queryrest.response.csv.CSVResponseStreamWriter; import ch.psi.daq.queryrest.response.csv.CSVResponseStreamWriter;
import ch.psi.daq.queryrest.response.json.JSONResponseStreamWriter; import ch.psi.daq.queryrest.response.json.JSONResponseStreamWriter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@RestController @RestController
@ -68,6 +70,9 @@ public class QueryRestController {
@Resource @Resource
private ApplicationContext appContext; private ApplicationContext appContext;
@Resource
private ObjectMapper objectMapper;
// using Deferred ensures that data-api startup succeeds even if DataBuffer/ArchiverAppliance is // using Deferred ensures that data-api startup succeeds even if DataBuffer/ArchiverAppliance is
// not reachable at startup // not reachable at startup
private Deferred<QueryProcessor> cassandraQueryProcessor = new Deferred<QueryProcessor>( private Deferred<QueryProcessor> cassandraQueryProcessor = new Deferred<QueryProcessor>(
@ -158,6 +163,25 @@ public class QueryRestController {
} }
} }
/**
* Accepts the properties for the {@link DAQQuery} instance as stringified JSON query string.
*
* @param jsonBody The {@link DAQQuery} properties sent as a JSON string, i.e. this is the
* stringified body of the POST request method
* @param res the current {@link HttpServletResponse} instance
* @throws Exception if reading the JSON string fails or if the subsequent call to
* {@link #executeQuery(DAQQuery, HttpServletResponse)} fails
*/
@RequestMapping(
value = QUERY,
method = RequestMethod.GET)
public void executeQueryBodyAsString(@RequestParam String jsonBody, HttpServletResponse res) throws Exception {
DAQQuery query = objectMapper.readValue(jsonBody, DAQQuery.class);
executeQuery(query, res);
}
/** /**
* Returns data in CSV format to the client. * Returns data in CSV format to the client.
*/ */