Merge branch 'ATEST-316' into 'master'

Atest 316



See merge request !10
This commit is contained in:
maerki_f
2016-04-22 17:01:33 +02:00
12 changed files with 152 additions and 152 deletions

View File

@ -1,5 +1,5 @@
# #
#Thu Apr 14 08:26:07 CEST 2016 #Thu Apr 21 16:55:55 CEST 2016
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve

View File

@ -25,12 +25,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
import ch.psi.daq.common.statistic.StorelessStatistics; import ch.psi.daq.common.statistic.StorelessStatistics;
import ch.psi.daq.domain.DataEvent; import ch.psi.daq.domain.DataEvent;
import ch.psi.daq.domain.query.operation.Aggregation;
import ch.psi.daq.domain.query.operation.QueryField;
import ch.psi.daq.query.analyzer.QueryAnalyzer; import ch.psi.daq.query.analyzer.QueryAnalyzer;
import ch.psi.daq.query.analyzer.QueryAnalyzerImpl; import ch.psi.daq.query.analyzer.QueryAnalyzerImpl;
import ch.psi.daq.query.config.QueryConfig; import ch.psi.daq.query.config.QueryConfig;
import ch.psi.daq.query.model.Aggregation;
import ch.psi.daq.query.model.Query; import ch.psi.daq.query.model.Query;
import ch.psi.daq.query.model.QueryField;
import ch.psi.daq.queryrest.controller.validator.QueryValidator; import ch.psi.daq.queryrest.controller.validator.QueryValidator;
import ch.psi.daq.queryrest.model.PropertyFilterMixin; import ch.psi.daq.queryrest.model.PropertyFilterMixin;
import ch.psi.daq.queryrest.response.csv.CSVResponseStreamWriter; import ch.psi.daq.queryrest.response.csv.CSVResponseStreamWriter;

View File

@ -2,7 +2,6 @@ package ch.psi.daq.queryrest.controller;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -37,43 +36,43 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import ch.psi.daq.cassandra.config.CassandraConfig; import ch.psi.daq.cassandra.config.CassandraConfig;
import ch.psi.daq.cassandra.request.validate.RequestProviderValidator;
import ch.psi.daq.common.json.deserialize.AttributeBasedDeserializer; import ch.psi.daq.common.json.deserialize.AttributeBasedDeserializer;
import ch.psi.daq.common.ordering.Ordering; import ch.psi.daq.common.ordering.Ordering;
import ch.psi.daq.domain.DataEvent; import ch.psi.daq.domain.DataEvent;
import ch.psi.daq.domain.cassandra.FieldNames; import ch.psi.daq.domain.FieldNames;
import ch.psi.daq.domain.config.DomainConfig;
import ch.psi.daq.domain.json.ChannelName; import ch.psi.daq.domain.json.ChannelName;
import ch.psi.daq.domain.query.DAQQueries;
import ch.psi.daq.domain.query.DAQQuery;
import ch.psi.daq.domain.query.DAQQueryElement;
import ch.psi.daq.domain.query.channels.ChannelsRequest;
import ch.psi.daq.domain.query.channels.ChannelsResponse;
import ch.psi.daq.domain.query.operation.Aggregation;
import ch.psi.daq.domain.query.operation.AggregationType;
import ch.psi.daq.domain.query.operation.QueryField;
import ch.psi.daq.domain.query.operation.ResponseFormat;
import ch.psi.daq.domain.reader.Backend; import ch.psi.daq.domain.reader.Backend;
import ch.psi.daq.domain.request.validate.RequestProviderValidator;
import ch.psi.daq.query.analyzer.QueryAnalyzer; import ch.psi.daq.query.analyzer.QueryAnalyzer;
import ch.psi.daq.query.config.QueryConfig; import ch.psi.daq.query.config.QueryConfig;
import ch.psi.daq.query.model.Aggregation;
import ch.psi.daq.query.model.AggregationType;
import ch.psi.daq.query.model.Query; import ch.psi.daq.query.model.Query;
import ch.psi.daq.query.model.QueryField;
import ch.psi.daq.query.model.ResponseFormat;
import ch.psi.daq.query.model.impl.BackendQuery; import ch.psi.daq.query.model.impl.BackendQuery;
import ch.psi.daq.query.model.impl.DAQQueries;
import ch.psi.daq.query.model.impl.DAQQuery;
import ch.psi.daq.query.model.impl.DAQQueryElement;
import ch.psi.daq.query.processor.ChannelNameCache; import ch.psi.daq.query.processor.ChannelNameCache;
import ch.psi.daq.query.processor.QueryProcessor; import ch.psi.daq.query.processor.QueryProcessor;
import ch.psi.daq.query.request.ChannelsRequest;
import ch.psi.daq.query.request.ChannelsResponse;
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.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hazelcast.nio.serialization.FieldType;
@RestController @RestController
public class QueryRestController { public class QueryRestController {
private static final Logger LOGGER = LoggerFactory.getLogger(QueryRestController.class); private static final Logger LOGGER = LoggerFactory.getLogger(QueryRestController.class);
public static final String CHANNELS = "/channels"; public static final String PATH_CHANNELS = DomainConfig.PATH_CHANNELS;
public static final String QUERY = "/query"; public static final String PATH_QUERY = DomainConfig.PATH_QUERY;
public static final String QUERIES = "/queries"; public static final String PATH_QUERIES = DomainConfig.PATH_QUERIES;
@Resource @Resource
private Validator queryValidator; private Validator queryValidator;
@ -100,7 +99,7 @@ public class QueryRestController {
@PostConstruct @PostConstruct
public void afterPropertiesSet() { public void afterPropertiesSet() {
List<Exception> exceptions = new ArrayList<>(); List<Exception> exceptions = new ArrayList<>();
try { try {
QueryProcessor queryProcessor = QueryProcessor queryProcessor =
appContext.getBean(QueryConfig.BEAN_NAME_CASSANDRA_QUERY_PROCESSOR, QueryProcessor.class); appContext.getBean(QueryConfig.BEAN_NAME_CASSANDRA_QUERY_PROCESSOR, QueryProcessor.class);
@ -126,13 +125,13 @@ public class QueryRestController {
LOGGER.warn("##########"); LOGGER.warn("##########");
LOGGER.warn(""); LOGGER.warn("");
} }
if(queryProcessors.isEmpty()){ if (queryProcessors.isEmpty()) {
LOGGER.error("No query processor could be loaded! Exceptions were: "); LOGGER.error("No query processor could be loaded! Exceptions were: ");
for (Exception exception : exceptions) { for (Exception exception : exceptions) {
LOGGER.error("", exception); LOGGER.error("", exception);
} }
throw new RuntimeException("No Backends available!"); throw new RuntimeException("No Backends available!");
} }
@ -158,7 +157,7 @@ public class QueryRestController {
} }
} }
@RequestMapping(value = CHANNELS, method = {RequestMethod.GET, RequestMethod.POST}, @RequestMapping(value = PATH_CHANNELS, method = {RequestMethod.GET, RequestMethod.POST},
produces = {MediaType.APPLICATION_JSON_VALUE}) produces = {MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody List<ChannelsResponse> getChannels(@RequestBody(required = false) ChannelsRequest request) public @ResponseBody List<ChannelsResponse> getChannels(@RequestBody(required = false) ChannelsRequest request)
throws Throwable { throws Throwable {
@ -177,7 +176,7 @@ public class QueryRestController {
* @return Collection of channel names matching the specified input channel name * @return Collection of channel names matching the specified input channel name
* @throws Throwable in case something goes wrong * @throws Throwable in case something goes wrong
*/ */
@RequestMapping(value = CHANNELS + "/{channelName}", method = {RequestMethod.GET}, @RequestMapping(value = PATH_CHANNELS + "/{channelName}", method = {RequestMethod.GET},
produces = {MediaType.APPLICATION_JSON_VALUE}) produces = {MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody Collection<ChannelsResponse> getChannels(@PathVariable(value = "channelName") String channelName) public @ResponseBody Collection<ChannelsResponse> getChannels(@PathVariable(value = "channelName") String channelName)
throws Throwable { throws Throwable {
@ -194,7 +193,7 @@ public class QueryRestController {
* {@link #executeQuery(DAQQuery, HttpServletResponse)} fails * {@link #executeQuery(DAQQuery, HttpServletResponse)} fails
*/ */
@RequestMapping( @RequestMapping(
value = QUERY, value = PATH_QUERY,
method = RequestMethod.GET) method = RequestMethod.GET)
public void executeQueryBodyAsString(@RequestParam String jsonBody, HttpServletResponse res) throws Exception { public void executeQueryBodyAsString(@RequestParam String jsonBody, HttpServletResponse res) throws Exception {
DAQQuery query = objectMapper.readValue(jsonBody, DAQQuery.class); DAQQuery query = objectMapper.readValue(jsonBody, DAQQuery.class);
@ -209,7 +208,7 @@ public class QueryRestController {
* @throws IOException thrown if writing to the output stream fails * @throws IOException thrown if writing to the output stream fails
*/ */
@RequestMapping( @RequestMapping(
value = QUERY, value = PATH_QUERY,
method = RequestMethod.POST, method = RequestMethod.POST,
consumes = {MediaType.APPLICATION_JSON_VALUE}) consumes = {MediaType.APPLICATION_JSON_VALUE})
public void executeQuery(@RequestBody @Valid DAQQuery query, HttpServletResponse res) throws Exception { public void executeQuery(@RequestBody @Valid DAQQuery query, HttpServletResponse res) throws Exception {
@ -226,7 +225,7 @@ public class QueryRestController {
* {@link #executeQueries(DAQQueries, HttpServletResponse)} fails * {@link #executeQueries(DAQQueries, HttpServletResponse)} fails
*/ */
@RequestMapping( @RequestMapping(
value = QUERIES, value = PATH_QUERIES,
method = RequestMethod.GET) method = RequestMethod.GET)
public void executeQueriesBodyAsString(@RequestParam String jsonBody, HttpServletResponse res) throws Exception { public void executeQueriesBodyAsString(@RequestParam String jsonBody, HttpServletResponse res) throws Exception {
DAQQueries queries = objectMapper.readValue(jsonBody, DAQQueries.class); DAQQueries queries = objectMapper.readValue(jsonBody, DAQQueries.class);
@ -246,7 +245,7 @@ public class QueryRestController {
* @throws IOException thrown if writing to the output stream fails * @throws IOException thrown if writing to the output stream fails
*/ */
@RequestMapping( @RequestMapping(
value = QUERIES, value = PATH_QUERIES,
method = RequestMethod.POST, method = RequestMethod.POST,
consumes = {MediaType.APPLICATION_JSON_VALUE}) consumes = {MediaType.APPLICATION_JSON_VALUE})
public void executeQueries(@RequestBody @Valid DAQQueries queries, HttpServletResponse res) throws Exception { public void executeQueries(@RequestBody @Valid DAQQueries queries, HttpServletResponse res) throws Exception {
@ -285,9 +284,9 @@ public class QueryRestController {
LOGGER.warn(message); LOGGER.warn(message);
throw new IllegalArgumentException(message); throw new IllegalArgumentException(message);
} }
if(!ArrayUtils.contains(query.getColumns(), FieldNames.FIELD_GLOBAL_TIME)){ if (!ArrayUtils.contains(query.getColumns(), FieldNames.FIELD_GLOBAL_TIME)) {
query.addField(QueryField.globalMillis); query.addField(QueryField.globalMillis);
} }
} }
@ -312,8 +311,8 @@ public class QueryRestController {
for (DAQQueryElement queryElement : queries) { for (DAQQueryElement queryElement : queries) {
Stream<Triple<BackendQuery, ChannelName, ?>> resultStreams = Stream<Triple<BackendQuery, ChannelName, ?>> resultStreams =
queryElement BackendQuery
.getBackendQueries() .getBackendQueries(queryElement)
.stream() .stream()
.filter(query -> { .filter(query -> {
QueryProcessor processor = queryProcessors.get(query.getBackend()); QueryProcessor processor = queryProcessors.get(query.getBackend());
@ -366,7 +365,8 @@ public class QueryRestController {
* *
* @return list of {@link Ordering}s as String array * @return list of {@link Ordering}s as String array
*/ */
@RequestMapping(value = "responseformat", method = {RequestMethod.GET}, produces = {MediaType.APPLICATION_JSON_VALUE}) @RequestMapping(value = "responseformat", method = {RequestMethod.GET},
produces = {MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody List<ResponseFormat> getResponseFormatValues() { public @ResponseBody List<ResponseFormat> getResponseFormatValues() {
return Lists.newArrayList(ResponseFormat.values()); return Lists.newArrayList(ResponseFormat.values());
} }

View File

@ -9,11 +9,11 @@ import javax.annotation.Resource;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.validation.Validator; import org.springframework.validation.Validator;
import ch.psi.daq.query.model.Aggregation; import ch.psi.daq.domain.query.DAQQueries;
import ch.psi.daq.query.model.QueryField; import ch.psi.daq.domain.query.DAQQuery;
import ch.psi.daq.query.model.impl.DAQQueries; import ch.psi.daq.domain.query.DAQQueryElement;
import ch.psi.daq.query.model.impl.DAQQuery; import ch.psi.daq.domain.query.operation.Aggregation;
import ch.psi.daq.query.model.impl.DAQQueryElement; import ch.psi.daq.domain.query.operation.QueryField;
import ch.psi.daq.queryrest.config.QueryRestConfig; import ch.psi.daq.queryrest.config.QueryRestConfig;
public class QueryValidator implements Validator { public class QueryValidator implements Validator {

View File

@ -9,8 +9,8 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import ch.psi.daq.query.model.ResponseFormat; import ch.psi.daq.domain.query.operation.ResponseFormat;
import ch.psi.daq.query.model.ResponseOptions; import ch.psi.daq.domain.query.operation.ResponseOptions;
public abstract class AbstractResponseStreamWriter implements ResponseStreamWriter { public abstract class AbstractResponseStreamWriter implements ResponseStreamWriter {

View File

@ -10,9 +10,9 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.tuple.Triple; import org.apache.commons.lang3.tuple.Triple;
import ch.psi.daq.domain.json.ChannelName; import ch.psi.daq.domain.json.ChannelName;
import ch.psi.daq.query.model.ResponseOptions; import ch.psi.daq.domain.query.DAQQueryElement;
import ch.psi.daq.domain.query.operation.ResponseOptions;
import ch.psi.daq.query.model.impl.BackendQuery; import ch.psi.daq.query.model.impl.BackendQuery;
import ch.psi.daq.query.model.impl.DAQQueryElement;
public interface ResponseStreamWriter { public interface ResponseStreamWriter {

View File

@ -36,13 +36,13 @@ import ch.psi.daq.common.stream.StreamIterable;
import ch.psi.daq.common.stream.StreamMatcher; import ch.psi.daq.common.stream.StreamMatcher;
import ch.psi.daq.domain.DataEvent; import ch.psi.daq.domain.DataEvent;
import ch.psi.daq.domain.json.ChannelName; import ch.psi.daq.domain.json.ChannelName;
import ch.psi.daq.domain.query.DAQQueryElement;
import ch.psi.daq.domain.query.operation.Aggregation;
import ch.psi.daq.domain.query.operation.QueryField;
import ch.psi.daq.domain.query.operation.ResponseOptions;
import ch.psi.daq.query.analyzer.QueryAnalyzer; import ch.psi.daq.query.analyzer.QueryAnalyzer;
import ch.psi.daq.query.model.Aggregation;
import ch.psi.daq.query.model.Query; import ch.psi.daq.query.model.Query;
import ch.psi.daq.query.model.QueryField;
import ch.psi.daq.query.model.ResponseOptions;
import ch.psi.daq.query.model.impl.BackendQuery; import ch.psi.daq.query.model.impl.BackendQuery;
import ch.psi.daq.query.model.impl.DAQQueryElement;
import ch.psi.daq.queryrest.response.AbstractResponseStreamWriter; import ch.psi.daq.queryrest.response.AbstractResponseStreamWriter;
/** /**

View File

@ -26,11 +26,11 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import ch.psi.daq.domain.json.ChannelName; import ch.psi.daq.domain.json.ChannelName;
import ch.psi.daq.query.model.Aggregation; import ch.psi.daq.domain.query.DAQQueryElement;
import ch.psi.daq.query.model.QueryField; import ch.psi.daq.domain.query.operation.Aggregation;
import ch.psi.daq.query.model.ResponseOptions; import ch.psi.daq.domain.query.operation.QueryField;
import ch.psi.daq.domain.query.operation.ResponseOptions;
import ch.psi.daq.query.model.impl.BackendQuery; import ch.psi.daq.query.model.impl.BackendQuery;
import ch.psi.daq.query.model.impl.DAQQueryElement;
import ch.psi.daq.queryrest.response.AbstractResponseStreamWriter; import ch.psi.daq.queryrest.response.AbstractResponseStreamWriter;
/** /**

View File

@ -23,20 +23,20 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers; import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import ch.psi.daq.cassandra.request.range.RequestRangeDate;
import ch.psi.daq.cassandra.request.range.RequestRangePulseId;
import ch.psi.daq.cassandra.request.range.RequestRangeTime;
import ch.psi.daq.common.ordering.Ordering; import ch.psi.daq.common.ordering.Ordering;
import ch.psi.daq.common.time.TimeUtils; import ch.psi.daq.common.time.TimeUtils;
import ch.psi.daq.domain.query.DAQQueries;
import ch.psi.daq.domain.query.DAQQuery;
import ch.psi.daq.domain.query.DAQQueryElement;
import ch.psi.daq.domain.query.operation.Aggregation;
import ch.psi.daq.domain.query.operation.AggregationType;
import ch.psi.daq.domain.query.operation.Compression;
import ch.psi.daq.domain.query.operation.QueryField;
import ch.psi.daq.domain.query.operation.ResponseFormat;
import ch.psi.daq.domain.request.range.RequestRangeDate;
import ch.psi.daq.domain.request.range.RequestRangePulseId;
import ch.psi.daq.domain.request.range.RequestRangeTime;
import ch.psi.daq.domain.test.TestTimeUtils; import ch.psi.daq.domain.test.TestTimeUtils;
import ch.psi.daq.query.model.Aggregation;
import ch.psi.daq.query.model.AggregationType;
import ch.psi.daq.query.model.Compression;
import ch.psi.daq.query.model.QueryField;
import ch.psi.daq.query.model.ResponseFormat;
import ch.psi.daq.query.model.impl.DAQQueries;
import ch.psi.daq.query.model.impl.DAQQuery;
import ch.psi.daq.query.model.impl.DAQQueryElement;
import ch.psi.daq.queryrest.controller.QueryRestController; import ch.psi.daq.queryrest.controller.QueryRestController;
import ch.psi.daq.queryrest.response.csv.CSVResponseStreamWriter; import ch.psi.daq.queryrest.response.csv.CSVResponseStreamWriter;
import ch.psi.daq.test.queryrest.AbstractDaqRestTest; import ch.psi.daq.test.queryrest.AbstractDaqRestTest;
@ -81,7 +81,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -169,7 +169,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -257,7 +257,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -354,7 +354,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERIES) .post(QueryRestController.PATH_QUERIES)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -437,7 +437,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -521,7 +521,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -608,7 +608,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -682,7 +682,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
try { try {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()); .andDo(MockMvcResultHandlers.print());
@ -712,7 +712,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
try { try {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()); .andDo(MockMvcResultHandlers.print());
@ -763,7 +763,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -863,7 +863,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -946,7 +946,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
MvcResult result = this.mockMvc MvcResult result = this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
@ -1002,7 +1002,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -1024,7 +1024,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))

View File

@ -8,21 +8,21 @@ import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import ch.psi.daq.cassandra.request.range.RequestRangeDate;
import ch.psi.daq.cassandra.request.range.RequestRangePulseId;
import ch.psi.daq.cassandra.request.range.RequestRangeTime;
import ch.psi.daq.common.ordering.Ordering; import ch.psi.daq.common.ordering.Ordering;
import ch.psi.daq.common.time.TimeUtils; import ch.psi.daq.common.time.TimeUtils;
import ch.psi.daq.domain.json.ChannelName; import ch.psi.daq.domain.json.ChannelName;
import ch.psi.daq.domain.query.DAQQueries;
import ch.psi.daq.domain.query.DAQQuery;
import ch.psi.daq.domain.query.DAQQueryElement;
import ch.psi.daq.domain.query.channels.ChannelsRequest;
import ch.psi.daq.domain.query.operation.AggregationType;
import ch.psi.daq.domain.query.operation.Compression;
import ch.psi.daq.domain.query.operation.QueryField;
import ch.psi.daq.domain.reader.Backend; import ch.psi.daq.domain.reader.Backend;
import ch.psi.daq.domain.request.range.RequestRangeDate;
import ch.psi.daq.domain.request.range.RequestRangePulseId;
import ch.psi.daq.domain.request.range.RequestRangeTime;
import ch.psi.daq.domain.test.TestTimeUtils; import ch.psi.daq.domain.test.TestTimeUtils;
import ch.psi.daq.query.model.AggregationType;
import ch.psi.daq.query.model.Compression;
import ch.psi.daq.query.model.QueryField;
import ch.psi.daq.query.model.impl.DAQQueries;
import ch.psi.daq.query.model.impl.DAQQuery;
import ch.psi.daq.query.model.impl.DAQQueryElement;
import ch.psi.daq.query.request.ChannelsRequest;
import ch.psi.daq.queryrest.controller.QueryRestController; import ch.psi.daq.queryrest.controller.QueryRestController;
import ch.psi.daq.test.queryrest.AbstractDaqRestTest; import ch.psi.daq.test.queryrest.AbstractDaqRestTest;
@ -44,13 +44,13 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform( .perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.get(QueryRestController.CHANNELS) .get(QueryRestController.PATH_CHANNELS)
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.databuffer.name())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").value("BoolScalar")) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").value("BoolScalar"))
@ -73,13 +73,13 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
public void testSpecificChannelSearch() throws Exception { public void testSpecificChannelSearch() throws Exception {
this.mockMvc.perform( this.mockMvc.perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.get(QueryRestController.CHANNELS + "/int32") .get(QueryRestController.PATH_CHANNELS + "/int32")
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.databuffer.name())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").value("Int32Scalar")) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").value("Int32Scalar"))
@ -98,21 +98,21 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
@Test @Test
public void testChannelNameQueryBackendOrder() throws Exception { public void testChannelNameQueryBackendOrder() throws Exception {
ChannelsRequest request = new ChannelsRequest("int64", Ordering.desc, Backend.databuffer); ChannelsRequest request = new ChannelsRequest("int64", Ordering.desc, Backend.SF_DATABUFFER);
String content = mapper.writeValueAsString(request); String content = mapper.writeValueAsString(request);
System.out.println(content); System.out.println(content);
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.CHANNELS) .post(QueryRestController.PATH_CHANNELS)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.databuffer.name())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").value("UInt64Waveform")) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[0]").value("UInt64Waveform"))
@ -134,14 +134,14 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.CHANNELS) .post(QueryRestController.PATH_CHANNELS)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.databuffer.name())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[23]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[23]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[24]").doesNotExist()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[24]").doesNotExist())
@ -160,14 +160,14 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.CHANNELS) .post(QueryRestController.PATH_CHANNELS)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.databuffer.name())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[24]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[24]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[25]").doesNotExist()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[25]").doesNotExist())
@ -185,7 +185,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc.perform( this.mockMvc.perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.options(QueryRestController.CHANNELS) .options(QueryRestController.PATH_CHANNELS)
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultHandlers.print()) .andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -201,7 +201,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
// curl -H "Origin: *" -H "Access-Control-Request-Method: POST" -X OPTIONS -v http://localhost:8080/channels // curl -H "Origin: *" -H "Access-Control-Request-Method: POST" -X OPTIONS -v http://localhost:8080/channels
this.mockMvc.perform( this.mockMvc.perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.options(QueryRestController.CHANNELS) .options(QueryRestController.PATH_CHANNELS)
.header("Origin", "*") .header("Origin", "*")
.header("Access-Control-Request-Method", "POST") .header("Access-Control-Request-Method", "POST")
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
@ -212,7 +212,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
// curl -H "Origin: http://localhost:8080" -H "Access-Control-Request-Method: POST" -X OPTIONS -v http://localhost:8080/channels // curl -H "Origin: http://localhost:8080" -H "Access-Control-Request-Method: POST" -X OPTIONS -v http://localhost:8080/channels
this.mockMvc.perform( this.mockMvc.perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.options(QueryRestController.CHANNELS) .options(QueryRestController.PATH_CHANNELS)
.header("Origin", "http://localhost:8080") .header("Origin", "http://localhost:8080")
.header("Access-Control-Request-Method", "POST") .header("Access-Control-Request-Method", "POST")
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
@ -239,7 +239,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -297,7 +297,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -325,15 +325,15 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
new RequestRangePulseId( new RequestRangePulseId(
100, 100,
101), 101),
new ChannelName(TEST_CHANNEL_01, Backend.databuffer), new ChannelName(TEST_CHANNEL_01, Backend.SF_DATABUFFER),
new ChannelName(TEST_CHANNEL_02, Backend.archiverappliance)); new ChannelName(TEST_CHANNEL_02, Backend.SF_ARCHIVERAPPLIANCE));
String content = mapper.writeValueAsString(request); String content = mapper.writeValueAsString(request);
System.out.println(content); System.out.println(content);
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -380,7 +380,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERIES) .post(QueryRestController.PATH_QUERIES)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -429,7 +429,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
String content = mapper.writeValueAsString(request); String content = mapper.writeValueAsString(request);
this.mockMvc.perform(MockMvcRequestBuilders this.mockMvc.perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -474,7 +474,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform( .perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content) .content(content)
) )
@ -483,7 +483,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
.andExpect(MockMvcResultMatchers.jsonPath("$").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.name").value(TEST_CHANNEL_01)) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.name").value(TEST_CHANNEL_01))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.backend").value("databuffer")) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(100)) .andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value( .andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value(
@ -493,7 +493,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
TestTimeUtils.getTimeStr(1, 10000000))) TestTimeUtils.getTimeStr(1, 10000000)))
.andExpect(MockMvcResultMatchers.jsonPath("$[1]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[1]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].channel.name").value(TEST_CHANNEL_02)) .andExpect(MockMvcResultMatchers.jsonPath("$[1].channel.name").value(TEST_CHANNEL_02))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].channel.backend").value("databuffer")) .andExpect(MockMvcResultMatchers.jsonPath("$[1].channel.backend").value("sf-databuffer"))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[1].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].pulseId").value(100)) .andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].globalSeconds").value( .andExpect(MockMvcResultMatchers.jsonPath("$[1].data[0].globalSeconds").value(
@ -516,7 +516,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
String content = mapper.writeValueAsString(request); String content = mapper.writeValueAsString(request);
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders.post(QueryRestController.QUERY) .perform(MockMvcRequestBuilders.post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -562,7 +562,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform( .perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content) .content(content)
) )
@ -572,7 +572,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").isMap()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").isMap())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.name").value(TEST_CHANNEL_01)) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.name").value(TEST_CHANNEL_01))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.backend").value(Backend.databuffer.name())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(100)) .andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(100))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value( .andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value(
@ -603,7 +603,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform( .perform(
MockMvcRequestBuilders MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content) .content(content)
) )
@ -613,7 +613,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
.andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists()) .andExpect(MockMvcResultMatchers.jsonPath("$[0]").exists())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").isMap()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel").isMap())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.name").value(TEST_CHANNEL_01)) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.name").value(TEST_CHANNEL_01))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.backend").value(Backend.databuffer.name())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channel.backend").value(Backend.SF_DATABUFFER.getKey()))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].data").isArray())
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(1000)) .andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].pulseId").value(1000))
.andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value( .andExpect(MockMvcResultMatchers.jsonPath("$[0].data[0].globalSeconds").value(
@ -671,7 +671,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))
@ -692,7 +692,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
this.mockMvc this.mockMvc
.perform(MockMvcRequestBuilders .perform(MockMvcRequestBuilders
.post(QueryRestController.QUERY) .post(QueryRestController.PATH_QUERY)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.content(content)) .content(content))

View File

@ -8,8 +8,9 @@ import java.util.stream.Stream;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import ch.psi.daq.domain.StreamEvent; import ch.psi.daq.domain.StreamEvent;
import ch.psi.daq.domain.cassandra.query.PulseIdRangeQuery; import ch.psi.daq.domain.query.backend.PulseIdRangeQuery;
import ch.psi.daq.domain.cassandra.query.TimeRangeQuery; import ch.psi.daq.domain.query.backend.TimeRangeQuery;
import ch.psi.daq.domain.query.event.EventQuery;
import ch.psi.daq.domain.reader.Backend; import ch.psi.daq.domain.reader.Backend;
import ch.psi.daq.domain.reader.DataReader; import ch.psi.daq.domain.reader.DataReader;
@ -25,7 +26,7 @@ public class DummyArchiverApplianceReader implements DataReader {
@Override @Override
public Backend getBackend() { public Backend getBackend() {
return Backend.archiverappliance; return Backend.SF_ARCHIVERAPPLIANCE;
} }
@Override @Override
@ -45,12 +46,12 @@ public class DummyArchiverApplianceReader implements DataReader {
public Stream<? extends StreamEvent> getEventStream(PulseIdRangeQuery query) { public Stream<? extends StreamEvent> getEventStream(PulseIdRangeQuery query) {
return DummyCassandraReader.getDummyEventStream(query.getChannel(), query.getStartPulseId(), query.getEndPulseId(), return DummyCassandraReader.getDummyEventStream(query.getChannel(), query.getStartPulseId(), query.getEndPulseId(),
query.getEventColumns()) query.getEventColumns())
.filter(query.getFilterOrDefault(NO_OP_FILTER)); .filter(query.getFilterOrDefault(EventQuery.NO_OP_FILTER));
} }
@Override @Override
public Stream<? extends StreamEvent> getEventStream(TimeRangeQuery query) { public Stream<? extends StreamEvent> getEventStream(TimeRangeQuery query) {
return DummyCassandraReader.getDummyEventStream(query.getChannel(), query.getStartMillis() / 10, query.getEndMillis() / 10) return DummyCassandraReader.getDummyEventStream(query.getChannel(), query.getStartMillis() / 10, query.getEndMillis() / 10)
.filter(query.getFilterOrDefault(NO_OP_FILTER)); .filter(query.getFilterOrDefault(EventQuery.NO_OP_FILTER));
} }
} }

View File

@ -7,7 +7,6 @@ import java.math.BigDecimal;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.StringJoiner;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -22,21 +21,21 @@ import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import ch.psi.daq.cassandra.domain.ChannelConfiguration;
import ch.psi.daq.cassandra.domain.ChannelEvent;
import ch.psi.daq.cassandra.domain.MetaPulseId;
import ch.psi.daq.cassandra.reader.CassandraReader; import ch.psi.daq.cassandra.reader.CassandraReader;
import ch.psi.daq.cassandra.util.test.CassandraDataGen; import ch.psi.daq.cassandra.util.test.CassandraDataGen;
import ch.psi.daq.common.time.TimeUtils; import ch.psi.daq.common.time.TimeUtils;
import ch.psi.daq.domain.DataEvent; import ch.psi.daq.domain.DataEvent;
import ch.psi.daq.domain.cassandra.ChannelConfiguration; import ch.psi.daq.domain.FieldNames;
import ch.psi.daq.domain.cassandra.ChannelEvent; import ch.psi.daq.domain.query.backend.PulseIdRangeQuery;
import ch.psi.daq.domain.cassandra.FieldNames; import ch.psi.daq.domain.query.backend.TimeRangeQuery;
import ch.psi.daq.domain.cassandra.MetaPulseId; import ch.psi.daq.domain.query.event.EventQuery;
import ch.psi.daq.domain.cassandra.query.PulseIdRangeQuery; import ch.psi.daq.domain.query.event.StreamEventQuery;
import ch.psi.daq.domain.cassandra.query.TimeRangeQuery;
import ch.psi.daq.domain.cassandra.querying.ChannelEventQuery;
import ch.psi.daq.domain.cassandra.querying.EventQuery;
import ch.psi.daq.domain.cassandra.querying.MetaChannelEvent;
import ch.psi.daq.domain.cassandra.utils.TablePropertiesUtils;
import ch.psi.daq.domain.reader.Backend; import ch.psi.daq.domain.reader.Backend;
import ch.psi.daq.domain.reader.MetaStreamEvent;
import ch.psi.daq.domain.utils.PropertiesUtils;
public class DummyCassandraReader implements CassandraReader { public class DummyCassandraReader implements CassandraReader {
private static final Logger LOGGER = LoggerFactory.getLogger(DummyCassandraReader.class); private static final Logger LOGGER = LoggerFactory.getLogger(DummyCassandraReader.class);
@ -82,7 +81,7 @@ public class DummyCassandraReader implements CassandraReader {
@Override @Override
public Backend getBackend() { public Backend getBackend() {
return Backend.databuffer; return Backend.SF_DATABUFFER;
} }
/** /**
@ -104,23 +103,23 @@ public class DummyCassandraReader implements CassandraReader {
public Stream<ChannelEvent> getEventStream(PulseIdRangeQuery query) { public Stream<ChannelEvent> getEventStream(PulseIdRangeQuery query) {
return getDummyEventStream(query.getChannel(), query.getStartPulseId(), query.getEndPulseId(), return getDummyEventStream(query.getChannel(), query.getStartPulseId(), query.getEndPulseId(),
query.getEventColumns()) query.getEventColumns())
.filter(query.getFilterOrDefault(NO_OP_FILTER)); .filter(query.getFilterOrDefault(EventQuery.NO_OP_FILTER));
} }
@Override @Override
public Stream<ChannelEvent> getEventStream(TimeRangeQuery query) { public Stream<ChannelEvent> getEventStream(TimeRangeQuery query) {
return getDummyEventStream(query.getChannel(), query.getStartMillis() / 10, query.getEndMillis() / 10) return getDummyEventStream(query.getChannel(), query.getStartMillis() / 10, query.getEndMillis() / 10)
.filter(query.getFilterOrDefault(NO_OP_FILTER)); .filter(query.getFilterOrDefault(EventQuery.NO_OP_FILTER));
} }
/** /**
* @{inheritDoc * @{inheritDoc
*/ */
@Override @Override
public Stream<ChannelEvent> getEventStream(EventQuery eventQuery, Stream<? extends ChannelEventQuery> queryProviders) { public Stream<ChannelEvent> getEventStream(EventQuery eventQuery, Stream<? extends StreamEventQuery> queryProviders) {
Stream<ChannelEvent> result = queryProviders.map(ceq -> { Stream<ChannelEvent> result = queryProviders.map(ceq -> {
if (ceq instanceof MetaChannelEvent) { if (ceq instanceof MetaStreamEvent) {
return getEvent((MetaChannelEvent) ceq); return getEvent((MetaStreamEvent<ChannelEvent>) ceq);
} else { } else {
throw new UnsupportedOperationException("This is not yet implemented!"); throw new UnsupportedOperationException("This is not yet implemented!");
} }
@ -158,14 +157,14 @@ public class DummyCassandraReader implements CassandraReader {
BigDecimal iocTime = BigDecimal iocTime =
(columns == null || columns.length == 0 || ArrayUtils.contains(columns, (columns == null || columns.length == 0 || ArrayUtils.contains(columns,
FieldNames.FIELD_IOC_TIME)) ? TimeUtils.getTimeFromMillis(i * 10, 0) FieldNames.FIELD_IOC_TIME)) ? TimeUtils.getTimeFromMillis(i * 10, 0)
: TablePropertiesUtils.DEFAULT_VALUE_DECIMAL; : PropertiesUtils.DEFAULT_VALUE_DECIMAL;
BigDecimal globalTime = BigDecimal globalTime =
(columns == null || columns.length == 0 || ArrayUtils.contains(columns, (columns == null || columns.length == 0 || ArrayUtils.contains(columns,
FieldNames.FIELD_GLOBAL_TIME)) ? TimeUtils.getTimeFromMillis(i * 10, 0) FieldNames.FIELD_GLOBAL_TIME)) ? TimeUtils.getTimeFromMillis(i * 10, 0)
: TablePropertiesUtils.DEFAULT_VALUE_DECIMAL; : PropertiesUtils.DEFAULT_VALUE_DECIMAL;
long pulseId = long pulseId =
(columns == null || columns.length == 0 || ArrayUtils.contains(columns, (columns == null || columns.length == 0 || ArrayUtils.contains(columns,
FieldNames.FIELD_PULSE_ID)) ? i : TablePropertiesUtils.DEFAULT_VALUE_BIGINT_PRIMITIVE; FieldNames.FIELD_PULSE_ID)) ? i : PropertiesUtils.DEFAULT_VALUE_BIGINT_PRIMITIVE;
if (channelLower.contains("waveform")) { if (channelLower.contains("waveform")) {
long[] value = random.longs(2048).toArray(); long[] value = random.longs(2048).toArray();
@ -235,7 +234,7 @@ public class DummyCassandraReader implements CassandraReader {
* @{inheritDoc * @{inheritDoc
*/ */
@Override @Override
public ChannelEvent getEvent(MetaChannelEvent queryInfo, String... columns) { public ChannelEvent getEvent(MetaStreamEvent<ChannelEvent> queryInfo, String... columns) {
if (queryInfo.getPulseId() > 0) { if (queryInfo.getPulseId() > 0) {
return (ChannelEvent) getDummyEvents(queryInfo.getChannel(), queryInfo.getPulseId(), queryInfo.getPulseId(), return (ChannelEvent) getDummyEvents(queryInfo.getChannel(), queryInfo.getPulseId(), queryInfo.getPulseId(),
columns) columns)
@ -249,7 +248,7 @@ public class DummyCassandraReader implements CassandraReader {
* @{inheritDoc * @{inheritDoc
*/ */
@Override @Override
public CompletableFuture<ChannelEvent> getEventAsync(MetaChannelEvent queryInfo, String... columns) { public CompletableFuture<ChannelEvent> getEventAsync(MetaStreamEvent<ChannelEvent> queryInfo, String... columns) {
// implement when needed // implement when needed
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -258,7 +257,7 @@ public class DummyCassandraReader implements CassandraReader {
* @{inheritDoc * @{inheritDoc
*/ */
@Override @Override
public Stream<? extends ChannelEventQuery> getChannelEventQueryStream(PulseIdRangeQuery query) { public Stream<? extends StreamEventQuery> getStreamEventQueryStream(PulseIdRangeQuery query) {
return dataGen.generateMetaPulseId( return dataGen.generateMetaPulseId(
query.getStartPulseId(), query.getStartPulseId(),
@ -278,7 +277,7 @@ public class DummyCassandraReader implements CassandraReader {
* @{inheritDoc * @{inheritDoc
*/ */
@Override @Override
public Stream<? extends ChannelEventQuery> getChannelEventQueryStream(TimeRangeQuery query) { public Stream<? extends StreamEventQuery> getStreamEventQueryStream(TimeRangeQuery query) {
return dataGen.generateMetaTime( return dataGen.generateMetaTime(
KEYSPACE, KEYSPACE,
@ -297,7 +296,7 @@ public class DummyCassandraReader implements CassandraReader {
@Override @Override
public Stream<MetaPulseId> getMetaStream(PulseIdRangeQuery query) { public Stream<MetaPulseId> getMetaStream(PulseIdRangeQuery query) {
return getChannelEventQueryStream(query).map(r -> { return getStreamEventQueryStream(query).map(r -> {
return (MetaPulseId) r; return (MetaPulseId) r;
}); });
@ -308,15 +307,15 @@ public class DummyCassandraReader implements CassandraReader {
* @{inheritDoc * @{inheritDoc
*/ */
@Override @Override
public Stream<? extends MetaChannelEvent> getMetaStream(TimeRangeQuery query) { public Stream<? extends MetaStreamEvent<ChannelEvent>> getMetaStream(TimeRangeQuery query) {
return getChannelEventQueryStream(query).map(r -> { return getStreamEventQueryStream(query).map(r -> {
return (MetaChannelEvent) r; return (MetaStreamEvent<ChannelEvent>) r;
}); });
} }
@Override @Override
public Stream<ChannelEvent> getEventStream(Stream<? extends MetaChannelEvent> queryInfos) { public Stream<ChannelEvent> getEventStream(Stream<? extends MetaStreamEvent<ChannelEvent>> queryInfos) {
return getEventStream(null, queryInfos); return getEventStream(null, queryInfos);
} }