Esempio n. 1
0
 /**
  * @param taskQueryForm
  * @param userId
  * @return
  */
 @Override
 public List<TaskVo> queryToDoTaskFiltered(TaskQueryForm taskQueryForm, String userId) {
   DataTablesInfo dataTablesInfo = taskQueryForm.getDataTablesInfo();
   int start = dataTablesInfo.getStart();
   int length = dataTablesInfo.getLength();
   TaskQuery taskQuery =
       taskService
           .createTaskQuery()
           .taskCandidateOrAssigned(userId)
           .orderByTaskCreateTime()
           .desc();
   List<Task> tasks = taskQuery.listPage(start, start + length);
   List<TaskVo> taskRtn = buildTaskVos(tasks);
   return taskRtn;
 }
Esempio n. 2
0
  public void testQueryPaging() {
    TaskQuery query = taskService.createTaskQuery().taskCandidateUser("kermit");

    assertEquals(11, query.listPage(0, Integer.MAX_VALUE).size());

    // Verifying the un-paged results
    assertEquals(11, query.count());
    assertEquals(11, query.list().size());

    // Verifying paged results
    assertEquals(2, query.listPage(0, 2).size());
    assertEquals(2, query.listPage(2, 2).size());
    assertEquals(3, query.listPage(4, 3).size());
    assertEquals(1, query.listPage(10, 3).size());
    assertEquals(1, query.listPage(10, 1).size());

    // Verifying odd usages
    assertEquals(0, query.listPage(-1, -1).size());
    assertEquals(0, query.listPage(11, 2).size()); // 10 is the last index with a result
    assertEquals(11, query.listPage(0, 15).size()); // there are only 11 tasks
  }