Search in sources :

Example 26 with ConvertedExpression

use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkMultivaluedSubFilters.

@Test
public void checkMultivaluedSubFilters() throws SearchException {
    Filter filterSub1 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, null).multiValued();
    ConvertedExpression expressionSub1 = simpleConverter.convertToCouchbaseFilter(filterSub1, null, null);
    String querySub1 = toSelectSQL(expressionSub1);
    assertEquals(querySub1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"%test%\" END");
    Filter filterSub2 = Filter.createSubstringFilter("uid", "a", new String[] { "test" }, null).multiValued();
    ConvertedExpression expressionSub2 = simpleConverter.convertToCouchbaseFilter(filterSub2, null, null);
    String querySub2 = toSelectSQL(expressionSub2);
    assertEquals(querySub2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"a%test%\" END");
    Filter filterSub3 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, "z").multiValued();
    ConvertedExpression expressionSub3 = simpleConverter.convertToCouchbaseFilter(filterSub3, null, null);
    String querySub3 = toSelectSQL(expressionSub3);
    assertEquals(querySub3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"%test%z\" END");
    Filter filterSub4 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, "z").multiValued(3);
    ConvertedExpression expressionSub4 = simpleConverter.convertToCouchbaseFilter(filterSub4, null, null);
    String querySub4 = toSelectSQL(expressionSub4);
    assertEquals(querySub4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"%test%z\" END");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 27 with ConvertedExpression

use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkOrWithLowerCaseFilter.

@Test
public void checkOrWithLowerCaseFilter() throws SearchException {
    boolean useLowercaseFilter = true;
    String[] targetArray = new String[] { "test_value" };
    Filter descriptionFilter, displayNameFilter;
    if (useLowercaseFilter) {
        descriptionFilter = Filter.createSubstringFilter(Filter.createLowercaseFilter("description"), null, targetArray, null);
        displayNameFilter = Filter.createSubstringFilter(Filter.createLowercaseFilter("displayName"), null, targetArray, null);
    } else {
        descriptionFilter = Filter.createSubstringFilter("description", null, targetArray, null);
        displayNameFilter = Filter.createSubstringFilter("displayName", null, targetArray, null);
    }
    Filter searchFilter = Filter.createORFilter(descriptionFilter, displayNameFilter);
    Filter typeFilter = Filter.createEqualityFilter("jansScrTyp", "person_authentication");
    Filter filter = Filter.createANDFilter(searchFilter, typeFilter);
    ConvertedExpression expression = simpleConverter.convertToCouchbaseFilter(filter, null, null);
    String query = toSelectSQL(expression);
    assertEquals(query, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( ( LOWER(description) LIKE \"%test_value%\" OR LOWER(displayName) LIKE \"%test_value%\" ) AND ( ( jansScrTyp = \"person_authentication\" ) OR ( \"person_authentication\" IN jansScrTyp ) ) )");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Aggregations

ConvertedExpression (io.jans.orm.couchbase.model.ConvertedExpression)27 Filter (io.jans.orm.search.filter.Filter)27 Test (org.testng.annotations.Test)21 SearchException (io.jans.orm.exception.operation.SearchException)6 AuthenticationException (io.jans.orm.exception.AuthenticationException)5 EntryDeleteException (io.jans.orm.exception.EntryDeleteException)5 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)5 MappingException (io.jans.orm.exception.MappingException)5 PropertyAnnotation (io.jans.orm.reflect.property.PropertyAnnotation)5 DateTimeException (java.time.DateTimeException)5 DateTimeParseException (java.time.format.DateTimeParseException)5 JsonObject (com.couchbase.client.java.document.json.JsonObject)4 ParsedKey (io.jans.orm.impl.model.ParsedKey)3 JsonArray (com.couchbase.client.java.document.json.JsonArray)1 Expression (com.couchbase.client.java.query.dsl.Expression)1 Sort (com.couchbase.client.java.query.dsl.Sort)1 FilterType (io.jans.orm.search.filter.FilterType)1 ISO_INSTANT (java.time.format.DateTimeFormatter.ISO_INSTANT)1 ArrayList (java.util.ArrayList)1