org.activiti.engine.impl.task.TaskDefinition Java Examples

The following examples show how to use org.activiti.engine.impl.task.TaskDefinition. 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 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 #2
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 #3
Source File: BpmActivityServiceImpl.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
@Override
public List<TaskDefinition> getNextActivities(String procDefId, String activityId, DelegateExecution execution) {
    ActivityImpl activity;
    if (activityId != null) {
        activity = getActivityById(procDefId, activityId);
    } else {
        activity = getStartEvent(procDefId);
    }

    List<PvmTransition> pvmTransitions = activity.getOutgoingTransitions();

    return pvmTransitions.stream()
            .map(PvmTransition::getDestination)
            .map(ActivityImpl.class::cast)          //强转为ActivityImpl
            .filter(Objects::nonNull)
            .map(act -> getTaskDefinition(act, execution)) //获取TaskDefinition集合
            .flatMap(Collection::stream)            //合并集合
            .collect(Collectors.toList());

}
 
Example #4
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get the taskDefinition key based on the Activiti task definition id,
 * @param taskDefinitionKey String
 * @param processDefinitionId String
 * @return WorkflowTaskDefinition
 */
public WorkflowTaskDefinition getTaskDefinition(String taskDefinitionKey, String processDefinitionId)
{
	 ProcessDefinitionEntity procDef = (ProcessDefinitionEntity) activitiUtil.getDeployedProcessDefinition(processDefinitionId);
	 Collection<PvmActivity> userTasks = findUserTasks(procDef.getInitial());
	 
	 TaskDefinition taskDefinition = null;
	 for(PvmActivity activity : userTasks)
	 {
		 taskDefinition = procDef.getTaskDefinitions().get(activity.getId());
		 if(taskDefinitionKey.equals(taskDefinition.getKey()))
		 {
			 String formKey = getFormKey(taskDefinition);
			 WorkflowNode node = convert(activity);
			 return factory.createTaskDefinition(formKey, node, formKey, false);
		 }
	 }
	 
	 return null;
}
 
Example #5
Source File: ProxyUserTaskBpmnParseHandler.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void parse(BpmnParse bpmnParse, BaseElement baseElement) {
    if (!(baseElement instanceof UserTask)) {
        return;
    }

    if (useDefaultUserTaskParser) {
        new UserTaskParseHandler().parse(bpmnParse, baseElement);
    }

    UserTask userTask = (UserTask) baseElement;
    logger.debug("bpmnParse : {}, userTask : {}", bpmnParse, userTask);

    TaskDefinition taskDefinition = (TaskDefinition) bpmnParse
            .getCurrentActivity().getProperty(
                    UserTaskParseHandler.PROPERTY_TASK_DEFINITION);

    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_CREATE);
    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_ASSIGNMENT);
    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_COMPLETE);
    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_DELETE);
}
 
Example #6
Source File: TaskEntity.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public void fireEvent(String taskEventName) {
    TaskDefinition taskDefinition = getTaskDefinition();
    if (taskDefinition != null) {
        List<TaskListener> taskEventListeners = getTaskDefinition().getTaskListener(taskEventName);
        if (taskEventListeners != null) {
            for (TaskListener taskListener : taskEventListeners) {
                ExecutionEntity execution = getExecution();
                if (execution != null) {
                    setEventName(taskEventName);
                }
                try {
                    Context.getProcessEngineConfiguration()
                            .getDelegateInterceptor()
                            .handleInvocation(new TaskListenerInvocation(taskListener, (DelegateTask) this));
                } catch (Exception e) {
                    throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e);
                }
            }
        }
    }
}
 
Example #7
Source File: TaskEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public TaskDefinition getTaskDefinition() {
    if (taskDefinition == null && taskDefinitionKey != null) {
        ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) Context
                .getProcessEngineConfiguration()
                .getDeploymentManager()
                .findDeployedProcessDefinitionById(processDefinitionId);
        taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
    }
    return taskDefinition;
}
 
Example #8
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 #9
Source File: ProxyUserTaskBpmnParseHandler.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void configEvent(TaskDefinition taskDefinition, BpmnParse bpmnParse,
        String eventName) {
    ActivitiListener activitiListener = new ActivitiListener();
    activitiListener.setEvent(eventName);
    activitiListener
            .setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
    activitiListener.setImplementation("#{" + taskListenerId + "}");
    taskDefinition
            .addTaskListener(eventName, bpmnParse.getListenerFactory()
                    .createDelegateExpressionTaskListener(activitiListener));
}
 
Example #10
Source File: UserTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, userTask, BpmnXMLConstants.ELEMENT_TASK_USER);

    activity.setAsync(userTask.isAsynchronous());
    activity.setExclusive(!userTask.isNotExclusive());

    TaskDefinition taskDefinition = parseTaskDefinition(bpmnParse, userTask, userTask.getId(), (ProcessDefinitionEntity) bpmnParse.getCurrentScope().getProcessDefinition());
    activity.setProperty(PROPERTY_TASK_DEFINITION, taskDefinition);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createUserTaskActivityBehavior(userTask, taskDefinition));
}
 
Example #11
Source File: SkipEventListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void doSkip(DelegateTask delegateTask) {
    delegateTask.getExecution().setVariableLocal(
            "_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);

    TaskDefinition taskDefinition = ((TaskEntity) delegateTask)
            .getTaskDefinition();
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();
    Expression expression = expressionManager
            .createExpression("${_ACTIVITI_SKIP_EXPRESSION_ENABLED}");
    taskDefinition.setSkipExpression(expression);
}
 
Example #12
Source File: TaskEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void setTaskDefinition(TaskDefinition taskDefinition) {
    this.taskDefinition = taskDefinition;
    this.taskDefinitionKey = taskDefinition.getKey();

    CommandContext commandContext = Context.getCommandContext();
    if (commandContext != null) {
        commandContext.getHistoryManager().recordTaskDefinitionKeyChange(this, taskDefinitionKey);
    }
}
 
Example #13
Source File: ActivitiInternalProcessConnector.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 获得任务定义.
 */
public List<ProcessTaskDefinition> findTaskDefinitions(
        String processDefinitionId) {
    List<ProcessTaskDefinition> processTaskDefinitions = new ArrayList<ProcessTaskDefinition>();
    FindTaskDefinitionsCmd cmd = new FindTaskDefinitionsCmd(
            processDefinitionId);
    List<TaskDefinition> taskDefinitions = processEngine
            .getManagementService().executeCommand(cmd);

    for (TaskDefinition taskDefinition : taskDefinitions) {
        ProcessTaskDefinition processTaskDefinition = new ProcessTaskDefinition();
        processTaskDefinition.setKey(taskDefinition.getKey());

        if (taskDefinition.getNameExpression() != null) {
            processTaskDefinition.setName(taskDefinition
                    .getNameExpression().getExpressionText());
        }

        if (taskDefinition.getAssigneeExpression() != null) {
            processTaskDefinition.setAssignee(taskDefinition
                    .getAssigneeExpression().getExpressionText());
        }

        processTaskDefinitions.add(processTaskDefinition);
    }

    return processTaskDefinitions;
}
 
Example #14
Source File: BpmResource.java    From lemon with Apache License 2.0 5 votes vote down vote up
public List<ActivityDTO> convertActivityDtoFromTaskDefinitions(
        List<TaskDefinition> taskDefinitions) {
    List<ActivityDTO> activityDtos = new ArrayList<ActivityDTO>();

    for (TaskDefinition taskDefinition : taskDefinitions) {
        ActivityDTO activityDto = new ActivityDTO();
        activityDto.setId(taskDefinition.getKey());
        activityDto.setName(taskDefinition.getNameExpression()
                .getExpressionText());
        activityDtos.add(activityDto);
    }

    return activityDtos;
}
 
Example #15
Source File: FindTaskDefinitionsCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public List<TaskDefinition> execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId).execute(commandContext);

    List<TaskDefinition> taskDefinitions = new ArrayList<TaskDefinition>();
    taskDefinitions.addAll(processDefinitionEntity.getTaskDefinitions()
            .values());

    return taskDefinitions;
}
 
Example #16
Source File: FlowableProcessController.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
@PostMapping("/next-task-candidate/{taskId}")
@Authorize(merge = false)
public ResponseMessage<List<CandidateDetail>> candidateList(@PathVariable String taskId,
                                                            @RequestBody Map<String, Object> data,
                                                            Authentication authentication) {

    Task task = taskService.createTaskQuery()
            .taskId(taskId)
            .singleResult();

    ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery()
            .processInstanceId(task.getProcessInstanceId())
            .activityId(task.getTaskDefinitionKey())
            .singleResult();

    execution.setTransientVariables(data);

    List<TaskDefinition> taskDefinitions = bpmActivityService
            .getNextActivities(task.getProcessDefinitionId(), task.getTaskDefinitionKey(), (execution));

    List<CandidateDetail> candidates = taskDefinitions.stream().map(TaskDefinition::getKey)
            .flatMap(key ->
                    processConfigurationService
                            .getActivityConfiguration(authentication.getUser().getId(), task.getProcessDefinitionId(), key)
                            .getCandidateInfo(task)
                            .stream())
            .distinct()
            .map(CandidateDetail::of)
            .collect(Collectors.toList());


    return ResponseMessage.ok(candidates);
}
 
Example #17
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String getFormKey(TaskDefinition taskDefinition) 
{
	 TaskFormHandler handler = taskDefinition.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 #18
Source File: FindFirstTaskFormCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
public FirstTaskForm execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getDeploymentManager()
            .findDeployedProcessDefinitionById(processDefinitionId);

    if (processDefinitionEntity == null) {
        throw new IllegalArgumentException(
                "cannot find processDefinition : " + processDefinitionId);
    }

    if (processDefinitionEntity.hasStartFormKey()) {
        return this.findStartEventForm(processDefinitionEntity);
    }

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.info("first activity is not userTask, just skip");

        return new FirstTaskForm();
    }

    FirstTaskForm firstTaskForm = new FirstTaskForm();
    firstTaskForm.setProcessDefinitionId(processDefinitionId);
    firstTaskForm.setExists(true);
    firstTaskForm.setTaskForm(true);

    String taskDefinitionKey = targetActivity.getId();
    logger.debug("activityId : {}", targetActivity.getId());
    firstTaskForm.setActivityId(taskDefinitionKey);

    TaskDefinition taskDefinition = processDefinitionEntity
            .getTaskDefinitions().get(taskDefinitionKey);

    Expression expression = taskDefinition.getAssigneeExpression();

    if (expression != null) {
        String expressionText = expression.getExpressionText();
        logger.debug("{}", expressionText);
        logger.debug("{}", startActivity.getProperties());
        logger.debug("{}", processDefinitionEntity.getProperties());
        firstTaskForm.setAssignee(expressionText);
    } else {
        logger.info("cannot find expression : {}, {}", processDefinitionId,
                taskDefinitionKey);
    }

    String initiatorVariableName = (String) processDefinitionEntity
            .getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
    firstTaskForm.setInitiatorName(initiatorVariableName);

    DefaultFormHandler formHandler = (DefaultFormHandler) taskDefinition
            .getTaskFormHandler();

    if (formHandler.getFormKey() != null) {
        String formKey = formHandler.getFormKey().getExpressionText();
        firstTaskForm.setFormKey(formKey);
    } else {
        logger.info("cannot find formKey from xml : {}, {}",
                processDefinitionId, taskDefinitionKey);
    }

    return firstTaskForm;
}
 
Example #19
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 #20
Source File: CustomUserTaskActivityBehavior.java    From lemon with Apache License 2.0 4 votes vote down vote up
public CustomUserTaskActivityBehavior(TaskDefinition taskDefinition) {
    super(taskDefinition);
    jdbcTemplate = ProcessEngineBeanFactory.getBean("jdbcTemplate");
}
 
Example #21
Source File: AutoCompleteFirstTaskEventListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
public void onCreate(DelegateTask delegateTask) throws Exception {
    String initiatorId = Authentication.getAuthenticatedUserId();

    if (initiatorId == null) {
        return;
    }

    String assignee = delegateTask.getAssignee();

    if (assignee == null) {
        return;
    }

    if (!initiatorId.equals(assignee)) {
        return;
    }

    PvmActivity targetActivity = this.findFirstActivity(delegateTask
            .getProcessDefinitionId());
    logger.debug("targetActivity : {}", targetActivity);

    if (!targetActivity.getId().equals(
            delegateTask.getExecution().getCurrentActivityId())) {
        return;
    }

    logger.debug("auto complete first task : {}", delegateTask);

    for (IdentityLink identityLink : delegateTask.getCandidates()) {
        String userId = identityLink.getUserId();
        String groupId = identityLink.getGroupId();

        if (userId != null) {
            delegateTask.deleteCandidateUser(userId);
        }

        if (groupId != null) {
            delegateTask.deleteCandidateGroup(groupId);
        }
    }

    // 对提交流程的任务进行特殊处理
    HumanTaskDTO humanTaskDto = humanTaskConnector
            .findHumanTaskByTaskId(delegateTask.getId());
    humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    humanTaskConnector.saveHumanTask(humanTaskDto);

    // ((TaskEntity) delegateTask).complete();
    // Context.getCommandContext().getHistoryManager().recordTaskId((TaskEntity) delegateTask);
    // Context.getCommandContext().getHistoryManager().recordTaskId((TaskEntity) delegateTask);
    // new CompleteTaskWithCommentCmd(delegateTask.getId(), null, "发起流程")
    // .execute(Context.getCommandContext());

    // 因为recordTaskId()会判断endTime,而complete以后会导致endTime!=null,
    // 所以才会出现record()放在complete后面导致taskId没记录到historyActivity里的情况
    delegateTask.getExecution().setVariableLocal(
            "_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);

    TaskDefinition taskDefinition = ((TaskEntity) delegateTask)
            .getTaskDefinition();
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();
    Expression expression = expressionManager
            .createExpression("${_ACTIVITI_SKIP_EXPRESSION_ENABLED}");
    taskDefinition.setSkipExpression(expression);
}
 
Example #22
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
/**
 * 根据任务历史,创建待办任务.
 */
public void processHistoryTask(CommandContext commandContext,
        TaskEntity taskEntity,
        HistoricTaskInstanceEntity historicTaskInstanceEntity,
        HistoricActivityInstanceEntity historicActivityInstanceEntity) {
    if (this.userId == null) {
        if (this.useLastAssignee) {
            this.userId = historicTaskInstanceEntity.getAssignee();
        } else {
            String processDefinitionId = taskEntity
                    .getProcessDefinitionId();
            ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
                    processDefinitionId).execute(commandContext);
            TaskDefinition taskDefinition = processDefinitionEntity
                    .getTaskDefinitions().get(
                            historicTaskInstanceEntity
                                    .getTaskDefinitionKey());

            if (taskDefinition == null) {
                String message = "cannot find taskDefinition : "
                        + historicTaskInstanceEntity.getTaskDefinitionKey();
                logger.info(message);
                throw new IllegalStateException(message);
            }

            if (taskDefinition.getAssigneeExpression() != null) {
                logger.info("assignee expression is null : {}",
                        taskDefinition.getKey());
                this.userId = (String) taskDefinition
                        .getAssigneeExpression().getValue(taskEntity);
            }
        }
    }

    /*
     * historicTaskInstanceEntity.setEndTime(null); historicTaskInstanceEntity.setDurationInMillis(null);
     * historicActivityInstanceEntity.setEndTime(null); historicActivityInstanceEntity.setDurationInMillis(null);
     */

    // 创建新任务
    TaskEntity task = TaskEntity.create(new Date());
    task.setProcessDefinitionId(historicTaskInstanceEntity
            .getProcessDefinitionId());
    // task.setId(historicTaskInstanceEntity.getId());
    task.setAssigneeWithoutCascade(userId);
    task.setParentTaskIdWithoutCascade(historicTaskInstanceEntity
            .getParentTaskId());
    task.setNameWithoutCascade(historicTaskInstanceEntity.getName());
    task.setTaskDefinitionKey(historicTaskInstanceEntity
            .getTaskDefinitionKey());
    task.setExecutionId(historicTaskInstanceEntity.getExecutionId());
    task.setPriority(historicTaskInstanceEntity.getPriority());
    task.setProcessInstanceId(historicTaskInstanceEntity
            .getProcessInstanceId());
    task.setExecutionId(historicTaskInstanceEntity.getExecutionId());
    task.setDescriptionWithoutCascade(historicTaskInstanceEntity
            .getDescription());
    task.setTenantId(historicTaskInstanceEntity.getTenantId());

    Context.getCommandContext().getTaskEntityManager().insert(task);

    // 把流程指向任务对应的节点
    ExecutionEntity executionEntity = Context.getCommandContext()
            .getExecutionEntityManager()
            .findExecutionById(historicTaskInstanceEntity.getExecutionId());
    executionEntity
            .setActivity(getActivity(historicActivityInstanceEntity));

    // 创建HistoricActivityInstance
    Context.getCommandContext().getHistoryManager()
            .recordActivityStart(executionEntity);

    // 创建HistoricTaskInstance
    Context.getCommandContext().getHistoryManager()
            .recordTaskCreated(task, executionEntity);
    Context.getCommandContext().getHistoryManager().recordTaskId(task);
    // 更新ACT_HI_ACTIVITY里的assignee字段
    Context.getCommandContext().getHistoryManager()
            .recordTaskAssignment(task);

    try {
        // humanTask
        this.createHumanTask(task, historicTaskInstanceEntity);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
Example #23
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 #24
Source File: RuntimeActivityCreatorSupport.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected TaskDefinition cloneTaskDefinition(TaskDefinition taskDefinition)
{
	TaskDefinition newTaskDefinition = new TaskDefinition(taskDefinition.getTaskFormHandler());
	BeanUtils.copyProperties(taskDefinition, newTaskDefinition);
	return newTaskDefinition;
}
 
Example #25
Source File: MyUserTaskActivityBehavior.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public MyUserTaskActivityBehavior(List<TaskAssignmentHandler> handlers, String userTaskId, TaskDefinition taskDefinition)
{
	super(userTaskId, taskDefinition);
	_handlers = handlers;
}
 
Example #26
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 #27
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 #28
Source File: UserTaskHistoryParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, UserTask element) {
    TaskDefinition taskDefinition = (TaskDefinition) bpmnParse.getCurrentActivity().getProperty(UserTaskParseHandler.PROPERTY_TASK_DEFINITION);
    taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, USER_TASK_ASSIGNMENT_HANDLER);
    taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, USER_TASK_ID_HANDLER);
}
 
Example #29
Source File: UserTaskActivityBehavior.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public TaskDefinition getTaskDefinition() {
    return taskDefinition;
}
 
Example #30
Source File: UserTaskActivityBehavior.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public UserTaskActivityBehavior(String userTaskId, TaskDefinition taskDefinition) {
    this.userTaskId = userTaskId;
    this.taskDefinition = taskDefinition;
}