Search in sources :

Example 11 with HistoryEventProducer

use of org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer 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 12 with HistoryEventProducer

use of org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer 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)

Example 13 with HistoryEventProducer

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

the class ExecutionEntity method fireHistoricProcessStartEvent.

@Override
public void fireHistoricProcessStartEvent() {
    ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
    HistoryLevel historyLevel = configuration.getHistoryLevel();
    // ParseListener
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_START, processInstance)) {
        HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

            @Override
            public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                return producer.createProcessInstanceStartEvt(processInstance);
            }
        });
    }
}
Also used : 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)

Example 14 with HistoryEventProducer

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

the class HistoricTaskInstanceManager method createHistoricTask.

public void createHistoricTask(final TaskEntity task) {
    ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
    HistoryLevel historyLevel = configuration.getHistoryLevel();
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_CREATE, task)) {
        HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

            @Override
            public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                return producer.createTaskInstanceCreateEvt(task);
            }
        });
    }
}
Also used : 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)

Example 15 with HistoryEventProducer

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

the class HistoricTaskInstanceManager method markTaskInstanceEnded.

public void markTaskInstanceEnded(String taskId, final String deleteReason) {
    ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
    final TaskEntity taskEntity = Context.getCommandContext().getDbEntityManager().selectById(TaskEntity.class, taskId);
    HistoryLevel historyLevel = configuration.getHistoryLevel();
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_COMPLETE, taskEntity)) {
        HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

            @Override
            public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                return producer.createTaskInstanceCompleteEvt(taskEntity, deleteReason);
            }
        });
    }
}
Also used : 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)

Aggregations

HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)16 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)15 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)15 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)15 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)12 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)1 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)1 HistoricProcessInstanceEventEntity (org.camunda.bpm.engine.impl.history.event.HistoricProcessInstanceEventEntity)1 HistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.HistoryEventHandler)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 ExecutionManager (org.camunda.bpm.engine.impl.persistence.entity.ExecutionManager)1 IncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity)1 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)1 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)1 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)1 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)1 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)1