org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntity Java Examples
The following examples show how to use
org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntity.
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: RollbackCmd.java From lemon with Apache License 2.0 | 6 votes |
public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity( String historyTaskId) { logger.info("historyTaskId : {}", historyTaskId); JdbcTemplate jdbcTemplate = ApplicationContextHelper .getBean(JdbcTemplate.class); String historicActivityInstanceId = jdbcTemplate.queryForObject( "select id_ from ACT_HI_ACTINST where task_id_=?", String.class, historyTaskId); logger.info("historicActivityInstanceId : {}", historicActivityInstanceId); HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl(); historicActivityInstanceQueryImpl .activityInstanceId(historicActivityInstanceId); HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) Context .getCommandContext() .getHistoricActivityInstanceEntityManager() .findHistoricActivityInstancesByQueryCriteria( historicActivityInstanceQueryImpl, new Page(0, 1)) .get(0); return historicActivityInstanceEntity; }
Example #2
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void recordExecutionReplacedBy(ExecutionEntity execution, InterpretableExecution replacedBy) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { // Update the cached historic activity instances that are open List<HistoricActivityInstanceEntity> cachedHistoricActivityInstances = getDbSqlSession().findInCache(HistoricActivityInstanceEntity.class); for (HistoricActivityInstanceEntity cachedHistoricActivityInstance : cachedHistoricActivityInstances) { if ((cachedHistoricActivityInstance.getEndTime() == null) && (execution.getId().equals(cachedHistoricActivityInstance.getExecutionId()))) { cachedHistoricActivityInstance.setExecutionId(replacedBy.getId()); } } // Update the persisted historic activity instances that are open List<HistoricActivityInstanceEntity> historicActivityInstances = (List) new HistoricActivityInstanceQueryImpl(Context.getCommandContext()) .executionId(execution.getId()) .unfinished() .list(); for (HistoricActivityInstanceEntity historicActivityInstance : historicActivityInstances) { historicActivityInstance.setExecutionId(replacedBy.getId()); } } }
Example #3
Source File: RollbackTaskCmd.java From lemon with Apache License 2.0 | 6 votes |
/** * 找到想要回退对应的节点历史. */ public HistoricActivityInstanceEntity findTargetHistoricActivity( CommandContext commandContext, TaskEntity taskEntity, ActivityImpl activityImpl) { HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl(); historicActivityInstanceQueryImpl.activityId(activityImpl.getId()); historicActivityInstanceQueryImpl.processInstanceId(taskEntity .getProcessInstanceId()); historicActivityInstanceQueryImpl .orderByHistoricActivityInstanceEndTime().desc(); HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) commandContext .getHistoricActivityInstanceEntityManager() .findHistoricActivityInstancesByQueryCriteria( historicActivityInstanceQueryImpl, new Page(0, 1)) .get(0); return historicActivityInstanceEntity; }
Example #4
Source File: RollbackTaskCmd.java From lemon with Apache License 2.0 | 6 votes |
/** * 查询历史节点. */ public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity( String historyTaskId) { logger.info("historyTaskId : {}", historyTaskId); JdbcTemplate jdbcTemplate = ApplicationContextHelper .getBean(JdbcTemplate.class); String historicActivityInstanceId = jdbcTemplate.queryForObject( "SELECT ID_ FROM ACT_HI_ACTINST WHERE TASK_ID_=?", String.class, historyTaskId); logger.info("historicActivityInstanceId : {}", historicActivityInstanceId); HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl(); historicActivityInstanceQueryImpl .activityInstanceId(historicActivityInstanceId); HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) Context .getCommandContext() .getHistoricActivityInstanceEntityManager() .findHistoricActivityInstancesByQueryCriteria( historicActivityInstanceQueryImpl, new Page(0, 1)) .get(0); return historicActivityInstanceEntity; }
Example #5
Source File: CheckWithdrawTaskCmd.java From lemon with Apache License 2.0 | 6 votes |
/** * 撤销流程. */ public Boolean execute(CommandContext commandContext) { // 获得历史任务 HistoricTaskInstanceEntity historicTaskInstanceEntity = Context .getCommandContext().getHistoricTaskInstanceEntityManager() .findHistoricTaskInstanceById(historyTaskId); // 获得历史节点 HistoricActivityInstanceEntity historicActivityInstanceEntity = getHistoricActivityInstanceEntity(historyTaskId); Graph graph = new ActivitiHistoryGraphBuilder( historicTaskInstanceEntity.getProcessInstanceId()).build(); Node node = graph.findById(historicActivityInstanceEntity.getId()); return checkCouldWithdraw(node); }
Example #6
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public HistoricActivityInstanceEntity findActivityInstance(ExecutionEntity execution, boolean createOnNotFound, boolean endTimeMustBeNull) { String activityId = null; if (execution.getCurrentFlowElement() instanceof FlowNode) { activityId = execution.getCurrentFlowElement().getId(); } else if (execution.getCurrentFlowElement() instanceof SequenceFlow && execution.getCurrentActivitiListener() == null) { // while executing sequence flow listeners, we don't want historic activities activityId = ( (SequenceFlow) (execution.getCurrentFlowElement())).getSourceFlowElement().getId(); } if (activityId != null) { return findActivityInstance(execution, activityId, createOnNotFound, endTimeMustBeNull); } return null; }
Example #7
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void recordActivityEnd(ExecutionEntity executionEntity, String deleteReason) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(executionEntity, false, true); if (historicActivityInstance != null) { historicActivityInstance.markEnded(deleteReason); // Fire event ActivitiEventDispatcher activitiEventDispatcher = getEventDispatcher(); if (activitiEventDispatcher != null && activitiEventDispatcher.isEnabled()) { activitiEventDispatcher.dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, historicActivityInstance)); } } } }
Example #8
Source File: CheckWithdrawTaskCmd.java From lemon with Apache License 2.0 | 6 votes |
public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity( String historyTaskId) { logger.info("historyTaskId : {}", historyTaskId); JdbcTemplate jdbcTemplate = ApplicationContextHelper .getBean(JdbcTemplate.class); String historicActivityInstanceId = jdbcTemplate.queryForObject( "select id_ from ACT_HI_ACTINST where task_id_=?", String.class, historyTaskId); logger.info("historicActivityInstanceId : {}", historicActivityInstanceId); HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl(); historicActivityInstanceQueryImpl .activityInstanceId(historicActivityInstanceId); HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) Context .getCommandContext() .getHistoricActivityInstanceEntityManager() .findHistoricActivityInstancesByQueryCriteria( historicActivityInstanceQueryImpl, new Page(0, 1)) .get(0); return historicActivityInstanceEntity; }
Example #9
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void recordSubProcessInstanceStart(ExecutionEntity parentExecution, ExecutionEntity subProcessInstance, FlowElement initialElement) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().create(subProcessInstance); // Fix for ACT-1728: startActivityId not initialized with subprocess instance if (historicProcessInstance.getStartActivityId() == null) { historicProcessInstance.setStartActivityId(initialElement.getId()); } getHistoricProcessInstanceEntityManager().insert(historicProcessInstance, false); // Fire event ActivitiEventDispatcher activitiEventDispatcher = getEventDispatcher(); if (activitiEventDispatcher != null && activitiEventDispatcher.isEnabled()) { activitiEventDispatcher.dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance)); } HistoricActivityInstanceEntity activitiyInstance = findActivityInstance(parentExecution, false, true); if (activitiyInstance != null) { activitiyInstance.setCalledProcessInstanceId(subProcessInstance.getProcessInstanceId()); } } }
Example #10
Source File: TerminateEndEventActivityBehavior.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void endAllHistoricActivities(String processInstanceId, String deleteReason) { if (!Context.getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { return; } List<HistoricActivityInstanceEntity> historicActivityInstances = Context.getCommandContext().getHistoricActivityInstanceEntityManager() .findUnfinishedHistoricActivityInstancesByProcessInstanceId(processInstanceId); for (HistoricActivityInstanceEntity historicActivityInstance : historicActivityInstances) { historicActivityInstance.markEnded(deleteReason); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, historicActivityInstance)); } } }
Example #11
Source File: WithdrawTaskCmd.java From lemon with Apache License 2.0 | 6 votes |
public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity( String historyTaskId) { logger.info("historyTaskId : {}", historyTaskId); JdbcTemplate jdbcTemplate = ApplicationContextHelper .getBean(JdbcTemplate.class); String historicActivityInstanceId = jdbcTemplate.queryForObject( "select id_ from ACT_HI_ACTINST where task_id_=?", String.class, historyTaskId); logger.info("historicActivityInstanceId : {}", historicActivityInstanceId); HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl(); historicActivityInstanceQueryImpl .activityInstanceId(historicActivityInstanceId); HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) Context .getCommandContext() .getHistoricActivityInstanceEntityManager() .findHistoricActivityInstancesByQueryCriteria( historicActivityInstanceQueryImpl, new Page(0, 1)) .get(0); return historicActivityInstanceEntity; }
Example #12
Source File: CheckWithdrawTaskCmd.java From lemon with Apache License 2.0 | 5 votes |
public ActivityImpl getActivity( HistoricActivityInstanceEntity historicActivityInstanceEntity) { ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd( historicActivityInstanceEntity.getProcessDefinitionId()) .execute(Context.getCommandContext()); return processDefinitionEntity .findActivity(historicActivityInstanceEntity.getActivityId()); }
Example #13
Source File: WithdrawTaskCmd.java From lemon with Apache License 2.0 | 5 votes |
/** * 撤销流程. * * @return 0-撤销成功 1-流程结束 2-下一结点已经通过,不能撤销 */ public Integer execute(CommandContext commandContext) { // 获得历史任务 HistoricTaskInstanceEntity historicTaskInstanceEntity = Context .getCommandContext().getHistoricTaskInstanceEntityManager() .findHistoricTaskInstanceById(historyTaskId); // 获得历史节点 HistoricActivityInstanceEntity historicActivityInstanceEntity = getHistoricActivityInstanceEntity(historyTaskId); Graph graph = new ActivitiHistoryGraphBuilder( historicTaskInstanceEntity.getProcessInstanceId()).build(); Node node = graph.findById(historicActivityInstanceEntity.getId()); if (!checkCouldWithdraw(node)) { logger.info("cannot withdraw {}", historyTaskId); return 2; } // 删除所有活动中的task this.deleteActiveTasks(historicTaskInstanceEntity .getProcessInstanceId()); // 获得期望撤销的节点后面的所有节点历史 List<String> historyNodeIds = new ArrayList<String>(); this.collectNodes(node, historyNodeIds); this.deleteHistoryActivities(historyNodeIds); // 恢复期望撤销的任务和历史 this.processHistoryTask(historicTaskInstanceEntity, historicActivityInstanceEntity); logger.info("activiti is withdraw {}", historicTaskInstanceEntity.getName()); return 0; }
Example #14
Source File: RollbackTaskCmd.java From lemon with Apache License 2.0 | 5 votes |
/** * 获得历史节点对应的节点信息. */ public ActivityImpl getActivity( HistoricActivityInstanceEntity historicActivityInstanceEntity) { ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd( historicActivityInstanceEntity.getProcessDefinitionId()) .execute(Context.getCommandContext()); return processDefinitionEntity .findActivity(historicActivityInstanceEntity.getActivityId()); }
Example #15
Source File: WithdrawTaskCmd.java From lemon with Apache License 2.0 | 5 votes |
public ActivityImpl getActivity( HistoricActivityInstanceEntity historicActivityInstanceEntity) { ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd( historicActivityInstanceEntity.getProcessDefinitionId()) .execute(Context.getCommandContext()); return processDefinitionEntity .findActivity(historicActivityInstanceEntity.getActivityId()); }
Example #16
Source File: RollbackCmd.java From lemon with Apache License 2.0 | 5 votes |
/** * 校验目标节点是否可以回退. */ public boolean validateTargetActivity(String targetActivityId) { JdbcTemplate jdbcTemplate = ApplicationContextHelper .getBean(JdbcTemplate.class); String historyTaskId = jdbcTemplate .queryForObject( "select id_ from ACT_HI_TASKINST where act_id_=? order by END_TIME_ desc", String.class, targetActivityId); // 先找到历史任务 HistoricTaskInstanceEntity historicTaskInstanceEntity = Context .getCommandContext().getHistoricTaskInstanceEntityManager() .findHistoricTaskInstanceById(historyTaskId); // 再反向查找历史任务对应的历史节点 HistoricActivityInstanceEntity historicActivityInstanceEntity = getHistoricActivityInstanceEntity(historyTaskId); logger.info("historic activity instance is : {}", historicActivityInstanceEntity.getId()); Graph graph = new ActivitiHistoryGraphBuilder( historicTaskInstanceEntity.getProcessInstanceId()).build(); Node node = graph.findById(historicActivityInstanceEntity.getId()); if (!this.checkCouldRollback(node)) { logger.info("cannot rollback {}", taskId); return false; } return true; }
Example #17
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordHistoricDetailVariableCreate(VariableInstanceEntity variable, ExecutionEntity sourceActivityExecution, boolean useActivityId) { if (isHistoryLevelAtLeast(HistoryLevel.FULL)) { HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = HistoricDetailVariableInstanceUpdateEntity.copyAndInsert(variable); if (useActivityId && sourceActivityExecution != null) { HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(sourceActivityExecution); if (historicActivityInstance != null) { historicVariableUpdate.setActivityInstanceId(historicActivityInstance.getId()); } } } }
Example #18
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordTaskId(TaskEntity task) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { ExecutionEntity execution = task.getExecution(); if (execution != null) { HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(execution); if (historicActivityInstance != null) { historicActivityInstance.setTaskId(task.getId()); } } } }
Example #19
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordTaskAssignment(TaskEntity task) { ExecutionEntity executionEntity = task.getExecution(); if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { if (executionEntity != null) { HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(executionEntity); if (historicActivityInstance != null) { historicActivityInstance.setAssignee(task.getAssignee()); } } } }
Example #20
Source File: RollbackCmd.java From lemon with Apache License 2.0 | 5 votes |
public ActivityImpl getActivity( HistoricActivityInstanceEntity historicActivityInstanceEntity) { ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd( historicActivityInstanceEntity.getProcessDefinitionId()) .execute(Context.getCommandContext()); return processDefinitionEntity .findActivity(historicActivityInstanceEntity.getActivityId()); }
Example #21
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
protected HistoricActivityInstanceEntity findActivityInstance(ExecutionEntity execution, String activityId, boolean checkPersistentStore) { String executionId = execution.getId(); // search for the historic activity instance in the dbsqlsession cache List<HistoricActivityInstanceEntity> cachedHistoricActivityInstances = getDbSqlSession() .findInCache(HistoricActivityInstanceEntity.class); for (HistoricActivityInstanceEntity cachedHistoricActivityInstance : cachedHistoricActivityInstances) { if (executionId.equals(cachedHistoricActivityInstance.getExecutionId()) && activityId != null && (activityId.equals(cachedHistoricActivityInstance.getActivityId())) && (cachedHistoricActivityInstance.getEndTime() == null)) { return cachedHistoricActivityInstance; } } List<HistoricActivityInstance> historicActivityInstances = null; if (checkPersistentStore) { historicActivityInstances = new HistoricActivityInstanceQueryImpl(Context.getCommandContext()) .executionId(executionId) .activityId(activityId) .unfinished() .listPage(0, 1); } if (historicActivityInstances != null && !historicActivityInstances.isEmpty()) { return (HistoricActivityInstanceEntity) historicActivityInstances.get(0); } if (execution.getParentId() != null) { return findActivityInstance(execution.getParent(), activityId, checkPersistentStore); } return null; }
Example #22
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordStartEventEnded(ExecutionEntity execution, String activityId) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { // Interrupted executions might not have an activityId set, skip recording history. if (activityId == null) { return; } HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(execution, activityId, false); // false -> no need to check the persistent store, as process just started if (historicActivityInstance != null) { endHistoricActivityInstance(historicActivityInstance); } } }
Example #23
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void endHistoricActivityInstance(HistoricActivityInstanceEntity historicActivityInstance) { historicActivityInstance.markEnded(null); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, historicActivityInstance)); } }
Example #24
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordActivityStart(ExecutionEntity executionEntity) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { if (executionEntity.getActivity() != null) { IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator(); String processDefinitionId = executionEntity.getProcessDefinitionId(); String processInstanceId = executionEntity.getProcessInstanceId(); String executionId = executionEntity.getId(); HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity(); historicActivityInstance.setId(idGenerator.getNextId()); historicActivityInstance.setProcessDefinitionId(processDefinitionId); historicActivityInstance.setProcessInstanceId(processInstanceId); historicActivityInstance.setExecutionId(executionId); historicActivityInstance.setActivityId(executionEntity.getActivityId()); historicActivityInstance.setActivityName((String) executionEntity.getActivity().getProperty("name")); historicActivityInstance.setActivityType((String) executionEntity.getActivity().getProperty("type")); historicActivityInstance.setStartTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime()); // Inherit tenant id (if applicable) if (executionEntity.getTenantId() != null) { historicActivityInstance.setTenantId(executionEntity.getTenantId()); } getDbSqlSession().insert(historicActivityInstance); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance)); } } } }
Example #25
Source File: MybatisHistoricActivityInstanceDataManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public List<HistoricActivityInstanceEntity> findUnfinishedHistoricActivityInstancesByExecutionAndActivityId(final String executionId, final String activityId) { Map<String, Object> params = new HashMap<String, Object>(); params.put("executionId", executionId); params.put("activityId", activityId); return getList("selectUnfinishedHistoricActivityInstanceExecutionIdAndActivityId", params, unfinishedHistoricActivityInstanceMatcher, true); }
Example #26
Source File: UnfinishedHistoricActivityInstanceMatcher.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public boolean isRetained(HistoricActivityInstanceEntity entity, Object parameter) { Map<String, String> paramMap = (Map<String, String>) parameter; String executionId = paramMap.get("executionId"); String activityId = paramMap.get("activityId"); return entity.getExecutionId() != null && entity.getExecutionId().equals(executionId) && entity.getActivityId() != null && entity.getActivityId().equals(activityId) && entity.getEndTime() == null; }
Example #27
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void recordActivityStart(ExecutionEntity executionEntity) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { if (executionEntity.getActivityId() != null && executionEntity.getCurrentFlowElement() != null) { HistoricActivityInstanceEntity historicActivityInstanceEntity = null; // Historic activity instance could have been created (but only in cache, never persisted) // for example when submitting form properties HistoricActivityInstanceEntity historicActivityInstanceEntityFromCache = getHistoricActivityInstanceFromCache(executionEntity.getId(), executionEntity.getActivityId(), true); if (historicActivityInstanceEntityFromCache != null) { historicActivityInstanceEntity = historicActivityInstanceEntityFromCache; } else { historicActivityInstanceEntity = createHistoricActivityInstanceEntity(executionEntity); } // Fire event ActivitiEventDispatcher activitiEventDispatcher = getEventDispatcher(); if (activitiEventDispatcher != null && activitiEventDispatcher.isEnabled()) { activitiEventDispatcher.dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstanceEntity)); } } } }
Example #28
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected HistoricActivityInstanceEntity getHistoricActivityInstanceFromCache(String executionId, String activityId, boolean endTimeMustBeNull) { List<HistoricActivityInstanceEntity> cachedHistoricActivityInstances = getEntityCache().findInCache(HistoricActivityInstanceEntity.class); for (HistoricActivityInstanceEntity cachedHistoricActivityInstance : cachedHistoricActivityInstances) { if (activityId != null && activityId.equals(cachedHistoricActivityInstance.getActivityId()) && (!endTimeMustBeNull || cachedHistoricActivityInstance.getEndTime() == null)) { if (executionId.equals(cachedHistoricActivityInstance.getExecutionId())) { return cachedHistoricActivityInstance; } } } return null; }
Example #29
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected HistoricActivityInstanceEntity createHistoricActivityInstanceEntity(ExecutionEntity execution) { IdGenerator idGenerator = getProcessEngineConfiguration().getIdGenerator(); String processDefinitionId = execution.getProcessDefinitionId(); String processInstanceId = execution.getProcessInstanceId(); HistoricActivityInstanceEntity historicActivityInstance = getHistoricActivityInstanceEntityManager().create(); historicActivityInstance.setId(idGenerator.getNextId()); historicActivityInstance.setProcessDefinitionId(processDefinitionId); historicActivityInstance.setProcessInstanceId(processInstanceId); historicActivityInstance.setExecutionId(execution.getId()); historicActivityInstance.setActivityId(execution.getActivityId()); if (execution.getCurrentFlowElement() != null) { historicActivityInstance.setActivityName(execution.getCurrentFlowElement().getName()); historicActivityInstance.setActivityType(parseActivityType(execution.getCurrentFlowElement())); } Date now = getClock().getCurrentTime(); historicActivityInstance.setStartTime(now); // Inherit tenant id (if applicable) if (execution.getTenantId() != null) { historicActivityInstance.setTenantId(execution.getTenantId()); } getHistoricActivityInstanceEntityManager().insert(historicActivityInstance); return historicActivityInstance; }
Example #30
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void recordTaskAssignment(TaskEntity task) { ExecutionEntity executionEntity = task.getExecution(); if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { if (executionEntity != null) { HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(executionEntity, false, true); if (historicActivityInstance != null) { historicActivityInstance.setAssignee(task.getAssignee()); } } } }