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