org.activiti.engine.repository.ProcessDefinition Java Examples
The following examples show how to use
org.activiti.engine.repository.ProcessDefinition.
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: BusinessProcess.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deprecated public ProcessInstance startProcessByName(String string) { if (Context.getCommandContext() != null) { throw new ActivitiCdiException("Cannot use startProcessByName in an activiti command."); } ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult(); if (definition == null) { throw new ActivitiObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class); } ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), getAndClearCachedVariables()); if (!instance.isEnded()) { setExecution(instance); } return instance; }
Example #2
Source File: MyFormEngineTest.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = {"chapter6/leave-formkey/leave-formkey.bpmn", "chapter6/leave-formkey/leave-start.form"}) public void allPass() throws Exception { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // 读取启动表单 Object renderedStartForm = formService.getRenderedStartForm(processDefinition.getId(), "myformengine"); // 验证表单对象 assertNotNull(renderedStartForm); assertTrue(renderedStartForm instanceof javax.swing.JButton); javax.swing.JButton button = (JButton) renderedStartForm; assertEquals("My Start Form Button", button.getName()); }
Example #3
Source File: SimpleFlowWorkController.java From activiti-demo with Apache License 2.0 | 6 votes |
/** * 查看流程定义图 * @param request * @param processDefId 流程定义id * @return */ @RequestMapping(value = "/viewprocessDefImage.do") public String viewprocessDefImage(HttpServletRequest request, HttpServletResponse response, @RequestParam("processDefId") String processDefId) throws Exception{ //根据流程定义id查询流程定义 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefId).singleResult(); InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName()); // // 输出资源内容到相应对象 // byte[] b = new byte[1024]; // int len; // while ((len = inputStream.read(b, 0, 1024)) != -1) { // response.getOutputStream().write(b, 0, len); // } response.getOutputStream().write(IoUtil.readInputStream(inputStream, "processDefInputStream")); return null; }
Example #4
Source File: TerminateEndEventTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testParseTerminateEndEventDefinitionWithExtensions() { org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.parseExtensionElements.bpmn20.xml").deploy(); ProcessDefinition processDefinitionQuery = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult(); BpmnModel bpmnModel = this.processEngineConfiguration.getProcessDefinitionCache() .get(processDefinitionQuery.getId()).getBpmnModel(); Map<String, List<ExtensionElement>> extensionElements = bpmnModel.getProcesses().get(0) .findFlowElementsOfType(EndEvent.class).get(0).getExtensionElements(); assertThat(extensionElements.size(), is(1)); List<ExtensionElement> strangeProperties = extensionElements.get("strangeProperty"); assertThat(strangeProperties.size(), is(1)); ExtensionElement strangeProperty = strangeProperties.get(0); assertThat(strangeProperty.getNamespace(), is("http://activiti.org/bpmn")); assertThat(strangeProperty.getElementText(), is("value")); assertThat(strangeProperty.getAttributes().size(), is(1)); ExtensionAttribute id = strangeProperty.getAttributes().get("id").get(0); assertThat(id.getName(), is("id")); assertThat(id.getValue(), is("strangeId")); repositoryService.deleteDeployment(deployment.getId()); }
Example #5
Source File: AbstractProcessDefinitionResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected FormDefinition getStartForm(ProcessDefinition processDefinition) { FormDefinition formDefinition = null; BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { formDefinition = formRepositoryService.getFormDefinitionByKeyAndParentDeploymentId(startEvent.getFormKey(), processDefinition.getDeploymentId(), processDefinition.getTenantId()); } } if (formDefinition == null) { // Definition found, but no form attached throw new NotFoundException("Process definition does not have a form defined: " + processDefinition.getId()); } return formDefinition; }
Example #6
Source File: DeploymentController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 读取流程资源 * * @param processDefinitionId 流程定义ID * @param resourceName 资源名称 */ @RequestMapping(value = "/read-resource") public void readResource(@RequestParam("pdid") String processDefinitionId, @RequestParam("resourceName") String resourceName, HttpServletResponse response) throws Exception { ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery(); ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult(); // 通过接口读取 InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName); // 输出资源内容到相应对象 byte[] b = new byte[1024]; int len = -1; while ((len = resourceAsStream.read(b, 0, 1024)) != -1) { response.getOutputStream().write(b, 0, len); } }
Example #7
Source File: GetDeploymentProcessDiagramCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public InputStream execute(CommandContext commandContext) { ProcessDefinition processDefinition = commandContext .getProcessEngineConfiguration() .getDeploymentManager() .findDeployedProcessDefinitionById(processDefinitionId); String deploymentId = processDefinition.getDeploymentId(); String resourceName = processDefinition.getDiagramResourceName(); if (resourceName == null ) { log.info("Resource name is null! No process diagram stream exists."); return null; } else { InputStream processDiagramStream = new GetDeploymentResourceCmd(deploymentId, resourceName) .execute(commandContext); return processDiagramStream; } }
Example #8
Source File: DeploymentController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 读取流程资源 * * @param processDefinitionId 流程定义ID * @param resourceName 资源名称 */ @RequestMapping(value = "/read-resource") public void readResource(@RequestParam("pdid") String processDefinitionId, @RequestParam("resourceName") String resourceName, HttpServletResponse response) throws Exception { ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery(); ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult(); // 通过接口读取 InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName); // 输出资源内容到相应对象 byte[] b = new byte[1024]; int len; while ((len = resourceAsStream.read(b, 0, 1024)) != -1) { response.getOutputStream().write(b, 0, len); } }
Example #9
Source File: AbstractProcessDefinitionResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected FormField getFormFieldFromRequest(String[] requestInfoArray, ProcessDefinition processDefinition, boolean isTableRequest) { FormDefinition form = getStartForm(processDefinition); int paramPosition = requestInfoArray.length - 1; if (isTableRequest) { paramPosition--; } String fieldVariable = requestInfoArray[paramPosition]; List<? extends FormField> allFields = form.listAllFields(); FormField selectedField = null; if (CollectionUtils.isNotEmpty(allFields)) { for (FormField formFieldRepresentation : allFields) { if (formFieldRepresentation.getId().equalsIgnoreCase(fieldVariable)) { selectedField = formFieldRepresentation; } } } if (selectedField == null) { throw new NotFoundException("Field could not be found in start form definition " + fieldVariable); } return selectedField; }
Example #10
Source File: OAController.java From my_curd with Apache License 2.0 | 6 votes |
/** * 根据流程定义 key 查询流程定义图 */ public void definitionDiagramByKey() { String processKey = getPara("key"); if (StringUtils.isEmpty(processKey)) { renderFail("Key 参数为空"); return; } List<ProcessDefinition> definitions = ActivitiKit.getRepositoryService().createProcessDefinitionQuery() .processDefinitionKey(processKey) .orderByProcessDefinitionVersion().desc() .list(); if (definitions.size() == 0) { renderFail("Key 参数错误"); return; } InputStream in = ActivitiKit.getRepositoryService().getProcessDiagram(definitions.get(0).getId()); render(new ImageRender().inputStream(in)); }
Example #11
Source File: ActProcessService.java From Shop-for-JavaWeb with MIT License | 6 votes |
/** * 流程定义列表 */ public Page<Object[]> processList(Page<Object[]> page, String category) { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery() .latestVersion().orderByProcessDefinitionKey().asc(); if (StringUtils.isNotEmpty(category)){ processDefinitionQuery.processDefinitionCategory(category); } page.setCount(processDefinitionQuery.count()); List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(page.getFirstResult(), page.getMaxResults()); for (ProcessDefinition processDefinition : processDefinitionList) { String deploymentId = processDefinition.getDeploymentId(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); page.getList().add(new Object[]{processDefinition, deployment}); } return page; }
Example #12
Source File: GetProcessDefinitionInfoCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public ObjectNode execute(CommandContext commandContext) { if (processDefinitionId == null) { throw new ActivitiIllegalArgumentException("process definition id is null"); } ObjectNode resultNode = null; DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager(); // make sure the process definition is in the cache ProcessDefinition processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId); if (Activiti5Util.isActiviti5ProcessDefinition(commandContext, processDefinition)) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); return activiti5CompatibilityHandler.getProcessDefinitionInfo(processDefinitionId); } ProcessDefinitionInfoCacheObject definitionInfoCacheObject = deploymentManager.getProcessDefinitionInfoCache().get(processDefinitionId); if (definitionInfoCacheObject != null) { resultNode = definitionInfoCacheObject.getInfoNode(); } return resultNode; }
Example #13
Source File: MyFormEngineTest.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = {"chapter6/leave-formkey/leave-formkey.bpmn", "chapter6/leave-formkey/leave-start.form"}) public void allPass() throws Exception { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // 读取启动表单 Object renderedStartForm = formService.getRenderedStartForm(processDefinition.getId(), "myformengine"); // 验证表单对象 assertNotNull(renderedStartForm); assertTrue(renderedStartForm instanceof javax.swing.JButton); javax.swing.JButton button = (JButton) renderedStartForm; assertEquals("My Start Form Button", button.getName()); }
Example #14
Source File: WorkFlowController.java From maven-framework-project with MIT License | 6 votes |
@RequestMapping(value="/processlist",method={RequestMethod.POST,RequestMethod.GET}) public ModelAndView processlist(HttpServletRequest request, HttpServletResponse response){ ModelAndView modelAndView=new ModelAndView("workflow/processlist"); /* * 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署) */ List<Object[]> objects = new ArrayList<Object[]>(); List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list(); for (ProcessDefinition processDefinition : list) { String deploymentId = processDefinition.getDeploymentId(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); objects.add(new Object[]{processDefinition,deployment}); } modelAndView.addObject("objects",objects); return modelAndView; }
Example #15
Source File: DeploymentController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 读取流程资源 * * @param processDefinitionId 流程定义ID * @param resourceName 资源名称 */ @RequestMapping(value = "/read-resource") public void readResource(@RequestParam("pdid") String processDefinitionId, @RequestParam("resourceName") String resourceName, HttpServletResponse response) throws Exception { ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery(); ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult(); // 通过接口读取 InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName); // 输出资源内容到相应对象 byte[] b = new byte[1024]; int len = -1; while ((len = resourceAsStream.read(b, 0, 1024)) != -1) { response.getOutputStream().write(b, 0, len); } }
Example #16
Source File: HistoricProcessInstanceQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void localize(HistoricProcessInstance processInstance, CommandContext commandContext) { HistoricProcessInstanceEntity processInstanceEntity = (HistoricProcessInstanceEntity) processInstance; processInstanceEntity.setLocalizedName(null); processInstanceEntity.setLocalizedDescription(null); if (locale != null && processInstance.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processInstanceEntity.getProcessDefinitionId()); ObjectNode languageNode = Context.getLocalizationElementProperties(locale, processDefinition.getKey(), processInstanceEntity.getProcessDefinitionId(), withLocalizationFallback); if (languageNode != null) { JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME); if (languageNameNode != null && languageNameNode.isNull() == false) { processInstanceEntity.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && languageDescriptionNode.isNull() == false) { processInstanceEntity.setLocalizedDescription(languageDescriptionNode.asText()); } } } }
Example #17
Source File: DeploymentEntityManagerImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void restoreSignalStartEvent(ProcessDefinition previousProcessDefinition, BpmnModel bpmnModel, StartEvent startEvent, EventDefinition eventDefinition) { SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition; SignalEventSubscriptionEntity subscriptionEntity = getEventSubscriptionEntityManager().createSignalEventSubscription(); Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef()); if (signal != null) { subscriptionEntity.setEventName(signal.getName()); } else { subscriptionEntity.setEventName(signalEventDefinition.getSignalRef()); } subscriptionEntity.setActivityId(startEvent.getId()); subscriptionEntity.setProcessDefinitionId(previousProcessDefinition.getId()); if (previousProcessDefinition.getTenantId() != null) { subscriptionEntity.setTenantId(previousProcessDefinition.getTenantId()); } getEventSubscriptionEntityManager().insert(subscriptionEntity); }
Example #18
Source File: HistoryProcessInstanceController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 查询已结束流程实例 * * @param request * @return */ @RequestMapping(value = "finished/manager") public ModelAndView finishedProcessInstanceListForManager(HttpServletRequest request) { ModelAndView mav = new ModelAndView("chapter13/finished-process-manager"); Page<HistoricProcessInstance> page = new Page<HistoricProcessInstance>(PageUtil.PAGE_SIZE); int[] pageParams = PageUtil.init(page, request); HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().finished(); List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage(pageParams[0], pageParams[1]); // 查询流程定义对象 Map<String, ProcessDefinition> definitionMap = new HashMap<String, ProcessDefinition>(); for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) { definitionCache(definitionMap, historicProcessInstance.getProcessDefinitionId()); } page.setResult(historicProcessInstances); page.setTotalCount(historicProcessInstanceQuery.count()); mav.addObject("page", page); mav.addObject("definitions", definitionMap); return mav; }
Example #19
Source File: ProcessDefinitionController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 读取启动流程的表单字段 */ @RequestMapping(value = "getform/start/{processDefinitionId}") public ModelAndView readStartForm(@PathVariable("processDefinitionId") String processDefinitionId) throws Exception { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); boolean hasStartFormKey = processDefinition.hasStartFormKey(); // 根据是否有formkey属性判断使用哪个展示层 String viewName = "chapter6/start-process-form"; ModelAndView mav = new ModelAndView(viewName); // 判断是否有formkey属性 if (hasStartFormKey) { Object renderedStartForm = formService.getRenderedStartForm(processDefinitionId); mav.addObject("startFormData", renderedStartForm); mav.addObject("processDefinition", processDefinition); } else { // 动态表单字段 StartFormData startFormData = formService.getStartFormData(processDefinitionId); mav.addObject("startFormData", startFormData); } mav.addObject("hasStartFormKey", hasStartFormKey); mav.addObject("processDefinitionId", processDefinitionId); return mav; }
Example #20
Source File: BusinessProcess.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deprecated public ProcessInstance startProcessByName(String string, Map<String, Object> variables) { if (Context.getCommandContext() != null) { throw new ActivitiCdiException("Cannot use startProcessByName in an activiti command."); } ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult(); if (definition == null) { throw new ActivitiObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class); } Map<String, Object> cachedVariables = getAndClearCachedVariables(); cachedVariables.putAll(variables); ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), cachedVariables); if (!instance.isEnded()) { setExecution(instance); } return instance; }
Example #21
Source File: FormServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testSubmitTaskFormData() { List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list(); assertEquals(1, processDefinitions.size()); ProcessDefinition processDefinition = processDefinitions.get(0); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey()); assertNotNull(processInstance); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertNotNull(task); Map<String, String> properties = new HashMap<String, String>(); properties.put("room", "5b"); formService.submitTaskFormData(task.getId(), properties); task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertNull(task); }
Example #22
Source File: MyFormEngineTest.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = {"chapter6/leave-formkey/leave-formkey.bpmn", "chapter6/leave-formkey/leave-start.form"}) public void allPass() throws Exception { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // 读取启动表单 Object renderedStartForm = formService.getRenderedStartForm(processDefinition.getId(), "myformengine"); // 验证表单对象 assertNotNull(renderedStartForm); assertTrue(renderedStartForm instanceof javax.swing.JButton); javax.swing.JButton button = (JButton) renderedStartForm; assertEquals("My Start Form Button", button.getName()); }
Example #23
Source File: RuntimeServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testStartProcessInstanceByIdUnexistingId() { try { runtimeService.startProcessInstanceById("unexistingId"); fail("ActivitiException expected"); } catch (ActivitiObjectNotFoundException ae) { assertTextPresent("no deployed process definition found with id", ae.getMessage()); assertEquals(ProcessDefinition.class, ae.getObjectClass()); } }
Example #24
Source File: FullHistoryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testHistoricDetailQueryMixed() throws Exception { Map<String, String> formProperties = new HashMap<String, String>(); formProperties.put("formProp1", "activiti rocks!"); formProperties.put("formProp2", "12345"); ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("historicDetailMixed").singleResult(); ProcessInstance processInstance = formService.submitStartFormData(procDef.getId(), formProperties); List<HistoricDetail> details = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).orderByVariableName().asc().list(); assertEquals(4, details.size()); assertTrue(details.get(0) instanceof HistoricFormProperty); HistoricFormProperty formProp1 = (HistoricFormProperty) details.get(0); assertEquals("formProp1", formProp1.getPropertyId()); assertEquals("activiti rocks!", formProp1.getPropertyValue()); assertTrue(details.get(1) instanceof HistoricFormProperty); HistoricFormProperty formProp2 = (HistoricFormProperty) details.get(1); assertEquals("formProp2", formProp2.getPropertyId()); assertEquals("12345", formProp2.getPropertyValue()); assertTrue(details.get(2) instanceof HistoricVariableUpdate); HistoricVariableUpdate varUpdate1 = (HistoricVariableUpdate) details.get(2); assertEquals("variable1", varUpdate1.getVariableName()); assertEquals("activiti rocks!", varUpdate1.getValue()); // This variable should be of type LONG since this is defined in the // process-definition assertTrue(details.get(3) instanceof HistoricVariableUpdate); HistoricVariableUpdate varUpdate2 = (HistoricVariableUpdate) details.get(3); assertEquals("variable2", varUpdate2.getVariableName()); assertEquals(12345L, varUpdate2.getValue()); }
Example #25
Source File: DeploymentController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义列表--过滤激活的流程定义 */ @RequestMapping(value = "/process-list-view") public ModelAndView processListReadonly(HttpServletRequest request) { // 对应WEB-INF/views/chapter5/process-list.jsp String viewName = "chapter5/process-list-view"; Page<ProcessDefinition> page = new Page<ProcessDefinition>(PageUtil.PAGE_SIZE); int[] pageParams = PageUtil.init(page, request); ModelAndView mav = new ModelAndView(viewName); // User user = UserUtil.getUserFromSession(request.getSession()); // ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().startableByUser(user.getId()); ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.suspended().active(); List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]); page.setResult(processDefinitionList); page.setTotalCount(processDefinitionQuery.count()); mav.addObject("page", page); // 读取每个流程定义的候选属性 Map<String, Map<String, List<? extends Object>>> linksMap = setCandidateUserAndGroups(processDefinitionList); mav.addObject("linksMap", linksMap); return mav; }
Example #26
Source File: SignalThrowingEventListener.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void onEvent(ActivitiEvent event) { if (isValidEvent(event)) { if (event.getProcessInstanceId() == null && processInstanceScope) { throw new ActivitiIllegalArgumentException("Cannot throw process-instance scoped signal, since the dispatched event is not part of an ongoing process instance"); } CommandContext commandContext = Context.getCommandContext(); EventSubscriptionEntityManager eventSubscriptionEntityManager = commandContext.getEventSubscriptionEntityManager(); List<SignalEventSubscriptionEntity> subscriptionEntities = null; if (processInstanceScope) { subscriptionEntities = eventSubscriptionEntityManager.findSignalEventSubscriptionsByProcessInstanceAndEventName(event.getProcessInstanceId(), signalName); } else { String tenantId = null; if (event.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(event.getProcessDefinitionId()); tenantId = processDefinition.getTenantId(); } subscriptionEntities = eventSubscriptionEntityManager.findSignalEventSubscriptionsByEventName(signalName, tenantId); } for (SignalEventSubscriptionEntity signalEventSubscriptionEntity : subscriptionEntities) { eventSubscriptionEntityManager.eventReceived(signalEventSubscriptionEntity, null, false); } } }
Example #27
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Converts the given list of {@link Task}s to a list of * {@link WorkflowTask}s that have a valid domain. * * Note that this method is not very performant. It will do many DB queries * for each of the Task item in the list of tasks as parameter. Make sure * that you limit the size of the tasks list depending on your needs. Hint: * use the WorkflowTaskQuery query parameter setLimit() method to limit the * number of Tasks to process * * @param tasks List<Task> */ private List<WorkflowTask> getValidWorkflowTasks(List<Task> tasks) { return typeConverter.filterByDomainAndConvert(tasks, new Function<Task, String>() { public String apply(Task task) { //TODO This probably isn't very performant! String defId = task.getProcessDefinitionId(); ProcessDefinition definition = repoService.createProcessDefinitionQuery().processDefinitionId(defId) .singleResult(); return definition.getKey(); } }); }
Example #28
Source File: DeploymentManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public ProcessDefinition findDeployedProcessDefinitionByKeyAndVersion(String processDefinitionKey, Integer processDefinitionVersion) { ProcessDefinition processDefinition = (ProcessDefinitionEntity) Context .getCommandContext() .getProcessDefinitionEntityManager() .findProcessDefinitionByKeyAndVersion(processDefinitionKey, processDefinitionVersion); if (processDefinition==null) { throw new ActivitiObjectNotFoundException("no processes deployed with key = '" + processDefinitionKey + "' and version = '" + processDefinitionVersion + "'", ProcessDefinition.class); } processDefinition = resolveProcessDefinition(processDefinition).getProcessDefinition(); return processDefinition; }
Example #29
Source File: AbstractActivitiTestCase.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Creates and deploys the one task process. See {@link #createOneTaskTestProcess()}. * * @return The process definition id (NOT the process definition key) of deployed one task process. */ public String deployOneTaskTestProcess() { BpmnModel bpmnModel = createOneTaskTestProcess(); Deployment deployment = repositoryService.createDeployment().addBpmnModel("oneTasktest.bpmn20.xml", bpmnModel).deploy(); deploymentIdsForAutoCleanup.add(deployment.getId()); // For auto-cleanup ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult(); return processDefinition.getId(); }
Example #30
Source File: DeploymentController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 流程定义列表--过滤激活的流程定义 */ @RequestMapping(value = "/process-list-view") public ModelAndView processListReadonly(HttpServletRequest request) { // 对应WEB-INF/views/chapter5/process-list.jsp String viewName = "chapter5/process-list-view"; Page<ProcessDefinition> page = new Page<ProcessDefinition>(PageUtil.PAGE_SIZE); int[] pageParams = PageUtil.init(page, request); ModelAndView mav = new ModelAndView(viewName); // User user = UserUtil.getUserFromSession(request.getSession()); // ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().startableByUser(user.getId()); ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); processDefinitionQuery.suspended().active(); List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]); page.setResult(processDefinitionList); page.setTotalCount(processDefinitionQuery.count()); mav.addObject("page", page); // 读取每个流程定义的候选属性 Map<String, Map<String, List<? extends Object>>> linksMap = setCandidateUserAndGroups(processDefinitionList); mav.addObject("linksMap", linksMap); return mav; }