Thursday, July 30, 2020

Filters and QueryOptions

# Filter class contains all the static methods but filter class is not a static.
e.g
Single Criteria in Filter    :

Filter filter    =    Filter.eq("name","101");
NOTE : name is a property, 101 is property value

Multiple Criteria's in Filter   :

Filter filter1 = Filter.eq("firstname","Prasad");
Filter filter2 = Filter.eq("lastname","Reddy");

Filter.ignoreCase(Filter.and(filter1,filter2));

How to use filter in QueryOptions    : 

Single filter  in QueyOptions    :

QueyOptions qOptions = new QueyOptions();
qo.setCloneResults(true);
qOptions.addFilter(Filter.eq("application.name","Mighty App"));

Multiple filters  in QueyOptions    :

e.g     : 1

List listOfFilters = newArrayList();
listOfFilters.add("application.name","Clock");
listOfFilters.add("application.name","Watch App");

QueryOptions qOptions = new QueryOptions();
qOptions.setFilters(listOfFilters);

e.g    : 2

QueryOptions qOptions = new QueryOptions();
qOptions.add(Fiter.eq("type", certification.Type.Manager));
qOptions.add(Fiter.eq("name","Adam.guerich"));
qOptions.add(Fiter.eq("application",appId));

Multiple Ordering in QueryOptions    :

List arrayList = new ArrayList();
arrayList.add(new QueryOptions.Ordering("lastname","true"));
arrayList.add(new QueryOptions.Ordering("id","true"));

QueryOptions qOptions = new QueryOptions();
qOptions.setOrderings(arrayList);


How to search in Sailpoint with multiple conditions    :

Filter filter = Filter.and(Filter.like("manager.name","101"), Filter.eq("lastname","reddy"));

QueryOptions qOptions = new QueryOptions();
qOptions.addFilter(filter);

List propertyName = new ArrayList();
propertyName.add("name");

List listOfNames = new ArrayList();

Iterator names = context.search(Identity.class, qo, propertyName);
if(null != names){
while(names.hasNext()){
String name = (String)names.next()[0];
listOfNames.add(name)
}









No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...