use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class DefaultPullCorrelationRule method getSearchCond.
@Override
public SearchCond getSearchCond(final ConnectorObject connObj, final Provision provision) {
Map<String, Item> mappingItems = provision.getMapping().getItems().stream().collect(Collectors.toMap(Item::getIntAttrName, Function.identity()));
// search for anys by attribute(s) specified in the policy
SearchCond searchCond = null;
for (String schema : conf.getSchemas()) {
Item mappingItem = mappingItems.get(schema);
Attribute attr = mappingItem == null ? null : connObj.getAttributeByName(mappingItem.getExtAttrName());
if (attr == null) {
throw new IllegalArgumentException("Connector object does not contains the attributes to perform the search: " + schema);
}
AttributeCond.Type type;
String expression = null;
if (attr.getValue() == null || attr.getValue().isEmpty() || (attr.getValue().size() == 1 && attr.getValue().get(0) == null)) {
type = AttributeCond.Type.ISNULL;
} else {
type = AttributeCond.Type.EQ;
expression = attr.getValue().size() > 1 ? attr.getValue().toString() : attr.getValue().get(0).toString();
}
SearchCond nodeCond;
// any objects: just key or name can be selected
if ("key".equalsIgnoreCase(schema) || "username".equalsIgnoreCase(schema) || "name".equalsIgnoreCase(schema)) {
AnyCond cond = new AnyCond();
cond.setSchema(schema);
cond.setType(type);
cond.setExpression(expression);
nodeCond = SearchCond.getLeafCond(cond);
} else {
AttributeCond cond = new AttributeCond();
cond.setSchema(schema);
cond.setType(type);
cond.setExpression(expression);
nodeCond = SearchCond.getLeafCond(cond);
}
searchCond = searchCond == null ? nodeCond : SearchCond.getAndCond(searchCond, nodeCond);
}
return searchCond;
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SearchCondConverterTest method ilike.
@Test
public void ilike() {
String fiql = new UserFiqlSearchConditionBuilder().is("username").equalToIgnoreCase("ros*").query();
assertEquals("username=~ros*", fiql);
AttributeCond attrCond = new AnyCond(AttributeCond.Type.ILIKE);
attrCond.setSchema("username");
attrCond.setExpression("ros%");
SearchCond simpleCond = SearchCond.getLeafCond(attrCond);
assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SearchCondConverterTest method ieq.
@Test
public void ieq() {
String fiql = new UserFiqlSearchConditionBuilder().is("username").equalToIgnoreCase("rossini").query();
assertEquals("username=~rossini", fiql);
AnyCond attrCond = new AnyCond(AttributeCond.Type.IEQ);
attrCond.setSchema("username");
attrCond.setExpression("rossini");
SearchCond simpleCond = SearchCond.getLeafCond(attrCond);
assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SearchCondConverterTest method eq.
@Test
public void eq() {
String fiql = new UserFiqlSearchConditionBuilder().is("username").equalTo("rossini").query();
assertEquals("username==rossini", fiql);
AnyCond attrCond = new AnyCond(AttributeCond.Type.EQ);
attrCond.setSchema("username");
attrCond.setExpression("rossini");
SearchCond simpleCond = SearchCond.getLeafCond(attrCond);
assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SearchCondConverterTest method relationships.
@Test
public void relationships() {
String fiql = new UserFiqlSearchConditionBuilder().inRelationships("ca20ffca-1305-442f-be9a-3723a0cd88ca").query();
assertEquals(SpecialAttr.RELATIONSHIPS + "==ca20ffca-1305-442f-be9a-3723a0cd88ca", fiql);
RelationshipCond relationshipCond = new RelationshipCond();
relationshipCond.setAnyObject("ca20ffca-1305-442f-be9a-3723a0cd88ca");
SearchCond simpleCond = SearchCond.getLeafCond(relationshipCond);
assertEquals(simpleCond, SearchCondConverter.convert(fiql));
}
Aggregations