/**
  * Get completed task instances which were finished after the given date and time
  *
  * @return BPMNTaskInstance array if the historic task instance list is not null
  */
 public BPMNTaskInstance[] getCompletedTaskInstances() {
   HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
   HistoricTaskInstanceQuery instanceQuery = historyService.createHistoricTaskInstanceQuery();
   List<HistoricTaskInstance> historicTaskInstanceList = null;
   String time =
       readPublishTimeFromRegistry(
           AnalyticsPublisherConstants.TASK_RESOURCE_PATH,
           AnalyticsPublisherConstants.LAST_TASK_INSTANCE_END_TIME);
   if (time == null) {
     if (instanceQuery.finished().list().size() != 0) {
       historicTaskInstanceList =
           instanceQuery.finished().orderByHistoricTaskInstanceEndTime().asc().list();
     }
   } else {
     Date dateFormat = DateConverter.convertStringToDate(time);
     int listSize = instanceQuery.finished().taskCompletedAfter(dateFormat).list().size();
     if (listSize != 0) {
       /*When using the startedAfter() method it returns the finished objects according to the time stored of
       last completed instance. But if the list length is one then it always return the same object in the
       list twice from the last updated time which stored in the carbon registry.
       (avoid to return same object repeatedly if the list has only one object)*/
       if (listSize == 1) {
         return null;
       }
       historicTaskInstanceList =
           instanceQuery
               .finished()
               .taskCompletedAfter(dateFormat)
               .orderByHistoricTaskInstanceEndTime()
               .asc()
               .listPage(1, listSize);
     }
   }
   if (historicTaskInstanceList != null) {
     if (log.isDebugEnabled()) {
       log.debug(
           "Write BPMN task instance to the carbon registry..."
               + historicTaskInstanceList.toString());
     }
     writeTaskEndTimeToRegistry(historicTaskInstanceList);
     return getBPMNTaskInstances(historicTaskInstanceList);
   }
   return null;
 }
コード例 #2
0
 @RequestMapping(value = "/list")
 @ResponseBody
 public Map<String, Object> list(
     @RequestParam("page") int curPage,
     @RequestParam("rows") int pageSize,
     HttpServletRequest req) {
   HistoricTaskInstanceQuery historicTaskInstanceQuery =
       historyService.createHistoricTaskInstanceQuery(); // .taskAssignee("5")
   long total = historicTaskInstanceQuery.count();
   List<HistoricTaskInstance> list =
       historicTaskInstanceQuery
           .orderByTaskCreateTime()
           .desc()
           .listPage((curPage - 1) * pageSize, pageSize);
   Map<String, Object> obj = new HashMap<String, Object>();
   obj.put("total", total);
   obj.put("list", list);
   return obj;
 }