本文整理汇总了Java中org.activiti.engine.IdentityService.setAuthenticatedUserId方法的典型用法代码示例。如果您正苦于以下问题:Java IdentityService.setAuthenticatedUserId方法的具体用法?Java IdentityService.setAuthenticatedUserId怎么用?Java IdentityService.setAuthenticatedUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.IdentityService
的用法示例。
在下文中一共展示了IdentityService.setAuthenticatedUserId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startProcess
import org.activiti.engine.IdentityService; //导入方法依赖的package包/类
public String startProcess(String userId, String businessKey,
String processDefinitionId, Map<String, Object> processParameters) {
// 先设置登录用户
IdentityService identityService = processEngine.getIdentityService();
identityService.setAuthenticatedUserId(userId);
ProcessInstance processInstance = processEngine.getRuntimeService()
.startProcessInstanceById(processDefinitionId, businessKey,
processParameters);
/*
* // {流程标题:title}-{发起人:startUser}-{发起时间:startTime} String processDefinitionName =
* processEngine.getRepositoryService() .createProcessDefinitionQuery()
* .processDefinitionId(processDefinitionId).singleResult() .getName(); String processInstanceName =
* processDefinitionName + "-" + userConnector.findById(userId).getDisplayName() + "-" + new
* SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
* processEngine.getRuntimeService().setProcessInstanceName( processInstance.getId(), processInstanceName);
*/
return processInstance.getId();
}
示例2: completeTask
import org.activiti.engine.IdentityService; //导入方法依赖的package包/类
/**
* 完成任务.
*/
public void completeTask(String taskId, String userId,
Map<String, Object> variables) {
TaskService taskService = processEngine.getTaskService();
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task == null) {
throw new IllegalStateException("任务不存在");
}
// 先设置登录用户
IdentityService identityService = processEngine.getIdentityService();
identityService.setAuthenticatedUserId(userId);
// 处理子任务
if ("subtask".equals(task.getCategory())) {
processEngine.getManagementService().executeCommand(
new DeleteTaskWithCommentCmd(taskId, "完成"));
int count = jdbcTemplate.queryForObject(
"select count(*) from ACT_RU_TASK where PARENT_TASK_ID_=?",
Integer.class, task.getParentTaskId());
if (count > 1) {
return;
}
taskId = task.getParentTaskId();
}
processEngine.getManagementService().executeCommand(
new CompleteTaskWithCommentCmd(taskId, variables, "完成"));
}