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(); }
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(); }
@Test public void shouldInitHistoryLevelByObject() throws Exception { ProcessEngineConfigurationImpl config = createConfig(); config.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL); ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config); assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4)); assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName())); }
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; }
@Test public void shouldInitHistoryLevelByString() throws Exception { ProcessEngineConfigurationImpl config = createConfig(); config.setHistory(HistoryLevel.HISTORY_LEVEL_FULL.getName()); ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config); assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4)); assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName())); }
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; }
@Test public void useDefaultLevelAudit() throws Exception { ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); // init the db with level=auto -> audit processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); // the history Level has been overwritten with audit assertThat(config.getHistoryLevel(), CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); // and this is written to the database HistoryLevel databaseLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(databaseLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }
@Test public void readLevelFullfromDB() throws Exception { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_FULL); // init the db with level=full processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); HistoryLevel historyLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(historyLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_FULL)); }
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(); }
@Test public void shouldInitHistoryLevelByObject() throws Exception { ProcessEngineConfigurationImpl config = createConfig(); config.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL); ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config); assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4)); assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName())); }
@Test public void shouldInitHistoryLevelByString() throws Exception { ProcessEngineConfigurationImpl config = createConfig(); config.setHistory(HistoryLevel.HISTORY_LEVEL_FULL.getName()); ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config); assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4)); assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL)); assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName())); }
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; }
@Test public void readLevelFullfromDB() throws Exception { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_FULL); // init the db with level=full processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); HistoryLevel historyLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(historyLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_FULL)); }
@Test public void useDefaultLevelAudit() throws Exception { ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); // init the db with level=auto -> audit processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); // the history Level has been overwritten with audit assertThat(config.getHistoryLevel(), CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); // and this is written to the database HistoryLevel databaseLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(databaseLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }