Java Code Examples for org.camunda.bpm.engine.impl.history.HistoryLevel#getId()

The following examples show how to use org.camunda.bpm.engine.impl.history.HistoryLevel#getId() . 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: DetermineHistoryLevelCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public HistoryLevel execute(final CommandContext commandContext) {
  final Integer databaseHistoryLevel = HistoryLevelSetupCommand.databaseHistoryLevel(commandContext);

  HistoryLevel result = null;

  if (databaseHistoryLevel != null) {
    for (final HistoryLevel historyLevel : historyLevels) {
      if (historyLevel.getId() == databaseHistoryLevel) {
        result = historyLevel;
        break;
      }
    }

    if (result != null) {
      return result;
    }
    else {
      // if a custom non-null value is not registered, throw an exception.
      throw new ProcessEngineException(String.format("The configured history level with id='%s' is not registered in this config.", databaseHistoryLevel));
    }
  }
  else {
    return null;
  }
}
 
Example 2
Source File: HistoryLevelDeterminatorJdbcTemplateImpl.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
protected String getHistoryLevelFrom(Integer historyLevelFromDb) {
  String result = defaultHistoryLevel;
  if (historyLevelFromDb != null) {
    for (HistoryLevel historyLevel : historyLevels) {
      if (historyLevel.getId() == historyLevelFromDb.intValue()) {
        result = historyLevel.getName();
        log.debug("found matching history level '{}'", result);
        break;
      }
    }
  }
  return result;
}
 
Example 3
Source File: HistoryLevelDeterminatorJdbcTemplateImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String getHistoryLevelFrom(Integer historyLevelFromDb) {
  String result = defaultHistoryLevel;
  if (historyLevelFromDb != null) {
    for (HistoryLevel historyLevel : historyLevels) {
      if (historyLevel.getId() == historyLevelFromDb.intValue()) {
        result = historyLevel.getName();
        log.debug("found matching history level '{}'", result);
        break;
      }
    }
  }
  return result;
}
 
Example 4
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 5
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();
}