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