@Test
  public void createNumberValueFilter() throws Exception {
    final ValueFilter queryFilter =
        ValueFilter.create()
            .fieldName("myField")
            .addValue(ValueFactory.newDouble(1.0))
            .addValue(ValueFactory.newDouble(2.0))
            .build();

    final String expected = load("filter_values_number.json");
    final FilterBuilder filterBuilder =
        new FilterBuilderFactory(new SearchQueryFieldNameResolver())
            .create(Filters.from(queryFilter));

    Assert.assertEquals(cleanString(expected), cleanString(filterBuilder.toString()));
  }
Example #2
0
 @Override
 public Value createDefaultValue(final Input input) {
   final String rootValue = input.getDefaultValue().getRootValue();
   if (rootValue != null) {
     return ValueFactory.newGeoPoint(GeoPoint.from(rootValue));
   }
   return super.createDefaultValue(input);
 }
 private static void addNodeIdFilter(
     final NodeVersionQuery nodeVersionQuery,
     final QueryBuilderFactory.Builder queryBuilderBuilder) {
   if (nodeVersionQuery.getNodeId() != null) {
     queryBuilderBuilder.addQueryFilter(
         ValueFilter.create()
             .fieldName(VersionIndexPath.NODE_ID.getPath())
             .addValue(ValueFactory.newString(nodeVersionQuery.getNodeId().toString()))
             .build());
   }
 }
Example #4
0
  public static Filter create(final PrincipalKeys principalsKeys) {
    if (isSuperUser()) {
      return null;
    }

    if (principalsKeys.isEmpty()) {
      return createNoPrincipalsFilter();
    }

    final ValueFilter.Builder valueFilterBuilder =
        ValueFilter.create().fieldName(NodeIndexPath.PERMISSIONS_READ.toString());

    for (final PrincipalKey principalKey : principalsKeys) {
      valueFilterBuilder.addValue(ValueFactory.newString(principalKey.toString()));
    }

    return valueFilterBuilder.build();
  }
Example #5
0
 private static Filter createNoPrincipalsFilter() {
   return ValueFilter.create()
       .fieldName(NodeIndexPath.PERMISSIONS_READ.toString())
       .addValue(ValueFactory.newString(PrincipalKey.ofAnonymous().toString()))
       .build();
 }
Example #6
0
 @Override
 public Value createValue(final Value value, final InputTypeConfig config) {
   return ValueFactory.newGeoPoint(value.asGeoPoint());
 }