Java Code Examples for org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#setEndActivityId()

The following examples show how to use org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#setEndActivityId() . 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 6 votes vote down vote up
@Override
public void recordProcessInstanceEnd(String processInstanceId, String deleteReason, String activityId) {

  if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
    HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().findById(processInstanceId);

    if (historicProcessInstance != null) {
      historicProcessInstance.markEnded(deleteReason);
      historicProcessInstance.setEndActivityId(activityId);
      
      // Fire event
      ActivitiEventDispatcher activitiEventDispatcher = getEventDispatcher();
      if (activitiEventDispatcher != null && activitiEventDispatcher.isEnabled()) {
        activitiEventDispatcher.dispatchEvent(
            ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_ENDED, historicProcessInstance));
      }
      
    }
  }
}
 
Example 2
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void recordProcessInstanceEnd(String processInstanceId, String deleteReason, String activityId) {

    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceManager()
                .findHistoricProcessInstance(processInstanceId);

        if (historicProcessInstance != null) {
            historicProcessInstance.markEnded(deleteReason);
            historicProcessInstance.setEndActivityId(activityId);

            // Fire event
            ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
            if (config != null && config.getEventDispatcher().isEnabled()) {
                config.getEventDispatcher().dispatchEvent(
                        ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_ENDED, historicProcessInstance));
            }
        }
    }
}
 
Example 3
Source File: ReOpenProcessCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
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;
}