Java Code Examples for org.activiti.engine.repository.ProcessDefinition#getKey()
The following examples show how to use
org.activiti.engine.repository.ProcessDefinition#getKey() .
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: SetProcessDefinitionVersionCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinition newProcessDefinition) { // check that the new process definition version contains the current activity org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(newProcessDefinition.getId()); if (execution.getActivityId() != null && process.getFlowElement(execution.getActivityId(), true) == null) { throw new ActivitiException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + execution.getActivityId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "')."); } // switch the process instance to the new process definition version execution.setProcessDefinitionId(newProcessDefinition.getId()); execution.setProcessDefinitionName(newProcessDefinition.getName()); execution.setProcessDefinitionKey(newProcessDefinition.getKey()); // and change possible existing tasks (as the process definition id is stored there too) List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByExecutionId(execution.getId()); for (TaskEntity taskEntity : tasks) { taskEntity.setProcessDefinitionId(newProcessDefinition.getId()); commandContext.getHistoryManager().recordTaskProcessDefinitionChange(taskEntity.getId(), newProcessDefinition.getId()); } }
Example 2
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 3
Source File: ExecutionQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked" }) public List<Execution> executeList(CommandContext commandContext, Page page) { checkQueryOk(); ensureVariablesInitialized(); List<?> executions = commandContext.getExecutionEntityManager().findExecutionsByQueryCriteria(this, page); for (ExecutionEntity execution : (List<ExecutionEntity>) executions) { String activityId = null; if (execution.getId().equals(execution.getProcessInstanceId())) { if (execution.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration() .getDeploymentManager() .findDeployedProcessDefinitionById(execution.getProcessDefinitionId()); activityId = processDefinition.getKey(); } } else { activityId = execution.getActivityId(); } if (activityId != null) { localize(execution, activityId); } } return (List<Execution>) executions; }
Example 4
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 5
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 6
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 7
Source File: ExecutionQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked" }) public List<Execution> executeList(CommandContext commandContext, Page page) { checkQueryOk(); ensureVariablesInitialized(); List<?> executions = commandContext.getExecutionEntityManager().findExecutionsByQueryCriteria(this, page); if (Context.getProcessEngineConfiguration().getPerformanceSettings().isEnableLocalization()) { for (ExecutionEntity execution : (List<ExecutionEntity>) executions) { String activityId = null; if (execution.getId().equals(execution.getProcessInstanceId())) { if (execution.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration() .getDeploymentManager() .findDeployedProcessDefinitionById(execution.getProcessDefinitionId()); activityId = processDefinition.getKey(); } } else { activityId = execution.getActivityId(); } if (activityId != null) { localize(execution, activityId); } } } return (List<Execution>) executions; }
Example 8
Source File: BaseJavaDelegate.java From herd with Apache License 2.0 | 5 votes |
/** * Retrieves application user per last updater of the current process instance's job definition. * * @param execution the delegate execution * * @return the application user */ protected ApplicationUser getApplicationUser(DelegateExecution execution) { String processDefinitionId = execution.getProcessDefinitionId(); // Get process definition by process definition ID from Activiti. ProcessDefinition processDefinition = activitiService.getProcessDefinitionById(processDefinitionId); // Validate that we retrieved the process definition from Activiti. if (processDefinition == null) { throw new ObjectNotFoundException(String.format("Failed to find Activiti process definition for processDefinitionId=\"%s\".", processDefinitionId)); } // Retrieve the process definition key. String processDefinitionKey = processDefinition.getKey(); // Get the job definition key. JobDefinitionAlternateKeyDto jobDefinitionKey = jobDefinitionHelper.getJobDefinitionKey(processDefinitionKey); // Get the job definition from the Herd repository and validate that it exists. JobDefinitionEntity jobDefinitionEntity = jobDefinitionDaoHelper.getJobDefinitionEntity(jobDefinitionKey.getNamespace(), jobDefinitionKey.getJobName()); // Set the security context per last updater of the job definition. String updatedByUserId = jobDefinitionEntity.getUpdatedBy(); ApplicationUser applicationUser = new ApplicationUser(getClass()); applicationUser.setUserId(updatedByUserId); return applicationUser; }
Example 9
Source File: ActivitiPropertyConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public Map<String, Object> getStartVariables(String processDefId, Map<QName, Serializable> properties) { ProcessDefinition procDef = activitiUtil.getProcessDefinition(processDefId); String startTaskTypeName = activitiUtil.getStartTaskTypeName(processDefId); TypeDefinition startTaskType = factory.getTaskFullTypeDefinition(startTaskTypeName, true); // Lookup type definition for the startTask Map<QName, PropertyDefinition> taskProperties = startTaskType.getProperties(); // Get all default values from the definitions Map<QName, Serializable> defaultProperties = new HashMap<QName, Serializable>(); for (Map.Entry<QName, PropertyDefinition> entry : taskProperties.entrySet()) { String defaultValue = entry.getValue().getDefaultValue(); if (defaultValue != null) { defaultProperties.put(entry.getKey(), defaultValue); } } // Put all passed properties in map with defaults if(properties != null) { defaultProperties.putAll(properties); } // Special case for task description default value // Use the shared description set in the workflowinstance String description = (String) defaultProperties.get(WorkflowModel.PROP_DESCRIPTION); if(description == null) { String wfDescription = (String) defaultProperties.get(WorkflowModel.PROP_WORKFLOW_DESCRIPTION); String procDefKey = procDef.getKey(); ReadOnlyProcessDefinition deployedDef = activitiUtil.getDeployedProcessDefinition(processDefId); String startEventName = deployedDef.getInitial().getId(); String wfDefKey = factory.buildGlobalId(procDefKey); description = factory.getTaskDescription(startTaskType, wfDefKey, wfDescription, startEventName); defaultProperties.put(WorkflowModel.PROP_DESCRIPTION, description); } //Special case for workflowDueDate. if(!defaultProperties.containsKey(WorkflowModel.PROP_WORKFLOW_DUE_DATE) && taskProperties.containsKey(WorkflowModel.PROP_WORKFLOW_DUE_DATE)) { defaultProperties.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, null); } return handlerRegistry.handleVariablesToSet(defaultProperties, startTaskType, null, Void.class); }
Example 10
Source File: ActProcessService.java From Shop-for-JavaWeb with MIT License | 4 votes |
/** * 导出图片文件到硬盘 */ public List<String> exportDiagrams(String exportDir) throws IOException { List<String> files = new ArrayList<String>(); List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list(); for (ProcessDefinition processDefinition : list) { String diagramResourceName = processDefinition.getDiagramResourceName(); String key = processDefinition.getKey(); int version = processDefinition.getVersion(); String diagramPath = ""; InputStream resourceAsStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), diagramResourceName); byte[] b = new byte[resourceAsStream.available()]; @SuppressWarnings("unused") int len = -1; resourceAsStream.read(b, 0, b.length); // create file if not exist String diagramDir = exportDir + "/" + key + "/" + version; File diagramDirFile = new File(diagramDir); if (!diagramDirFile.exists()) { diagramDirFile.mkdirs(); } diagramPath = diagramDir + "/" + diagramResourceName; File file = new File(diagramPath); // 文件存在退出 if (file.exists()) { // 文件大小相同时直接返回否则重新创建文件(可能损坏) logger.debug("diagram exist, ignore... : {}", diagramPath); files.add(diagramPath); } else { file.createNewFile(); logger.debug("export diagram to : {}", diagramPath); // wirte bytes to file FileUtils.writeByteArrayToFile(file, b, true); files.add(diagramPath); } } return files; }