Java Code Examples for org.activiti.engine.repository.ProcessDefinitionQuery#singleResult()
The following examples show how to use
org.activiti.engine.repository.ProcessDefinitionQuery#singleResult() .
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: ProcessDefinitionsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ProcessDefinition getProcessDefinition(String definitionId) { ProcessDefinitionQuery query = activitiProcessEngine .getRepositoryService() .createProcessDefinitionQuery() .processDefinitionId(definitionId); if (tenantService.isEnabled() && deployWorkflowsInTenant) { query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%"); } org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult(); if (processDefinition == null) { throw new EntityNotFoundException(definitionId); } ProcessDefinition deploymentRest = createProcessDefinitionRest((ProcessDefinitionEntity) processDefinition); return deploymentRest; }
Example 2
Source File: ProcessInstanceManagerController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 3
Source File: ProcessInstanceManagerController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 4
Source File: ExecutionController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 5
Source File: HistoryProcessInstanceController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 6
Source File: ProcessInstanceManagerController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 7
Source File: ExecutionController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 8
Source File: HistoryProcessInstanceController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 9
Source File: ProcessInstanceManagerController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 10
Source File: ExecutionController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 11
Source File: HistoryProcessInstanceController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 12
Source File: ProcessDefinitionQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private void verifySingleResultFails(ProcessDefinitionQuery query) { try { query.singleResult(); fail(); } catch (ActivitiException e) { } }
Example 13
Source File: ExecutionController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 14
Source File: HistoryProcessInstanceController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 15
Source File: ExecutionController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 16
Source File: HistoryProcessInstanceController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义对象缓存 * * @param definitionMap * @param processDefinitionId */ private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) { if (definitionMap.get(processDefinitionId) == null) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.processDefinitionId(processDefinitionId); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); // 放入缓存 definitionMap.put(processDefinitionId, processDefinition); } }
Example 17
Source File: ProcessDefinitionsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CollectionWithPagingInfo<FormModelElement> getStartFormModel(String definitionId, Paging paging) { // first validate if user is allowed to access the process definition if workflows are deployed per tenant if (tenantService.isEnabled() && deployWorkflowsInTenant) { ProcessDefinitionQuery query = activitiProcessEngine .getRepositoryService() .createProcessDefinitionQuery() .processDefinitionId(definitionId); query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%"); org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult(); if (processDefinition == null) { throw new EntityNotFoundException(definitionId); } } StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(definitionId); if (startFormData == null) { throw new EntityNotFoundException(definitionId); } if (qNameConverter == null) { qNameConverter = new WorkflowQNameConverter(namespaceService); } if (workflowFactory == null) { workflowFactory = new WorkflowObjectFactory(qNameConverter, tenantService, messageService, dictionaryService, engineId, defaultStartTaskType); } // Lookup type definition for the startTask TypeDefinition startTaskType = workflowFactory.getTaskFullTypeDefinition(startFormData.getFormKey(), true); return getFormModelElements(startTaskType, paging); }
Example 18
Source File: ClasspathDeploymentTest.java From activiti-in-action-codes with Apache License 2.0 | 4 votes |
@Test public void testClasspathDeployment() throws Exception { // 定义classpath String bpmnClasspath = "chapter5/candidateUserInUserTask.bpmn"; String pngClasspath = "chapter5/candidateUserInUserTask.png"; // 创建部署构建器 DeploymentBuilder deploymentBuilder = repositoryService.createDeployment(); // 添加资源 deploymentBuilder.addClasspathResource(bpmnClasspath); deploymentBuilder.addClasspathResource(pngClasspath); // 执行部署 deploymentBuilder.deploy(); // 验证流程定义是否部署成功 ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); long count = processDefinitionQuery.processDefinitionKey("candidateUserInUserTask").count(); assertEquals(1, count); // 读取图片文件 ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); String diagramResourceName = processDefinition.getDiagramResourceName(); assertEquals(pngClasspath, diagramResourceName); Map<String, Object> vars = new HashMap<String, Object>(); ArrayList<Date> objs = new ArrayList<Date>(); objs.add(new Date()); vars.put("list", objs); // vars.put("aaa", "333"); runtimeService.startProcessInstanceByKey("candidateUserInUserTask", vars); List<Task> list = taskService.createTaskQuery().includeProcessVariables().list(); System.out.println(list); Task task = taskService.createTaskQuery().taskId(list.get(0).getId()) .includeProcessVariables().includeTaskLocalVariables().singleResult(); CommandContext commandContext = Context.getCommandContext(); System.out.println(task); System.out.println(commandContext); // ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine(); // Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration()); // Context.setCommandContext(defaultProcessEngine.getProcessEngineConfiguration().getCommandContextFactory().createCommandContext(null)); System.out.println(Context.getCommandContext()); System.out.println(task.getProcessVariables()); }
Example 19
Source File: ProcessDefinitionsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
@Override public BinaryResource getProcessDefinitionImage(String definitionId) { ProcessDefinitionQuery query = activitiProcessEngine .getRepositoryService() .createProcessDefinitionQuery() .processDefinitionId(definitionId); if (tenantService.isEnabled() && deployWorkflowsInTenant) { query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%"); } org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult(); if (processDefinition == null) { throw new EntityNotFoundException(definitionId); } try { InputStream processDiagram = activitiProcessEngine.getRepositoryService().getProcessDiagram(definitionId); if (processDiagram != null) { File file = TempFileProvider.createTempFile(definitionId + UUID.randomUUID(), ".png"); FileOutputStream fos = new FileOutputStream(file); IOUtils.copy(processDiagram, fos); fos.close(); return new FileBinaryResource(file); } else { throw new ApiException("No image available for definitionId " + definitionId); } } catch (IOException error) { throw new ApiException("Error while getting process definition image."); } }
Example 20
Source File: ProcessDefinitionQueryTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
private void verifySingleResultFails(ProcessDefinitionQuery query) { try { query.singleResult(); fail(); } catch (ActivitiException e) {} }