@Test
  public void createStringValueFilter() throws Exception {
    final ValueFilter queryFilter =
        ValueFilter.create()
            .fieldName("myField")
            .addValue(ValueFactory.newString("myValue1"))
            .addValue(ValueFactory.newString("myValue2"))
            .build();

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

    Assert.assertEquals(cleanString(expected), cleanString(filterBuilder.toString()));
  }
 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());
   }
 }
Пример #3
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();
  }
Пример #4
0
 private static Filter createNoPrincipalsFilter() {
   return ValueFilter.create()
       .fieldName(NodeIndexPath.PERMISSIONS_READ.toString())
       .addValue(ValueFactory.newString(PrincipalKey.ofAnonymous().toString()))
       .build();
 }