/* * Helper methods */ public static Activity activity(Process process, ProcessInstance instance, Task task) throws StatusCodeError { Activity activity = null; if (process.isAllowPerInstanceActivities() && task != null && task.getTaskDefinitionKey() != null && instance != null) { Map<String, Activity> activityMap = instance.getActivityMap(); if (activityMap != null) activity = activityMap.get(task.getTaskDefinitionKey()); if (activity != null) return activity; } ProcessDeployment deployment = process.getDeployment(); if (deployment == null) throw new InternalServerError(Constants.ExceptionCodes.process_is_misconfigured); String activityKey = deployment.getStartActivityKey(); if (task != null) activityKey = task.getTaskDefinitionKey(); if (activityKey != null) activity = deployment.getActivity(activityKey); if (activity != null) return activity; throw new InternalServerError(Constants.ExceptionCodes.process_is_misconfigured); }
ProcessDeployment execute( DeploymentRepository deploymentRepository, ProcessRepository processRepository) throws PieceworkException { if (LOG.isDebugEnabled()) LOG.debug("Executing publication command " + this.toString()); // Verify that this deployment belongs to this process ProcessDeploymentVersion selectedDeploymentVersion = ProcessUtility.deploymentVersion(process, deploymentId); if (selectedDeploymentVersion == null) throw new NotFoundError(); // Grab the actual deployment object back from the repository ProcessDeployment original = deploymentRepository.findOne(deploymentId); if (original == null) throw new NotFoundError(); if (!original.isDeployed()) throw new ForbiddenError(Constants.ExceptionCodes.process_not_deployed); // Update the deployment to indicate that it is published PassthroughSanitizer passthroughSanitizer = new PassthroughSanitizer(); ProcessDeployment updatedDeployment = new ProcessDeployment.Builder( original, process.getProcessDefinitionKey(), passthroughSanitizer, true) .publish() .build(); // Make sure we persist that fact ProcessDeployment persistedDeployment = deploymentRepository.save(updatedDeployment); // And update the process definition to indicate that this is the officially published // deployment for the process Process updatedProcess = new Process.Builder(process, passthroughSanitizer) .deploy(selectedDeploymentVersion, persistedDeployment) .build(); // Persist that too processRepository.save(updatedProcess); return persistedDeployment; }
@Cacheable("processDefinitionIdMap") public ManyMap<String, Process> getProcessDefinitionIdMap(Set<Process> processes) { ManyMap<String, Process> processDefinitionKeyMap = new ManyMap<String, Process>(); for (Process process : processes) { ProcessDeployment deployment = process.getDeployment(); if (deployment != null && deployment.getEngine() != null && getKey() != null && deployment.getEngine().equals(getKey())) processDefinitionKeyMap.putOne(deployment.getEngineProcessDefinitionKey(), process); } ManyMap<String, Process> map = new ManyMap<String, Process>(); for (ProcessDefinition processDefinition : processEngine.getRepositoryService().createProcessDefinitionQuery().list()) { List<Process> matchingProcesses = processDefinitionKeyMap.get(processDefinition.getKey()); if (matchingProcesses != null && !matchingProcesses.isEmpty()) map.put(processDefinition.getId(), matchingProcesses); } return map; }