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);
}
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;
}
Aggregations