@Test public void testFilters() throws InvalidCreateOperationException, InvalidParseOperationException { Map<String, Query> filters = new HashMap<>(); filters.put("query_1", QueryHelper.eq("var1", 1)); filters.put("query_2", QueryHelper.and().add(QueryHelper.match("var2", "value"))); Facet facet1 = filters("facet1", filters); Facet facet2 = filters(facet1.getCurrentFacet(), noAdapter); assertEquals("String shall be equal", facet1.getCurrentFacet().toString(), facet2.getCurrentFacet().toString()); filters.remove("query_2"); facet1 = filters("facet1", filters); assertNotEquals("String shall be equal", facet1.getCurrentFacet().toString(), facet2.getCurrentFacet().toString()); assertThatThrownBy(() -> { filters("facet1", null); }).isInstanceOf(InvalidCreateOperationException.class); assertThatThrownBy(() -> { filters("facet1", new HashMap<>()); }).isInstanceOf(InvalidCreateOperationException.class); }
public static final Facet filters(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode filtersFacetnode = facet.get(FACET.FILTERS.exactToken()); Map<String, Query> filters = new HashMap<>(); ArrayNode filtersNode = (ArrayNode) filtersFacetnode.get(FACETARGS.QUERY_FILTERS.exactToken()); for (JsonNode node : filtersNode) { String key = node.get(FACETARGS.NAME.exactToken()).asText(); JsonNode queryNode = node.get(FACETARGS.QUERY.exactToken()); final Entry<String, JsonNode> queryItem = JsonHandler.checkUnicity("RootRequest", queryNode); Query query = QueryParserHelper.query(queryItem.getKey(), queryItem.getValue(), adapter); filters.put(key, query); } return FacetHelper.filters(name, filters); }
FacetParserHelper extends FacetHelper { public static final Facet filters(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode filtersFacetnode = facet.get(FACET.FILTERS.exactToken()); Map<String, Query> filters = new HashMap<>(); ArrayNode filtersNode = (ArrayNode) filtersFacetnode.get(FACETARGS.QUERY_FILTERS.exactToken()); for (JsonNode node : filtersNode) { String key = node.get(FACETARGS.NAME.exactToken()).asText(); JsonNode queryNode = node.get(FACETARGS.QUERY.exactToken()); final Entry<String, JsonNode> queryItem = JsonHandler.checkUnicity("RootRequest", queryNode); Query query = QueryParserHelper.query(queryItem.getKey(), queryItem.getValue(), adapter); filters.put(key, query); } return FacetHelper.filters(name, filters); } }
FacetParserHelper extends FacetHelper { public static final Facet filters(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode filtersFacetnode = facet.get(FACET.FILTERS.exactToken()); Map<String, Query> filters = new HashMap<>(); ArrayNode filtersNode = (ArrayNode) filtersFacetnode.get(FACETARGS.QUERY_FILTERS.exactToken()); for (JsonNode node : filtersNode) { String key = node.get(FACETARGS.NAME.exactToken()).asText(); JsonNode queryNode = node.get(FACETARGS.QUERY.exactToken()); final Entry<String, JsonNode> queryItem = JsonHandler.checkUnicity("RootRequest", queryNode); Query query = QueryParserHelper.query(queryItem.getKey(), queryItem.getValue(), adapter); filters.put(key, query); } return FacetHelper.filters(name, filters); } protected  FacetParserHelper(); }
FacetParserHelper extends FacetHelper { public static final Facet filters(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode filtersFacetnode = facet.get(FACET.FILTERS.exactToken()); Map<String, Query> filters = new HashMap<>(); ArrayNode filtersNode = (ArrayNode) filtersFacetnode.get(FACETARGS.QUERY_FILTERS.exactToken()); for (JsonNode node : filtersNode) { String key = node.get(FACETARGS.NAME.exactToken()).asText(); JsonNode queryNode = node.get(FACETARGS.QUERY.exactToken()); final Entry<String, JsonNode> queryItem = JsonHandler.checkUnicity("RootRequest", queryNode); Query query = QueryParserHelper.query(queryItem.getKey(), queryItem.getValue(), adapter); filters.put(key, query); } return FacetHelper.filters(name, filters); } protected  FacetParserHelper(); static final Facet terms(final JsonNode facet, VarNameAdapter adapter); static final Facet dateRange(final JsonNode facet, VarNameAdapter adapter); static final Facet filters(final JsonNode facet, VarNameAdapter adapter); }
FacetParserHelper extends FacetHelper { public static final Facet filters(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode filtersFacetnode = facet.get(FACET.FILTERS.exactToken()); Map<String, Query> filters = new HashMap<>(); ArrayNode filtersNode = (ArrayNode) filtersFacetnode.get(FACETARGS.QUERY_FILTERS.exactToken()); for (JsonNode node : filtersNode) { String key = node.get(FACETARGS.NAME.exactToken()).asText(); JsonNode queryNode = node.get(FACETARGS.QUERY.exactToken()); final Entry<String, JsonNode> queryItem = JsonHandler.checkUnicity("RootRequest", queryNode); Query query = QueryParserHelper.query(queryItem.getKey(), queryItem.getValue(), adapter); filters.put(key, query); } return FacetHelper.filters(name, filters); } protected  FacetParserHelper(); static final Facet terms(final JsonNode facet, VarNameAdapter adapter); static final Facet dateRange(final JsonNode facet, VarNameAdapter adapter); static final Facet filters(final JsonNode facet, VarNameAdapter adapter);  }