//Then remove the current user from the inProgressUsers
InProgressUser.findByWorkflowItemAndEPerson(c, wfi.getID(), user.getID()).delete();
Workflow workflow = WorkflowFactory.getWorkflow(wfi.getCollection());
Step step = workflow.getStep(stepID);
// WorkflowManager.deleteOwnedTask(c, user, wfi, step, step.getActionConfig());
//We had reached our total user, so recreate tasks for the user who don't have one
if(totalUsers == step.getRequiredUsers()){
//Create a list of the users we are to ignore
List<InProgressUser> toIgnore = InProgressUser.findByWorkflowItem(c, wfi.getID());
//Remove the users to ignore
RoleMembers roleMembers = step.getRole().getMembers(c, wfi);
//Create a list out all the users we are to pool a task for
for (InProgressUser ipu: toIgnore) {
roleMembers.removeEperson(ipu.getUserID());
}
step.getUserSelectionMethod().getProcessingAction().regenerateTasks(c, wfi, roleMembers);
}else{
//If the user previously had a personal PoolTask, this must be regenerated. Therefore we call the regeneration method
//with only one EPerson
RoleMembers role = step.getRole().getMembers(c, wfi);
List<EPerson> epersons = role.getEPersons();
for(EPerson eperson: epersons){
if(eperson.getID() == user.getID()){
RoleMembers memberToRegenerateTasksFor = new RoleMembers();
memberToRegenerateTasksFor.addEPerson(user);
step.getUserSelectionMethod().getProcessingAction().regenerateTasks(c, wfi, memberToRegenerateTasksFor);
break;
}
}
}
//Update our item