本文整理汇总了Java中org.activiti.engine.TaskService.claim方法的典型用法代码示例。如果您正苦于以下问题:Java TaskService.claim方法的具体用法?Java TaskService.claim怎么用?Java TaskService.claim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.TaskService
的用法示例。
在下文中一共展示了TaskService.claim方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: claimWorkItem
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
public void claimWorkItem(String workItemId, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException {
OperationResult result = parentResult.createSubresult(OPERATION_CLAIM_WORK_ITEM);
result.addParam("workItemId", workItemId);
try {
MidPointPrincipal principal = securityEnforcer.getPrincipal();
result.addContext("user", toShortString(principal.getUser()));
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Claiming work item {} by {}", workItemId, toShortString(principal.getUser()));
}
TaskService taskService = activitiEngine.getTaskService();
Task task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
if (task.getAssignee() != null) {
String desc = MiscDataUtil.stringToRef(task.getAssignee()).getOid().equals(principal.getOid()) ? "the current" : "another";
throw new SystemException("The work item is already assigned to "+desc+" user");
}
if (!miscDataUtil.isAuthorizedToClaim(task.getId())) {
throw new SecurityViolationException("You are not authorized to claim the selected work item.");
}
taskService.claim(workItemId, principal.getOid());
task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
setNewAssignees(task, Collections.singletonList(ObjectTypeUtil.createObjectRef(principal.getOid(), ObjectTypes.USER)), taskService);
} catch (ObjectNotFoundException|SecurityViolationException|RuntimeException e) {
result.recordFatalError("Couldn't claim the work item " + workItemId + ": " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
示例2: claimTask
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
/**
* 认领任务(对应的是在组任务,即从组任务中领取任务)
*
* @return
*/
@RequestMapping("workspace-claimTask")
public String claimTask(@RequestParam("taskId") String taskId) {
String userId = currentUserHolder.getUserId();
TaskService taskService = processEngine.getTaskService();
taskService.claim(taskId, userId);
return "redirect:/bpm/workspace-listPersonalTasks.do";
}
示例3: claimWorkItem
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
public void claimWorkItem(String workItemId, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException {
OperationResult result = parentResult.createSubresult(OPERATION_CLAIM_WORK_ITEM);
result.addParam("workItemId", workItemId);
try {
MidPointPrincipal principal = securityContextManager.getPrincipal();
result.addContext("user", toShortString(principal.getUser()));
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Claiming work item {} by {}", workItemId, toShortString(principal.getUser()));
}
TaskService taskService = activitiEngine.getTaskService();
Task task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
if (task.getAssignee() != null) {
String desc = MiscDataUtil.stringToRef(task.getAssignee()).getOid().equals(principal.getOid()) ? "the current" : "another";
throw new SystemException("The work item is already assigned to "+desc+" user");
}
if (!miscDataUtil.isAuthorizedToClaim(task.getId())) {
throw new SecurityViolationException("You are not authorized to claim the selected work item.");
}
taskService.claim(workItemId, principal.getOid());
task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
setNewAssignees(task, Collections.singletonList(ObjectTypeUtil.createObjectRef(principal.getOid(), ObjectTypes.USER)), taskService);
} catch (ObjectNotFoundException|SecurityViolationException|RuntimeException e) {
result.recordFatalError("Couldn't claim the work item " + workItemId + ": " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
示例4: main
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
// Build process enigne
ProcessEngine processEngine = new StandaloneInMemProcessEngineConfiguration()
// enable process definition info cache
.setEnableProcessDefinitionInfoCache(true)
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
// deploy process definition
repositoryService.createDeployment()
.addClasspathResource("dynamic-user-task.bpmn20.xml")
.deploy();
String processDefinitionId = repositoryService.createProcessDefinitionQuery()
.singleResult().getId();
// change user task candidate groups
DynamicBpmnService dynamicBpmnService = processEngine.getDynamicBpmnService();
ObjectNode infoNode = dynamicBpmnService
.changeUserTaskCandidateGroup("userTask",
"management", true);
dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
// start a process instance
runtimeService.startProcessInstanceByKey("dynamic-user-task");
TaskService taskService = processEngine.getTaskService();
// tasks claimable by users group
long count = taskService.createTaskQuery()
.taskCandidateGroup("users").count();
System.out.println("tasks claimable by users group " + count);
// fetch the task (tasks claimable by management group)
Task task = taskService.createTaskQuery()
.taskCandidateGroup("management")
.singleResult();
// claim task and complete
taskService.claim(task.getId(), "manager");
taskService.complete(task.getId());
}