Quick tips on Case Management audit events

Oracle Adaptive Case Management has rich APIs to retrieve the events that transpired within a case instance. Here is an example of using case events and some important tips. This information applies to Oracle BPM 11g and 12c.

Create a java class with a main method to retrieve the case audit events

public static void main(String[] args) {
String caseUser = "weblogic";
String caseUserPassword = "welcome1";
String caseId = "507ff826-95ef-4425-9438-9f4255ebe0c9";
try {
//Get the caseService
 ICaseService caseService =
 ConnectionFixture.getBPMServiceClientFactory().getCaseManagementServiceClient().getCaseService();

 //Get the context for the User
 IBPMContext context =
 ConnectionFixture.getIBPMContext(caseUser, caseUserPassword);
 CMCommon.getCaseObjects(caseService, context, caseId,
 null);

 } catch (Exception e) {
 System.out.println("Exception thrown: " + e.getMessage());
 e.printStackTrace();
 }

 }

Let take a look at the audit event query:

public static void getCaseObjects(ICaseService caseService,
IBPMContext context,String caseId, TEventType eventType) throws CaseServiceException {
System.out.println("n************************************************");
System.out.println("executing getCaseObjects");
System.out.println("going to get case objects: " + eventType +
" for caseId: " + caseId);

CaseIdentifier caseIdentifier = CMCommon.getCaseIdentifierBasedOnCaseId(caseId);

System.out.println("getCaseId:"+ caseIdentifier.getCaseId());
int pageNum = 1;
int pageSize = 10;
String updatedBy= null;
// Set option to query Task assignees for HWF Task based activity
List<ICaseConstants.CaseEventInfo> additionalCaseEventInfo = new ArrayList<ICaseConstants.CaseEventInfo>();
additionalCaseEventInfo.add(ICaseConstants.CaseEventInfo.taskInfo);
// This method has been deprecated
// CaseObjectsList caseObjectsList = caseService.getAudit(context, caseIdentifier, null, updatedBy, pageNum, pageSize);
CaseObjectsList caseObjectsList = caseService.queryCaseEvent(context, caseIdentifier, eventType, null, updatedBy, pageSize, pageNum, additionalCaseEventInfo);

List<CaseEvent> persistedEvents = caseObjectsList.getCaseObjects();
int nEvents = caseObjectsList.getCaseObjects().size();
System.out.println("persistedEvents.size:"+nEvents);
for (CaseEvent ce: persistedEvents)
{
System.out.println("=============="+"getEventType:"+ce.getEventType().toString()+"==================");
System.out.println("case event getTaskInfo:"+(ce.getTaskInfo()!= null? ce.getTaskInfo().toString(): ""));
System.out.println("getUpdatedBy:"+ce.getUpdatedByDisplayName());
System.out.println("getDisplayName:"+ce.getActivityName());
}
return;
}

Some key tips:

1. Passing a null value for TEventType will retrieve all the case events just like the default view on the case workspace. Passing a specific value retrieves only those specific event types – see the API for more details.

2. Make sure the pageNum and pageSize are in the correct position when calling the method – it will not retrieve any values if they are wrong.

3. Using additionalCaseEventInfo.add(ICaseConstants.CaseEventInfo.taskInfo); will work only for Case activities that are Human Tasks (does not work on BPMN or custom case activities). This retrieves an oracle.bpm.casemgmt.task.model.TaskInfo object that will retrieve all the details on the task including task assignees (see oracle.bpm.casemgmt.task.model.Task API for more details)

4. The search String for case events only searches the audit event case object display names and updated by display names with an OR condition. You can use enclose your search string with wildcard %.

case audit events logging in EM

case audit events logging in EM

5. To debug the case event search you can navigate to Enterprise manager and enable the logger oracle.bpm.casemgmt.event to TRACE32:FINEST

Vikram