IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing client applications for BPEL processes and tasks > Create plug-ins to customize human task functionality > Use a plug-in to post-process people query results
Developing a plug-in using the StaffQueryResultPostProcessorPlugin interface
The StaffQueryResultPostProcessorPlugin interface allows you to modify the people query results. This interface does not offer the performance optimizations that are available in the StaffQueryResultPostProcessorPlugin2 interface.
You must implement all four methods that are defined in the interface. Each method receives context information about a different type of invocation.
- Task instance
- For task instances, you must implement the following method for the following task roles: Administrator, Reader, Potential Starter, Potential Owner, and Editor.
public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, Task task, int role, Map context);- Escalation instance (for a task instance)
- For escalations of task instances, you must implement the following method for the escalation role Escalation Receiver.
public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, Escalation escalation, Task task, int role, Map context);- Task template
- For task templates, you must implement the following method for the task template roles Potential Instance Creator, Administrator, and Reader.
public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, TaskTemplate template, int role, Map context);- Application component
- For any application components that have no modeled Potential Instance Creator specification, you must implement the following method.
public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, ApplicationComponent applicationComponent, int role, Map context);If you want to call the HumanTaskManagerService interface from this class, do not call a method that updates the task that produced the event. This action might result in inconsistent task data in the database.
Parameters
The originalStaffQueryResult parameter is of type StaffQueryResult. It contains information about the user entries that are retrieved during people resolution, for example, by accessing the virtual member manager people directory.The context parameter is of type Map. The following code snippets show how to access specific information in the context.
- People assignment criteria definition
- To access this information proceed as follows:
Map pacAsMap = (Map) context.get("HTM_VERB"); // to retrieve the name of the people assignment criteria (PAC) String pacName = (String) pacAsMap.get("HTM_VERB_NAME"); // to retrieve the PAC parameter names Set paramNames = pacAsMap.keySet(); // to retrieve the value of a specific parameter String paramValue = (String) pacAsMap.get( paramName);Where paramName is the name of a parameter that you want the value of.
- Replacement variables specified as people assignment criteria parameter values
- To access this information proceed as follows:
Object replVarObj = context.get( replVarName); if (replVarObj instanceof String) String replVarValue = (String) replVarObj; if (replVarObj instanceof String[]) String[] replVarValues = (String[]) replVarObj;Where replVarName is the name of a replacement variable that you want the value of.
- List of users that have been explicitly excluded by people resolution
- To access this information proceed as follows:
String[] removedUserIDs = (String[]) context.get("HTM_REMOVED_USERS");
Example: StaffQueryResultPostProcessorPlugin implementation
The following example illustrates shows how you might change the Editor role of a task called SpecialTask.
import java.util.Collection; import java.util.Locale; import java.util.Map; import com.ibm.task.api.ApplicationComponent; import com.ibm.task.api.Escalation; import com.ibm.task.api.EscalationTemplate; import com.ibm.task.api.Task; import com.ibm.task.api.TaskTemplate; import com.ibm.task.spi.StaffQueryResult; import com.ibm.task.spi.StaffQueryResultFactory; import com.ibm.task.spi.StaffQueryResultPostProcessorPlugin; import com.ibm.task.spi.UserData; public class MyStaffResultProcessor implements StaffQueryResultPostProcessorPlugin { public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, ApplicationComponent applicationComponent, int role, Map context) { return(originalStaffQueryResult); } public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, Escalation escalation, Task task, int role, Map context) { return(originalStaffQueryResult); } public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, EscalationTemplate template, int role, Map context) { return(originalStaffQueryResult); } public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, Task task, int role, Map context) { StaffQueryResult newStaffQueryResult = originalStaffQueryResult; StaffQueryResultFactory staffResultFactory = StaffQueryResultFactory.newInstance(); if (role == com.ibm.task.api.WorkItem.REASON_EDITOR && task.getName() != null && task.getName().equals("SpecialTask")) { Map userDataMap; UserData userDataObj; // get the user data map from passed staff query result and clear // the map. Then add a new Editor (new UserData instance) userDataMap = newStaffQueryResult.getUserDataMap(); userDataMap.clear(); userDataObj = staffResultFactory.newUserData("MyEditor", new Locale("en-US"), "MyEditor@company.com"); userDataMap.put(userDataObj.getUserName(), userDataObj); } return(newStaffQueryResult); } public StaffQueryResult processStaffQueryResult(StaffQueryResult originalStaffQueryResult, TaskTemplate template, int role, Map context) { return(originalStaffQueryResult); } } // end of class MyStaffResultProcessorFor more information about this interface, see the Javadoc.
Use a plug-in to post-process people query results
Related concepts:
People query result post-processing plug-in
Developing a plug-in using the StaffQueryResultPostProcessorPlugin2 interface
Replacement variables in human tasks
Related information:
Sample: People assignment customization using the Post Processor Plugin