Search in sources :

Example 46 with SearchCond

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

the class SCIMFilterTest method pr.

@Test
public void pr() {
    SearchCond cond = SearchCondConverter.convert(VISITOR, "title pr");
    assertNotNull(cond);
    assertNotNull(cond.getAttributeCond());
    assertEquals("title", cond.getAttributeCond().getSchema());
    assertEquals(AttributeCond.Type.ISNOTNULL, cond.getAttributeCond().getType());
    assertNull(cond.getAttributeCond().getExpression());
}
Also used : SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

Example 47 with SearchCond

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

the class SCIMFilterTest method name.

@Test
public void name() {
    SearchCond cond = SearchCondConverter.convert(VISITOR, "name.familyName co \"O'Malley\"");
    assertNotNull(cond);
    assertEquals(SearchCond.Type.LEAF, cond.getType());
    AttributeCond leaf = cond.getAttributeCond();
    assertNotNull(leaf);
    assertEquals("surname", leaf.getSchema());
    assertEquals(AttributeCond.Type.ILIKE, leaf.getType());
    assertEquals("%O'Malley%", leaf.getExpression());
}
Also used : 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)

Example 48 with SearchCond

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

the class SCIMFilterTest method and.

@Test
public void and() {
    SearchCond cond = SearchCondConverter.convert(VISITOR, "title pr and userName sw \"J\"");
    assertNotNull(cond);
    assertEquals(SearchCond.Type.AND, cond.getType());
    SearchCond left = cond.getLeftSearchCond();
    assertNotNull(left);
    assertNotNull(left.getAttributeCond());
    assertEquals("title", left.getAttributeCond().getSchema());
    assertEquals(AttributeCond.Type.ISNOTNULL, left.getAttributeCond().getType());
    assertNull(left.getAttributeCond().getExpression());
    SearchCond right = cond.getRightSearchCond();
    assertNotNull(right);
    assertNotNull(right.getAnyCond());
    assertEquals("username", right.getAnyCond().getSchema());
    assertEquals(AttributeCond.Type.ILIKE, right.getAnyCond().getType());
    assertEquals("J%", right.getAnyCond().getExpression());
}
Also used : SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

Example 49 with SearchCond

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

the class SCIMFilterTest method emails.

@Test
public void emails() {
    SearchCond cond = SearchCondConverter.convert(VISITOR, "emails co \"example.com\" or emails.value co \"example.org\"");
    assertNotNull(cond);
    assertEquals(SearchCond.Type.OR, cond.getType());
    SearchCond left = cond.getLeftSearchCond();
    assertNotNull(left);
    assertEquals(SearchCond.Type.OR, left.getType());
    SearchCond left1 = left.getLeftSearchCond();
    assertNotNull(left1);
    assertNotNull(left1.getAttributeCond());
    assertEquals("email", left1.getAttributeCond().getSchema());
    assertEquals(AttributeCond.Type.ILIKE, left1.getAttributeCond().getType());
    assertEquals("%example.com%", left1.getAttributeCond().getExpression());
    SearchCond left2 = left.getRightSearchCond();
    assertNotNull(left2);
    assertNotNull(left2.getAttributeCond());
    assertEquals("gmail", left2.getAttributeCond().getSchema());
    assertEquals(AttributeCond.Type.ILIKE, left2.getAttributeCond().getType());
    assertEquals("%example.com%", left2.getAttributeCond().getExpression());
    SearchCond right = cond.getRightSearchCond();
    assertNotNull(right);
    assertEquals(SearchCond.Type.OR, right.getType());
    SearchCond right1 = right.getLeftSearchCond();
    assertNotNull(right1);
    assertNotNull(right1.getAttributeCond());
    assertEquals("email", right1.getAttributeCond().getSchema());
    assertEquals(AttributeCond.Type.ILIKE, right1.getAttributeCond().getType());
    assertEquals("%example.org%", right1.getAttributeCond().getExpression());
    SearchCond right2 = right.getRightSearchCond();
    assertNotNull(right2);
    assertNotNull(right2.getAttributeCond());
    assertEquals("gmail", right2.getAttributeCond().getSchema());
    assertEquals(AttributeCond.Type.ILIKE, right2.getAttributeCond().getType());
    assertEquals("%example.org%", right2.getAttributeCond().getExpression());
}
Also used : SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Test(org.junit.jupiter.api.Test)

Example 50 with SearchCond

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

the class SCIMDataBinder method toSCIMGroup.

public SCIMGroup toSCIMGroup(final GroupTO groupTO, final String location, final List<String> attributes, final List<String> excludedAttributes) {
    SCIMGroup group = new SCIMGroup(groupTO.getKey(), new Meta(Resource.Group, groupTO.getCreationDate(), groupTO.getLastChangeDate() == null ? groupTO.getCreationDate() : groupTO.getLastChangeDate(), groupTO.getETagValue(), location), output(attributes, excludedAttributes, "displayName", groupTO.getName()));
    MembershipCond membCond = new MembershipCond();
    membCond.setGroup(groupTO.getKey());
    SearchCond searchCond = SearchCond.getLeafCond(membCond);
    if (output(attributes, excludedAttributes, "members")) {
        int count = userLogic.search(searchCond, 1, 1, Collections.<OrderByClause>emptyList(), SyncopeConstants.ROOT_REALM, false).getLeft();
        for (int page = 1; page <= (count / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
            List<UserTO> users = userLogic.search(searchCond, page, AnyDAO.DEFAULT_PAGE_SIZE, Collections.<OrderByClause>emptyList(), SyncopeConstants.ROOT_REALM, false).getRight();
            users.forEach(userTO -> {
                group.getMembers().add(new Member(userTO.getKey(), StringUtils.substringBefore(location, "/Groups") + "/Users/" + userTO.getKey(), userTO.getUsername()));
            });
        }
    }
    return group;
}
Also used : Meta(org.apache.syncope.ext.scimv2.api.data.Meta) SCIMGroup(org.apache.syncope.ext.scimv2.api.data.SCIMGroup) OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) UserTO(org.apache.syncope.common.lib.to.UserTO) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Member(org.apache.syncope.ext.scimv2.api.data.Member)

Aggregations

SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)74 Test (org.junit.jupiter.api.Test)55 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)30 AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)26 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)25 User (org.apache.syncope.core.persistence.api.entity.user.User)20 UserFiqlSearchConditionBuilder (org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder)17 MembershipCond (org.apache.syncope.core.persistence.api.dao.search.MembershipCond)12 OrderByClause (org.apache.syncope.core.persistence.api.dao.search.OrderByClause)11 ArrayList (java.util.ArrayList)10 Group (org.apache.syncope.core.persistence.api.entity.group.Group)10 List (java.util.List)8 AnyTypeCond (org.apache.syncope.core.persistence.api.dao.search.AnyTypeCond)8 AssignableCond (org.apache.syncope.core.persistence.api.dao.search.AssignableCond)7 MemberCond (org.apache.syncope.core.persistence.api.dao.search.MemberCond)7 Collections (java.util.Collections)6 Collectors (java.util.stream.Collectors)6 SyncopeConstants (org.apache.syncope.common.lib.SyncopeConstants)6 RelationshipCond (org.apache.syncope.core.persistence.api.dao.search.RelationshipCond)6 ResourceCond (org.apache.syncope.core.persistence.api.dao.search.ResourceCond)6