Java Code Examples for org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#getActivities()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#getActivities() . 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: BpmnParseHandlerTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = "chapter6/dynamic-form/leave.bpmn")
public void testParseHandler() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertEquals("请假流程-动态表单-被PRE解析器修改", processDefinition.getName());
    assertEquals("leave-modified-by-post-parse-handler", processDefinition.getKey());

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(processDefinition.getId());

    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinitionEntity.getActivities();//获得当前任务的所有节点
    for (ActivityImpl activity : activitiList) {
        System.out.println("Activity Name: " + activity.getProperty("name") + ", async=" + activity.isAsync());
    }

    InputStream processBpmn = activitiRule.getRepositoryService()
            .getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
    String userHomeDir = getClass().getResource("/").getFile();
    FileUtils.copyInputStreamToFile(processBpmn,
            new File(userHomeDir + "/leave.bpmn20.xml"));
}
 
Example 2
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) {
    List<String> highLightedFlows = new ArrayList<String>();
    List<HistoricActivityInstance> historicActivityInstances = historyService
            .createHistoricActivityInstanceQuery()
            .processInstanceId(processInstanceId)
            .orderByHistoricActivityInstanceStartTime().asc().list();

    List<String> historicActivityInstanceList = new ArrayList<String>();
    for (HistoricActivityInstance hai : historicActivityInstances) {
        historicActivityInstanceList.add(hai.getActivityId());
    }

    // add current activities to list
    List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
    historicActivityInstanceList.addAll(highLightedActivities);

    // activities and their sequence-flows
    for (ActivityImpl activity : processDefinition.getActivities()) {
        int index = historicActivityInstanceList.indexOf(activity.getId());

        if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {
            List<PvmTransition> pvmTransitionList = activity
                    .getOutgoingTransitions();
            for (PvmTransition pvmTransition : pvmTransitionList) {
                String destinationFlowId = pvmTransition.getDestination().getId();
                if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {
                    highLightedFlows.add(pvmTransition.getId());
                }
            }
        }
    }
    return highLightedFlows;
}
 
Example 3
Source File: WorkflowTraceService.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 流程跟踪图
 * @param processInstanceId		流程实例ID
 * @return	封装了各种节点信息
 */
public List<Map<String, Object>> traceProcess(String processInstanceId) throws Exception {
	//根据流程实例获取流程节点
	Execution execution = runtimeService.createExecutionQuery().executionId(processInstanceId).singleResult();//执行实例
	Object property = PropertyUtils.getProperty(execution, "activityId");
	String activityId = "";
	if (property != null) {
		activityId = property.toString();
	}
	//查询流程实例
	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
	//根据流程定义id查询流程定义
	ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
	//获取该流程定义的所有节点
	List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

	List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
	for (ActivityImpl activity : activitiList) {

		boolean currentActiviti = false;
		String id = activity.getId();

		// 判断是否是当前节点
		if (id.equals(activityId)) {
			currentActiviti = true;
		}

		Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, processInstance, currentActiviti);

		activityInfos.add(activityImageInfo);
	}

	return activityInfos;
}
 
Example 4
Source File: WorkFlowController.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 输出跟踪流程信息
 * @param processInstanceId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/process/{executionId}/trace/{processInstanceId}",produces={MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody Map<String,Object> traceProcess(@PathVariable("executionId") String executionId,@PathVariable("processInstanceId") String processInstanceId) throws Exception {
	
	//根据executionId查询当前执行的节点
	ExecutionEntity execution=(ExecutionEntity) runtimeService.createExecutionQuery().processInstanceId(processInstanceId).executionId(executionId).singleResult();
	
	//获取当前节点的activityId
	String activityId=execution.getActivityId();
	
	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
	
	ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
	
	List<ActivityImpl> activities = processDefinitionEntity.getActivities();
	
	Map<String,Object> activityImageInfo=new HashMap<String,Object>();
	
	for (ActivityImpl activityImpl : activities) {
		String id=activityImpl.getId();
		//判断是否是当前节点
		if(id.equals(activityId)){
			activityImageInfo.put("x", activityImpl.getX());
			activityImageInfo.put("y", activityImpl.getY());
			activityImageInfo.put("width", activityImpl.getWidth());
			activityImageInfo.put("height", activityImpl.getHeight());
			break;//跳出循环
		}
	}
	return activityImageInfo;
}
 
Example 5
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) {
    List<String> highLightedFlows = new ArrayList<String>();
    List<HistoricActivityInstance> historicActivityInstances = historyService
            .createHistoricActivityInstanceQuery()
            .processInstanceId(processInstanceId)
            .orderByHistoricActivityInstanceStartTime().asc().list();

    List<String> historicActivityInstanceList = new ArrayList<String>();
    for (HistoricActivityInstance hai : historicActivityInstances) {
        historicActivityInstanceList.add(hai.getActivityId());
    }

    // add current activities to list
    List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
    historicActivityInstanceList.addAll(highLightedActivities);

    // activities and their sequence-flows
    for (ActivityImpl activity : processDefinition.getActivities()) {
        int index = historicActivityInstanceList.indexOf(activity.getId());

        if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {
            List<PvmTransition> pvmTransitionList = activity
                    .getOutgoingTransitions();
            for (PvmTransition pvmTransition : pvmTransitionList) {
                String destinationFlowId = pvmTransition.getDestination().getId();
                if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {
                    highLightedFlows.add(pvmTransition.getId());
                }
            }
        }
    }
    return highLightedFlows;
}
 
Example 6
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) {
    List<String> highLightedFlows = new ArrayList<String>();
    List<HistoricActivityInstance> historicActivityInstances = historyService
            .createHistoricActivityInstanceQuery()
            .processInstanceId(processInstanceId)
            .orderByHistoricActivityInstanceStartTime().asc().list();

    List<String> historicActivityInstanceList = new ArrayList<String>();
    for (HistoricActivityInstance hai : historicActivityInstances) {
        historicActivityInstanceList.add(hai.getActivityId());
    }

    // add current activities to list
    List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
    historicActivityInstanceList.addAll(highLightedActivities);

    // activities and their sequence-flows
    for (ActivityImpl activity : processDefinition.getActivities()) {
        int index = historicActivityInstanceList.indexOf(activity.getId());

        if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {
            List<PvmTransition> pvmTransitionList = activity
                    .getOutgoingTransitions();
            for (PvmTransition pvmTransition : pvmTransitionList) {
                String destinationFlowId = pvmTransition.getDestination().getId();
                if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {
                    highLightedFlows.add(pvmTransition.getId());
                }
            }
        }
    }
    return highLightedFlows;
}
 
Example 7
Source File: BaseProcessDefinitionDiagramLayoutResource.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
private List<String> getHighLightedFlows(String processInstanceId, ProcessDefinitionEntity processDefinition) {

        List<String> highLightedFlows = new ArrayList<String>();
        List<HistoricActivityInstance> historicActivityInstances = historyService
                .createHistoricActivityInstanceQuery()
                .processInstanceId(processInstanceId)
                .orderByHistoricActivityInstanceStartTime().asc().list();

        List<String> historicActivityInstanceList = new ArrayList<String>();
        for (HistoricActivityInstance hai : historicActivityInstances) {
            historicActivityInstanceList.add(hai.getActivityId());
        }

        // add current activities to list
        List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
        historicActivityInstanceList.addAll(highLightedActivities);

        // activities and their sequence-flows
        for (ActivityImpl activity : processDefinition.getActivities()) {
            int index = historicActivityInstanceList.indexOf(activity.getId());

            if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {
                List<PvmTransition> pvmTransitionList = activity
                        .getOutgoingTransitions();
                for (PvmTransition pvmTransition : pvmTransitionList) {
                    String destinationFlowId = pvmTransition.getDestination().getId();
                    if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {
                        highLightedFlows.add(pvmTransition.getId());
                    }
                }
            }
        }
        return highLightedFlows;
    }
 
Example 8
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) {
    List<String> highLightedFlows = new ArrayList<String>();
    List<HistoricActivityInstance> historicActivityInstances = historyService
            .createHistoricActivityInstanceQuery()
            .processInstanceId(processInstanceId)
            .orderByHistoricActivityInstanceStartTime().asc().list();

    List<String> historicActivityInstanceList = new ArrayList<String>();
    for (HistoricActivityInstance hai : historicActivityInstances) {
        historicActivityInstanceList.add(hai.getActivityId());
    }

    // add current activities to list
    List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
    historicActivityInstanceList.addAll(highLightedActivities);

    // activities and their sequence-flows
    for (ActivityImpl activity : processDefinition.getActivities()) {
        int index = historicActivityInstanceList.indexOf(activity.getId());

        if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {
            List<PvmTransition> pvmTransitionList = activity
                    .getOutgoingTransitions();
            for (PvmTransition pvmTransition : pvmTransitionList) {
                String destinationFlowId = pvmTransition.getDestination().getId();
                if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {
                    highLightedFlows.add(pvmTransition.getId());
                }
            }
        }
    }
    return highLightedFlows;
}
 
Example 9
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) {
    List<String> highLightedFlows = new ArrayList<String>();
    List<HistoricActivityInstance> historicActivityInstances = historyService
            .createHistoricActivityInstanceQuery()
            .processInstanceId(processInstanceId)
            .orderByHistoricActivityInstanceStartTime().asc().list();

    List<String> historicActivityInstanceList = new ArrayList<String>();
    for (HistoricActivityInstance hai : historicActivityInstances) {
        historicActivityInstanceList.add(hai.getActivityId());
    }

    // add current activities to list
    List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
    historicActivityInstanceList.addAll(highLightedActivities);

    // activities and their sequence-flows
    for (ActivityImpl activity : processDefinition.getActivities()) {
        int index = historicActivityInstanceList.indexOf(activity.getId());

        if (index >= 0 && index + 1 < historicActivityInstanceList.size()) {
            List<PvmTransition> pvmTransitionList = activity
                    .getOutgoingTransitions();
            for (PvmTransition pvmTransition : pvmTransitionList) {
                String destinationFlowId = pvmTransition.getDestination().getId();
                if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) {
                    highLightedFlows.add(pvmTransition.getId());
                }
            }
        }
    }
    return highLightedFlows;
}
 
Example 10
Source File: ActTaskService.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
/**
 * 流程跟踪图信息
 * @param processInstanceId		流程实例ID
 * @return	封装了各种节点信息
 */
public List<Map<String, Object>> traceProcess(String processInstanceId) throws Exception {
	Execution execution = runtimeService.createExecutionQuery().executionId(processInstanceId).singleResult();//执行实例
	Object property = PropertyUtils.getProperty(execution, "activityId");
	String activityId = "";
	if (property != null) {
		activityId = property.toString();
	}
	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId)
			.singleResult();
	ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
			.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
	List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

	List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
	for (ActivityImpl activity : activitiList) {

		boolean currentActiviti = false;
		String id = activity.getId();

		// 当前节点
		if (id.equals(activityId)) {
			currentActiviti = true;
		}

		Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, processInstance, currentActiviti);

		activityInfos.add(activityImageInfo);
	}

	return activityInfos;
}
 
Example 11
Source File: BpmActivityServiceImpl.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
@Override
public List<ActivityImpl> getActivitiesById(String processDefId, String activityId) {
    ProcessDefinitionEntity pde = getProcessDefinition(processDefId);
    if (activityId == null) {
        return pde.getActivities();
    } else {
        ActivityImpl activity = pde.findActivity(activityId);
        if (null == activity) {
            return new java.util.ArrayList<>();
        }
        return Collections.singletonList(activity);
    }
}
 
Example 12
Source File: BpmTaskServiceImpl.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
@Override
public ActivityImpl selectActivityImplByTask(String taskId) {
    if (StringUtils.isNullOrEmpty(taskId)) {
        return new ActivityImpl(null, null);
    }
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    ProcessDefinitionEntity entity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(task.getProcessDefinitionId());
    List<ActivityImpl> activities = entity.getActivities();
    return activities
            .stream()
            .filter(activity -> "userTask".equals(activity.getProperty("type")) && activity.getProperty("name").equals(task.getName()))
            .findFirst()
            .orElseThrow(() -> new NotFoundException("获取节点信息失败"));
}
 
Example 13
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example 14
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example 15
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example 16
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}
 
Example 17
Source File: BpmnParseTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Deployment
public void testParseDiagramInterchangeElements() {

    ProcessDefinition processDefinition = processEngineConfiguration.getFlowable5CompatibilityHandler().getProcessDefinitionByKey("myProcess");
    ProcessDefinitionEntity rawEntity = (ProcessDefinitionEntity) processDefinition;

    assertNotNull(rawEntity);
    assertEquals(7, rawEntity.getActivities().size());

    // Check if diagram has been created based on Diagram Interchange when it's not a headless instance
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(rawEntity.getDeploymentId());
    assertEquals(2, resourceNames.size());

    for (ActivityImpl activity : rawEntity.getActivities()) {

        if (activity.getId().equals("theStart")) {
            assertActivityBounds(activity, 70, 255, 30, 30);
        } else if (activity.getId().equals("task1")) {
            assertActivityBounds(activity, 176, 230, 100, 80);
        } else if (activity.getId().equals("gateway1")) {
            assertActivityBounds(activity, 340, 250, 40, 40);
        } else if (activity.getId().equals("task2")) {
            assertActivityBounds(activity, 445, 138, 100, 80);
        } else if (activity.getId().equals("gateway2")) {
            assertActivityBounds(activity, 620, 250, 40, 40);
        } else if (activity.getId().equals("task3")) {
            assertActivityBounds(activity, 453, 304, 100, 80);
        } else if (activity.getId().equals("theEnd")) {
            assertActivityBounds(activity, 713, 256, 28, 28);
        }

        for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {
            assertTrue(((TransitionImpl) sequenceFlow).getWaypoints().size() >= 4);

            TransitionImpl transitionImpl = (TransitionImpl) sequenceFlow;
            if (transitionImpl.getId().equals("flowStartToTask1")) {
                assertSequenceFlowWayPoints(transitionImpl, 100, 270, 176, 270);
            } else if (transitionImpl.getId().equals("flowTask1ToGateway1")) {
                assertSequenceFlowWayPoints(transitionImpl, 276, 270, 340, 270);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask2")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 250, 360, 178, 445, 178);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask3")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 290, 360, 344, 453, 344);
            } else if (transitionImpl.getId().equals("flowTask2ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 545, 178, 640, 178, 640, 250);
            } else if (transitionImpl.getId().equals("flowTask3ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 553, 344, 640, 344, 640, 290);
            } else if (transitionImpl.getId().equals("flowGateway2ToEnd")) {
                assertSequenceFlowWayPoints(transitionImpl, 660, 270, 713, 270);
            }

        }
    }
}
 
Example 18
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取跟踪数据
 *
 * @param executionId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "trace/data/{executionId}")
@ResponseBody
public List<Map<String, Object>> readActivityDatas(@PathVariable("executionId") String executionId) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);

    RepositoryServiceImpl repositoryServiceImpl = (RepositoryServiceImpl) repositoryService;
    ReadOnlyProcessDefinition deployedProcessDefinition = repositoryServiceImpl
            .getDeployedProcessDefinition(executionEntity.getProcessDefinitionId());

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deployedProcessDefinition;
    List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

        ActivityBehavior activityBehavior = activity.getActivityBehavior();

        boolean currentActiviti = false;
        // 当前节点
        String activityId = activity.getId();
        if (activeActivityIds.contains(activityId)) {
            currentActiviti = true;
        }
        Map<String, Object> activityImageInfo = packageSingleActivitiInfo(activity, executionEntity.getId(), currentActiviti);
        activityInfos.add(activityImageInfo);

        // 处理子流程
        if (activityBehavior instanceof SubProcessActivityBehavior) {
            List<ActivityImpl> innerActivityList = activity.getActivities();
            for (ActivityImpl innerActivity : innerActivityList) {
                String innerActivityId = innerActivity.getId();
                if (activeActivityIds.contains(innerActivityId)) {
                    currentActiviti = true;
                } else {
                    currentActiviti = false;
                }
                activityImageInfo = packageSingleActivitiInfo(innerActivity, executionEntity.getId(), currentActiviti);
                activityInfos.add(activityImageInfo);
            }
        }

    }

    return activityInfos;
}