@RequestMapping(
      value = {""},
      method = RequestMethod.GET)
  public ModelAndView index(Integer pageNum) {
    Map<String, Object> map = new HashMap<String, Object>();

    Paginator paginator = new Paginator();
    pageNum = ((pageNum == null) || (pageNum < 0)) ? 0 : pageNum;

    List<WorkflowTaskInstance> instances =
        this.workflowTaskInstanceService.list(
            pageNum, paginator, UserContextHolder.getUserContext().getId());
    List<WorkflowTaskInstanceVO> list = new ArrayList<WorkflowTaskInstanceVO>(instances.size());
    if (list != null) {
      for (WorkflowTaskInstance instance : instances) {
        WorkflowTaskInstanceVO vo = new WorkflowTaskInstanceVO(instance);
        list.add(vo);
      }
    }

    map.put("list", list);
    map.put("paginator", paginator);

    return screen(map, SCREEN_NAME);
  }
  @RequestMapping(value = {""})
  public ModelAndView index(Integer pageNum, long instanceId) {
    Map<String, Object> map = new HashMap<String, Object>();

    Paginator paginator = new Paginator();
    pageNum = ((pageNum == null) || (pageNum < 0)) ? 0 : pageNum;

    List<TaskInstance> taskInstances = null;

    if (UserContextHolder.getUserContext().isAdmin()) {
      taskInstances =
          this.taskInstanceService.listByWorkflowInstanceId(instanceId, pageNum, paginator);
    } else {
      taskInstances =
          this.taskInstanceService.listByWorkflowInstanceIdAndUserId(
              instanceId, UserContextHolder.getUserContext().getId(), pageNum, paginator);
    }

    WorkflowInstance workflowInstance = this.instanceService.get(instanceId);

    List<WorkflowInstanceTasksVO> voList = new ArrayList<WorkflowInstanceTasksVO>();

    for (TaskInstance taskInstance : taskInstances) {
      WorkflowInstanceTasksVO vo = new WorkflowInstanceTasksVO(taskInstance);
      vo.setTaskName(this.taskService.get(taskInstance.getTaskId()).getName());
      Attempt attempt = this.attemptService.getLastOne(taskInstance.getId());
      if (attempt != null) {
        vo.setAttempt(attempt);
        vo.setEndTime(attempt.getEndTime());
      }
      voList.add(vo);
    }

    map.put("workflow", this.workflowService.get(workflowInstance.getWorkflowId()));
    map.put("list", voList);
    map.put("paginator", paginator);
    map.put("instance", workflowInstance);

    return screen(map, SCREEN_NAME);
  }