@Override
public void executeActivity(WMSessionHandle shandle, WfActivityInternal act) throws Exception, ToolAgentGeneralException {
ApplicationContext appContext = WorkflowUtil.getApplicationContext();
WorkflowHelper workflowMapper = (WorkflowHelper) appContext.getBean("workflowHelper");
try {
String processId = act.container(shandle).manager(shandle).name(shandle);
String activityId = act.activity_definition_id(shandle);
String version = act.container(shandle).manager(shandle).version(shandle);
// retrieve assignment
WorkflowAssignment workflowAssignment = new WorkflowAssignment();
workflowAssignment.setProcessId(act.process_id(shandle));
workflowAssignment.setProcessDefId(processId);
workflowAssignment.setProcessName(act.container(shandle).name(shandle));
workflowAssignment.setProcessVersion(version);
workflowAssignment.setProcessRequesterId((String) shandle.getVendorData());
workflowAssignment.setDescription(act.description(shandle));
workflowAssignment.setActivityDefId(activityId);
workflowAssignment.setActivityId(act.key(shandle));
workflowAssignment.setActivityName(act.name(shandle));
workflowAssignment.setAssigneeId(act.getPerformerId(shandle));
// retrieve workflow variables
List<WorkflowVariable> processVariableList = new ArrayList();
Map variableMap = act.process_context(shandle);
Iterator it = variableMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pairs = (Map.Entry) it.next();
WorkflowVariable var = new WorkflowVariable();
var.setId(pairs.getKey());
var.setVal(pairs.getValue());
processVariableList.add(var);
}
workflowAssignment.setProcessVariableList(processVariableList);
// execute tool
WorkflowUtil.addAuditTrail(this.getClass().getName(), "executeTool", workflowAssignment.getActivityId());
if(!workflowMapper.executeTool(workflowAssignment)){
WorkflowUtil.addAuditTrail(this.getClass().getName(), "executeActivity", "Could not execute tool [processId=" + act.container(shandle).manager(shandle).name(shandle) + ", version=" + act.container(shandle).manager(shandle).version(shandle) + ", activityId=" + act.activity_definition_id(shandle) + "]");
}else{
WorkflowUtil.addAuditTrail(this.getClass().getName(), "executeToolCompleted", workflowAssignment.getActivityId());
}
} catch (Throwable ex) {
workflowMapper.addAuditTrail(this.getClass().getName(), "executeActivity", "Could not execute tool [processId=" + act.container(shandle).manager(shandle).name(shandle) + ", version=" + act.container(shandle).manager(shandle).version(shandle) + ", activityId=" + act.activity_definition_id(shandle) + "]");
LogUtil.error(getClass().getName(), ex, "Could not execute tool [processId=" + act.container(shandle).manager(shandle).name(shandle) + ", version=" + act.container(shandle).manager(shandle).version(shandle) + ", activityId=" + act.activity_definition_id(shandle) + "]");
}
}