Adaptive Case Management series – in action – part 4
User Events
Besides automatic events one can also make use of user events in ACM, i.e. events activated by a user action. This for example enables an applicant to withdraw his application or add additional information to the application. User events can be caught and act upon by business rules as demonstrated in the previous blogpost. A user event provides an ideal means for establishing ad hoc interaction with an exisiting case. Now how to trigger a user event?
Currently the only way to raise a user event in ACM is by making use of the Case Management API in custom java code. This makes it possible for example to raise a user event for a specific case in a custom ADF form, e.g. by clicking a button. The sample code below shows the code you need to do this.
import oracle.bpel.services.bpm.common.IBPMContext;
import oracle.bpm.casemgmt.CaseIdentifier;
import oracle.bpm.casemgmt.ICaseService;
import oracle.bpm.casemgmt.persistence.factory.CaseEventFactory;
import oracle.bpm.casemgmt.persistence.model.CaseEvent;
import oracle.bpm.client.BPMServiceClientFactory;
private static BPMServiceClientFactory getBPMServiceClientFactory() {
BPMServiceClientFactory factory =
BPMServiceClientFactory.getInstance(BPMServiceClientFactory.REMOTE_CLIENT, null, null);
return factory;
}
private static IBPMContext getIBPMContext(String username, String password) throws Exception {
return getBPMServiceClientFactory().getBPMUserAuthenticationService().authenticate(username, password.toCharArray(), null);
}
public void triggerUserEvent(String caseNumber, String eventName) {
ICaseService caseService = getBPMServiceClientFactory().getCaseManagementServiceClient().getCaseService();
IBPMContext context;
try {
context = getIBPMContext("weblogic", "welcome01");
CaseIdentifier id = new CaseIdentifier(null, Long.valueOf(caseNumber), null);
CaseEvent caseEvent = CaseEventFactory.createUserDefinedEvent(eventName, null, null);
caseService.raiseCaseEvent(context, id, caseEvent);
} catch (Exception e) {
e.printStackTrace();
}
}
The triggerUserEvent method fires the event eventName for the case instance with case number caseNumber. To get access to the context you need a valid user, i.e. weblogic in this ecample. You need to couple some libraries to your project to get this code to compile and run in an ADF form. At compile time you need the libraries/jars BPM Services, oracle.bpm.casemgmt.interface.jarand oracle.bpm.bpm-services.client.jar. Furthermore you’ll need to add the libraries oracle.soa.workflow and oracle.bpm.client as shared libs to the weblogic-application.xml descriptor. You can find a working example right here.
The Case Management API supplied by Oracle offers a lot more possibilities for managing a case in ACM through java code. To name one you have the opportunity to get to the case data by means of the ICaseInstanceServiceinterface. In this interface you’ll find the useful methods getCase, getCaseData and queryCase.
Geen reacties
Geef jouw mening
Reactie plaatsenReactie toevoegen