cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to properly process many IdentityIQ objects in a run rule task

How to properly process many IdentityIQ objects in a run rule task

Sometimes, all you need is to update many objects in IIQ, for example, you want to change some attribute, let's say, hundreds of thousands of them.

Because IIQ uses hibernate, you can't just bring all objects into memory at once, or if you do, you can't let them stay in the object cache.

So this code snippet shows how to properly split this task into smaller transaction chunks. 

Please notice that the debug's "run rule" feature is subject to the UI timeout for a synchronous request. 

So in order to run a long-running task, create a "Run Rule"  task and execute it in background.

Here's a simple example on how to do that. I hope it helps.


import sailpoint.object.Identity;
import java.util.Iterator;
import sailpoint.object.Filter;
import sailpoint.object.QueryOptions;

int count = context.countObjects(Identity.class, null);


QueryOptions qo = new QueryOptions();
qo.addOrdering("id", true);

int slices = count / 500;

if (slices == 0) {

Iterator it = context.search(Identity.class, qo);
while (it.hasNext()) {

Identity i = (Identity) it.next();
i.setAttribute("type", "partner");
context.saveObject(i);

}

context.commitTransaction();
context.decache();

} else {

for (int j = 0; j < slices; j++) {

qo.setFirstRow(j*500);
qo.setResultLimit(500);

Iterator it = context.search(Identity.class, qo);
while (it.hasNext()) {

Identity i = (Identity) it.next();
i.setAttribute("type", "partner");
context.saveObject(i);

}

context.commitTransaction();
context.decache();

}

}

 

Labels (1)
Version history
Revision #:
7 of 7
Last update:
‎May 22, 2023 06:00 PM
Updated by: