use of com.enonic.xp.query.filter.Filters in project xp by enonic.
the class JsonToFilterMapperTest method array_on_root_single.
@Test
public void array_on_root_single() throws Exception {
final List<Map<String, Object>> existsFilters = new ArrayList<>();
existsFilters.add(createExistsFilter());
final Filters filters = com.enonic.xp.lib.common.JsonToFilterMapper.create(existsFilters);
assertTrue(filters.get(0) instanceof ExistsFilter);
}
use of com.enonic.xp.query.filter.Filters in project xp by enonic.
the class JsonToFilterMapperTest method ids_filter.
@Test
public void ids_filter() throws Exception {
Map<String, Object> value = new HashMap<>();
List<String> values = List.of("fisk", "ost", "løk");
final HashMap<String, Object> valueFilter = new HashMap<>();
valueFilter.put("values", values);
value.put("ids", valueFilter);
final Filters filters = com.enonic.xp.lib.common.JsonToFilterMapper.create(value);
assertTrue(filters.get(0) instanceof IdFilter);
assertEquals(3, ((IdFilter) filters.get(0)).getValues().size());
}
use of com.enonic.xp.query.filter.Filters in project xp by enonic.
the class JsonToFilterMapperTest method exists_filter.
@Test
public void exists_filter() throws Exception {
final Map<String, Object> existsFilter = createExistsFilter();
final Filters filters = com.enonic.xp.lib.common.JsonToFilterMapper.create(existsFilter);
assertTrue(filters.get(0) instanceof ExistsFilter);
assertEquals("myField", ((ExistsFilter) filters.get(0)).getFieldName());
}
use of com.enonic.xp.query.filter.Filters in project xp by enonic.
the class JsonToFilterMapperTest method notExists_filter.
@Test
public void notExists_filter() throws Exception {
Map<String, Object> value = new HashMap<>();
final HashMap<String, Object> notExistsFilter = new HashMap<>();
notExistsFilter.put("field", "myField");
value.put("notExists", notExistsFilter);
final Filters filters = com.enonic.xp.lib.common.JsonToFilterMapper.create(value);
assertTrue(filters.get(0) instanceof BooleanFilter);
final BooleanFilter booleanFilter = (BooleanFilter) filters.get(0);
final ImmutableSet<Filter> mustNotFilters = booleanFilter.getMustNot();
assertEquals(1, mustNotFilters.size());
final Filter mustNotFilter = mustNotFilters.iterator().next();
assertTrue(mustNotFilter instanceof ExistsFilter);
}
use of com.enonic.xp.query.filter.Filters in project xp by enonic.
the class AbstractFindNodesQueryHandler method createNodeQuery.
NodeQuery createNodeQuery() {
final int start = valueOrDefault(this.start, 0);
final int count = valueOrDefault(this.count, 10);
final QueryExpr queryExpr = QueryExpr.from(buildConstraintExpr(), buildOrderExpr());
final Filters filters = JsonToFilterMapper.create(this.filters);
final AggregationQueries aggregations = new QueryAggregationParams().getAggregations(this.aggregations);
final SuggestionQueries suggestions = new QuerySuggestionParams().getSuggestions(this.suggestions);
final HighlightQuery highlight = new QueryHighlightParams().getHighlightQuery(this.highlight);
return NodeQuery.create().from(start).size(count).addAggregationQueries(aggregations).addSuggestionQueries(suggestions).highlight(highlight).query(queryExpr).addQueryFilters(filters).explain(this.explain).build();
}
Aggregations