Java Code Examples for org.activiti.engine.delegate.DelegateTask#getProcessInstanceId()
The following examples show how to use
org.activiti.engine.delegate.DelegateTask#getProcessInstanceId() .
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: SkipTaskListener.java From lemon with Apache License 2.0 | 6 votes |
public void processPosition(DelegateTask delegateTask, String value) { String processInstanceId = delegateTask.getProcessInstanceId(); HistoricProcessInstanceEntity historicProcessInstanceEntity = Context .getCommandContext().getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); String initiator = historicProcessInstanceEntity.getStartUserId(); OrgConnector orgConnector = (OrgConnector) ApplicationContextHelper .getBean(OrgConnector.class); // 获得发起人的职位 int initiatorLevel = orgConnector.getJobLevelByUserId(initiator); // 获得审批人的职位 int assigneeLevel = orgConnector.getJobLevelByUserId(delegateTask .getAssignee()); // 比较 if (initiatorLevel >= assigneeLevel) { logger.info("skip task : {}", delegateTask.getId()); logger.info("initiatorLevel : {}, assigneeLevel : {}", initiatorLevel, assigneeLevel); new CompleteTaskWithCommentCmd(delegateTask.getId(), Collections.<String, Object> emptyMap(), "高级职位自动跳过") .execute(Context.getCommandContext()); } }
Example 2
Source File: LeaveModifyProcessor.java From Shop-for-JavaWeb with MIT License | 5 votes |
public void notify(DelegateTask delegateTask) { String processInstanceId = delegateTask.getProcessInstanceId(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); Leave leave = new Leave(processInstance.getBusinessKey()); leave.setLeaveType((String) delegateTask.getVariable("leaveType")); leave.setStartTime((Date) delegateTask.getVariable("startTime")); leave.setEndTime((Date) delegateTask.getVariable("endTime")); leave.setReason((String) delegateTask.getVariable("reason")); leave.preUpdate(); leaveDao.update(leave); }
Example 3
Source File: LeaveReportProcessor.java From Shop-for-JavaWeb with MIT License | 5 votes |
/** * 销假完成后执行,保存实际开始和结束时间 */ public void notify(DelegateTask delegateTask) { String processInstanceId = delegateTask.getProcessInstanceId(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); Leave leave = new Leave(processInstance.getBusinessKey()); leave.setRealityStartTime((Date) delegateTask.getVariable("realityStartTime")); leave.setRealityEndTime((Date) delegateTask.getVariable("realityEndTime")); leave.preUpdate(); leaveDao.updateRealityTime(leave); }
Example 4
Source File: AfterModifyApplyContentProcessor.java From maven-framework-project with MIT License | 5 votes |
public void notify(DelegateTask delegateTask) { String processInstanceId = delegateTask.getProcessInstanceId(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); Leave leave = leaveService.findById(processInstance.getBusinessKey()); leave.setLeaveType((String) delegateTask.getVariable("leaveType")); leave.setStartTime((Date) delegateTask.getVariable("startTime")); leave.setEndTime((Date) delegateTask.getVariable("endTime")); leave.setReason((String) delegateTask.getVariable("reason")); leaveService.save(leave); }
Example 5
Source File: ReportBackEndProcessor.java From maven-framework-project with MIT License | 5 votes |
public void notify(DelegateTask delegateTask) { String processInstanceId = delegateTask.getProcessInstanceId(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); Leave leave = leaveService.findById(processInstance.getBusinessKey()); Object realityStartTime = delegateTask.getVariable("realityStartTime"); leave.setRealityStartTime((Date) realityStartTime); Object realityEndTime = delegateTask.getVariable("realityEndTime"); leave.setRealityEndTime((Date) realityEndTime); leaveService.save(leave); }
Example 6
Source File: SkipTaskListener.java From lemon with Apache License 2.0 | 5 votes |
@Override public void onCreate(DelegateTask delegateTask) throws Exception { String taskDefinitionKey = delegateTask.getTaskDefinitionKey(); String processDefinitionId = delegateTask.getProcessDefinitionId(); String processInstanceId = delegateTask.getProcessInstanceId(); HistoricProcessInstanceEntity historicProcessInstanceEntity = Context .getCommandContext().getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); List<BpmConfRule> bpmConfRules = ApplicationContextHelper .getBean(BpmConfRuleManager.class) .find("from BpmConfRule where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?", processDefinitionId, taskDefinitionKey); logger.debug("delegateTask.getId : {}", delegateTask.getId()); logger.debug("taskDefinitionKey : {}", taskDefinitionKey); logger.debug("processDefinitionId : {}", processDefinitionId); logger.debug("processInstanceId : {}", processInstanceId); logger.debug("bpmConfRules : {}", bpmConfRules); for (BpmConfRule bpmConfRule : bpmConfRules) { String value = bpmConfRule.getValue(); if ("职位".equals(value) || "高级职位自动跳过".equals(value)) { this.processPosition(delegateTask, value); } else if ("相邻相同人员自动跳过".equals(value)) { this.processNeighbor(delegateTask, value); } else { this.processExpression(delegateTask, value); } } }
Example 7
Source File: SkipTaskListener.java From lemon with Apache License 2.0 | 5 votes |
public void processExpression(DelegateTask delegateTask, String value) { UserConnector userConnector = ApplicationContextHelper .getBean(UserConnector.class); ExpressionManager expressionManager = Context .getProcessEngineConfiguration().getExpressionManager(); String processInstanceId = delegateTask.getProcessInstanceId(); HistoricProcessInstanceEntity historicProcessInstanceEntity = Context .getCommandContext().getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); String initiator = historicProcessInstanceEntity.getStartUserId(); MapVariableScope mapVariableScope = new MapVariableScope(); mapVariableScope.setVariable("initiator", userConnector.findById(initiator)); Object objectResult = expressionManager.createExpression(value) .getValue(mapVariableScope); if ((objectResult == null) || (!(objectResult instanceof Boolean))) { logger.error("{} is not Boolean, just return", objectResult); return; } Boolean result = (Boolean) objectResult; logger.info("value : {}, result : {}", value, result); if (result) { logger.info("skip task : {}", delegateTask.getId()); new CompleteTaskWithCommentCmd(delegateTask.getId(), Collections.<String, Object> emptyMap(), "跳过") .execute(Context.getCommandContext()); } }
Example 8
Source File: AssigneeAliasTaskListener.java From lemon with Apache License 2.0 | 5 votes |
public void processSuperior(DelegateTask delegateTask, AssigneeRule assigneeRule, String value) { String processInstanceId = delegateTask.getProcessInstanceId(); String startUserId = Context.getCommandContext() .getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId) .getStartUserId(); String userId = assigneeRule.process(startUserId); logger.debug("userId : {}", userId); delegateTask.setAssignee(userId); }
Example 9
Source File: AssigneeAliasTaskListener.java From lemon with Apache License 2.0 | 5 votes |
public void processPosition(DelegateTask delegateTask, AssigneeRule assigneeRule, String value) { String processInstanceId = delegateTask.getProcessInstanceId(); String startUserId = Context.getCommandContext() .getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId) .getStartUserId(); List<String> userIds = assigneeRule.process(value, startUserId); logger.debug("userIds : {}", userIds); if (!userIds.isEmpty()) { delegateTask.setAssignee(userIds.get(0)); } }
Example 10
Source File: SkipEventListener.java From lemon with Apache License 2.0 | 5 votes |
public void onCreate(DelegateTask delegateTask) throws Exception { String taskDefinitionKey = delegateTask.getTaskDefinitionKey(); String processDefinitionId = delegateTask.getProcessDefinitionId(); String processInstanceId = delegateTask.getProcessInstanceId(); HistoricProcessInstanceEntity historicProcessInstanceEntity = Context .getCommandContext().getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); List<BpmConfRule> bpmConfRules = ApplicationContextHelper .getBean(BpmConfRuleManager.class) .find("from BpmConfRule where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?", processDefinitionId, taskDefinitionKey); logger.debug("delegateTask.getId : {}", delegateTask.getId()); logger.debug("taskDefinitionKey : {}", taskDefinitionKey); logger.debug("processDefinitionId : {}", processDefinitionId); logger.debug("processInstanceId : {}", processInstanceId); logger.debug("bpmConfRules : {}", bpmConfRules); for (BpmConfRule bpmConfRule : bpmConfRules) { String value = bpmConfRule.getValue(); if ("职位".equals(value) || "高级职位自动跳过".equals(value)) { this.processPosition(delegateTask, value); } else if ("相邻相同人员自动跳过".equals(value)) { this.processNeighbor(delegateTask, value); } else { this.processExpression(delegateTask, value); } } }
Example 11
Source File: SkipEventListener.java From lemon with Apache License 2.0 | 5 votes |
public void processPosition(DelegateTask delegateTask, String value) { String processInstanceId = delegateTask.getProcessInstanceId(); HistoricProcessInstanceEntity historicProcessInstanceEntity = Context .getCommandContext().getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); String initiator = historicProcessInstanceEntity.getStartUserId(); OrgConnector orgConnector = (OrgConnector) ApplicationContextHelper .getBean(OrgConnector.class); // 获得发起人的职位 int initiatorLevel = orgConnector.getJobLevelByUserId(initiator); // 获得审批人的职位 int assigneeLevel = orgConnector.getJobLevelByUserId(delegateTask .getAssignee()); // 比较 if (initiatorLevel >= assigneeLevel) { logger.info("skip task : {}", delegateTask.getId()); logger.info("initiatorLevel : {}, assigneeLevel : {}", initiatorLevel, assigneeLevel); // new CompleteTaskWithCommentCmd(delegateTask.getId(), // Collections.<String, Object> emptyMap(), "高级职位自动跳过") // .execute(Context.getCommandContext()); this.doSkip(delegateTask); } }
Example 12
Source File: SkipEventListener.java From lemon with Apache License 2.0 | 5 votes |
public void processExpression(DelegateTask delegateTask, String value) { UserConnector userConnector = ApplicationContextHelper .getBean(UserConnector.class); ExpressionManager expressionManager = Context .getProcessEngineConfiguration().getExpressionManager(); String processInstanceId = delegateTask.getProcessInstanceId(); HistoricProcessInstanceEntity historicProcessInstanceEntity = Context .getCommandContext().getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); String initiator = historicProcessInstanceEntity.getStartUserId(); MapVariableScope mapVariableScope = new MapVariableScope(); mapVariableScope.setVariable("initiator", userConnector.findById(initiator)); Object objectResult = expressionManager.createExpression(value) .getValue(mapVariableScope); if ((objectResult == null) || (!(objectResult instanceof Boolean))) { logger.error("{} is not Boolean, just return", objectResult); return; } Boolean result = (Boolean) objectResult; logger.info("value : {}, result : {}", value, result); if (result) { logger.info("skip task : {}", delegateTask.getId()); // new CompleteTaskWithCommentCmd(delegateTask.getId(), // Collections.<String, Object> emptyMap(), "跳过") // .execute(Context.getCommandContext()); this.doSkip(delegateTask); } }