Java Code Examples for org.activiti.engine.impl.pvm.PvmActivity#getOutgoingTransitions()
The following examples show how to use
org.activiti.engine.impl.pvm.PvmActivity#getOutgoingTransitions() .
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 | 5 votes |
private void findUserTasks(PvmActivity currentActivity, Map<String, PvmActivity> userTasks, Set<String> processedActivities) { // Only process activity if not already processed, to prevent endless loops if(!processedActivities.contains(currentActivity.getId())) { processedActivities.add(currentActivity.getId()); if(isUserTask(currentActivity)) { userTasks.put(currentActivity.getId(), currentActivity); } // Process outgoing transitions if(currentActivity.getOutgoingTransitions() != null) { for(PvmTransition transition : currentActivity.getOutgoingTransitions()) { if(transition.getDestination() != null) { findUserTasks(transition.getDestination(), userTasks, processedActivities); } } } if (isSubProcess(currentActivity)) { Map<String, Object> properties = ((ActivityImpl)currentActivity).getProperties(); PvmActivity startEvent = (PvmActivity) properties.get(ActivitiConstants.PROP_INITIAL_ACTIVITY); findUserTasks(startEvent, userTasks, processedActivities); } } }
Example 2
Source File: ProcessDefinitionPersistenceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void testProcessDefinitionIntrospection() { String deploymentId = repositoryService .createDeployment() .addClasspathResource("org/activiti/engine/test/db/processOne.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy() .getId(); String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawProcessConfiguration(); ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) activiti5ProcessEngineConfig.getRepositoryService()).getDeployedProcessDefinition(procDefId); assertEquals(procDefId, processDefinition.getId()); assertEquals("Process One", processDefinition.getName()); assertEquals("the first process", processDefinition.getProperty("documentation")); PvmActivity start = processDefinition.findActivity("start"); assertNotNull(start); assertEquals("start", start.getId()); assertEquals("S t a r t", start.getProperty("name")); assertEquals("the start event", start.getProperty("documentation")); assertEquals(Collections.EMPTY_LIST, start.getActivities()); List<PvmTransition> outgoingTransitions = start.getOutgoingTransitions(); assertEquals(1, outgoingTransitions.size()); assertEquals("${a == b}", outgoingTransitions.get(0).getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT)); PvmActivity end = processDefinition.findActivity("end"); assertNotNull(end); assertEquals("end", end.getId()); PvmTransition transition = outgoingTransitions.get(0); assertEquals("flow1", transition.getId()); assertEquals("Flow One", transition.getProperty("name")); assertEquals("The only transitions in the process", transition.getProperty("documentation")); assertSame(start, transition.getSource()); assertSame(end, transition.getDestination()); repositoryService.deleteDeployment(deploymentId); }
Example 3
Source File: FindNextActivitiesCmd.java From lemon with Apache License 2.0 | 5 votes |
public List<PvmActivity> getNextActivities(PvmActivity pvmActivity) { List<PvmActivity> pvmActivities = new ArrayList<PvmActivity>(); for (PvmTransition pvmTransition : pvmActivity.getOutgoingTransitions()) { PvmActivity targetActivity = pvmTransition.getDestination(); if ("userTask".equals(targetActivity.getProperty("type"))) { pvmActivities.add(targetActivity); } else { pvmActivities.addAll(this.getNextActivities(targetActivity)); } } return pvmActivities; }
Example 4
Source File: ActivitiGraphBuilder.java From lemon with Apache License 2.0 | 5 votes |
/** * 遍历. */ public Node visitNode(PvmActivity pvmActivity) { if (visitedNodeIds.contains(pvmActivity.getId())) { return null; } visitedNodeIds.add(pvmActivity.getId()); Node currentNode = new Node(); currentNode.setId(pvmActivity.getId()); currentNode.setName(this.getString(pvmActivity.getProperty("name"))); currentNode.setType(this.getString(pvmActivity.getProperty("type"))); for (PvmTransition pvmTransition : pvmActivity.getOutgoingTransitions()) { PvmActivity destination = pvmTransition.getDestination(); Node targetNode = this.visitNode(destination); if (targetNode == null) { continue; } Edge edge = new Edge(); edge.setId(pvmTransition.getId()); edge.setSrc(currentNode); edge.setDest(targetNode); currentNode.getOutgoingEdges().add(edge); } return currentNode; }
Example 5
Source File: BpmActivityServiceImpl.java From hsweb-framework with Apache License 2.0 | 4 votes |
@Override public List<TaskDefinition> getTaskDefinition(ActivityImpl activityImpl, DelegateExecution execution) { Set<TaskDefinition> taskDefinitionList = new HashSet<>(); List<TaskDefinition> nextTaskDefinition; if ("userTask".equals(activityImpl.getProperty("type"))) { TaskDefinition taskDefinition = ((UserTaskActivityBehavior) activityImpl.getActivityBehavior()).getTaskDefinition(); taskDefinitionList.add(taskDefinition); } else { List<PvmTransition> pvmTransitions = activityImpl.getOutgoingTransitions(); List<PvmTransition> outTransitionsTemp; for (PvmTransition tr : pvmTransitions) { PvmActivity pvmActivity = tr.getSource(); //获取线路的终点节点 boolean exclusiveGateway = "exclusiveGateway".equals(pvmActivity.getProperty("type")); boolean parallelGateway = "parallelGateway".equals(pvmActivity.getProperty("type")); if (exclusiveGateway || parallelGateway) { outTransitionsTemp = pvmActivity.getOutgoingTransitions(); if (outTransitionsTemp.size() == 1) { nextTaskDefinition = getTaskDefinition((ActivityImpl) outTransitionsTemp.get(0).getDestination(), execution); taskDefinitionList.addAll(nextTaskDefinition); } else if (outTransitionsTemp.size() > 1) { for (PvmTransition transition : outTransitionsTemp) { String condition = (String) transition.getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT); if (StringUtils.isEmpty(condition)) { nextTaskDefinition = getTaskDefinition((ActivityImpl) transition.getDestination(), execution); if (exclusiveGateway) { if (!CollectionUtils.isEmpty(nextTaskDefinition)) { taskDefinitionList.add(nextTaskDefinition.get(0)); } } else { taskDefinitionList.addAll(nextTaskDefinition); } continue; } ExpressionManager expressionManager = ((ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration()).getExpressionManager(); ELContext elContext = expressionManager.getElContext(execution); ExpressionFactoryImpl factory = new ExpressionFactoryImpl(); Object e = factory.createValueExpression(elContext, condition, Object.class).getValue(elContext); if (Boolean.TRUE.equals(e)) { nextTaskDefinition = getTaskDefinition((ActivityImpl) transition.getDestination(), execution); taskDefinitionList.addAll(nextTaskDefinition); } } } } else if ("userTask".equals(pvmActivity.getProperty("type"))) { taskDefinitionList.add(((UserTaskActivityBehavior) ((ActivityImpl) pvmActivity).getActivityBehavior()).getTaskDefinition()); } } } return new ArrayList<>(taskDefinitionList); }