@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)); }
/** @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; }