}
protected ReportWorkflowActivityInstance updateActivityData(WorkflowActivity wfActivity, WorkflowActivity wfTrackActivity, WorkflowProcess wfProcess, WorkflowProcess wfTrackProcess, String appId, String appVersion) {
String activityInstanceId = wfActivity.getId();
WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
ReportManager reportManager = (ReportManager) AppUtil.getApplicationContext().getBean("reportManager");
if (wfActivity != null) {
ReportWorkflowActivityInstance aInstance = reportManager.getReportWorkflowActivityInstance(activityInstanceId);
List<String> userList = new ArrayList<String>();
if (aInstance == null) {
aInstance = new ReportWorkflowActivityInstance();
aInstance.setInstanceId(activityInstanceId);
//set process Instance
String processInstanceId = wfActivity.getProcessId();
ReportWorkflowProcessInstance processInstance = reportManager.getReportWorkflowProcessInstance(processInstanceId);
if (processInstance == null) {
processInstance = updateProcessData(wfProcess, wfTrackProcess, appId, appVersion);
}
aInstance.setReportWorkflowProcessInstance(processInstance);
//set activity
ReportWorkflowActivity reportActivtiy = reportManager.getReportWorkflowActivity(processInstance.getReportWorkflowProcess(), wfActivity.getActivityDefId(), wfActivity.getName());
aInstance.setReportWorkflowActivity(reportActivtiy);
//get assignment users
try {
Thread.sleep(2000);
int maxAttempt = 5;
int numOfAttempt = 0;
while ((userList == null || userList.isEmpty()) && numOfAttempt < maxAttempt) {
LogUtil.debug(getClass().getName(), "Attempting to get resource ids....");
userList = workflowManager.getAssignmentResourceIds(wfActivity.getProcessDefId(), wfActivity.getProcessId(), activityInstanceId);
Thread.sleep(2000);
numOfAttempt++;
}
LogUtil.debug(getClass().getName(), "Resource ids=" + userList);
} catch (Exception e) {
LogUtil.error(getClass().getName(), e, "Error executing report plugin");
}
} else {
userList = workflowManager.getAssignmentResourceIds(wfActivity.getProcessDefId(), wfActivity.getProcessId(), activityInstanceId);
}
String assignmentUsers = "";
if (userList != null) {
for (String username : userList) {