@Test public void testTerms() { try { Facet facet1 = terms("facet1", "var1", 2, FacetOrder.ASC); Facet facet2 = terms(facet1.getCurrentFacet(), noAdapter); assertEquals("String shall be equal", facet1.getCurrentFacet().toString(), facet2.getCurrentFacet().toString()); facet1 = terms("facet1", "var1", 1, FacetOrder.ASC); facet2 = terms(facet1.getCurrentFacet(), noAdapter); assertEquals("String shall be equal", facet1.getCurrentFacet().toString(), facet2.getCurrentFacet().toString()); facet1 = terms("facet1", "var1", 3, FacetOrder.ASC); assertNotEquals("String shall be equal", facet1.getCurrentFacet().toString(), facet2.getCurrentFacet().toString()); } catch (InvalidCreateOperationException | InvalidParseOperationException e) { e.printStackTrace(); fail(e.getMessage()); } }
public static final Facet terms(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode terms = facet.get(FACET.TERMS.exactToken()); if (!terms.has(FACETARGS.ORDER.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.ORDER.exactToken())); } if (!terms.has(FACETARGS.SIZE.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.SIZE.exactToken())); } String translatedNestedPath = null; if(terms.get(FACETARGS.SUBOBJECT.exactToken()) != null) { String nestedPath = terms.get(FACETARGS.SUBOBJECT.exactToken()).asText(); translatedNestedPath = adapter.getVariableName(nestedPath); if(translatedNestedPath == null) { translatedNestedPath = nestedPath; } } String fieldName = terms.get(FACETARGS.FIELD.exactToken()).asText(); String translatedFieldName = adapter.getVariableName(fieldName); if(translatedFieldName == null) { translatedFieldName = fieldName; } Integer size = terms.get(FACETARGS.SIZE.exactToken()).asInt(); FacetOrder order = FacetOrder.valueOf(terms.get(FACETARGS.ORDER.exactToken()).asText()); return FacetHelper.terms(name, translatedFieldName, translatedNestedPath, size, order); }
FacetParserHelper extends FacetHelper { public static final Facet terms(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode terms = facet.get(FACET.TERMS.exactToken()); if (!terms.has(FACETARGS.ORDER.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.ORDER.exactToken())); } if (!terms.has(FACETARGS.SIZE.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.SIZE.exactToken())); } String translatedNestedPath = null; if(terms.get(FACETARGS.SUBOBJECT.exactToken()) != null) { String nestedPath = terms.get(FACETARGS.SUBOBJECT.exactToken()).asText(); translatedNestedPath = adapter.getVariableName(nestedPath); if(translatedNestedPath == null) { translatedNestedPath = nestedPath; } } String fieldName = terms.get(FACETARGS.FIELD.exactToken()).asText(); String translatedFieldName = adapter.getVariableName(fieldName); if(translatedFieldName == null) { translatedFieldName = fieldName; } Integer size = terms.get(FACETARGS.SIZE.exactToken()).asInt(); FacetOrder order = FacetOrder.valueOf(terms.get(FACETARGS.ORDER.exactToken()).asText()); return FacetHelper.terms(name, translatedFieldName, translatedNestedPath, size, order); } }
FacetParserHelper extends FacetHelper { public static final Facet terms(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode terms = facet.get(FACET.TERMS.exactToken()); if (!terms.has(FACETARGS.ORDER.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.ORDER.exactToken())); } if (!terms.has(FACETARGS.SIZE.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.SIZE.exactToken())); } String translatedNestedPath = null; if(terms.get(FACETARGS.SUBOBJECT.exactToken()) != null) { String nestedPath = terms.get(FACETARGS.SUBOBJECT.exactToken()).asText(); translatedNestedPath = adapter.getVariableName(nestedPath); if(translatedNestedPath == null) { translatedNestedPath = nestedPath; } } String fieldName = terms.get(FACETARGS.FIELD.exactToken()).asText(); String translatedFieldName = adapter.getVariableName(fieldName); if(translatedFieldName == null) { translatedFieldName = fieldName; } Integer size = terms.get(FACETARGS.SIZE.exactToken()).asInt(); FacetOrder order = FacetOrder.valueOf(terms.get(FACETARGS.ORDER.exactToken()).asText()); return FacetHelper.terms(name, translatedFieldName, translatedNestedPath, size, order); } protected  FacetParserHelper(); }
FacetParserHelper extends FacetHelper { public static final Facet terms(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode terms = facet.get(FACET.TERMS.exactToken()); if (!terms.has(FACETARGS.ORDER.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.ORDER.exactToken())); } if (!terms.has(FACETARGS.SIZE.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.SIZE.exactToken())); } String translatedNestedPath = null; if(terms.get(FACETARGS.SUBOBJECT.exactToken()) != null) { String nestedPath = terms.get(FACETARGS.SUBOBJECT.exactToken()).asText(); translatedNestedPath = adapter.getVariableName(nestedPath); if(translatedNestedPath == null) { translatedNestedPath = nestedPath; } } String fieldName = terms.get(FACETARGS.FIELD.exactToken()).asText(); String translatedFieldName = adapter.getVariableName(fieldName); if(translatedFieldName == null) { translatedFieldName = fieldName; } Integer size = terms.get(FACETARGS.SIZE.exactToken()).asInt(); FacetOrder order = FacetOrder.valueOf(terms.get(FACETARGS.ORDER.exactToken()).asText()); return FacetHelper.terms(name, translatedFieldName, translatedNestedPath, size, order); } 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 terms(final JsonNode facet, VarNameAdapter adapter) throws InvalidCreateOperationException, InvalidParseOperationException { final String name = facet.get(FACETARGS.NAME.exactToken()).asText(); JsonNode terms = facet.get(FACET.TERMS.exactToken()); if (!terms.has(FACETARGS.ORDER.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.ORDER.exactToken())); } if (!terms.has(FACETARGS.SIZE.exactToken())) { throw new InvalidCreateOperationException( String.format("facet must contain a %s parameter", FACETARGS.SIZE.exactToken())); } String translatedNestedPath = null; if(terms.get(FACETARGS.SUBOBJECT.exactToken()) != null) { String nestedPath = terms.get(FACETARGS.SUBOBJECT.exactToken()).asText(); translatedNestedPath = adapter.getVariableName(nestedPath); if(translatedNestedPath == null) { translatedNestedPath = nestedPath; } } String fieldName = terms.get(FACETARGS.FIELD.exactToken()).asText(); String translatedFieldName = adapter.getVariableName(fieldName); if(translatedFieldName == null) { translatedFieldName = fieldName; } Integer size = terms.get(FACETARGS.SIZE.exactToken()).asInt(); FacetOrder order = FacetOrder.valueOf(terms.get(FACETARGS.ORDER.exactToken()).asText()); return FacetHelper.terms(name, translatedFieldName, translatedNestedPath, size, order); } 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);  }