Search in sources :

Example 16 with HistoryLevel

use of org.camunda.bpm.engine.impl.history.HistoryLevel 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 17 with HistoryLevel

use of org.camunda.bpm.engine.impl.history.HistoryLevel in project camunda-bpm-platform by camunda.

the class HistoryLevelSetupCommand method dbCreateHistoryLevel.

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);
}
Also used : HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) PropertyEntity(org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity) DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 18 with HistoryLevel

use of org.camunda.bpm.engine.impl.history.HistoryLevel in project camunda-bpm-platform by camunda.

the class ProcessEngineConfigurationImpl method initHistoryLevel.

// history //////////////////////////////////////////////////////////////////
public void initHistoryLevel() {
    if (historyLevel != null) {
        setHistory(historyLevel.getName());
    }
    if (historyLevels == null) {
        historyLevels = new ArrayList<HistoryLevel>();
        historyLevels.add(HistoryLevel.HISTORY_LEVEL_NONE);
        historyLevels.add(HistoryLevel.HISTORY_LEVEL_ACTIVITY);
        historyLevels.add(HistoryLevel.HISTORY_LEVEL_AUDIT);
        historyLevels.add(HistoryLevel.HISTORY_LEVEL_FULL);
    }
    if (customHistoryLevels != null) {
        historyLevels.addAll(customHistoryLevels);
    }
    if (HISTORY_VARIABLE.equalsIgnoreCase(history)) {
        historyLevel = HistoryLevel.HISTORY_LEVEL_ACTIVITY;
        LOG.usingDeprecatedHistoryLevelVariable();
    } else {
        for (HistoryLevel historyLevel : historyLevels) {
            if (historyLevel.getName().equalsIgnoreCase(history)) {
                this.historyLevel = historyLevel;
            }
        }
    }
    // do allow null for history level in case of "auto"
    if (historyLevel == null && !ProcessEngineConfiguration.HISTORY_AUTO.equalsIgnoreCase(history)) {
        throw new ProcessEngineException("invalid history level: " + history);
    }
}
Also used : HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 19 with HistoryLevel

use of org.camunda.bpm.engine.impl.history.HistoryLevel in project camunda-bpm-platform by camunda.

the class AbstractSetProcessInstanceStateCmd method triggerHistoryEvent.

@Override
protected void triggerHistoryEvent(CommandContext commandContext) {
    HistoryLevel historyLevel = commandContext.getProcessEngineConfiguration().getHistoryLevel();
    List<ProcessInstance> updatedProcessInstances = obtainProcessInstances(commandContext);
    // suspension state is not updated synchronously
    if (getNewSuspensionState() != null && updatedProcessInstances != null) {
        for (final ProcessInstance processInstance : updatedProcessInstances) {
            if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance)) {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

                    @Override
                    public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                        HistoricProcessInstanceEventEntity processInstanceUpdateEvt = (HistoricProcessInstanceEventEntity) producer.createProcessInstanceUpdateEvt((DelegateExecution) processInstance);
                        if (SuspensionState.SUSPENDED.getStateCode() == getNewSuspensionState().getStateCode()) {
                            processInstanceUpdateEvt.setState(HistoricProcessInstance.STATE_SUSPENDED);
                        } else {
                            processInstanceUpdateEvt.setState(HistoricProcessInstance.STATE_ACTIVE);
                        }
                        return processInstanceUpdateEvt;
                    }
                });
            }
        }
    }
}
Also used : HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) HistoryEventProcessor(org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor) HistoricProcessInstanceEventEntity(org.camunda.bpm.engine.impl.history.event.HistoricProcessInstanceEventEntity) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoryEventProducer(org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer) HistoryEvent(org.camunda.bpm.engine.impl.history.event.HistoryEvent)

Example 20 with HistoryLevel

use of org.camunda.bpm.engine.impl.history.HistoryLevel in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method fireFormPropertyHistoryEvents.

protected void fireFormPropertyHistoryEvents(VariableMap properties, VariableScope variableScope) {
    final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    HistoryLevel historyLevel = processEngineConfiguration.getHistoryLevel();
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.FORM_PROPERTY_UPDATE, variableScope)) {
        // fire history events
        final ExecutionEntity executionEntity;
        final String taskId;
        if (variableScope instanceof ExecutionEntity) {
            executionEntity = (ExecutionEntity) variableScope;
            taskId = null;
        } else if (variableScope instanceof TaskEntity) {
            TaskEntity task = (TaskEntity) variableScope;
            executionEntity = task.getExecution();
            taskId = task.getId();
        } else {
            executionEntity = null;
            taskId = null;
        }
        if (executionEntity != null) {
            for (final String variableName : properties.keySet()) {
                final TypedValue value = properties.getValueTyped(variableName);
                // NOTE: SerializableValues are never stored as form properties
                if (!(value instanceof SerializableValue) && value.getValue() != null && value.getValue() instanceof String) {
                    final String stringValue = (String) value.getValue();
                    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

                        @Override
                        public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                            return producer.createFormPropertyUpdateEvt(executionEntity, variableName, stringValue, taskId);
                        }
                    });
                }
            }
        }
    }
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) SerializableValue(org.camunda.bpm.engine.variable.value.SerializableValue) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) HistoryEventProcessor(org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor) HistoryEventProducer(org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer) HistoryEvent(org.camunda.bpm.engine.impl.history.event.HistoryEvent) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Aggregations

HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)30 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)22 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)16 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)15 HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)15 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 DetermineHistoryLevelCmd (org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd)4 Test (org.junit.Test)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 HashMap (java.util.HashMap)1 List (java.util.List)1 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)1 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)1 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 HistoricProcessInstanceEventEntity (org.camunda.bpm.engine.impl.history.event.HistoricProcessInstanceEventEntity)1 HistoryEventType (org.camunda.bpm.engine.impl.history.event.HistoryEventType)1 HistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.HistoryEventHandler)1