本文整理汇总了Java中org.activiti.engine.delegate.DelegateTask.getCandidates方法的典型用法代码示例。如果您正苦于以下问题:Java DelegateTask.getCandidates方法的具体用法?Java DelegateTask.getCandidates怎么用?Java DelegateTask.getCandidates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.delegate.DelegateTask
的用法示例。
在下文中一共展示了DelegateTask.getCandidates方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHumanTask
import org.activiti.engine.delegate.DelegateTask; //导入方法依赖的package包/类
public HumanTaskDTO createHumanTask(DelegateTask delegateTask)
throws Exception {
HumanTaskDTO humanTaskDto = new HumanTaskBuilder()
.setDelegateTask(delegateTask)
.setVote(this.isVote(delegateTask)).build();
humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto);
logger.debug("candidates : {}", delegateTask.getCandidates());
for (IdentityLink identityLink : delegateTask.getCandidates()) {
String type = identityLink.getType();
ParticipantDTO participantDto = new ParticipantDTO();
participantDto.setType(type);
participantDto.setHumanTaskId(humanTaskDto.getId());
if ("user".equals(type)) {
participantDto.setCode(identityLink.getUserId());
} else {
participantDto.setCode(identityLink.getGroupId());
}
humanTaskConnector.saveParticipant(participantDto);
}
return humanTaskDto;
}
示例2: onCreate
import org.activiti.engine.delegate.DelegateTask; //导入方法依赖的package包/类
@Override
public void onCreate(DelegateTask delegateTask) throws Exception {
String initiatorId = Authentication.getAuthenticatedUserId();
if (initiatorId == null) {
return;
}
String assignee = delegateTask.getAssignee();
if (assignee == null) {
return;
}
PvmActivity targetActivity = this.findFirstActivity(delegateTask
.getProcessDefinitionId());
if (!targetActivity.getId().equals(
delegateTask.getExecution().getCurrentActivityId())) {
return;
}
if (!initiatorId.equals(assignee)) {
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);
new CompleteTaskWithCommentCmd(delegateTask.getId(), null, "发起流程")
.execute(Context.getCommandContext());
}
示例3: onCreate
import org.activiti.engine.delegate.DelegateTask; //导入方法依赖的package包/类
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);
}
示例4: notifyMidpointAboutTaskEvent
import org.activiti.engine.delegate.DelegateTask; //导入方法依赖的package包/类
public void notifyMidpointAboutTaskEvent(DelegateTask delegateTask) {
OperationResult result = new OperationResult(DOT_CLASS + "notifyMidpointAboutTaskEvent");
TaskEvent taskEvent;
if (TaskListener.EVENTNAME_CREATE.equals(delegateTask.getEventName())) {
taskEvent = new TaskCreatedEvent(); // TODO distinguish created vs. assigned event
} else if (TaskListener.EVENTNAME_COMPLETE.equals(delegateTask.getEventName())) {
taskEvent = new TaskCompletedEvent();
} else if (TaskListener.EVENTNAME_DELETE.equals(delegateTask.getEventName())) {
taskEvent = new TaskDeletedEvent();
} else {
return; // ignoring other events
}
taskEvent.setVariables(delegateTask.getVariables());
taskEvent.setAssigneeOid(delegateTask.getAssignee());
taskEvent.setTaskId(delegateTask.getId());
taskEvent.setTaskName(delegateTask.getName());
taskEvent.setProcessInstanceName((String) delegateTask.getVariable(CommonProcessVariableNames.VARIABLE_PROCESS_INSTANCE_NAME));
taskEvent.setProcessInstanceId(delegateTask.getProcessInstanceId());
taskEvent.setCreateTime(delegateTask.getCreateTime());
taskEvent.setDueDate(delegateTask.getDueDate());
taskEvent.setExecutionId(delegateTask.getExecutionId());
taskEvent.setOwner(delegateTask.getOwner());
for (IdentityLink identityLink : delegateTask.getCandidates()) {
if (identityLink.getUserId() != null) {
taskEvent.getCandidateUsers().add(identityLink.getUserId());
} else if (identityLink.getGroupId() != null) {
taskEvent.getCandidateGroups().add(identityLink.getGroupId());
} else {
throw new IllegalStateException("Neither candidate user nor group id is provided in delegateTask: " + delegateTask);
}
}
try {
WorkItemType workItem = workItemProvider.taskEventToWorkItemNew(taskEvent, null, true, true, true, result);
wfTaskController.onTaskEvent(workItem, taskEvent, result);
} catch (Exception e) { // todo fix the exception processing e.g. think about situation where an event cannot be audited - should we allow to proceed?
String message = "Couldn't process an event coming from the workflow management system";
LoggingUtils.logUnexpectedException(LOGGER, message, e);
result.recordFatalError(message, e);
}
}