Java Code Examples for org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#getHistoryLevel()

The following examples show how to use org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#getHistoryLevel() . 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: AbstractDeleteProcessInstanceCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void triggerHistoryEvent(List<ProcessInstance> subProcesslist) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  HistoryLevel historyLevel = configuration.getHistoryLevel();

  for (final ProcessInstance processInstance : subProcesslist) {
    // TODO: This smells bad, as the rest of the history is done via the
    // ParseListener
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance)) {

      HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
        @Override
        public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
          return producer.createProcessInstanceUpdateEvt((DelegateExecution) processInstance);
        }
      });
    }
  }
}
 
Example 2
Source File: IdentityLinkEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void fireHistoricIdentityLinkEvent(final HistoryEventType eventType) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = processEngineConfiguration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(eventType, this)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        HistoryEvent event = null;
        if (HistoryEvent.IDENTITY_LINK_ADD.equals(eventType.getEventName())) {
          event = producer.createHistoricIdentityLinkAddEvent(IdentityLinkEntity.this);
        } else if (HistoryEvent.IDENTITY_LINK_DELETE.equals(eventType.getEventName())) {
          event = producer.createHistoricIdentityLinkDeleteEvent(IdentityLinkEntity.this);
        }
        return event;
      }
    });

  }
}
 
Example 3
Source File: IncidentEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void fireHistoricIncidentEvent(final HistoryEventType eventType) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = processEngineConfiguration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(eventType, this)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {

        HistoryEvent event = null;
        if (HistoryEvent.INCIDENT_CREATE.equals(eventType.getEventName())) {
          event = producer.createHistoricIncidentCreateEvt(IncidentEntity.this);

        } else if (HistoryEvent.INCIDENT_RESOLVE.equals(eventType.getEventName())) {
          event = producer.createHistoricIncidentResolveEvt(IncidentEntity.this);

        } else if (HistoryEvent.INCIDENT_DELETE.equals(eventType.getEventName())) {
          event = producer.createHistoricIncidentDeleteEvt(IncidentEntity.this);
        }
        return event;
      }
    });
  }
}
 
Example 4
Source File: HistoricTaskInstanceManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void markTaskInstanceEnded(String taskId, final String deleteReason) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();

  final TaskEntity taskEntity = Context.getCommandContext()
      .getDbEntityManager()
      .selectById(TaskEntity.class, taskId);

  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_COMPLETE, taskEntity)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createTaskInstanceCompleteEvt(taskEntity, deleteReason);
      }
    });
  }
}
 
Example 5
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void fireHistoricProcessStartEvent() {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  HistoryLevel historyLevel = configuration.getHistoryLevel();
  // TODO: This smells bad, as the rest of the history is done via the
  // ParseListener
  if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_START, processInstance)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createProcessInstanceStartEvt(processInstance);
      }
    });
  }
}
 
Example 6
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void fireHistoricActivityInstanceUpdate() {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if (historyLevel.isHistoryEventProduced(HistoryEventTypes.ACTIVITY_INSTANCE_UPDATE, this)) {
    // publish update event for current activity instance (containing the id
    // of the sub process/case)
    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createActivityInstanceUpdateEvt(ExecutionEntity.this);
      }
    });
  }
}
 
Example 7
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private static boolean historyLevelCheck(ProcessEngine processEngine, RequiredHistoryLevel annotation) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();

  HistoryLevel requiredHistoryLevel = getHistoryLevelForName(processEngineConfiguration.getHistoryLevels(), annotation.value());
  HistoryLevel currentHistoryLevel = processEngineConfiguration.getHistoryLevel();

  return currentHistoryLevel.getId() >= requiredHistoryLevel.getId();
}
 
Example 8
Source File: HistoricBatchManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void completeHistoricBatch(final BatchEntity batch) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(HistoryEventTypes.BATCH_END, batch)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createBatchEndEvent(batch);
      }
    });
  }
}
 
Example 9
Source File: HistoricBatchManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void createHistoricBatch(final BatchEntity batch) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(HistoryEventTypes.BATCH_START, batch)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createBatchStartEvent(batch);
      }
    });
  }
}
 
Example 10
Source File: HistoryLevelSetupCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Void execute(CommandContext commandContext) {

    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();

    checkStartupLockExists(commandContext);

    HistoryLevel databaseHistoryLevel = new DetermineHistoryLevelCmd(processEngineConfiguration.getHistoryLevels()).execute(commandContext);
    determineAutoHistoryLevel(processEngineConfiguration, databaseHistoryLevel);

    HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel();

    if (databaseHistoryLevel == null) {

      commandContext.getPropertyManager().acquireExclusiveLockForStartup();
      databaseHistoryLevel = new DetermineHistoryLevelCmd(processEngineConfiguration.getHistoryLevels()).execute(commandContext);

      if (databaseHistoryLevel == null) {
        LOG.noHistoryLevelPropertyFound();
        dbCreateHistoryLevel(commandContext);
      }
    } else {
      if (configuredHistoryLevel.getId() != databaseHistoryLevel.getId()) {
        throw new ProcessEngineException("historyLevel mismatch: configuration says " + configuredHistoryLevel
            + " and database says " + databaseHistoryLevel);
      }
    }

    return null;
  }
 
Example 11
Source File: HistoricTaskInstanceManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void createHistoricTask(final TaskEntity task) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_CREATE, task)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createTaskInstanceCreateEvt(task);
      }
    });

  }
}
 
Example 12
Source File: HistoricTaskInstanceManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void updateHistoricTaskInstance(final TaskEntity taskEntity) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();

  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if(historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_UPDATE, taskEntity)) {

    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
      @Override
      public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
        return producer.createTaskInstanceUpdateEvt(taskEntity);
      }
    });
  }
}
 
Example 13
Source File: CaseExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void fireHistoricCaseActivityInstanceUpdate() {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  HistoryLevel historyLevel = configuration.getHistoryLevel();
  if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_ACTIVITY_INSTANCE_UPDATE, this)) {
    CmmnHistoryEventProducer eventProducer = configuration.getCmmnHistoryEventProducer();
    HistoryEventHandler eventHandler = configuration.getHistoryEventHandler();

    HistoryEvent event = eventProducer.createCaseActivityInstanceUpdateEvt(this);
    eventHandler.handleEvent(event);
  }
}
 
Example 14
Source File: HistoryLevelSetupCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void determineAutoHistoryLevel(ProcessEngineConfigurationImpl engineConfiguration, HistoryLevel databaseHistoryLevel) {
  HistoryLevel configuredHistoryLevel = engineConfiguration.getHistoryLevel();

  if (configuredHistoryLevel == null
      && ProcessEngineConfiguration.HISTORY_AUTO.equals(engineConfiguration.getHistory())) {

    // automatically determine history level or use default AUDIT
    if (databaseHistoryLevel != null) {
      engineConfiguration.setHistoryLevel(databaseHistoryLevel);
    }
    else {
      engineConfiguration.setHistoryLevel(engineConfiguration.getDefaultHistoryLevel());
    }
  }
}
 
Example 15
Source File: HistoryLevelSetupCommand.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void dbCreateHistoryLevel(CommandContext commandContext) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel();
  PropertyEntity property = new PropertyEntity("historyLevel", Integer.toString(configuredHistoryLevel.getId()));
  commandContext.getSession(DbEntityManager.class).insert(property);
  LOG.creatingHistoryLevelPropertyInDatabase(configuredHistoryLevel);
}
 
Example 16
Source File: HistoricExternalTaskLogManager.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isHistoryEventProduced(HistoryEventType eventType, ExternalTask externalTask) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  HistoryLevel historyLevel = configuration.getHistoryLevel();
  return historyLevel.isHistoryEventProduced(eventType, externalTask);
}
 
Example 17
Source File: HistoricJobLogManager.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isHistoryEventProduced(HistoryEventType eventType, Job job) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  HistoryLevel historyLevel = configuration.getHistoryLevel();
  return historyLevel.isHistoryEventProduced(eventType, job);
}
 
Example 18
Source File: ProcessEngineImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public ProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration) {

    this.processEngineConfiguration = processEngineConfiguration;
    this.name = processEngineConfiguration.getProcessEngineName();

    this.repositoryService = processEngineConfiguration.getRepositoryService();
    this.runtimeService = processEngineConfiguration.getRuntimeService();
    this.historicDataService = processEngineConfiguration.getHistoryService();
    this.identityService = processEngineConfiguration.getIdentityService();
    this.taskService = processEngineConfiguration.getTaskService();
    this.formService = processEngineConfiguration.getFormService();
    this.managementService = processEngineConfiguration.getManagementService();
    this.authorizationService = processEngineConfiguration.getAuthorizationService();
    this.caseService = processEngineConfiguration.getCaseService();
    this.filterService = processEngineConfiguration.getFilterService();
    this.externalTaskService = processEngineConfiguration.getExternalTaskService();
    this.decisionService = processEngineConfiguration.getDecisionService();

    this.databaseSchemaUpdate = processEngineConfiguration.getDatabaseSchemaUpdate();
    this.jobExecutor = processEngineConfiguration.getJobExecutor();
    this.commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutorSchemaOperations = processEngineConfiguration.getCommandExecutorSchemaOperations();
    this.sessionFactories = processEngineConfiguration.getSessionFactories();
    this.historyLevel = processEngineConfiguration.getHistoryLevel();
    this.transactionContextFactory = processEngineConfiguration.getTransactionContextFactory();

    executeSchemaOperations();

    if (name == null) {
      LOG.processEngineCreated(ProcessEngines.NAME_DEFAULT);
    } else {
      LOG.processEngineCreated(name);
    }

    ProcessEngines.registerProcessEngine(this);

    if ((jobExecutor != null)) {
      // register process engine with Job Executor
      jobExecutor.registerProcessEngine(this);
    }

    if (processEngineConfiguration.isMetricsEnabled()) {
      String reporterId;
      // only use a deprecated, custom MetricsReporterIdProvider,
      // if no static hostname AND custom HostnameProvider are set.
      // See ProcessEngineConfigurationImpl#initHostname()
      if (processEngineConfiguration.getMetricsReporterIdProvider() != null
          && processEngineConfiguration.getHostnameProvider() instanceof SimpleIpBasedProvider) {
        reporterId = processEngineConfiguration.getMetricsReporterIdProvider().provideId(this);
      } else {
        reporterId = processEngineConfiguration.getHostname();;
      }

      DbMetricsReporter dbMetricsReporter = processEngineConfiguration.getDbMetricsReporter();
      dbMetricsReporter.setReporterId(reporterId);

      if(processEngineConfiguration.isDbMetricsReporterActivate()) {
        dbMetricsReporter.start();
      }
    }
  }
 
Example 19
Source File: AbstractPersistenceSession.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void dbSchemaCreate() {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();

  HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel();
  if ( (!processEngineConfiguration.isDbHistoryUsed())
       && (!configuredHistoryLevel.equals(HistoryLevel.HISTORY_LEVEL_NONE))
     ) {
    throw LOG.databaseHistoryLevelException(configuredHistoryLevel.getName());
  }

  if (isEngineTablePresent()) {
    String dbVersion = getDbVersion();
    if (!ProcessEngine.VERSION.equals(dbVersion)) {
      throw LOG.wrongDbVersionException(ProcessEngine.VERSION, dbVersion);
    }
  } else {
    dbSchemaCreateEngine();
  }

  if (processEngineConfiguration.isDbHistoryUsed()) {
    dbSchemaCreateHistory();
  }

  if (processEngineConfiguration.isDbIdentityUsed()) {
    dbSchemaCreateIdentity();
  }

  if (processEngineConfiguration.isCmmnEnabled()) {
    dbSchemaCreateCmmn();
  }

  if (processEngineConfiguration.isCmmnEnabled() && processEngineConfiguration.isDbHistoryUsed()) {
    dbSchemaCreateCmmnHistory();
  }

  if (processEngineConfiguration.isDmnEnabled()) {
    dbSchemaCreateDmn();

    if(processEngineConfiguration.isDbHistoryUsed()) {
      dbSchemaCreateDmnHistory();
    }
  }
}