org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior Java Examples

The following examples show how to use org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior. 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: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String getFormKey(PvmActivity act)
{
    if(act instanceof ActivityImpl) 
    {
        ActivityImpl actImpl = (ActivityImpl) act;
        if (actImpl.getActivityBehavior() instanceof UserTaskActivityBehavior)        
        {
            UserTaskActivityBehavior uta = (UserTaskActivityBehavior) actImpl.getActivityBehavior();
            TaskFormHandler handler = uta.getTaskDefinition().getTaskFormHandler();
            if(handler != null && handler instanceof DefaultTaskFormHandler)
            {
                // We cast to DefaultTaskFormHandler since we do not configure our own
                return ((DefaultTaskFormHandler)handler).getFormKey().getExpressionText();
            }
            
        }
    }
    return null;
}
 
Example #2
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getFormKey(PvmActivity act, ReadOnlyProcessDefinition processDefinition)
{
    if(act instanceof ActivityImpl) 
    {
        ActivityImpl actImpl = (ActivityImpl) act;
        if (actImpl.getActivityBehavior() instanceof UserTaskActivityBehavior)        
        {
        	UserTaskActivityBehavior uta = (UserTaskActivityBehavior) actImpl.getActivityBehavior();
            return getFormKey(uta.getTaskDefinition());
        }
        else if(actImpl.getActivityBehavior() instanceof MultiInstanceActivityBehavior) 
        {
        	// Get the task-definition from the process-definition
        	if(processDefinition instanceof ProcessDefinitionEntity)
        	{
        		// Task definition id is the same the the activity id
        		TaskDefinition taskDef = ((ProcessDefinitionEntity) processDefinition).getTaskDefinitions().get(act.getId());
        		if(taskDef != null)
        		{
        			return getFormKey(taskDef);
        		}
        	}
        }
    }
    return null;
}
 
Example #3
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 #4
Source File: RuntimeActivityCreatorSupport.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected ActivityImpl createActivity(ProcessEngine processEngine, ProcessDefinitionEntity processDefinition,
		ActivityImpl prototypeActivity, String cloneActivityId, String assignee)
{
	ActivityImpl clone = cloneActivity(processDefinition, prototypeActivity, cloneActivityId, "executionListeners",
		"properties");

	//设置assignee
	UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior) (prototypeActivity.getActivityBehavior());

	TaskDefinition taskDefinition = cloneTaskDefinition(activityBehavior.getTaskDefinition());
	taskDefinition.setKey(cloneActivityId);
	if (assignee != null)
	{
		taskDefinition.setAssigneeExpression(new FixedValue(assignee));
	}

	UserTaskActivityBehavior cloneActivityBehavior = new UserTaskActivityBehavior(prototypeActivity.getId(), taskDefinition);
	clone.setActivityBehavior(cloneActivityBehavior);

	return clone;
}
 
Example #5
Source File: TaskEntityManager.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public void deleteTasksByProcessInstanceId(String processInstanceId, String deleteReason, boolean cascade) {
    List<TaskEntity> tasks = (List) getDbSqlSession()
            .createTaskQuery()
            .processInstanceId(processInstanceId)
            .list();

    String reason = (deleteReason == null || deleteReason.length() == 0) ? TaskEntity.DELETE_REASON_DELETED : deleteReason;

    CommandContext commandContext = Context.getCommandContext();

    for (TaskEntity task : tasks) {
        if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                    ActivitiEventBuilder.createActivityCancelledEvent(
                            task.getExecution().getActivityId(),
                            task.getName(),
                            task.getExecutionId(),
                            task.getProcessInstanceId(),
                            task.getProcessDefinitionId(),
                            "userTask", UserTaskActivityBehavior.class.getName(), deleteReason));
        }

        deleteTask(task, reason, cascade);
    }
}
 
Example #6
Source File: AlfrescoUserTaskBpmnParseHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void addListeners(UserTaskActivityBehavior activityBehavior) 
{
    if (createTaskListener != null)
    {
        addTaskListenerAsFirst(createTaskListener, TaskListener.EVENTNAME_CREATE, activityBehavior);
    }
    if (completeTaskListener != null)
    {
        addTaskListenerAsFirst(completeTaskListener, TaskListener.EVENTNAME_COMPLETE, activityBehavior);
    }
    if(notificationTaskListener != null)
    {
        addTaskListenerAsLast(notificationTaskListener, TaskListener.EVENTNAME_CREATE, activityBehavior);
    }
}
 
Example #7
Source File: ProcessDefinitionUtils.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void grantPermission(ActivityImpl activity, String assigneeExpression,
		String candidateGroupIdExpressions, String candidateUserIdExpressions) throws Exception
{
	TaskDefinition taskDefinition = ((UserTaskActivityBehavior) activity.getActivityBehavior()).getTaskDefinition();
	taskDefinition.setAssigneeExpression(assigneeExpression == null ? null : new FixedValue(assigneeExpression));
	FieldUtils.writeField(taskDefinition, "candidateUserIdExpressions",
		ExpressionUtils.stringToExpressionSet(candidateUserIdExpressions), true);
	FieldUtils.writeField(taskDefinition, "candidateGroupIdExpressions",
		ExpressionUtils.stringToExpressionSet(candidateGroupIdExpressions), true);

	Logger.getLogger(ProcessDefinitionUtils.class).info(
		String.format("granting previledges for [%s, %s, %s] on [%s, %s]", assigneeExpression,
			candidateGroupIdExpressions, candidateUserIdExpressions, activity.getProcessDefinition().getKey(),
			activity.getProperty("name")));
}
 
Example #8
Source File: AlfrescoUserTaskBpmnParseHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected List<TaskListener> getOrCreateListenerList(String eventName, UserTaskActivityBehavior userTask) 
{
    List<TaskListener> taskEventListeners = userTask.getTaskDefinition().getTaskListeners().get(eventName);
    if (taskEventListeners == null) {
      taskEventListeners = new ArrayList<TaskListener>();
      userTask.getTaskDefinition().getTaskListeners().put(eventName, taskEventListeners);
    }
    return taskEventListeners;
}
 
Example #9
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 #10
Source File: CustomActivityBehaviorFactory.java    From lemon with Apache License 2.0 4 votes vote down vote up
public UserTaskActivityBehavior createUserTaskActivityBehavior(
        UserTask userTask, TaskDefinition taskDefinition) {
    log.info("change usertask Behavior : {}  ", userTask);

    return new CustomUserTaskActivityBehavior(taskDefinition);
}
 
Example #11
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;
}
 
Example #12
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask, TaskDefinition taskDefinition)
{
	return _source.createUserTaskActivityBehavior(userTask, taskDefinition);
}
 
Example #13
Source File: MyActivityBehaviorFactory.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask, TaskDefinition taskDefinition)
{
	String userTaskId = userTask.getId();
	return new MyUserTaskActivityBehavior(_handlers, userTaskId, taskDefinition);
}
 
Example #14
Source File: DefaultActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask, TaskDefinition taskDefinition) {
    return new UserTaskActivityBehavior(userTask.getId(), taskDefinition);
}
 
Example #15
Source File: TestActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public UserTaskActivityBehavior createUserTaskActivityBehavior(
        UserTask userTask, TaskDefinition taskDefinition) {
    return wrappedActivityBehaviorFactory.createUserTaskActivityBehavior(userTask, taskDefinition);
}
 
Example #16
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) {
  return new UserTaskActivityBehavior(userTask);
}
 
Example #17
Source File: BpmActivityServiceImpl.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #18
Source File: AlfrescoUserTaskBpmnParseHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void addTaskListenerAsLast(TaskListener taskListener, String eventName, UserTaskActivityBehavior userTask) 
{
    getOrCreateListenerList(eventName, userTask).add(taskListener);
}
 
Example #19
Source File: AlfrescoUserTaskBpmnParseHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void addTaskListenerAsFirst(TaskListener taskListener, String eventName, UserTaskActivityBehavior userTask) 
{
    getOrCreateListenerList(eventName, userTask).add(0, taskListener);
}
 
Example #20
Source File: TestActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) {
  return wrappedActivityBehaviorFactory.createUserTaskActivityBehavior(userTask);
}
 
Example #21
Source File: ActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 votes vote down vote up
public abstract UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask, TaskDefinition taskDefinition); 
Example #22
Source File: ActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 votes vote down vote up
public abstract UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask);