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;
}
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);
}
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);
}
}
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;
}
});
}
}
}
}
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);
}
});
}
}
}
}
}
Aggregations