Search in sources :

Example 81 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkMultivaluedLowerFilters.

@Test
public void checkMultivaluedLowerFilters() throws SearchException {
    Filter userUidFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter("uid"), "test").multiValued();
    ConvertedExpression expressionUserUid = simpleConverter.convertToCouchbaseFilter(userUidFilter, null, null);
    String queryUserUid = toSelectSQL(expressionUserUid);
    assertEquals(queryUserUid, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES LOWER(uid_) = \"test\" END");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 82 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkMultivaluedLeFilters.

@Test
public void checkMultivaluedLeFilters() throws SearchException {
    // LE -- String
    Filter filterLe1 = Filter.createLessOrEqualFilter("uid", "test").multiValued();
    ConvertedExpression expressionLe1 = simpleConverter.convertToCouchbaseFilter(filterLe1, null, null);
    String queryLe1 = toSelectSQL(expressionLe1);
    assertEquals(queryLe1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ <= \"test\" END");
    // LE -- Integer
    Filter filterLe2 = Filter.createLessOrEqualFilter("age", 23).multiValued();
    ConvertedExpression expressionLe2 = simpleConverter.convertToCouchbaseFilter(filterLe2, null, null);
    String queryLe2 = toSelectSQL(expressionLe2);
    assertEquals(queryLe2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY age_ IN age SATISFIES age_ <= 23 END");
    // LE -- Long
    Filter filterLe3 = Filter.createLessOrEqualFilter("age", 23L).multiValued();
    ConvertedExpression expressionLe3 = simpleConverter.convertToCouchbaseFilter(filterLe3, null, null);
    String queryLe3 = toSelectSQL(expressionLe3);
    assertEquals(queryLe3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY age_ IN age SATISFIES age_ <= 23 END");
    // LE -- Date
    Filter filterLe4 = Filter.createLessOrEqualFilter("added", getUtcDateFromMillis(1608130698398L)).multiValued();
    ConvertedExpression expressionLe4 = simpleConverter.convertToCouchbaseFilter(filterLe4, null, null);
    String queryLe4 = toSelectSQL(expressionLe4);
    assertEquals(queryLe4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY added_ IN added SATISFIES added_ <= \"Wed Dec 16 14:58:18 UTC 2020\" END");
    // LE -- Date
    Filter filterLe5 = Filter.createLessOrEqualFilter("added", getUtcDateFromMillis(1608130698398L)).multiValued(3);
    ConvertedExpression expressionLe5 = simpleConverter.convertToCouchbaseFilter(filterLe5, null, null);
    String queryLe5 = toSelectSQL(expressionLe5);
    assertEquals(queryLe5, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY added_ IN added SATISFIES added_ <= \"Wed Dec 16 14:58:18 UTC 2020\" END");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 83 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkOrFilters.

@Test
public void checkOrFilters() throws SearchException {
    Filter filterEq1 = Filter.createEqualityFilter("uid", "test");
    Filter filterPresence1 = Filter.createPresenceFilter("mail");
    Filter filterLe1 = Filter.createLessOrEqualFilter("age", 23);
    Filter filterOr1 = Filter.createORFilter(filterPresence1, filterEq1, filterLe1);
    ConvertedExpression expressionAnd1 = simpleConverter.convertToCouchbaseFilter(filterOr1, null, null);
    String queryAnd1 = toSelectSQL(expressionAnd1);
    assertEquals(queryAnd1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( mail IS NOT MISSING OR ( ( uid = \"test\" ) OR ( \"test\" IN uid ) ) OR age <= 23 )");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 84 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkLeFilters.

@Test
public void checkLeFilters() throws SearchException {
    // LE -- String
    Filter filterLe1 = Filter.createLessOrEqualFilter("uid", "test");
    ConvertedExpression expressionLe1 = simpleConverter.convertToCouchbaseFilter(filterLe1, null, null);
    String queryLe1 = toSelectSQL(expressionLe1);
    assertEquals(queryLe1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE uid <= \"test\"");
    // LE -- Integer
    Filter filterLe2 = Filter.createLessOrEqualFilter("age", 23);
    ConvertedExpression expressionLe2 = simpleConverter.convertToCouchbaseFilter(filterLe2, null, null);
    String queryLe2 = toSelectSQL(expressionLe2);
    assertEquals(queryLe2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE age <= 23");
    // LE -- Long
    Filter filterLe3 = Filter.createLessOrEqualFilter("age", 23L);
    ConvertedExpression expressionLe3 = simpleConverter.convertToCouchbaseFilter(filterLe3, null, null);
    String queryLe3 = toSelectSQL(expressionLe3);
    assertEquals(queryLe3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE age <= 23");
    // LE -- Date
    Filter filterLe4 = Filter.createLessOrEqualFilter("added", getUtcDateFromMillis(1608130698398L));
    ConvertedExpression expressionLe4 = simpleConverter.convertToCouchbaseFilter(filterLe4, null, null);
    String queryLe4 = toSelectSQL(expressionLe4);
    assertEquals(queryLe4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE added <= \"Wed Dec 16 14:58:18 UTC 2020\"");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 85 with Filter

use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkAndFilters.

@Test
public void checkAndFilters() throws SearchException {
    Filter filterEq1 = Filter.createEqualityFilter("uid", "test");
    Filter filterPresence1 = Filter.createPresenceFilter("mail");
    Filter filterLe1 = Filter.createLessOrEqualFilter("age", 23);
    Filter filterAnd1 = Filter.createANDFilter(filterPresence1, filterEq1, filterLe1);
    ConvertedExpression expressionAnd1 = simpleConverter.convertToCouchbaseFilter(filterAnd1, null, null);
    String queryAnd1 = toSelectSQL(expressionAnd1);
    assertEquals(queryAnd1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( mail IS NOT MISSING AND ( ( uid = \"test\" ) OR ( \"test\" IN uid ) ) AND age <= 23 )");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Aggregations

Filter (io.jans.orm.search.filter.Filter)188 Test (org.testng.annotations.Test)50 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)32 ConvertedExpression (io.jans.orm.couchbase.model.ConvertedExpression)28 SearchException (io.jans.orm.exception.operation.SearchException)25 ConvertedExpression (io.jans.orm.sql.model.ConvertedExpression)24 MappingException (io.jans.orm.exception.MappingException)22 ArrayList (java.util.ArrayList)21 AuthenticationException (io.jans.orm.exception.AuthenticationException)20 PropertyAnnotation (io.jans.orm.reflect.property.PropertyAnnotation)19 EntryDeleteException (io.jans.orm.exception.EntryDeleteException)18 Date (java.util.Date)14 List (java.util.List)14 SqlEntryManager (io.jans.orm.sql.impl.SqlEntryManager)11 SqlEntryManagerSample (io.jans.orm.sql.persistence.SqlEntryManagerSample)11 CustomAttribute (io.jans.orm.model.base.CustomAttribute)9 CustomObjectAttribute (io.jans.orm.model.base.CustomObjectAttribute)9 DateTimeParseException (java.time.format.DateTimeParseException)9 SpannerEntryManager (io.jans.orm.cloud.spanner.impl.SpannerEntryManager)8 SpannerEntryManagerSample (io.jans.orm.cloud.spanner.persistence.SpannerEntryManagerSample)8