Search in sources :

Example 1 with DetermineHistoryLevelCmd

use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.

the class DetermineHistoryLevelCmdTest method failWhenExistingHistoryLevelIsNotRegistered.

@Test
public void failWhenExistingHistoryLevelIsNotRegistered() {
    // init the db with custom level
    HistoryLevel customLevel = new HistoryLevel() {

        @Override
        public int getId() {
            return 99;
        }

        @Override
        public String getName() {
            return "custom";
        }

        @Override
        public boolean isHistoryEventProduced(HistoryEventType eventType, Object entity) {
            return false;
        }
    };
    ProcessEngineConfigurationImpl config = config("true", "custom");
    config.setCustomHistoryLevels(Arrays.asList(customLevel));
    processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine();
    thrown.expect(ProcessEngineException.class);
    thrown.expectMessage("The configured history level with id='99' is not registered in this config.");
    config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(Collections.<HistoryLevel>emptyList()));
}
Also used : DetermineHistoryLevelCmd(org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) HistoryEventType(org.camunda.bpm.engine.impl.history.event.HistoryEventType) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Test(org.junit.Test)

Example 2 with DetermineHistoryLevelCmd

use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.

the class DetermineHistoryLevelCmdTest method readLevelFullfromDB.

@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));
}
Also used : DetermineHistoryLevelCmd(org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Test(org.junit.Test)

Example 3 with DetermineHistoryLevelCmd

use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.

the class HistoryLevelSetupCommand method execute.

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;
}
Also used : DetermineHistoryLevelCmd(org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 4 with DetermineHistoryLevelCmd

use of org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd in project camunda-bpm-platform by camunda.

the class DetermineHistoryLevelCmdTest method useDefaultLevelAudit.

@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));
}
Also used : DetermineHistoryLevelCmd(org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Test(org.junit.Test)

Aggregations

ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)4 DetermineHistoryLevelCmd (org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd)4 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)4 Test (org.junit.Test)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 HistoryEventType (org.camunda.bpm.engine.impl.history.event.HistoryEventType)1