Search in sources :

Example 1 with SCIMComplexConf

use of org.apache.syncope.common.lib.scim.SCIMComplexConf in project syncope by apache.

the class SCIMFilterTest method setup.

@BeforeAll
public static void setup() {
    SCIMConf conf = new SCIMConf();
    conf.setUserConf(new SCIMUserConf());
    conf.getUserConf().setTitle("title");
    conf.getUserConf().setDisplayName("cn");
    conf.getUserConf().setUserType("userType");
    conf.getUserConf().setName(new SCIMUserNameConf());
    conf.getUserConf().getName().setFamilyName("surname");
    SCIMComplexConf<EmailCanonicalType> email = new SCIMComplexConf<>();
    email.setValue("email");
    email.setType(EmailCanonicalType.work);
    conf.getUserConf().getEmails().add(email);
    email = new SCIMComplexConf<>();
    email.setValue("gmail");
    email.setType(EmailCanonicalType.home);
    conf.getUserConf().getEmails().add(email);
    VISITOR = new SearchCondVisitor(Resource.User, conf);
}
Also used : SCIMUserConf(org.apache.syncope.common.lib.scim.SCIMUserConf) SCIMConf(org.apache.syncope.common.lib.scim.SCIMConf) SCIMComplexConf(org.apache.syncope.common.lib.scim.SCIMComplexConf) SCIMUserNameConf(org.apache.syncope.common.lib.scim.SCIMUserNameConf) EmailCanonicalType(org.apache.syncope.common.lib.scim.types.EmailCanonicalType) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with SCIMComplexConf

use of org.apache.syncope.common.lib.scim.SCIMComplexConf in project syncope by apache.

the class SearchCondVisitor method complex.

private <E extends Enum<?>> SearchCond complex(final String operator, final String left, final String right, final List<SCIMComplexConf<E>> items) {
    if (left.endsWith(".type")) {
        Optional<SCIMComplexConf<E>> item = items.stream().filter(object -> object.getType().name().equals(StringUtils.strip(right, "\""))).findFirst();
        if (item.isPresent()) {
            AttributeCond attributeCond = new AttributeCond();
            attributeCond.setSchema(item.get().getValue());
            attributeCond.setType(AttributeCond.Type.ISNOTNULL);
            return SearchCond.getLeafCond(attributeCond);
        }
    } else if (!conf.getUserConf().getEmails().isEmpty() && (MULTIVALUE.contains(left) || left.endsWith(".value"))) {
        List<SearchCond> orConds = new ArrayList<>();
        items.forEach(item -> {
            AttributeCond cond = new AttributeCond();
            cond.setSchema(item.getValue());
            cond.setExpression(StringUtils.strip(right, "\""));
            orConds.add(setOperator(cond, operator));
        });
        if (!orConds.isEmpty()) {
            return SearchCond.getOrCond(orConds);
        }
    }
    return null;
}
Also used : Arrays(java.util.Arrays) SCIMUserConf(org.apache.syncope.common.lib.scim.SCIMUserConf) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) SCIMUserAddressConf(org.apache.syncope.common.lib.scim.SCIMUserAddressConf) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) List(java.util.List) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) Resource(org.apache.syncope.ext.scimv2.api.type.Resource) SCIMComplexConf(org.apache.syncope.common.lib.scim.SCIMComplexConf) SCIMConf(org.apache.syncope.common.lib.scim.SCIMConf) Map(java.util.Map) Optional(java.util.Optional) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) SCIMComplexConf(org.apache.syncope.common.lib.scim.SCIMComplexConf) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

SCIMComplexConf (org.apache.syncope.common.lib.scim.SCIMComplexConf)2 SCIMConf (org.apache.syncope.common.lib.scim.SCIMConf)2 SCIMUserConf (org.apache.syncope.common.lib.scim.SCIMUserConf)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 StringUtils (org.apache.commons.lang3.StringUtils)1 SCIMUserAddressConf (org.apache.syncope.common.lib.scim.SCIMUserAddressConf)1 SCIMUserNameConf (org.apache.syncope.common.lib.scim.SCIMUserNameConf)1 EmailCanonicalType (org.apache.syncope.common.lib.scim.types.EmailCanonicalType)1 AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)1 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)1 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)1 Resource (org.apache.syncope.ext.scimv2.api.type.Resource)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1