Java Code Examples for org.activiti.engine.impl.task.TaskDefinition#setKey()

The following examples show how to use org.activiti.engine.impl.task.TaskDefinition#setKey() . 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: 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 2
Source File: UserTaskParseHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public TaskDefinition parseTaskDefinition(BpmnParse bpmnParse, UserTask userTask, String taskDefinitionKey, ProcessDefinitionEntity processDefinition) {
    TaskFormHandler taskFormHandler = new DefaultTaskFormHandler();
    taskFormHandler.parseConfiguration(userTask.getFormProperties(), userTask.getFormKey(), bpmnParse.getDeployment(), processDefinition);

    TaskDefinition taskDefinition = new TaskDefinition(taskFormHandler);

    taskDefinition.setKey(taskDefinitionKey);
    processDefinition.getTaskDefinitions().put(taskDefinitionKey, taskDefinition);
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();

    if (StringUtils.isNotEmpty(userTask.getName())) {
        taskDefinition.setNameExpression(expressionManager.createExpression(userTask.getName()));
    }

    if (StringUtils.isNotEmpty(userTask.getDocumentation())) {
        taskDefinition.setDescriptionExpression(expressionManager.createExpression(userTask.getDocumentation()));
    }

    if (StringUtils.isNotEmpty(userTask.getAssignee())) {
        taskDefinition.setAssigneeExpression(expressionManager.createExpression(userTask.getAssignee()));
    }
    if (StringUtils.isNotEmpty(userTask.getOwner())) {
        taskDefinition.setOwnerExpression(expressionManager.createExpression(userTask.getOwner()));
    }
    for (String candidateUser : userTask.getCandidateUsers()) {
        taskDefinition.addCandidateUserIdExpression(expressionManager.createExpression(candidateUser));
    }
    for (String candidateGroup : userTask.getCandidateGroups()) {
        taskDefinition.addCandidateGroupIdExpression(expressionManager.createExpression(candidateGroup));
    }

    // Activiti custom extension

    // Task listeners
    for (FlowableListener taskListener : userTask.getTaskListeners()) {
        taskDefinition.addTaskListener(taskListener.getEvent(), createTaskListener(bpmnParse, taskListener, userTask.getId()));
    }

    // Due date
    if (StringUtils.isNotEmpty(userTask.getDueDate())) {
        taskDefinition.setDueDateExpression(expressionManager.createExpression(userTask.getDueDate()));
    }

    // Business calendar name
    if (StringUtils.isNotEmpty(userTask.getBusinessCalendarName())) {
        taskDefinition.setBusinessCalendarNameExpression(expressionManager.createExpression(userTask.getBusinessCalendarName()));
    } else {
        taskDefinition.setBusinessCalendarNameExpression(expressionManager.createExpression(DueDateBusinessCalendar.NAME));
    }

    // Category
    if (StringUtils.isNotEmpty(userTask.getCategory())) {
        taskDefinition.setCategoryExpression(expressionManager.createExpression(userTask.getCategory()));
    }

    // Priority
    if (StringUtils.isNotEmpty(userTask.getPriority())) {
        taskDefinition.setPriorityExpression(expressionManager.createExpression(userTask.getPriority()));
    }

    if (StringUtils.isNotEmpty(userTask.getFormKey())) {
        taskDefinition.setFormKeyExpression(expressionManager.createExpression(userTask.getFormKey()));
    }

    // CustomUserIdentityLinks
    for (String customUserIdentityLinkType : userTask.getCustomUserIdentityLinks().keySet()) {
        Set<Expression> userIdentityLinkExpression = new HashSet<>();
        for (String userIdentityLink : userTask.getCustomUserIdentityLinks().get(customUserIdentityLinkType)) {
            userIdentityLinkExpression.add(expressionManager.createExpression(userIdentityLink));
        }
        taskDefinition.addCustomUserIdentityLinkExpression(customUserIdentityLinkType, userIdentityLinkExpression);
    }

    // CustomGroupIdentityLinks
    for (String customGroupIdentityLinkType : userTask.getCustomGroupIdentityLinks().keySet()) {
        Set<Expression> groupIdentityLinkExpression = new HashSet<>();
        for (String groupIdentityLink : userTask.getCustomGroupIdentityLinks().get(customGroupIdentityLinkType)) {
            groupIdentityLinkExpression.add(expressionManager.createExpression(groupIdentityLink));
        }
        taskDefinition.addCustomGroupIdentityLinkExpression(customGroupIdentityLinkType, groupIdentityLinkExpression);
    }

    if (StringUtils.isNotEmpty(userTask.getSkipExpression())) {
        taskDefinition.setSkipExpression(expressionManager.createExpression(userTask.getSkipExpression()));
    }

    return taskDefinition;
}