To be able to dynamically update at runtime the status and processing time of notifications you need to instantiate the runtime and notification managers and retrieve the available notification instances of the relevant process.
You have set up your project in SAP NetWeaver Developer Studio. For more information, see Setting Up Your Project.
...
1. Instantiate the runtime and notification managers:
import com.sap.caf.eu.gp.process.api.GPProcessFactory; import com.sap.caf.eu.gp.process.rt.api.IGPNotificationManager; import com.sap.caf.eu.gp.process.rt.api.IGPRuntimeManager;
IGPRuntimeManager rtManager = GPProcessFactory.getRuntimeManager(); IGPNotificationManager notifManager = GPProcessFactory.getNotificationManager();
|
2. Retrieve a running process instance by specifying search criteria:
a. Specify start and end dates for the process:
import java.util.Calendar; import java.util.Date;
Calendar calendar = Calendar.getInstance(); calendar.set(2006, 1, 1); Date startDate = calendar.getTime();
calendar.set(2006, 11, 31); Date endDate = calendar.getTime();
|
b. Search for process instances meeting your requirements:
import java.util.Locale; import com.sap.security.api.IUser; import com.sap.caf.eu.gp.context.api.GPContextFactory; import com.sap.caf.eu.gp.context.api.IGPContextManager; import com.sap.caf.eu.gp.context.api.IGPUserContext; import com.sap.caf.eu.gp.process.api.GPSearchRole; import com.sap.caf.eu.gp.process.api.IGPProcessInstanceInfo;
// create user context from the current user and locale IGPContextManager contextManager = GPContextFactory.getContextManager(); IGPUserContext userContext = contextManager.createUserContext(user, locale);
IGPProcessInstanceInfo processInfo[] = rtManager.getRunningInstances( // specify a search role GPSearchRole.SEARCH_ROLE_ADMINISTRATOR, startDate, endDate, // specify user context userContext ); |
c. Retrieve the information for a single process instance:
import com.sap.caf.eu.gp.process.api.IGPProcessInstance;
// get process instance information for (int i = 0; i < processInfo.length; i++) { IGPProcessInstance process = rtManager.getProcessInstance( processInfo[i], userContext ); |
3. Retrieve all notification instances related to the running process instance:
import java.util.Enumeration;
Enumeration notifications = process.getNotificationInstanceEnumeration();
|
You can directly retrieve a process notification if you know its ID, the ID of the process, and, optionally, the activity ID (if it is defined at the activity level):
import com.sap.caf.eu.gp.process.rt.notification.api.IGPNotificationInstance;
IGPNotificationInstance notif = notifManager.retrieveNotification( processInstanceID, activityID, notifID ); |
You can retrieve all versions of a notification instance by providing its ID, the ID of the process, and, optionally, the activity ID (if it is defined at the activity level):
import com.sap.caf.eu.gp.process.rt.notification.api.IGPNotificationInstanceEnumeration;
IGPNotificationInstanceEnumeration notifEnum = notifManager.retrieveNotificationHistory( processInstanceID, activityID, notifID ); |
Once you have information about the process notifications, you can update them or change their status. For more information, see Updating Notification Processing Time and Status.