Java Code Examples for org.activiti.engine.repository.ProcessDefinition#getName()
The following examples show how to use
org.activiti.engine.repository.ProcessDefinition#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiTypeConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Convert a {@link ProcessDefinition} into a {@link WorkflowDefinition}. * @param definition ProcessDefinition * @return WorkflowDefinition */ public WorkflowDefinition convert(ProcessDefinition definition) { if(definition==null) return null; String defId = definition.getId(); String defName = definition.getKey(); int version = definition.getVersion(); String defaultTitle = definition.getName(); String startTaskName = null; StartFormData startFormData = getStartFormData(defId, defName); if(startFormData != null) { startTaskName = startFormData.getFormKey(); } ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(defId); PvmActivity startEvent = def.getInitial(); WorkflowTaskDefinition startTask = getTaskDefinition(startEvent, startTaskName, definition.getKey(), true); return factory.createDefinition(defId, defName, version, defaultTitle, null, startTask); }
Example 2
Source File: NeedsActiveProcessDefinitionCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public T execute(CommandContext commandContext) { DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager(); ProcessDefinition processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId); if (deploymentManager.isProcessDefinitionSuspended(processDefinitionId)) { throw new ActivitiException("Cannot execute operation because process definition '" + processDefinition.getName() + "' (id=" + processDefinition.getId() + ") is supended"); } return execute(commandContext, processDefinition); }
Example 3
Source File: TaskRepresentation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition) { this.id = taskInfo.getId(); this.name = taskInfo.getName(); this.description = taskInfo.getDescription(); this.category = taskInfo.getCategory(); this.created = taskInfo.getCreateTime(); this.dueDate = taskInfo.getDueDate(); this.priority = taskInfo.getPriority(); this.processInstanceId = taskInfo.getProcessInstanceId(); this.processDefinitionId = taskInfo.getProcessDefinitionId(); if (taskInfo instanceof HistoricTaskInstance) { this.endDate = ((HistoricTaskInstance) taskInfo).getEndTime(); this.formKey = taskInfo.getFormKey(); this.duration = ((HistoricTaskInstance) taskInfo).getDurationInMillis(); } else { // Rendering of forms for historic tasks not supported currently this.formKey = taskInfo.getFormKey(); } if (processDefinition != null) { this.processDefinitionName = processDefinition.getName(); this.processDefinitionDescription = processDefinition.getDescription(); this.processDefinitionKey = processDefinition.getKey(); this.processDefinitionCategory = processDefinition.getCategory(); this.processDefinitionVersion = processDefinition.getVersion(); this.processDefinitionDeploymentId = processDefinition.getDeploymentId(); } }
Example 4
Source File: ProcessDefinitionRepresentation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public ProcessDefinitionRepresentation(ProcessDefinition processDefinition) { this.id = processDefinition.getId(); this.name = processDefinition.getName(); this.description = processDefinition.getDescription(); this.key = processDefinition.getKey(); this.category = processDefinition.getCategory(); this.version = processDefinition.getVersion(); this.deploymentId = processDefinition.getDeploymentId(); this.tenantId = processDefinition.getTenantId(); this.hasStartForm = processDefinition.hasStartFormKey(); }
Example 5
Source File: ProcessInstanceRepresentation.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void mapProcessDefinition(ProcessDefinition processDefinition) { if (processDefinition != null) { this.processDefinitionName = processDefinition.getName(); this.processDefinitionDescription = processDefinition.getDescription(); this.processDefinitionKey = processDefinition.getKey(); this.processDefinitionCategory = processDefinition.getCategory(); this.processDefinitionVersion = processDefinition.getVersion(); this.processDefinitionDeploymentId = processDefinition.getDeploymentId(); } }
Example 6
Source File: ProcessInstanceHelper.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected ProcessInstance createAndStartProcessInstance(ProcessDefinition processDefinition, String businessKey, String processInstanceName, Map<String, Object> variables, Map<String, Object> transientVariables, boolean startProcessInstance) { CommandContext commandContext = Context.getCommandContext(); // Todo: ideally, context should be passed here if (Activiti5Util.isActiviti5ProcessDefinition(commandContext, processDefinition)) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); return activiti5CompatibilityHandler.startProcessInstance(processDefinition.getKey(), processDefinition.getId(), variables, businessKey, processDefinition.getTenantId(), processInstanceName); } // Do not start process a process instance if the process definition is suspended if (ProcessDefinitionUtil.isProcessDefinitionSuspended(processDefinition.getId())) { throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended"); } // Get model from cache Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId()); if (process == null) { throw new ActivitiException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found"); } FlowElement initialFlowElement = process.getInitialFlowElement(); if (initialFlowElement == null) { throw new ActivitiException("No start element found for process definition " + processDefinition.getId()); } return createAndStartProcessInstanceWithInitialFlowElement(processDefinition, businessKey, processInstanceName, initialFlowElement, process, variables, transientVariables, startProcessInstance); }
Example 7
Source File: StartProcessInstanceCmd.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public ProcessInstance execute(CommandContext commandContext) { DeploymentManager deploymentManager = commandContext .getProcessEngineConfiguration() .getDeploymentManager(); // Find the process definition ProcessDefinition processDefinition = null; if (processDefinitionId!=null) { processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for id = '" + processDefinitionId + "'", ProcessDefinition.class); } } else if (processDefinitionKey != null && (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId))){ processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processDefinitionKey); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for key '" + processDefinitionKey +"'", ProcessDefinition.class); } } else if (processDefinitionKey != null && tenantId != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) { processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId); if (processDefinition == null) { throw new ActivitiObjectNotFoundException("No process definition found for key '" + processDefinitionKey +"' for tenant identifier " + tenantId, ProcessDefinition.class); } } else { throw new ActivitiIllegalArgumentException("processDefinitionKey and processDefinitionId are null"); } // Do not start process a process instance if the process definition is suspended if (deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) { throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended"); } // Start the process instance ExecutionEntity processInstance = ((ProcessDefinitionEntity) processDefinition).createProcessInstance(businessKey); // now set the variables passed into the start command initializeVariables(processInstance); // now set processInstance name if (processInstanceName != null) { processInstance.setName(processInstanceName); commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstance.getId(), processInstanceName); } processInstance.start(); return processInstance; }
Example 8
Source File: CallActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void execute(DelegateExecution execution) { String processDefinitonKey = this.processDefinitonKey; if (processDefinitionExpression != null) { processDefinitonKey = (String) processDefinitionExpression.getValue(execution); } DeploymentManager deploymentManager = Context.getProcessEngineConfiguration().getDeploymentManager(); ProcessDefinition processDefinition = null; if (execution.getTenantId() == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(execution.getTenantId())) { processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processDefinitonKey); } else { processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitonKey, execution.getTenantId()); } // Do not start a process instance if the process definition is suspended if (deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) { throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended"); } ActivityExecution activityExecution = (ActivityExecution) execution; PvmProcessInstance subProcessInstance = activityExecution.createSubProcessInstance((ProcessDefinitionEntity) processDefinition); if (inheritVariables) { Map<String, Object> variables = execution.getVariables(); for (Map.Entry<String, Object> entry : variables.entrySet()) { subProcessInstance.setVariable(entry.getKey(), entry.getValue()); } } // copy process variables for (AbstractDataAssociation dataInputAssociation : dataInputAssociations) { Object value = null; if (dataInputAssociation.getSourceExpression()!=null) { value = dataInputAssociation.getSourceExpression().getValue(execution); } else { value = execution.getVariable(dataInputAssociation.getSource()); } subProcessInstance.setVariable(dataInputAssociation.getTarget(), value); } try { subProcessInstance.start(); } catch (RuntimeException e) { if (!ErrorPropagation.mapException(e, activityExecution, mapExceptions, true)) throw e; } }
Example 9
Source File: ProcessInstanceHelper.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public ProcessInstance createAndStartProcessInstanceByMessage(ProcessDefinition processDefinition, String messageName, Map<String, Object> variables, Map<String, Object> transientVariables) { CommandContext commandContext = Context.getCommandContext(); if (processDefinition.getEngineVersion() != null) { if (Activiti5CompatibilityHandler.ACTIVITI_5_ENGINE_TAG.equals(processDefinition.getEngineVersion())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = commandContext.getProcessEngineConfiguration().getActiviti5CompatibilityHandler(); if (activiti5CompatibilityHandler == null) { throw new ActivitiException("Found Activiti 5 process definition, but no compatibility handler on the classpath"); } return activiti5CompatibilityHandler.startProcessInstanceByMessage(messageName, variables, null, processDefinition.getTenantId()); } else { throw new ActivitiException("Invalid 'engine' for process definition " + processDefinition.getId() + " : " + processDefinition.getEngineVersion()); } } // Do not start process a process instance if the process definition is suspended if (ProcessDefinitionUtil.isProcessDefinitionSuspended(processDefinition.getId())) { throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended"); } // Get model from cache Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId()); if (process == null) { throw new ActivitiException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found"); } FlowElement initialFlowElement = null; for (FlowElement flowElement : process.getFlowElements()) { if (flowElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) flowElement; if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions().get(0) instanceof MessageEventDefinition) { MessageEventDefinition messageEventDefinition = (MessageEventDefinition) startEvent.getEventDefinitions().get(0); if (messageEventDefinition.getMessageRef().equals(messageName)) { initialFlowElement = flowElement; break; } } } } if (initialFlowElement == null) { throw new ActivitiException("No message start event found for process definition " + processDefinition.getId() + " and message name " + messageName); } return createAndStartProcessInstanceWithInitialFlowElement(processDefinition, null, null, initialFlowElement, process, variables, transientVariables, true); }