ATEST-627

This commit is contained in:
Fabian Märki
2016-12-08 15:51:55 +01:00
parent a77c5665be
commit 101af582d2
7 changed files with 149 additions and 22 deletions
@@ -1,7 +1,9 @@
package ch.psi.daq.queryrest.controller;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
@@ -236,7 +238,9 @@ public class QueryRestController {
*/
@RequestMapping(value = "queryfields", method = {RequestMethod.GET}, produces = {MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody List<QueryField> getQueryFieldValues() {
return Lists.newArrayList(QueryField.values());
return Arrays.stream(QueryField.values())
.filter(queryField -> queryField.isPublish())
.collect(Collectors.toList());
}
/**
@@ -79,11 +79,18 @@ public class QueryValidator implements Validator {
if (query.getAggregation().getAggregations() == null || query.getAggregation().getAggregations().isEmpty()) {
query.getAggregation().setAggregations(new ArrayList<>(defaultResponseAggregations));
}
if (!query.getFields().contains(QueryField.value)) {
// without this field, json will not contain Stats (as
query.addField(QueryField.value);
}
// without adding this field, user need to explicitly ask for value field when querying
// aggregations.
// if (!query.getFields().contains(QueryField.value)) {
// // without this field, json will not contain Stats
// query.addField(QueryField.value);
// }
}
if (query.getValueTransformation() != null) {
// without this field, json will not contain transformedValue
query.addField(QueryField.transformedValue);
}
}
}