use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project elide by yahoo.
the class VerboseErrorResponsesTestBinder method configure.
@Override
protected void configure() {
EntityDictionary dictionary = EntityDictionary.builder().injector(injector::inject).checks(TestCheckMappings.MAPPINGS).build();
bind(dictionary).to(EntityDictionary.class);
// Elide instance
bindFactory(new Factory<Elide>() {
@Override
public Elide provide() {
DefaultFilterDialect defaultFilterStrategy = new DefaultFilterDialect(dictionary);
RSQLFilterDialect rsqlFilterStrategy = RSQLFilterDialect.builder().dictionary(dictionary).build();
MultipleFilterDialect multipleFilterStrategy = new MultipleFilterDialect(Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy), Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy));
Elide elide = new Elide(new ElideSettingsBuilder(getDataStore()).withAuditLogger(auditLogger).withJoinFilterDialect(multipleFilterStrategy).withSubqueryFilterDialect(multipleFilterStrategy).withEntityDictionary(dictionary).withVerboseErrors().build());
elide.doScans();
return elide;
}
@Override
public void dispose(Elide elide) {
// do nothing
}
}).to(Elide.class).named("elide");
bind(new BillingService() {
@Override
public long purchase(Invoice invoice) {
return 0;
}
}).to(BillingService.class);
}
use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project elide by yahoo.
the class JpaDataStoreTransactionTest method getTestArguments.
private Stream<Arguments> getTestArguments() throws Exception {
RSQLFilterDialect parser = RSQLFilterDialect.builder().dictionary(dictionary).build();
FilterExpression expression = parser.parse(ClassType.of(Book.class), Collections.emptySet(), "title=='foo'", NO_VERSION);
return Stream.of(arguments(true, 1, null, true), arguments(true, 2, null, true), arguments(false, 1, null, true), arguments(false, 2, null, true), arguments(true, 1, expression, false), arguments(true, 2, expression, true), arguments(false, 1, expression, false), arguments(false, 2, expression, false));
}
use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project faf-java-api by FAForever.
the class ElideConfig method elide.
@Bean
public Elide elide(SpringHibernateDataStore springHibernateDataStore, ObjectMapper objectMapper, EntityDictionary entityDictionary, ExtendedAuditLogger extendedAuditLogger) {
RSQLFilterDialect rsqlFilterDialect = new RSQLFilterDialect(entityDictionary);
registerAdditionalConverters();
return new Elide(new ElideSettingsBuilder(springHibernateDataStore).withJsonApiMapper(new JsonApiMapper(entityDictionary, objectMapper)).withAuditLogger(extendedAuditLogger).withEntityDictionary(entityDictionary).withJoinFilterDialect(rsqlFilterDialect).withSubqueryFilterDialect(rsqlFilterDialect).build());
}
use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project elide by yahoo.
the class FilteredIteratorTest method testEmptyResult.
@Test
public void testEmptyResult() throws Exception {
EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(Book.class);
List<Book> books = List.of();
RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).build();
FilterExpression expression = filterDialect.parse(ClassType.of(Book.class), new HashSet<>(), "title==*bar", NO_VERSION);
RequestScope scope = new TestRequestScope(null, null, dictionary);
Iterator<Book> bookIterator = new FilteredIterator<>(expression, scope, books.iterator());
assertFalse(bookIterator.hasNext());
assertThrows(NoSuchElementException.class, () -> bookIterator.next());
}
use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project elide by yahoo.
the class RequiresFilter method getRequiredFilter.
default FilterExpression getRequiredFilter(EntityDictionary dictionary) {
Type<?> cls = dictionary.getEntityClass(getTable().getName(), getTable().getVersion());
RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).addDefaultArguments(false).build();
if (StringUtils.isNotEmpty(getRequiredFilter())) {
try {
return filterDialect.parseFilterExpression(getRequiredFilter(), cls, false, true);
} catch (ParseException e) {
throw new IllegalStateException(e);
}
}
return null;
}
Aggregations