Search in sources :

Example 31 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method initHistoricIdentityLinkEvent.

protected void initHistoricIdentityLinkEvent(HistoricIdentityLinkLogEventEntity evt, IdentityLink identityLink, HistoryEventType eventType) {
    if (identityLink.getTaskId() != null) {
        TaskEntity task = Context.getCommandContext().getTaskManager().findTaskById(identityLink.getTaskId());
        evt.setProcessDefinitionId(task.getProcessDefinitionId());
        if (task.getProcessDefinition() != null) {
            evt.setProcessDefinitionKey(task.getProcessDefinition().getKey());
        }
    }
    if (identityLink.getProcessDefId() != null) {
        evt.setProcessDefinitionId(identityLink.getProcessDefId());
        ProcessDefinitionEntity definition = Context.getProcessEngineConfiguration().getDeploymentCache().findProcessDefinitionFromCache(identityLink.getProcessDefId());
        evt.setProcessDefinitionKey(definition.getKey());
    }
    evt.setTime(ClockUtil.getCurrentTime());
    evt.setType(identityLink.getType());
    evt.setUserId(identityLink.getUserId());
    evt.setGroupId(identityLink.getGroupId());
    evt.setTaskId(identityLink.getTaskId());
    evt.setTenantId(identityLink.getTenantId());
    // There is a conflict in HistoryEventTypes for 'delete' keyword,
    // So HistoryEventTypes.IDENTITY_LINK_ADD /
    // HistoryEventTypes.IDENTITY_LINK_DELETE is provided with the event name
    // 'add-identity-link' /'delete-identity-link'
    // and changed to 'add'/'delete' (While inserting it into the database) on
    // Historic identity link add / delete event
    String operationType = "add";
    if (eventType.getEventName().equals(HistoryEventTypes.IDENTITY_LINK_DELETE.getEventName())) {
        operationType = "delete";
    }
    evt.setOperationType(operationType);
    evt.setEventType(eventType.getEventName());
    evt.setAssignerId(Context.getCommandContext().getAuthenticatedUserId());
}
Also used : ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 32 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method createHistoricVariableEvent.

protected HistoryEvent createHistoricVariableEvent(VariableInstanceEntity variableInstance, VariableScope sourceVariableScope, HistoryEventType eventType) {
    String scopeActivityInstanceId = null;
    String sourceActivityInstanceId = null;
    if (variableInstance.getExecutionId() != null) {
        ExecutionEntity scopeExecution = Context.getCommandContext().getDbEntityManager().selectById(ExecutionEntity.class, variableInstance.getExecutionId());
        if (variableInstance.getTaskId() == null && !variableInstance.isConcurrentLocal()) {
            scopeActivityInstanceId = scopeExecution.getParentActivityInstanceId();
        } else {
            scopeActivityInstanceId = scopeExecution.getActivityInstanceId();
        }
    } else if (variableInstance.getCaseExecutionId() != null) {
        scopeActivityInstanceId = variableInstance.getCaseExecutionId();
    }
    ExecutionEntity sourceExecution = null;
    CaseExecutionEntity sourceCaseExecution = null;
    if (sourceVariableScope instanceof ExecutionEntity) {
        sourceExecution = (ExecutionEntity) sourceVariableScope;
        sourceActivityInstanceId = sourceExecution.getActivityInstanceId();
    } else if (sourceVariableScope instanceof TaskEntity) {
        sourceExecution = ((TaskEntity) sourceVariableScope).getExecution();
        if (sourceExecution != null) {
            sourceActivityInstanceId = sourceExecution.getActivityInstanceId();
        } else {
            sourceCaseExecution = ((TaskEntity) sourceVariableScope).getCaseExecution();
            if (sourceCaseExecution != null) {
                sourceActivityInstanceId = sourceCaseExecution.getId();
            }
        }
    } else if (sourceVariableScope instanceof CaseExecutionEntity) {
        sourceCaseExecution = (CaseExecutionEntity) sourceVariableScope;
        sourceActivityInstanceId = sourceCaseExecution.getId();
    }
    // create event
    HistoricVariableUpdateEventEntity evt = newVariableUpdateEventEntity(sourceExecution);
    // initialize
    initHistoricVariableUpdateEvt(evt, variableInstance, eventType);
    // initialize sequence counter
    initSequenceCounter(variableInstance, evt);
    // set scope activity instance id
    evt.setScopeActivityInstanceId(scopeActivityInstanceId);
    // set source activity instance id
    evt.setActivityInstanceId(sourceActivityInstanceId);
    return evt;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)

Example 33 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity 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 34 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class HistoryTaskListener method notify.

public void notify(DelegateTask task) {
    // get the event handler
    final HistoryEventHandler historyEventHandler = Context.getProcessEngineConfiguration().getHistoryEventHandler();
    ExecutionEntity execution = ((TaskEntity) task).getExecution();
    if (execution != null) {
        // delegate creation of the history event to the producer
        HistoryEvent historyEvent = createHistoryEvent(task, execution);
        if (historyEvent != null) {
            // pass the event to the handler
            historyEventHandler.handleEvent(historyEvent);
        }
    }
}
Also used : HistoryEventHandler(org.camunda.bpm.engine.impl.history.handler.HistoryEventHandler) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) HistoryEvent(org.camunda.bpm.engine.impl.history.event.HistoryEvent)

Example 35 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class JuelFormEngine method renderTaskForm.

public Object renderTaskForm(TaskFormData taskForm) {
    if (taskForm.getFormKey() == null) {
        return null;
    }
    String formTemplateString = getFormTemplateString(taskForm, taskForm.getFormKey());
    TaskEntity task = (TaskEntity) taskForm.getTask();
    return executeScript(formTemplateString, task.getExecution());
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)

Aggregations

TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)53 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)17 Deployment (org.camunda.bpm.engine.test.Deployment)11 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)10 Date (java.util.Date)4 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)4 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)3 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)3 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)3 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)2 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)2 AttachmentEntity (org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Task (org.camunda.bpm.engine.task.Task)2 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)2 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)2 Before (org.junit.Before)2