// 根据任务定义上不同的策略调用不同的策略分配类
// 为了兼容老的系统,当没有找到 assignPolicyType 类型的时候 就默认按照
// bpmn2:potentialOwner bpmn2:humanPerformer 两种类型来分配任务
// taskDefinition
AssignPolicyType assignPolicyType = taskDefinition.getAssignPolicyType();
if (assignPolicyType == null) {
List<TaskAssigneeDefinitionTo> taskAssigneeDefinitionTos = taskDefinition.getTaskAssigneeDefinitionTos();
for (TaskAssigneeDefinitionTo taskAssigneeDefinitionTo : taskAssigneeDefinitionTos) {
if (taskAssigneeDefinitionTo.getUserIdExpression() != null) {
List<String> resultList = executionExpression(taskAssigneeDefinitionTo.getUserIdExpression(), executionContext);
if (resultList.size() > 0) {
for (String userId : resultList) {
if (userId != null && !userId.equals("")) {
if (taskAssigneeDefinitionTo.getIdentityLinkType().toString().equals(IdentityLinkType.assignee.toString())) {
// assignable.addAssigneeUser(userId,
// taskAssigneeDefinitionTo.getIncludeExclusion());
if (userId.equals("fixflow_allusers")) {
throw new FixFlowException("任务分配给所有人的时候不能采用独占方式分配,请重新修改节点 " + ((TaskInstance) assignable).getNodeId()
+ " 的任务分配定义");
}
assignable.setAssignee(userId);
} else {
assignable.addCandidateUser(userId, taskAssigneeDefinitionTo.getIncludeExclusion());
}
}
}
}
}
if (taskAssigneeDefinitionTo.getGroupIdExpression() != null) {
List<String> resultList = executionExpression(taskAssigneeDefinitionTo.getGroupIdExpression(), executionContext);
if (resultList.size() > 0) {
for (String groupId : resultList) {
if (groupId != null && !groupId.equals("")) {
if (taskAssigneeDefinitionTo.isContainsSub) {
List<GroupTo> groupTos = null;
try {
groupTos = Authentication.findGroupChildMembersIncludeByGroupId(groupId,
taskAssigneeDefinitionTo.getGroupTypeExpression());
} catch (Exception e) {
throw new FixFlowException("节点 " + ((TaskInstance) assignable).getNodeId() + " 的任务获取子分配组出错!", e);
}
if (groupTos != null) {
for (GroupTo groupTo : groupTos) {
GroupTo groupToObj = new GroupTo(groupTo.getGroupId(), taskAssigneeDefinitionTo.getGroupTypeExpression());
assignable.addCandidateGroup(groupToObj, taskAssigneeDefinitionTo.getIncludeExclusion());
}
} else {
throw new FixFlowException("节点 " + ((TaskInstance) assignable).getNodeId() + " 的任务获取子分配组出错!");
}
} else {
GroupTo groupTo = new GroupTo(groupId, taskAssigneeDefinitionTo.getGroupTypeExpression());
assignable.addCandidateGroup(groupTo, taskAssigneeDefinitionTo.getIncludeExclusion());
}
}
}
}
}
}
} else {
String typeId = assignPolicyType.getId();
AssignPolicyConfig assignPolicyConfig = Context.getProcessEngineConfiguration().getAssignPolicyConfig();
AssignPolicy assignPolicy = null;
for (AssignPolicy assignPolicyObj : assignPolicyConfig.getAssignPolicy()) {
if (assignPolicyObj.getId().equals(typeId)) {
assignPolicy = assignPolicyObj;