use of org.activiti.engine.impl.cfg.IdGenerator in project Activiti by Activiti.
the class DefaultHistoryManager method recordProcessInstanceStart.
/* (non-Javadoc)
* @see org.activiti.engine.impl.history.HistoryManagerInterface#recordProcessInstanceStart(org.activiti.engine.impl.persistence.entity.ExecutionEntity)
*/
@Override
public void recordProcessInstanceStart(ExecutionEntity processInstance) {
if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(processInstance);
// Insert historic process-instance
getDbSqlSession().insert(historicProcessInstance);
// Fire event
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
if (config != null && config.getEventDispatcher().isEnabled()) {
config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance));
}
// Also record the start-event manually, as there is no "start" activity history listener for this
IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator();
String processDefinitionId = processInstance.getProcessDefinitionId();
String processInstanceId = processInstance.getProcessInstanceId();
String executionId = processInstance.getId();
HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity();
historicActivityInstance.setId(idGenerator.getNextId());
historicActivityInstance.setProcessDefinitionId(processDefinitionId);
historicActivityInstance.setProcessInstanceId(processInstanceId);
historicActivityInstance.setExecutionId(executionId);
historicActivityInstance.setActivityId(processInstance.getActivityId());
historicActivityInstance.setActivityName((String) processInstance.getActivity().getProperty("name"));
historicActivityInstance.setActivityType((String) processInstance.getActivity().getProperty("type"));
Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
historicActivityInstance.setStartTime(now);
// Inherit tenant id (if applicable)
if (processInstance.getTenantId() != null) {
historicActivityInstance.setTenantId(processInstance.getTenantId());
}
getDbSqlSession().insert(historicActivityInstance);
// Fire event
if (config != null && config.getEventDispatcher().isEnabled()) {
config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance));
}
}
}
use of org.activiti.engine.impl.cfg.IdGenerator in project Activiti by Activiti.
the class DefaultHistoryManager method createHistoricActivityInstanceEntity.
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;
}
use of org.activiti.engine.impl.cfg.IdGenerator in project Activiti by Activiti.
the class DefaultHistoryManager method recordSubProcessInstanceStart.
/* (non-Javadoc)
* @see org.activiti.engine.impl.history.HistoryManagerInterface#recordSubProcessInstanceStart(org.activiti.engine.impl.persistence.entity.ExecutionEntity, org.activiti.engine.impl.persistence.entity.ExecutionEntity)
*/
@Override
public void recordSubProcessInstanceStart(ExecutionEntity parentExecution, ExecutionEntity subProcessInstance) {
if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity((ExecutionEntity) subProcessInstance);
ActivityImpl initialActivity = subProcessInstance.getActivity();
// Fix for ACT-1728: startActivityId not initialized with subprocess-instance
if (historicProcessInstance.getStartActivityId() == null) {
historicProcessInstance.setStartActivityId(subProcessInstance.getProcessDefinition().getInitial().getId());
initialActivity = subProcessInstance.getProcessDefinition().getInitial();
}
getDbSqlSession().insert(historicProcessInstance);
// Fire event
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
if (config != null && config.getEventDispatcher().isEnabled()) {
config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance));
}
HistoricActivityInstanceEntity activitiyInstance = findActivityInstance(parentExecution);
if (activitiyInstance != null) {
activitiyInstance.setCalledProcessInstanceId(subProcessInstance.getProcessInstanceId());
}
// Fix for ACT-1728: start-event not recorded for subprocesses
IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator();
// Also record the start-event manually, as there is no "start" activity history listener for this
HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity();
historicActivityInstance.setId(idGenerator.getNextId());
historicActivityInstance.setProcessDefinitionId(subProcessInstance.getProcessDefinitionId());
historicActivityInstance.setProcessInstanceId(subProcessInstance.getProcessInstanceId());
historicActivityInstance.setExecutionId(subProcessInstance.getId());
historicActivityInstance.setActivityId(initialActivity.getId());
historicActivityInstance.setActivityName((String) initialActivity.getProperty("name"));
historicActivityInstance.setActivityType((String) initialActivity.getProperty("type"));
Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
historicActivityInstance.setStartTime(now);
getDbSqlSession().insert(historicActivityInstance);
// Fire event
if (config != null && config.getEventDispatcher().isEnabled()) {
config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance));
}
}
}
Aggregations