@Override
 public void update() {
   HashMap<String, ProcessFilter> filters = new HashMap<String, ProcessFilter>();
   Models models = client.getModels();
   models.update();
   Iterator<DeployedModelDescription> iterator = models.iterator();
   while (iterator.hasNext()) {
     Model model = models.getModel(iterator.next().getModelOID());
     @SuppressWarnings("unchecked")
     List<ProcessDefinition> definitions = model.getAllProcessDefinitions();
     for (ProcessDefinition processDefinition : definitions) {
       @SuppressWarnings("unchecked")
       List<Activity> activities = processDefinition.getAllActivities();
       for (Activity activity : activities) {
         if (activity.isInteractive()) {
           String id = processDefinition.getId();
           ProcessFilter filter = filters.get(id);
           if (filter == null) {
             filter = new ProcessFilter(client, id);
             filters.put(id, filter);
           }
           filter.add(processDefinition);
           break;
         }
       }
     }
   }
   items = filters.values().toArray(new ProcessFilter[filters.size()]);
   observers.notifyObservers(StatusEvent.updated(this));
 }
  public static ActivityStatisticsQuery forProcesses(Set<ProcessDefinition> processes) {
    Set<String> processIds = CollectionUtils.newSet();
    for (Iterator<ProcessDefinition> i = processes.iterator(); i.hasNext(); ) {
      ProcessDefinition process = i.next();
      processIds.add(process.getQualifiedId());
    }

    return forProcessIds(processIds);
  }
  /** @return dataPathContacts */
  private List<DataPathValue> generateDataPathContacts() {
    List<DataPathValue> dataPathContacts = new ArrayList<DataPathValue>();
    ProcessDefinition processDefinition = null;
    try {
      processDefinition =
          ContextPortalServices.getQueryService()
              .getProcessDefinition(processInstance.getProcessID());
    } catch (Exception e) {
      trace.error(e);
    }
    if (processDefinition != null) {
      List<DataPath> list = processDefinition.getAllDataPaths();

      for (int n = 0; n < list.size(); ++n) {
        DataPath dataPath = list.get(n);
        if (dataPath.getDirection().equals(Direction.IN)
            || dataPath.getDirection().equals(Direction.IN_OUT)) {
          Object dataValue = null;
          try {
            dataValue =
                ContextPortalServices.getWorkflowService()
                    .getInDataPath(processInstance.getOID(), dataPath.getId());
          } catch (Exception e) {
            trace.error(e);
          }
          if (dataValue != null
              && EMailAddressValidator.validateEmailAddress(dataValue.toString())) {
            dataPathContacts.add(
                new DataPathValue(
                    dataPath.getId(),
                    dataPath.getName(),
                    dataValue != null ? dataValue.toString() : ""));
          }
        }
      }
    }
    return dataPathContacts;
  }
  /** @return */
  public List<ModelDTO> getModels(Boolean allActive, boolean includePredefinedModel)
      throws Exception {
    List<ModelDTO> modelList = CollectionUtils.newArrayList();
    try {
      Collection<DeployedModel> models = CollectionUtils.newArrayList();
      if (allActive.equals(true)) {
        models = ModelCache.findModelCache().getActiveModels();
      } else {
        models = ModelCache.findModelCache().getAllModels();
      }

      for (DeployedModel model : models) {
        if (includePredefinedModel
            || !(PredefinedConstants.PREDEFINED_MODEL_ID.equals(model.getId()))) {
          ModelDTO modelDTO = DTOBuilder.build(model, ModelDTO.class);
          String modelName = I18nUtils.getModelName(model);
          List<ProcessDefinitionDTO> processDefitionDTOList = CollectionUtils.newArrayList();
          List<Data> modelData = model.getAllData();
          List<ProcessDefinition> processDefinitions = model.getAllProcessDefinitions();
          List<ActivityDTO> activityDTOList = CollectionUtils.newArrayList();
          List<DataDTO> dataDTOList = CollectionUtils.newArrayList();

          // Create DataDTO list
          for (Data data : modelData) {
            DataDTO dataDTO = DTOBuilder.build(data, DataDTO.class);
            dataDTOList.add(dataDTO);
          }

          // Create ProcessDefinitionDTO list
          for (ProcessDefinition processDefinition : processDefinitions) {
            ProcessDefinitionDTO processDefinitionDTO =
                DTOBuilder.build(processDefinition, ProcessDefinitionDTO.class);
            processDefinitionDTO.modelName = modelName;
            processDefinitionDTO.auxillary = isAuxiliaryProcess(processDefinition);
            processDefinitionDTO.name = I18nUtils.getProcessName(processDefinition);
            processDefitionDTOList.add(processDefinitionDTO);
            activityDTOList = CollectionUtils.newArrayList();
            List<Activity> activities = processDefinition.getAllActivities();
            // Create ActivityDTO list
            for (Activity activity : activities) {
              ActivityDTO activityDTO = DTOBuilder.build(activity, ActivityDTO.class);
              activityDTO.auxillary = isAuxiliaryActivity(activity);
              activityDTO.name = I18nUtils.getActivityName(activity);
              activityDTO.runtimeElementOid = activity.getRuntimeElementOID();
              activityDTOList.add(activityDTO);
            }
            processDefinitionDTO.activities = activityDTOList;
          }
          modelDTO.processDefinitions = processDefitionDTOList;
          modelDTO.data = dataDTOList;
          modelList.add(modelDTO);

          // Add all top-level Organizations
          modelDTO.allTopLevelOrganizations = updateTopLevelOrganizations(model);

          // Add all top-level Roles
          modelDTO.allTopLevelRoles = updateTopLevelRoles(model);
        }
      }
    } catch (Exception e) {
      throw e;
    }

    return modelList;
  }
 public String getTitle() {
   return I18nUtils.getDescriptionAsHtml(processDefinition, processDefinition.getDescription());
 }