public List<DeploymentRef> getDeployments() { List<DeploymentRef> results = new ArrayList<DeploymentRef>(); RepositoryService repositoryService = this.processEngine.getRepositoryService(); List<Deployment> dpls = repositoryService.createDeploymentQuery().list(); for (Deployment dpl : dpls) { DeploymentRef deploymentRef = ModelAdaptor.adoptDeployment(dpl); // active processes for deployment ProcessDefinitionQuery pdQuery = repositoryService.createProcessDefinitionQuery(); pdQuery.deploymentId(dpl.getId()); List<ProcessDefinition> activePds = pdQuery.list(); for (ProcessDefinition procDef : activePds) { deploymentRef.getDefinitions().add(procDef.getId()); } // suspended processes for deployment List<ProcessDefinition> suspendedPds = repositoryService.createProcessDefinitionQuery() .deploymentId(dpl.getId()) .suspended() .list(); for (ProcessDefinition procDef : suspendedPds) { deploymentRef.getDefinitions().add(procDef.getId()); } results.add(deploymentRef); } return results; }
public static ProcessDefinitionRef adoptDefinition(ProcessDefinition processDefinition) { ProcessDefinitionRef def = new ProcessDefinitionRef(); def.setId(processDefinition.getId()); def.setName(processDefinition.getName()); def.setVersion(processDefinition.getVersion()); def.setKey(processDefinition.getKey()); def.setSuspended(processDefinition.isSuspended()); def.setDeploymentId(processDefinition.getDeploymentId()); // TODO: Are these needed? // ProcessDefinitionImpl cast = (ProcessDefinitionImpl) processDefinition; // def.setDescription(processDefinition.getDescription()); // def.setPackageName(cast.getPackageName()); return def; }