Search in sources :

Example 6 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class SearchCondConverterTest method isNull.

@Test
public void isNull() {
    String fiql = new UserFiqlSearchConditionBuilder().is("loginDate").nullValue().query();
    assertEquals("loginDate==" + SpecialAttr.NULL, fiql);
    AttributeCond attrCond = new AttributeCond(AttributeCond.Type.ISNULL);
    attrCond.setSchema("loginDate");
    SearchCond simpleCond = SearchCond.getLeafCond(attrCond);
    assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
Also used : AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) UserFiqlSearchConditionBuilder(org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

Example 7 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class SearchCondVisitor method createAttributeCond.

private AttributeCond createAttributeCond(final String schema) {
    AttributeCond attributeCond = SearchableFields.contains(schema) ? new AnyCond() : new AttributeCond();
    attributeCond.setSchema(schema);
    return attributeCond;
}
Also used : AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond)

Example 8 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class AnySearchTest method searchByBoolean.

@Test
public void searchByBoolean() {
    AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.EQ);
    coolLeafCond.setSchema("cool");
    coolLeafCond.setExpression("true");
    SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
    assertTrue(cond.isValid());
    List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(1, users.size());
    assertEquals("c9b2dec2-00a7-4855-97c0-d854842b4b24", users.get(0).getKey());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 9 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class AnySearchTest method searchCaseInsensitiveWithNotCondition.

@Test
public void searchCaseInsensitiveWithNotCondition() {
    AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.IEQ);
    fullnameLeafCond.setSchema("fullname");
    fullnameLeafCond.setExpression("giuseppe verdi");
    SearchCond cond = SearchCond.getNotLeafCond(fullnameLeafCond);
    assertTrue(cond.isValid());
    List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(4, users.size());
    Set<String> ids = users.stream().map(Entity::getKey).collect(Collectors.toSet());
    assertTrue(ids.contains("1417acbe-cbf6-4277-9372-e75e04f97000"));
    assertTrue(ids.contains("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee"));
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 10 with AttributeCond

use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.

the class AnySearchTest method searchCaseInsensitiveWithLikeCondition.

@Test
public void searchCaseInsensitiveWithLikeCondition() {
    AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.ILIKE);
    fullnameLeafCond.setSchema("fullname");
    fullnameLeafCond.setExpression("%O%");
    MembershipCond groupCond = new MembershipCond();
    groupCond.setGroup("root");
    AttributeCond loginDateCond = new AttributeCond(AttributeCond.Type.EQ);
    loginDateCond.setSchema("loginDate");
    loginDateCond.setExpression("2009-05-26");
    SearchCond subCond = SearchCond.getAndCond(SearchCond.getLeafCond(fullnameLeafCond), SearchCond.getLeafCond(groupCond));
    assertTrue(subCond.isValid());
    SearchCond cond = SearchCond.getAndCond(subCond, SearchCond.getLeafCond(loginDateCond));
    assertTrue(cond.isValid());
    List<User> users = searchDAO.search(cond, AnyTypeKind.USER);
    assertNotNull(users);
    assertEquals(1, users.size());
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)35 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)25 Test (org.junit.jupiter.api.Test)25 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)16 User (org.apache.syncope.core.persistence.api.entity.user.User)15 AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)12 UserFiqlSearchConditionBuilder (org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder)8 ArrayList (java.util.ArrayList)4 MembershipCond (org.apache.syncope.core.persistence.api.dao.search.MembershipCond)4 Map (java.util.Map)3 SCIMUserAddressConf (org.apache.syncope.common.lib.scim.SCIMUserAddressConf)3 SCIMUserConf (org.apache.syncope.common.lib.scim.SCIMUserConf)3 OrderByClause (org.apache.syncope.core.persistence.api.dao.search.OrderByClause)3 Group (org.apache.syncope.core.persistence.api.entity.group.Group)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Optional (java.util.Optional)2 StringUtils (org.apache.commons.lang3.StringUtils)2 SCIMComplexConf (org.apache.syncope.common.lib.scim.SCIMComplexConf)2 SCIMConf (org.apache.syncope.common.lib.scim.SCIMConf)2