Flowable-6.7.2 源码注释地址:https://github.com/solojin/flowable-6.7.2-annotated
TaskActivityBehavior 任务活动行为类
/**
* 任务活动行为类
*
* 所有BPMN 2.0任务类型(如ServiceTask、ScriptTask、UserTask等)的父类。
*
* 单独使用时,它的行为就像一个传递活动。
*
* @author Joram Barrez
*/
public class TaskActivityBehavior extends AbstractBpmnActivityBehavior {
private static final long serialVersionUID = 1L;
protected List<String> getActiveValueList(List<String> originalValues, String propertyName, ObjectNode taskElementProperties) {
List<String> activeValues = originalValues;
if (taskElementProperties != null) {
JsonNode overrideValuesNode = taskElementProperties.get(propertyName);
if (overrideValuesNode != null) {
if (overrideValuesNode.isNull() || !overrideValuesNode.isArray() || overrideValuesNode.size() == 0) {
activeValues = null;
} else {
activeValues = new ArrayList<>();
for (JsonNode valueNode : overrideValuesNode) {
activeValues.add(valueNode.asText());
}
}
}
}
return activeValues;
}
}
UserTaskActivityBehavior 用户任务活动行为类
/**
* 用户任务活动行为类
*
* @author Joram Barrez
*/
public class UserTaskActivityBehavior extends TaskActivityBehavior implements ActivityWithMigrationContextBehavior {
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LoggerFactory.getLogger(UserTaskActivityBehavior.class);
protected UserTask userTask;
public UserTaskActivityBehavior(UserTask userTask) {
this.userTask = userTask;
}
@Override
public void execute(DelegateExecution execution) {
execute(execution, null);
}
@Override
public void execute(DelegateExecution execution, MigrationContext migrationContext) {
CommandContext commandContext = CommandContextUtil.getCommandContext();
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
TaskService taskService = processEngineConfiguration.getTaskServiceConfiguration().getTaskService();
TaskEntity task = taskService.createTask();
task.setExecutionId(execution.getId());
task.setTaskDefinitionKey(userTask.getId());
task.setPropagatedStageInstanceId(execution.getPropagatedStageInstanceId());
String activeTaskName = null;
String activeTaskDescription = null;
String activeTaskDueDate = null;
String activeTaskPriority = null;
String activeTaskCategory = null;
String activeTaskFormKey = null;
String activeTaskSkipExpression = null;
String activeTaskAssignee = null;
String activeTaskOwner = null;
String activeTaskIdVariableName = null;
List<String> activeTaskCandidateUsers = null;
List<String> activeTaskCandidateGroups = null;
ExpressionManager expressionManager = processEngineConfiguration.getExpressionManager();
if (processEngineConfiguration.isEnableProcessDefinitionInfoCache()) {
ObjectNode taskElementProperties = BpmnOverrideContext.getBpmnOverrideElementProperties(userTask.getId(), execution.getProcessDefinitionId());
activeTaskName = DynamicPropertyUtil.getActiveValue(userTask.getName(), DynamicBpmnConstants.USER_TASK_NAME, taskElementProperties);
activeTaskDescription = DynamicPropertyUtil.getActiveValue(userTask.getDocumentation(), DynamicBpmnConstants.USER_TASK_DESCRIPTION, taskElementProperties);
activeTaskDueDate = DynamicPropertyUtil.getActiveValue(userTask.getDueDate(), DynamicBpmnConstants.USER_TASK_DUEDATE, taskElementProperties);
activeTaskPriority = DynamicPropertyUtil.getActiveValue(userTask.getPriority(), DynamicBpmnConstants.USER_TASK_PRIORITY, taskElementProperties);
activeTaskCategory = DynamicPropertyUtil.getActiveValue(userTask.getCategory(), DynamicBpmnConstants.USER_TASK_CATEGORY, taskElementProperties);
activeTaskFormKey = DynamicPropertyUtil.getActiveValue(userTask.getFormKey(), DynamicBpmnConstants.USER_TASK_FORM_KEY, taskElementProperties);
activeTaskSkipExpression = DynamicPropertyUtil.getActiveValue(userTask.getSkipExpression(), DynamicBpmnConstants.TASK_SKIP_EXPRESSION, taskElementProperties);
activeTaskAssignee = getAssigneeValue(userTask, migrationContext, taskElementProperties);
activeTaskOwner = DynamicPropertyUtil.getActiveValue(userTask.getOwner(), DynamicBpmnConstants.USER_TASK_OWNER, taskElementProperties);
activeTaskCandidateUsers = getActiveValueList(userTask.getCandidateUsers(), DynamicBpmnConstants.USER_TASK_CANDIDATE_USERS, taskElementProperties);
activeTaskCandidateGroups = getActiveValueList(userTask.getCandidateGroups(), DynamicBpmnConstants.USER_TASK_CANDIDATE_GROUPS, taskElementProperties);
activeTaskIdVariableName = DynamicPropertyUtil.getActiveValue(userTask.getTaskIdVariableName(), DynamicBpmnConstants.USER_TASK_TASK_ID_VARIABLE_NAME, taskElementProperties);
} else {
activeTaskName = userTask.getName();
activeTaskDescription = userTask.getDocumentation();
activeTaskDueDate = userTask.getDueDate();
activeTaskPriority = userTask.getPriority();
activeTaskCategory = userTask.getCategory();
activeTaskFormKey = userTask