@Test public void testProjectionParse() { final SelectParserMultiple request = new SelectParserMultiple(); final SelectMultiQuery select = new SelectMultiQuery(); try { request.filterParse(select.getFilter()); assertNull("Hint should be null", request.getRequest().getFilter().get(SELECTFILTER.HINT.exactToken())); assertNotNull("Limit should not be null", request.getRequest().getFilter() .get(SELECTFILTER.LIMIT.exactToken())); assertNull("Offset should be null", request.getRequest().getFilter() .get(SELECTFILTER.OFFSET.exactToken())); assertNull("OrderBy should be null", request.getRequest().getFilter() .get(SELECTFILTER.ORDERBY.exactToken())); select.addHintFilter(FILTERARGS.CACHE.exactToken()); request.filterParse(select.getFilter()); assertEquals("Hint should be True", FILTERARGS.CACHE.exactToken(), request.getRequest().getFilter().get(SELECTFILTER.HINT.exactToken()) .get(0).asText()); select.resetHintFilter(); request.filterParse(select.getFilter()); assertNull("Hint should be null", request.getRequest().getFilter().get(SELECTFILTER.HINT.exactToken())); select.setLimitFilter(0, 1000); request.filterParse(select.getFilter()); assertEquals(1000, request.getRequest().getFilter().get(SELECTFILTER.LIMIT.exactToken()) .asLong()); assertNull("Offset should be null", request.getRequest().getFilter() .get(SELECTFILTER.OFFSET.exactToken())); select.setLimitFilter(100, 0); request.filterParse(select.getFilter()); assertEquals(100, request.getRequest().getFilter().get(SELECTFILTER.OFFSET.exactToken()) .asLong()); assertEquals(GlobalDatas.LIMIT_LOAD, request.getRequest().getFilter().get(SELECTFILTER.LIMIT.exactToken()) .asLong()); select.addOrderByAscFilter("var1", "var2").addOrderByDescFilter("var3"); request.filterParse(select.getFilter()); assertNotNull("OrderBy should not be null", request.getRequest().getFilter() .get(SELECTFILTER.ORDERBY.exactToken())); assertEquals(3, request.getRequest().getFilter() .get(SELECTFILTER.ORDERBY.exactToken()).size()); for (final Iterator<Entry<String, JsonNode>> iterator = request.getRequest().getFilter() .get(SELECTFILTER.ORDERBY.exactToken()).fields(); iterator .hasNext();) { final Entry<String, JsonNode> entry = iterator.next(); if (entry.getKey().equals("var1")) { assertEquals(1, entry.getValue().asInt()); } if (entry.getKey().equals("var2")) { assertEquals(1, entry.getValue().asInt()); } if (entry.getKey().equals("var3")) { assertEquals(-1, entry.getValue().asInt()); } } select.resetOrderByFilter(); request.filterParse(select.getFilter()); assertNull("OrderBy should be null", request.getRequest().getFilter() .get(SELECTFILTER.ORDERBY.exactToken())); } catch (final InvalidParseOperationException e) { e.printStackTrace(); fail(e.getMessage()); } }
protected void projectionParse(final JsonNode rootNode) throws InvalidParseOperationException { if (rootNode == null) { return; } GlobalDatas.sanityParametersCheck(rootNode.toString(), GlobalDatas.NB_PROJECTIONS); try { ((SelectMultiQuery) request).resetUsageProjection().resetUsedProjection(); final ObjectNode node = JsonHandler.createObjectNode(); if (rootNode.has(PROJECTION.FIELDS.exactToken())) { adapter.setVarsValue(node, rootNode.path(PROJECTION.FIELDS.exactToken())); ((ObjectNode) rootNode).set(PROJECTION.FIELDS.exactToken(), node); } ((SelectMultiQuery) request).setProjection(rootNode); } catch (final Exception e) { throw new InvalidParseOperationException( "Parse in error for Projection: " + rootNode, e); } }
SelectParserMultiple extends RequestParserMultiple { protected void projectionParse(final JsonNode rootNode) throws InvalidParseOperationException { if (rootNode == null) { return; } GlobalDatas.sanityParametersCheck(rootNode.toString(), GlobalDatas.NB_PROJECTIONS); try { ((SelectMultiQuery) request).resetUsageProjection().resetUsedProjection(); final ObjectNode node = JsonHandler.createObjectNode(); if (rootNode.has(PROJECTION.FIELDS.exactToken())) { adapter.setVarsValue(node, rootNode.path(PROJECTION.FIELDS.exactToken())); ((ObjectNode) rootNode).set(PROJECTION.FIELDS.exactToken(), node); } ((SelectMultiQuery) request).setProjection(rootNode); } catch (final Exception e) { throw new InvalidParseOperationException( "Parse in error for Projection: " + rootNode, e); } } }
SelectParserMultiple extends RequestParserMultiple { protected void projectionParse(final JsonNode rootNode) throws InvalidParseOperationException { if (rootNode == null) { return; } GlobalDatas.sanityParametersCheck(rootNode.toString(), GlobalDatas.NB_PROJECTIONS); try { ((SelectMultiQuery) request).resetUsageProjection().resetUsedProjection(); final ObjectNode node = JsonHandler.createObjectNode(); if (rootNode.has(PROJECTION.FIELDS.exactToken())) { adapter.setVarsValue(node, rootNode.path(PROJECTION.FIELDS.exactToken())); ((ObjectNode) rootNode).set(PROJECTION.FIELDS.exactToken(), node); } ((SelectMultiQuery) request).setProjection(rootNode); } catch (final Exception e) { throw new InvalidParseOperationException( "Parse in error for Projection: " + rootNode, e); } } SelectParserMultiple();  SelectParserMultiple(VarNameAdapter adapter); }
SelectParserMultiple extends RequestParserMultiple { protected void projectionParse(final JsonNode rootNode) throws InvalidParseOperationException { if (rootNode == null) { return; } GlobalDatas.sanityParametersCheck(rootNode.toString(), GlobalDatas.NB_PROJECTIONS); try { ((SelectMultiQuery) request).resetUsageProjection().resetUsedProjection(); final ObjectNode node = JsonHandler.createObjectNode(); if (rootNode.has(PROJECTION.FIELDS.exactToken())) { adapter.setVarsValue(node, rootNode.path(PROJECTION.FIELDS.exactToken())); ((ObjectNode) rootNode).set(PROJECTION.FIELDS.exactToken(), node); } ((SelectMultiQuery) request).setProjection(rootNode); } catch (final Exception e) { throw new InvalidParseOperationException( "Parse in error for Projection: " + rootNode, e); } } SelectParserMultiple();  SelectParserMultiple(VarNameAdapter adapter); @Override void parse(final JsonNode request); @Override void parseQueryOnly(final String query); static final FACET getFacetCommand(final JsonNode facet); @Override SelectMultiQuery getRequest(); }
SelectParserMultiple extends RequestParserMultiple { protected void projectionParse(final JsonNode rootNode) throws InvalidParseOperationException { if (rootNode == null) { return; } GlobalDatas.sanityParametersCheck(rootNode.toString(), GlobalDatas.NB_PROJECTIONS); try { ((SelectMultiQuery) request).resetUsageProjection().resetUsedProjection(); final ObjectNode node = JsonHandler.createObjectNode(); if (rootNode.has(PROJECTION.FIELDS.exactToken())) { adapter.setVarsValue(node, rootNode.path(PROJECTION.FIELDS.exactToken())); ((ObjectNode) rootNode).set(PROJECTION.FIELDS.exactToken(), node); } ((SelectMultiQuery) request).setProjection(rootNode); } catch (final Exception e) { throw new InvalidParseOperationException( "Parse in error for Projection: " + rootNode, e); } } SelectParserMultiple();  SelectParserMultiple(VarNameAdapter adapter); @Override void parse(final JsonNode request); @Override void parseQueryOnly(final String query); static final FACET getFacetCommand(final JsonNode facet); @Override SelectMultiQuery getRequest();  }