org.activiti.engine.impl.identity.Authentication Java Examples
The following examples show how to use
org.activiti.engine.impl.identity.Authentication.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpressionManagerTest.java From activiti6-boot2 with Apache License 2.0 | 7 votes |
@Deployment public void testAuthenticatedUserIdAvailable() { try { // Setup authentication Authentication.setAuthenticatedUserId("frederik"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testAuthenticatedUserIdAvailableProcess"); // Check if the variable that has been set in service-task is the authenticated user String value = (String) runtimeService.getVariable(processInstance.getId(), "theUser"); assertNotNull(value); assertEquals("frederik", value); } finally { // Cleanup Authentication.setAuthenticatedUserId(null); } }
Example #2
Source File: ProcessServiceImpl.java From open-cloud with MIT License | 6 votes |
/** * 执行任务 * * @param taskOperate */ @Override public void complete(TaskOperate taskOperate) { String taskId = taskOperate.getTaskId(); String user = taskOperate.getUser(); // 放入流程变量 Map<String, Object> variables = Maps.newHashMap(); // 设置任务变量_OPT variables.put(BpmConstants.TASK_OPERATE_KEY, taskOperate); // 使用任务id,获取任务对象,获取流程实例id Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); if (task == null) { throw new OpenAlertException("任务不存在"); } //利用任务对象,获取流程实例id String processInstancesId = task.getProcessInstanceId(); //由于流程用户上下文对象是线程独立的,所以要在需要的位置设置,要保证设置和获取操作在同一个线程中 //批注人的名称 一定要写,不然查看的时候不知道人物信息 Authentication.setAuthenticatedUserId(user); taskService.addComment(taskId, processInstancesId, taskOperate.getOperateType().name(), taskOperate.getComment()); //执行任务 completeTask(taskOperate.getTaskId(), variables); }
Example #3
Source File: FunctionEventListener.java From lemon with Apache License 2.0 | 6 votes |
public void onProcessCompleted(ActivitiEntityEvent event) { logger.debug("process completed {}", event); String processInstanceId = event.getProcessInstanceId(); ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(processInstanceId); String businessKey = executionEntity.getBusinessKey(); String processDefinitionId = event.getProcessDefinitionId(); String activityId = ""; String activityName = this.findActivityName(activityId, processDefinitionId); int eventCode = 24; String eventName = "process-end"; String userId = Authentication.getAuthenticatedUserId(); this.invokeExpression(eventCode, eventName, businessKey, userId, activityId, activityName); }
Example #4
Source File: FunctionEventListener.java From lemon with Apache License 2.0 | 6 votes |
public void onTaskCompleted(ActivitiEntityEvent event) { logger.debug("task completed {}", event); String processInstanceId = event.getProcessInstanceId(); ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(processInstanceId); String businessKey = executionEntity.getBusinessKey(); String processDefinitionId = event.getProcessDefinitionId(); Task task = (Task) event.getEntity(); String activityId = task.getTaskDefinitionKey(); String activityName = this.findActivityName(activityId, processDefinitionId); int eventCode = 5; String eventName = "complete"; String userId = Authentication.getAuthenticatedUserId(); this.invokeExpression(eventCode, eventName, businessKey, userId, activityId, activityName); }
Example #5
Source File: FunctionEventListener.java From lemon with Apache License 2.0 | 6 votes |
public void onProcessCancelled(ActivitiCancelledEvent event) { logger.debug("process cancelled {}", event); String processInstanceId = event.getProcessInstanceId(); ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(processInstanceId); String businessKey = executionEntity.getBusinessKey(); String processDefinitionId = event.getProcessDefinitionId(); String activityId = ""; String activityName = this.findActivityName(activityId, processDefinitionId); int eventCode = 23; String eventName = "process-close"; String userId = Authentication.getAuthenticatedUserId(); this.invokeExpression(eventCode, eventName, businessKey, userId, activityId, activityName); }
Example #6
Source File: FunctionEventListener.java From lemon with Apache License 2.0 | 6 votes |
public void onActivityEnd(ActivitiActivityEvent event) { logger.debug("activity end {}", event); String processInstanceId = event.getProcessInstanceId(); ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(processInstanceId); String businessKey = executionEntity.getBusinessKey(); String processDefinitionId = event.getProcessDefinitionId(); String activityId = event.getActivityId(); String activityName = this.findActivityName(activityId, processDefinitionId); int eventCode = 1; String eventName = "end"; String userId = Authentication.getAuthenticatedUserId(); this.invokeExpression(eventCode, eventName, businessKey, userId, activityId, activityName); }
Example #7
Source File: FunctionEventListener.java From lemon with Apache License 2.0 | 6 votes |
public void onActivityStart(ActivitiActivityEvent event) { logger.debug("activity start {}", event); String processInstanceId = event.getProcessInstanceId(); ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(processInstanceId); String businessKey = executionEntity.getBusinessKey(); String processDefinitionId = event.getProcessDefinitionId(); String activityId = event.getActivityId(); String activityName = this.findActivityName(activityId, processDefinitionId); int eventCode = 0; String eventName = "start"; String userId = Authentication.getAuthenticatedUserId(); this.invokeExpression(eventCode, eventName, businessKey, userId, activityId, activityName); }
Example #8
Source File: HumanTaskTaskListener.java From lemon with Apache License 2.0 | 6 votes |
@Override public void onDelete(DelegateTask delegateTask) throws Exception { HumanTaskDTO humanTaskDto = humanTaskConnector .findHumanTaskByTaskId(delegateTask.getId()); if (humanTaskDto == null) { return; } if (!"complete".equals(humanTaskDto.getStatus())) { humanTaskDto.setStatus("delete"); humanTaskDto.setCompleteTime(new Date()); humanTaskDto.setAction("人工终止"); humanTaskDto.setOwner(humanTaskDto.getAssignee()); humanTaskDto.setAssignee(Authentication.getAuthenticatedUserId()); humanTaskConnector.saveHumanTask(humanTaskDto, false); } }
Example #9
Source File: DeleteTaskWithCommentCmd.java From lemon with Apache License 2.0 | 6 votes |
public Object execute(CommandContext commandContext) { TaskEntity taskEntity = commandContext.getTaskEntityManager() .findTaskById(taskId); // taskEntity.fireEvent(TaskListener.EVENTNAME_COMPLETE); if ((Authentication.getAuthenticatedUserId() != null) && (taskEntity.getProcessInstanceId() != null)) { taskEntity.getProcessInstance().involveUser( Authentication.getAuthenticatedUserId(), IdentityLinkType.PARTICIPANT); } Context.getCommandContext().getTaskEntityManager() .deleteTask(taskEntity, comment, false); if (taskEntity.getExecutionId() != null) { ExecutionEntity execution = taskEntity.getExecution(); execution.removeTask(taskEntity); // execution.signal(null, null); } return null; }
Example #10
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) { if (isHistoryEnabled()) { String userId = Authentication.getAuthenticatedUserId(); CommentEntity comment = new CommentEntity(); comment.setUserId(userId); comment.setType(CommentEntity.TYPE_EVENT); comment.setTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime()); comment.setTaskId(taskId); comment.setProcessInstanceId(processInstanceId); if (create) { comment.setAction(Event.ACTION_ADD_ATTACHMENT); } else { comment.setAction(Event.ACTION_DELETE_ATTACHMENT); } comment.setMessage(attachmentName); getSession(CommentEntityManager.class).insert(comment); } }
Example #11
Source File: HistoricProcessInstanceEntity.java From flowable-engine with Apache License 2.0 | 6 votes |
public HistoricProcessInstanceEntity(ExecutionEntity processInstance) { id = processInstance.getId(); processInstanceId = processInstance.getId(); businessKey = processInstance.getBusinessKey(); processDefinitionId = processInstance.getProcessDefinitionId(); processDefinitionKey = processInstance.getProcessDefinitionKey(); processDefinitionName = processInstance.getProcessDefinitionName(); processDefinitionVersion = processInstance.getProcessDefinitionVersion(); deploymentId = processInstance.getDeploymentId(); startTime = Context.getProcessEngineConfiguration().getClock().getCurrentTime(); startUserId = Authentication.getAuthenticatedUserId(); startActivityId = processInstance.getActivityId(); superProcessInstanceId = processInstance.getSuperExecution() != null ? processInstance.getSuperExecution().getProcessInstanceId() : null; // Inherit tenant id (if applicable) if (processInstance.getTenantId() != null) { tenantId = processInstance.getTenantId(); } }
Example #12
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) { if (isHistoryEnabled()) { String userId = Authentication.getAuthenticatedUserId(); CommentEntity comment = getCommentEntityManager().create(); comment.setUserId(userId); comment.setType(CommentEntity.TYPE_EVENT); comment.setTime(getClock().getCurrentTime()); comment.setTaskId(taskId); comment.setProcessInstanceId(processInstanceId); if (create) { comment.setAction(Event.ACTION_ADD_ATTACHMENT); } else { comment.setAction(Event.ACTION_DELETE_ATTACHMENT); } comment.setMessage(attachmentName); getCommentEntityManager().insert(comment); } }
Example #13
Source File: IdentityLinkEventsTest.java From flowable-engine with Apache License 2.0 | 6 votes |
/** * Check deletion of links on process instances. */ @Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void testProcessInstanceIdentityDeleteCandidateGroupEvents() throws Exception { Authentication.setAuthenticatedUserId(null); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertNotNull(task); // Add identity link taskService.addCandidateUser(task.getId(), "kermit"); taskService.addCandidateGroup(task.getId(), "sales"); // Three events are received, since the user link on the task also creates an involvement in the process. See previous test assertEquals(6, listener.getEventsReceived().size()); listener.clearEventsReceived(); taskService.deleteCandidateUser(task.getId(), "kermit"); assertEquals(1, listener.getEventsReceived().size()); listener.clearEventsReceived(); taskService.deleteCandidateGroup(task.getId(), "sales"); assertEquals(1, listener.getEventsReceived().size()); }
Example #14
Source File: ProcessInstanceIdentityLinksTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/activiti/engine/test/api/runtime/IdentityLinksProcess.bpmn20.xml") public void testCustomLinkGroupLink() { Authentication.setAuthenticatedUserId(null); runtimeService.startProcessInstanceByKey("IdentityLinksProcess"); String processInstanceId = runtimeService .createProcessInstanceQuery() .singleResult() .getId(); runtimeService.addGroupIdentityLink(processInstanceId, "muppets", "playing"); List<IdentityLink> identityLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId); IdentityLink identityLink = identityLinks.get(0); assertEquals("muppets", identityLink.getGroupId()); assertNull("kermit", identityLink.getUserId()); assertEquals("playing", identityLink.getType()); assertEquals(processInstanceId, identityLink.getProcessInstanceId()); assertEquals(1, identityLinks.size()); runtimeService.deleteGroupIdentityLink(processInstanceId, "muppets", "playing"); assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstanceId).size()); }
Example #15
Source File: ExpressionManagerTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testAuthenticatedUserIdAvailable() { try { // Setup authentication Authentication.setAuthenticatedUserId("frederik"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testAuthenticatedUserIdAvailableProcess"); // Check if the variable that has been set in service-task is the // authenticated user String value = (String) runtimeService.getVariable(processInstance.getId(), "theUser"); assertNotNull(value); assertEquals("frederik", value); } finally { // Cleanup Authentication.setAuthenticatedUserId(null); } }
Example #16
Source File: ProcessInstanceIdentityLinksTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/activiti/engine/test/api/runtime/IdentityLinksProcess.bpmn20.xml") public void testCustomTypeUserLink() { Authentication.setAuthenticatedUserId(null); runtimeService.startProcessInstanceByKey("IdentityLinksProcess"); String processInstanceId = runtimeService .createProcessInstanceQuery() .singleResult() .getId(); runtimeService.addUserIdentityLink(processInstanceId, "kermit", "interestee"); List<IdentityLink> identityLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId); IdentityLink identityLink = identityLinks.get(0); assertNull(identityLink.getGroupId()); assertEquals("kermit", identityLink.getUserId()); assertEquals("interestee", identityLink.getType()); assertEquals(processInstanceId, identityLink.getProcessInstanceId()); assertEquals(1, identityLinks.size()); runtimeService.deleteUserIdentityLink(processInstanceId, "kermit", "interestee"); assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstanceId).size()); }
Example #17
Source File: ProcessInstanceIdentityLinksTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/activiti/engine/test/api/runtime/IdentityLinksProcess.bpmn20.xml") public void testParticipantUserLink() { Authentication.setAuthenticatedUserId(null); runtimeService.startProcessInstanceByKey("IdentityLinksProcess"); String processInstanceId = runtimeService .createProcessInstanceQuery() .singleResult() .getId(); runtimeService.addParticipantUser(processInstanceId, "kermit"); List<IdentityLink> identityLinks = runtimeService.getIdentityLinksForProcessInstance(processInstanceId); IdentityLink identityLink = identityLinks.get(0); assertNull(identityLink.getGroupId()); assertEquals("kermit", identityLink.getUserId()); assertEquals(IdentityLinkType.PARTICIPANT, identityLink.getType()); assertEquals(processInstanceId, identityLink.getProcessInstanceId()); assertEquals(1, identityLinks.size()); runtimeService.deleteParticipantUser(processInstanceId, "kermit"); assertEquals(0, runtimeService.getIdentityLinksForProcessInstance(processInstanceId).size()); }
Example #18
Source File: PurchaseApplyUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 6 votes |
public boolean completeTask(@RequestBody PurchaseApplyDto purchaseApplyDto) { TaskService taskService = processEngine.getTaskService(); Task task = taskService.createTaskQuery().taskId(purchaseApplyDto.getTaskId()).singleResult(); String processInstanceId = task.getProcessInstanceId(); Authentication.setAuthenticatedUserId(purchaseApplyDto.getCurrentUserId()); taskService.addComment(purchaseApplyDto.getTaskId(), processInstanceId, purchaseApplyDto.getAuditMessage()); Map<String, Object> variables = new HashMap<String, Object>(); variables.put("auditCode", purchaseApplyDto.getAuditCode()); variables.put("currentUserId", purchaseApplyDto.getCurrentUserId()); variables.put("nextAuditStaffId",purchaseApplyDto.getStaffId()); //taskService.setAssignee(complaintDto.getTaskId(),complaintDto.getCurrentUserId()); //taskService.addCandidateUser(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); //taskService.claim(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); taskService.complete(purchaseApplyDto.getTaskId(), variables); //taskService.setVariable(purchaseApplyDto.getTaskId(), "purchaseApplyDto", purchaseApplyDto); ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (pi == null) { return true; } return false; }
Example #19
Source File: ComplaintUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 6 votes |
public boolean completeTask(@RequestBody ComplaintDto complaintDto) { TaskService taskService = processEngine.getTaskService(); Task task = taskService.createTaskQuery().taskId(complaintDto.getTaskId()).singleResult(); String processInstanceId = task.getProcessInstanceId(); Authentication.setAuthenticatedUserId(complaintDto.getCurrentUserId()); taskService.addComment(complaintDto.getTaskId(), processInstanceId, complaintDto.getAuditMessage()); Map<String, Object> variables = new HashMap<String, Object>(); variables.put("auditCode", complaintDto.getAuditCode()); variables.put("currentUserId", complaintDto.getCurrentUserId()); variables.put("flag", "1200".equals(complaintDto.getAuditCode()) ? "false" : "true"); variables.put("startUserId", complaintDto.getStartUserId()); //taskService.setAssignee(complaintDto.getTaskId(),complaintDto.getCurrentUserId()); //taskService.addCandidateUser(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); //taskService.claim(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); taskService.complete(complaintDto.getTaskId(), variables); ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (pi == null) { return true; } return false; }
Example #20
Source File: HistoricProcessInstanceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti/engine/test/history/oneTaskProcess.bpmn20.xml" }) public void testHistoricIdenityLinksOnProcessInstance() { Authentication.setAuthenticatedUserId(null); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.addUserIdentityLink(pi.getId(), "kermit", "myType"); // Check historic links List<HistoricIdentityLink> historicLinks = historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()); assertEquals(1, historicLinks.size()); assertEquals("myType", historicLinks.get(0).getType()); assertEquals("kermit", historicLinks.get(0).getUserId()); assertNull(historicLinks.get(0).getGroupId()); assertEquals(pi.getId(), historicLinks.get(0).getProcessInstanceId()); // When process is ended, link should remain taskService.complete(taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult().getId()); assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult()); assertEquals(1, historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()).size()); // When process is deleted, identitylinks shouldn't exist anymore historyService.deleteHistoricProcessInstance(pi.getId()); assertEquals(0, historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()).size()); } }
Example #21
Source File: TaskEntity.java From flowable-engine with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") public void complete(Map variablesMap, boolean localScope, boolean fireEvents) { if (getDelegationState() != null && getDelegationState() == DelegationState.PENDING) { throw new ActivitiException("A delegated task cannot be completed, but should be resolved instead."); } if (fireEvents) { fireEvent(TaskListener.EVENTNAME_COMPLETE); } if (Authentication.getAuthenticatedUserId() != null && processInstanceId != null) { getProcessInstance().involveUser(Authentication.getAuthenticatedUserId(), IdentityLinkType.PARTICIPANT); } if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled() && fireEvents) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityWithVariablesEvent(FlowableEngineEventType.TASK_COMPLETED, this, variablesMap, localScope)); } Context .getCommandContext() .getTaskEntityManager() .deleteTask(this, TaskEntity.DELETE_REASON_COMPLETED, false); if (executionId != null) { ExecutionEntity execution = getExecution(); execution.removeTask(this); execution.signal(null, null); } }
Example #22
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void createProcessInstanceIdentityLinkComment(String processInstanceId, String userId, String groupId, String type, boolean create, boolean forceNullUserId) { if (isHistoryEnabled()) { String authenticatedUserId = Authentication.getAuthenticatedUserId(); CommentEntity comment = new CommentEntity(); comment.setUserId(authenticatedUserId); comment.setType(CommentEntity.TYPE_EVENT); comment.setTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime()); comment.setProcessInstanceId(processInstanceId); if (userId != null || forceNullUserId) { if (create) { comment.setAction(Event.ACTION_ADD_USER_LINK); } else { comment.setAction(Event.ACTION_DELETE_USER_LINK); } comment.setMessage(new String[] { userId, type }); } else { if (create) { comment.setAction(Event.ACTION_ADD_GROUP_LINK); } else { comment.setAction(Event.ACTION_DELETE_GROUP_LINK); } comment.setMessage(new String[] { groupId, type }); } getSession(CommentEntityManager.class).insert(comment); } }
Example #23
Source File: WorkspaceController.java From lemon with Apache License 2.0 | 5 votes |
@RequestMapping("workspace-endProcessInstance") public String endProcessInstance( @RequestParam("processInstanceId") String processInstanceId) { Authentication.setAuthenticatedUserId(currentUserHolder.getUserId()); processEngine.getRuntimeService().deleteProcessInstance( processInstanceId, "人工终止"); return "redirect:/bpm/workspace-listRunningProcessInstances.do"; }
Example #24
Source File: AbstractProcessEngineTest.java From openwebflow with BSD 2-Clause "Simplified" License | 5 votes |
/** * 测试后加签 */ @Test public void testInsertTasksAfter() throws Exception { ProcessInstance instance = _processEngine.getRuntimeService().startProcessInstanceByKey("test2"); TaskService taskService = _processEngine.getTaskService(); TaskFlowControlService tfcs = _taskFlowControlServiceFactory.create(instance.getId()); //到了step2 Assert.assertEquals("step2", taskService.createTaskQuery().singleResult().getTaskDefinitionKey()); //在前面加两个节点 Authentication.setAuthenticatedUserId("kermit"); ActivityImpl[] as = tfcs.insertTasksAfter("step2", "bluejoe", "alex"); //应该执行到了第一个节点 Assert.assertEquals(as[0].getId(), taskService.createTaskQuery().singleResult().getTaskDefinitionKey()); Assert.assertEquals("kermit", taskService.createTaskQuery().singleResult().getAssignee()); //完成该节点 taskService.complete(taskService.createTaskQuery().singleResult().getId()); //应该到了下一个节点 Assert.assertEquals(as[1].getId(), taskService.createTaskQuery().singleResult().getTaskDefinitionKey()); Assert.assertEquals("bluejoe", taskService.createTaskQuery().singleResult().getAssignee()); //完成该节点 taskService.complete(taskService.createTaskQuery().singleResult().getId()); //应该到了下一个节点 Assert.assertEquals(as[2].getId(), taskService.createTaskQuery().singleResult().getTaskDefinitionKey()); Assert.assertEquals("alex", taskService.createTaskQuery().singleResult().getAssignee()); //完成该节点 taskService.complete(taskService.createTaskQuery().singleResult().getId()); //应该到了下一个节点 Assert.assertEquals("step3", taskService.createTaskQuery().singleResult().getTaskDefinitionKey()); //确认历史轨迹里已保存 //step1,step2,step2,step2-1,step2-2,step3 List<HistoricActivityInstance> activities = _processEngine.getHistoryService() .createHistoricActivityInstanceQuery().processInstanceId(instance.getId()).list(); Assert.assertEquals(6, activities.size()); //删掉流程 _processEngine.getRuntimeService().deleteProcessInstance(instance.getId(), "test"); }
Example #25
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void createIdentityLinkComment(String taskId, String userId, String groupId, String type, boolean create, boolean forceNullUserId) { if (isHistoryEnabled()) { String authenticatedUserId = Authentication.getAuthenticatedUserId(); CommentEntity comment = new CommentEntity(); comment.setUserId(authenticatedUserId); comment.setType(CommentEntity.TYPE_EVENT); comment.setTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime()); comment.setTaskId(taskId); if (userId != null || forceNullUserId) { if (create) { comment.setAction(Event.ACTION_ADD_USER_LINK); } else { comment.setAction(Event.ACTION_DELETE_USER_LINK); } comment.setMessage(new String[] { userId, type }); } else { if (create) { comment.setAction(Event.ACTION_ADD_GROUP_LINK); } else { comment.setAction(Event.ACTION_DELETE_GROUP_LINK); } comment.setMessage(new String[] { groupId, type }); } getSession(CommentEntityManager.class).insert(comment); } }
Example #26
Source File: HumanTaskEventListener.java From lemon with Apache License 2.0 | 5 votes |
public void onDelete(DelegateTask delegateTask) throws Exception { HumanTaskDTO humanTaskDto = humanTaskConnector .findHumanTaskByTaskId(delegateTask.getId()); if (humanTaskDto == null) { return; } if ("complete".equals(humanTaskDto.getStatus())) { return; } logger.info(delegateTask.getId()); HistoricTaskInstance historicTaskInstance = Context.getCommandContext().getHistoricTaskInstanceEntityManager() .findHistoricTaskInstanceById(delegateTask.getId()); if ("驳回".equals(historicTaskInstance.getDeleteReason())) { humanTaskDto.setStatus("delete"); humanTaskDto.setCompleteTime(new Date()); humanTaskDto.setAction("驳回"); humanTaskDto.setOwner(humanTaskDto.getAssignee()); humanTaskDto.setAssignee(Authentication.getAuthenticatedUserId()); humanTaskConnector.saveHumanTask(humanTaskDto, false); } else { humanTaskDto.setStatus("delete"); humanTaskDto.setCompleteTime(new Date()); humanTaskDto.setAction("作废"); humanTaskDto.setOwner(humanTaskDto.getAssignee()); humanTaskDto.setAssignee(Authentication.getAuthenticatedUserId()); humanTaskConnector.saveHumanTask(humanTaskDto, false); } }
Example #27
Source File: FormLeaveController.java From my_curd with Apache License 2.0 | 5 votes |
/** * 新增 action */ @TxConfig(ActivitiConfig.DATASOURCE_NAME) @Before(Tx.class) public void addAction() { // 保存业务表 FormLeave formLeave = getBean(FormLeave.class, ""); formLeave.setId(IdUtils.id()) .setCreater(WebUtils.getSessionUsername(this)) .setCreateTime(new Date()); formLeave.save(); //发起流程 String businessFormInfoId = getPara("businessFormInfoId"); if (StringUtils.isEmpty(businessFormInfoId)) { renderFail("businessFormInfoId 参数为空"); return; } BusinessFormInfo info = BusinessFormInfo.dao.findById(businessFormInfoId); if (info == null) { renderFail("businessFormInfoId 参数错误"); return; } SysUser sysUser = WebUtils.getSysUser(this); String processInstanceName = info.getName() + "-( " + sysUser.getRealName() + new DateTime(formLeave.getCreateTime()).toString(" yyyy/MM/dd HH:mm )"); Authentication.setAuthenticatedUserId(WebUtils.getSessionUsername(this)); ProcessInstanceBuilder builder = ActivitiKit.getRuntimeService().createProcessInstanceBuilder() .processDefinitionKey(info.getProcessKey()) .businessKey(formLeave.getId()) .processInstanceName(processInstanceName) .addVariable("businessForm", info.getFormName()); builder.start(); renderSuccess(NEW_PROCESS_SUCCESS); }
Example #28
Source File: HumanTaskBuilder.java From lemon with Apache License 2.0 | 5 votes |
public HumanTaskBuilder setDelegateTask(DelegateTask delegateTask) { humanTaskDto.setBusinessKey(delegateTask.getExecution() .getProcessBusinessKey()); humanTaskDto.setName(delegateTask.getName()); humanTaskDto.setDescription(delegateTask.getDescription()); humanTaskDto.setCode(delegateTask.getTaskDefinitionKey()); humanTaskDto.setAssignee(delegateTask.getAssignee()); humanTaskDto.setOwner(delegateTask.getOwner()); humanTaskDto.setDelegateStatus("none"); humanTaskDto.setPriority(delegateTask.getPriority()); humanTaskDto.setCreateTime(new Date()); humanTaskDto.setDuration(delegateTask.getDueDate() + ""); humanTaskDto.setSuspendStatus("none"); humanTaskDto.setCategory(delegateTask.getCategory()); humanTaskDto.setForm(delegateTask.getFormKey()); humanTaskDto.setTaskId(delegateTask.getId()); humanTaskDto.setExecutionId(delegateTask.getExecutionId()); humanTaskDto.setProcessInstanceId(delegateTask.getProcessInstanceId()); humanTaskDto.setProcessDefinitionId(delegateTask .getProcessDefinitionId()); humanTaskDto.setTenantId(delegateTask.getTenantId()); humanTaskDto.setStatus("active"); humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_NORMAL); ExecutionEntity executionEntity = (ExecutionEntity) delegateTask .getExecution(); ExecutionEntity processInstance = executionEntity.getProcessInstance(); humanTaskDto.setPresentationSubject(processInstance.getName()); String userId = Authentication.getAuthenticatedUserId(); humanTaskDto.setProcessStarter(userId); return this; }
Example #29
Source File: DefaultTaskFlowControlService.java From openwebflow with BSD 2-Clause "Simplified" License | 5 votes |
/** * 后加签 */ @Override public ActivityImpl[] insertTasksAfter(String targetTaskDefinitionKey, String... assignees) throws Exception { List<String> assigneeList = new ArrayList<String>(); assigneeList.add(Authentication.getAuthenticatedUserId()); assigneeList.addAll(CollectionUtils.arrayToList(assignees)); String[] newAssignees = assigneeList.toArray(new String[0]); ActivityImpl prototypeActivity = ProcessDefinitionUtils.getActivity(_processEngine, _processDefinition.getId(), targetTaskDefinitionKey); return cloneAndMakeChain(targetTaskDefinitionKey, prototypeActivity.getOutgoingTransitions().get(0) .getDestination().getId(), newAssignees); }
Example #30
Source File: ReOpenProcessCmd.java From lemon with Apache License 2.0 | 5 votes |
public Void execute(CommandContext commandContext) { HistoricProcessInstanceEntity historicProcessInstanceEntity = commandContext .getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(historicProcessInstanceId); if (historicProcessInstanceEntity.getEndTime() == null) { logger.info("historicProcessInstanceId is running"); return null; } historicProcessInstanceEntity.setEndActivityId(null); historicProcessInstanceEntity.setEndTime(null); String processDefinitionId = historicProcessInstanceEntity .getProcessDefinitionId(); String initiator = historicProcessInstanceEntity.getStartUserId(); String businessKey = historicProcessInstanceEntity.getBusinessKey(); ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(commandContext); // ExecutionEntity processInstance = processDefinition // .createProcessInstance(businessKey); ExecutionEntity processInstance = this.createProcessInstance( historicProcessInstanceEntity.getId(), businessKey, initiator, processDefinition); try { Authentication.setAuthenticatedUserId(initiator); // start processInstance.start(); } finally { Authentication.setAuthenticatedUserId(null); } return null; }