Java Code Examples for org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#getStartUserId()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#getStartUserId() .
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: 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 3
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 4
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); } }
Example 5
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; }