/**
   * Retrieves the number of items belonging directly and indirectly to this worklist.
   *
   * @return The number of items directly and indirectly belonging to this worklist, possibly
   *     constrained by its {@link SubsetPolicy}. The size of possibly existing sub-worklist is
   *     taken into account.
   * @see #size
   * @see #getCumulatedItems()
   */
  public int getCumulatedSize() {
    int totalSize = size();

    for (Iterator i = getSubWorklists(); i.hasNext(); ) {
      Worklist worklist = (Worklist) i.next();
      totalSize += worklist.getCumulatedSize();
    }

    return totalSize;
  }
 @SuppressWarnings("unchecked")
 private List<ActivityInstance> getWorklist(EvaluationPolicy... policies) {
   WorkflowService ws = sf.getWorkflowService();
   WorklistQuery query = WorklistQuery.findCompleteWorklist();
   if (policies != null) {
     for (EvaluationPolicy policy : policies) {
       query.setPolicy(policy);
     }
   }
   Worklist worklist = ws.getWorklist(query);
   return worklist.getCumulatedItems();
 }
 @SuppressWarnings("unchecked")
 private List<ActivityInstance> getWorklist(ProcessInstance pi, EvaluationPolicy... policies) {
   WorkflowService ws = sf.getWorkflowService();
   WorklistQuery query = WorklistQuery.findCompleteWorklist();
   if (policies != null) {
     for (EvaluationPolicy policy : policies) {
       query.setPolicy(policy);
     }
   }
   query.getFilter().add(new ProcessInstanceFilter(pi.getOID(), false));
   Worklist worklist = ws.getWorklist(query);
   return worklist.getCumulatedItems();
 }