org.activiti.engine.impl.cfg.IdGenerator Java Examples

The following examples show how to use org.activiti.engine.impl.cfg.IdGenerator. 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: DefaultHistoryManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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 #2
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@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 #3
Source File: DbSqlSessionFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public IdGenerator getIdGenerator() {
  return idGenerator;
}
 
Example #4
Source File: DbSqlSessionFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void setIdGenerator(IdGenerator idGenerator) {
  this.idGenerator = idGenerator;
}
 
Example #5
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public IdGenerator getIdGenerator() {
  return idGenerator;
}
 
Example #6
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void setIdGenerator(IdGenerator idGenerator) {
  this.idGenerator = idGenerator;
}
 
Example #7
Source File: DbSqlSessionFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public IdGenerator getIdGenerator() {
    return idGenerator;
}
 
Example #8
Source File: DbSqlSessionFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setIdGenerator(IdGenerator idGenerator) {
    this.idGenerator = idGenerator;
}
 
Example #9
Source File: BpmnDeployer.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public IdGenerator getIdGenerator() {
    return idGenerator;
}
 
Example #10
Source File: BpmnDeployer.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setIdGenerator(IdGenerator idGenerator) {
    this.idGenerator = idGenerator;
}
 
Example #11
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@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(FlowableEngineEventType.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(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance));
        }

    }
}
 
Example #12
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void recordSubProcessInstanceStart(ExecutionEntity parentExecution, ExecutionEntity subProcessInstance) {
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {

        HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(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(FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance));
        }

        HistoricActivityInstanceEntity activityInstance = findActivityInstance(parentExecution);
        if (activityInstance != null) {
            activityInstance.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(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance));
        }

    }
}