Search in sources :

Example 1 with DefaultFilterDialect

use of com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect 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);
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) Invoice(example.models.triggers.Invoice) MultipleFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect) DefaultFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect) Elide(com.yahoo.elide.Elide) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect) BillingService(example.models.triggers.services.BillingService)

Example 2 with DefaultFilterDialect

use of com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect in project elide by yahoo.

the class ElideSettingsBuilder method build.

public ElideSettings build() {
    if (joinFilterDialects.isEmpty()) {
        joinFilterDialects.add(new DefaultFilterDialect(entityDictionary));
        joinFilterDialects.add(RSQLFilterDialect.builder().dictionary(entityDictionary).build());
    }
    if (subqueryFilterDialects.isEmpty()) {
        subqueryFilterDialects.add(new DefaultFilterDialect(entityDictionary));
        subqueryFilterDialects.add(RSQLFilterDialect.builder().dictionary(entityDictionary).build());
    }
    if (graphqlFilterDialect == null) {
        graphqlFilterDialect = RSQLFilterDialect.builder().dictionary(entityDictionary).build();
    }
    if (entityDictionary == null) {
        throw new IllegalStateException("EntityDictionary must be set in ElideSettings.");
    }
    return new ElideSettings(auditLogger, dataStore, entityDictionary, jsonApiMapper, errorMapper, permissionExecutorFunction, joinFilterDialects, subqueryFilterDialects, graphqlFilterDialect, jsonApiLinks, defaultMaxPageSize, defaultPageSize, updateStatusCode, serdes, enableJsonLinks, strictQueryParams, baseUrl, jsonApiPath, graphQLApiPath, exportApiPath);
}
Also used : DefaultFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect)

Example 3 with DefaultFilterDialect

use of com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect in project elide by yahoo.

the class FilterPredicateTest method setup.

@BeforeAll
static void setup() {
    EntityDictionary entityDictionary = EntityDictionary.builder().build();
    entityDictionary.bindEntity(Book.class);
    entityDictionary.bindEntity(Author.class);
    strategy = new DefaultFilterDialect(entityDictionary);
}
Also used : DefaultFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with DefaultFilterDialect

use of com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect in project elide by yahoo.

the class DefaultFilterDialectTest method init.

@BeforeAll
public static void init() {
    EntityDictionary dictionary = EntityDictionary.builder().build();
    dictionary.bindEntity(Author.class);
    dictionary.bindEntity(Book.class);
    dialect = new DefaultFilterDialect(dictionary);
}
Also used : DefaultFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with DefaultFilterDialect

use of com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect in project elide by yahoo.

the class StandardTestBinder 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(IntegrationTest.getDataStore()).withAuditLogger(auditLogger).withJoinFilterDialect(multipleFilterStrategy).withSubqueryFilterDialect(multipleFilterStrategy).withEntityDictionary(dictionary).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", Calendar.getInstance().getTimeZone()).build());
            elide.doScans();
            return elide;
        }

        @Override
        public void dispose(Elide elide) {
        }
    }).to(Elide.class).named("elide");
    bind(BILLING_SERVICE).to(BillingService.class);
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) MultipleFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect) DefaultFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect) Elide(com.yahoo.elide.Elide) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)

Aggregations

DefaultFilterDialect (com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect)5 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)4 Elide (com.yahoo.elide.Elide)2 ElideSettingsBuilder (com.yahoo.elide.ElideSettingsBuilder)2 RSQLFilterDialect (com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)2 MultipleFilterDialect (com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 Invoice (example.models.triggers.Invoice)1 BillingService (example.models.triggers.services.BillingService)1