@Override
 public void addFinishedUser(Context c, XmlWorkflowItem wfi, EPerson user)
     throws AuthorizeException, SQLException {
   InProgressUser ipu = inProgressUserService.findByWorkflowItemAndEPerson(c, wfi, user);
   ipu.setFinished(true);
   inProgressUserService.update(c, ipu);
 }
  @Override
  public void removeClaimedUser(Context context, XmlWorkflowItem wfi, EPerson user, String stepID)
      throws SQLException, IOException, WorkflowConfigurationException, AuthorizeException {
    // Check if we had reached our max number @ this moment
    int totalUsers =
        inProgressUserService.getNumberOfInProgressUsers(context, wfi)
            + inProgressUserService.getNumberOfFinishedUsers(context, wfi);

    // Then remove the current user from the inProgressUsers
    inProgressUserService.delete(
        context, inProgressUserService.findByWorkflowItemAndEPerson(context, wfi, user));

    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 = inProgressUserService.findByWorkflowItem(context, wfi);

      // Remove the users to ignore
      RoleMembers roleMembers = step.getRole().getMembers(context, wfi);
      // Create a list out all the users we are to pool a task for
      for (InProgressUser ipu : toIgnore) {
        roleMembers.removeEperson(ipu.getUser());
      }
      step.getUserSelectionMethod()
          .getProcessingAction()
          .regenerateTasks(context, 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(context, wfi);
      List<EPerson> epersons = role.getEPersons();
      for (EPerson eperson : epersons) {
        if (eperson.getID().equals(user.getID())) {
          RoleMembers memberToRegenerateTasksFor = new RoleMembers();
          memberToRegenerateTasksFor.addEPerson(user);
          step.getUserSelectionMethod()
              .getProcessingAction()
              .regenerateTasks(context, wfi, memberToRegenerateTasksFor);
          break;
        }
      }
    }
    // Update our item
    itemService.update(context, wfi.getItem());
  }