Search in sources :

Example 1 with LEPredicate

use of com.yahoo.elide.core.filter.predicates.LEPredicate in project elide by yahoo.

the class InMemoryFilterExecutorTest method negativeTests.

@Test
public void negativeTests() throws Exception {
    author = new Author();
    author.setId(10L);
    PathElement pathElement = new PathElement(Author.class, Long.class, "id");
    expression = new NotFilterExpression(new LTPredicate(pathElement, listEleven));
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new NotFilterExpression(new LEPredicate(pathElement, listTen));
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new NotFilterExpression(new GTPredicate(pathElement, listNine));
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new NotFilterExpression(new GEPredicate(pathElement, listTen));
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new NotFilterExpression(new LTPredicate(pathElement, listTen));
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
    expression = new NotFilterExpression(new LEPredicate(pathElement, listNine));
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
    expression = new NotFilterExpression(new GTPredicate(pathElement, listTen));
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
    expression = new NotFilterExpression(new GEPredicate(pathElement, listEleven));
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
}
Also used : PathElement(com.yahoo.elide.core.Path.PathElement) GTPredicate(com.yahoo.elide.core.filter.predicates.GTPredicate) LEPredicate(com.yahoo.elide.core.filter.predicates.LEPredicate) GEPredicate(com.yahoo.elide.core.filter.predicates.GEPredicate) Author(example.Author) LTPredicate(com.yahoo.elide.core.filter.predicates.LTPredicate) Test(org.junit.jupiter.api.Test)

Example 2 with LEPredicate

use of com.yahoo.elide.core.filter.predicates.LEPredicate in project elide by yahoo.

the class InMemoryFilterExecutorTest method compareOpPredicateTests.

@Test
public void compareOpPredicateTests() throws Exception {
    author = new Author();
    author.setId(10L);
    expression = new LTPredicate(authorIdElement, listEleven);
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
    expression = new LEPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
    expression = new GTPredicate(authorIdElement, listNine);
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
    expression = new GEPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertTrue(fn.test(author));
    expression = new LTPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new LEPredicate(authorIdElement, listNine);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new GTPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new GEPredicate(authorIdElement, listEleven);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    // when val is null
    author.setId(null);
    expression = new LTPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new LEPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new GTPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
    expression = new GEPredicate(authorIdElement, listTen);
    fn = expression.accept(visitor);
    assertFalse(fn.test(author));
}
Also used : GTPredicate(com.yahoo.elide.core.filter.predicates.GTPredicate) LEPredicate(com.yahoo.elide.core.filter.predicates.LEPredicate) GEPredicate(com.yahoo.elide.core.filter.predicates.GEPredicate) Author(example.Author) LTPredicate(com.yahoo.elide.core.filter.predicates.LTPredicate) Test(org.junit.jupiter.api.Test)

Example 3 with LEPredicate

use of com.yahoo.elide.core.filter.predicates.LEPredicate in project elide by yahoo.

the class AsyncAPICleanerRunnable method deleteAsyncAPI.

/**
 * This method deletes the historical queries based on threshold.
 * @param type AsyncAPI Type Implementation.
 */
protected <T extends AsyncAPI> void deleteAsyncAPI(Class<T> type) {
    try {
        Date cleanupDate = dateUtil.calculateFilterDate(Calendar.DATE, queryCleanupDays);
        PathElement createdOnPathElement = new PathElement(type, Long.class, "createdOn");
        FilterExpression fltDeleteExp = new LEPredicate(createdOnPathElement, cleanupDate);
        asyncAPIDao.deleteAsyncAPIAndResultByFilter(fltDeleteExp, type);
    } catch (Exception e) {
        log.error("Exception in scheduled cleanup: {}", e.toString());
    }
}
Also used : PathElement(com.yahoo.elide.core.Path.PathElement) LEPredicate(com.yahoo.elide.core.filter.predicates.LEPredicate) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Date(java.util.Date)

Example 4 with LEPredicate

use of com.yahoo.elide.core.filter.predicates.LEPredicate in project elide by yahoo.

the class AsyncAPICleanerRunnable method timeoutAsyncAPI.

/**
 * This method updates the status of long running async query which
 * were interrupted due to host crash/app shutdown to TIMEDOUT.
 * @param type AsyncAPI Type Implementation.
 */
protected <T extends AsyncAPI> void timeoutAsyncAPI(Class<T> type) {
    try {
        Date filterDate = dateUtil.calculateFilterDate(Calendar.MINUTE, maxRunTimeMinutes);
        PathElement createdOnPathElement = new PathElement(type, Long.class, "createdOn");
        PathElement statusPathElement = new PathElement(type, String.class, "status");
        FilterPredicate inPredicate = new InPredicate(statusPathElement, QueryStatus.PROCESSING, QueryStatus.QUEUED);
        FilterPredicate lePredicate = new LEPredicate(createdOnPathElement, filterDate);
        AndFilterExpression fltTimeoutExp = new AndFilterExpression(inPredicate, lePredicate);
        asyncAPIDao.updateStatusAsyncAPIByFilter(fltTimeoutExp, QueryStatus.TIMEDOUT, type);
    } catch (Exception e) {
        log.error("Exception in scheduled cleanup: {}", e.toString());
    }
}
Also used : PathElement(com.yahoo.elide.core.Path.PathElement) LEPredicate(com.yahoo.elide.core.filter.predicates.LEPredicate) FilterPredicate(com.yahoo.elide.core.filter.predicates.FilterPredicate) InPredicate(com.yahoo.elide.core.filter.predicates.InPredicate) Date(java.util.Date) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression)

Aggregations

LEPredicate (com.yahoo.elide.core.filter.predicates.LEPredicate)4 PathElement (com.yahoo.elide.core.Path.PathElement)3 AndFilterExpression (com.yahoo.elide.core.filter.expression.AndFilterExpression)2 GEPredicate (com.yahoo.elide.core.filter.predicates.GEPredicate)2 GTPredicate (com.yahoo.elide.core.filter.predicates.GTPredicate)2 LTPredicate (com.yahoo.elide.core.filter.predicates.LTPredicate)2 Author (example.Author)2 Date (java.util.Date)2 Test (org.junit.jupiter.api.Test)2 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)1 FilterPredicate (com.yahoo.elide.core.filter.predicates.FilterPredicate)1 InPredicate (com.yahoo.elide.core.filter.predicates.InPredicate)1