Skip to content

Instantly share code, notes, and snippets.

@hasithaa
Last active December 17, 2015 17:49
Show Gist options
  • Select an option

  • Save hasithaa/5648471 to your computer and use it in GitHub Desktop.

Select an option

Save hasithaa/5648471 to your computer and use it in GitHub Desktop.
Sample HumanTask Event Listener for WSO2 BPS
package org.wso2.carbon.humantask.sample;
import org.wso2.carbon.humantask.core.api.event.HumanTaskEventListener;
import org.wso2.carbon.humantask.core.api.event.TaskEventInfo;
import org.wso2.carbon.humantask.core.dao.TaskType;
public class SimpleEventListener implements HumanTaskEventListener {
@Override
public void onEvent(TaskEventInfo taskEventInfo) {
System.out.println("[ Task ID : " + taskEventInfo.getTaskInfo().getId() + " ] [ Event : " + taskEventInfo.getEventType() + " ] at " + taskEventInfo.getTaskInfo().getModifiedDate());
if (taskEventInfo.getTaskInfo().getType() == TaskType.TASK) {
System.out.println("\tTask Name :" + taskEventInfo.getTaskInfo().getName());
System.out.println("\tTask Subject :" + taskEventInfo.getTaskInfo().getSubject());
System.out.println("\tTask Description :" + taskEventInfo.getTaskInfo().getDescription());
System.out.println("\tTask Owner : " + taskEventInfo.getTaskInfo().getOwner());
} else if (taskEventInfo.getTaskInfo().getType() == TaskType.NOTIFICATION) {
System.out.println("\tNotification Name :" + taskEventInfo.getTaskInfo().getName());
System.out.println("\tNotification Subject :" + taskEventInfo.getTaskInfo().getSubject());
System.out.println("\tNotification Description :" + taskEventInfo.getTaskInfo().getDescription());
}
}
}
@hasithaa
Copy link
Author

Example Output of above code: [Revision 2]

[ Task ID : 5351 ] [ Event : CREATE ] at Mon Mar 24 14:32:56 IST 2014
Task Name :Approve Claim
Task Subject :Approve the insurance claim for €5000.0 on behalf of
? ?
Task Description :Approve this claim following corporate guideline
#4711.0815/7 ...
Task Owner : admin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment