org.activiti.engine.impl.pvm.delegate.ActivityBehavior Java Examples

The following examples show how to use org.activiti.engine.impl.pvm.delegate.ActivityBehavior. 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: AlfrescoUserTaskBpmnParseHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, UserTask userTask)
{
    ActivityImpl activity = findActivity(bpmnParse, userTask.getId());
    ActivityBehavior activitybehaviour = activity.getActivityBehavior();
    if (activitybehaviour instanceof UserTaskActivityBehavior)
    {
        addListeners((UserTaskActivityBehavior) activity.getActivityBehavior());
    } 
    else if(activitybehaviour instanceof MultiInstanceActivityBehavior) 
    {
        MultiInstanceActivityBehavior multiInstance = (MultiInstanceActivityBehavior) activitybehaviour;
        if(multiInstance.getInnerActivityBehavior() instanceof UserTaskActivityBehavior) 
        {
            addListeners((UserTaskActivityBehavior) multiInstance.getInnerActivityBehavior());
        }
    }
}
 
Example #2
Source File: AlfrescoCallActivityBpmnParseHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, CallActivity callActivity)
{
    if (multiTenancyEnabled && tenantService.isEnabled())
    {
        ActivityImpl activity = findActivity(bpmnParse, callActivity.getId());
        ActivityBehavior activityBehavior = activity.getActivityBehavior();
        if(activityBehavior instanceof CallActivityBehavior)
        {
            CallActivityBehavior callActivityBehavior = (CallActivityBehavior) activityBehavior;
            
            // Make name of process-definition to be called aware of the current tenant
            callActivityBehavior.setProcessDefinitonKey(tenantService.getName(callActivityBehavior.getProcessDefinitonKey()));
        }
    }
}
 
Example #3
Source File: ActTaskService.java    From Shop-for-JavaWeb with MIT License 4 votes vote down vote up
/**
 * 封装输出信息,包括:当前节点的X、Y坐标、变量信息、任务类型、任务描述
 * @param activity
 * @param processInstance
 * @param currentActiviti
 * @return
 */
private Map<String, Object> packageSingleActivitiInfo(ActivityImpl activity, ProcessInstance processInstance,
		boolean currentActiviti) throws Exception {
	Map<String, Object> vars = new HashMap<String, Object>();
	Map<String, Object> activityInfo = new HashMap<String, Object>();
	activityInfo.put("currentActiviti", currentActiviti);
	setPosition(activity, activityInfo);
	setWidthAndHeight(activity, activityInfo);

	Map<String, Object> properties = activity.getProperties();
	vars.put("节点名称", properties.get("name"));
	vars.put("任务类型", ActUtils.parseToZhType(properties.get("type").toString()));

	ActivityBehavior activityBehavior = activity.getActivityBehavior();
	logger.debug("activityBehavior={}", activityBehavior);
	if (activityBehavior instanceof UserTaskActivityBehavior) {

		Task currentTask = null;

		// 当前节点的task
		if (currentActiviti) {
			currentTask = getCurrentTaskInfo(processInstance);
		}

		// 当前任务的分配角色
		UserTaskActivityBehavior userTaskActivityBehavior = (UserTaskActivityBehavior) activityBehavior;
		TaskDefinition taskDefinition = userTaskActivityBehavior.getTaskDefinition();
		Set<Expression> candidateGroupIdExpressions = taskDefinition.getCandidateGroupIdExpressions();
		if (!candidateGroupIdExpressions.isEmpty()) {

			// 任务的处理角色
			setTaskGroup(vars, candidateGroupIdExpressions);

			// 当前处理人
			if (currentTask != null) {
				setCurrentTaskAssignee(vars, currentTask);
			}
		}
	}

	vars.put("节点说明", properties.get("documentation"));

	String description = activity.getProcessDefinition().getDescription();
	vars.put("描述", description);

	logger.debug("trace variables: {}", vars);
	activityInfo.put("vars", vars);
	return activityInfo;
}
 
Example #4
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ActivityBehavior createCamelActivityBehavior(SendTask sendTask, BpmnModel bpmnModel)
{
	return _source.createCamelActivityBehavior(sendTask, bpmnModel);
}
 
Example #5
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ActivityBehavior createCamelActivityBehavior(ServiceTask serviceTask, BpmnModel bpmnModel)
{
	return _source.createCamelActivityBehavior(serviceTask, bpmnModel);
}
 
Example #6
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ActivityBehavior createMuleActivityBehavior(SendTask sendTask, BpmnModel bpmnModel)
{
	return _source.createMuleActivityBehavior(sendTask, bpmnModel);
}
 
Example #7
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ActivityBehavior createMuleActivityBehavior(ServiceTask serviceTask, BpmnModel bpmnModel)
{
	return _source.createMuleActivityBehavior(serviceTask, bpmnModel);
}
 
Example #8
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 #9
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 #10
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 #11
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 #12
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 #13
Source File: WorkflowTraceService.java    From maven-framework-project with MIT License 4 votes vote down vote up
/**
 * 封装输出信息,包括:当前节点的X、Y坐标、变量信息、任务类型、任务描述
 * @param activity
 * @param processInstance
 * @param currentActiviti
 * @return
 */
private Map<String, Object> packageSingleActivitiInfo(ActivityImpl activity, ProcessInstance processInstance,
		boolean currentActiviti) throws Exception {
	Map<String, Object> vars = new HashMap<String, Object>();
	Map<String, Object> activityInfo = new HashMap<String, Object>();
	activityInfo.put("currentActiviti", currentActiviti);
	setPosition(activity, activityInfo);
	setWidthAndHeight(activity, activityInfo);

	Map<String, Object> properties = activity.getProperties();
	vars.put("任务类型", WorkflowUtils.parseToZhType(properties.get("type").toString()));

	ActivityBehavior activityBehavior = activity.getActivityBehavior();
	logger.debug("activityBehavior={}", activityBehavior);
	if (activityBehavior instanceof UserTaskActivityBehavior) {

		Task currentTask = null;

		/*
		 * 当前节点的task
		 */
		if (currentActiviti) {
			currentTask = getCurrentTaskInfo(processInstance);
		}

		/*
		 * 当前任务的分配角色
		 */
		UserTaskActivityBehavior userTaskActivityBehavior = (UserTaskActivityBehavior) activityBehavior;
		TaskDefinition taskDefinition = userTaskActivityBehavior.getTaskDefinition();
		Set<Expression> candidateGroupIdExpressions = taskDefinition.getCandidateGroupIdExpressions();
		if (!candidateGroupIdExpressions.isEmpty()) {

			// 任务的处理角色
			setTaskGroup(vars, candidateGroupIdExpressions);

			// 当前处理人
			if (currentTask != null) {
				setCurrentTaskAssignee(vars, currentTask);
			}
		}
	}

	vars.put("节点说明", properties.get("documentation"));

	String description = activity.getProcessDefinition().getDescription();
	vars.put("描述", description);

	logger.debug("trace variables: {}", vars);
	activityInfo.put("vars", vars);
	return activityInfo;
}