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()); } }
@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())); }
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(); }
private static Filter createNoPrincipalsFilter() { return ValueFilter.create() .fieldName(NodeIndexPath.PERMISSIONS_READ.toString()) .addValue(ValueFactory.newString(PrincipalKey.ofAnonymous().toString())) .build(); }