Search in sources :

Example 46 with ProcessDefinitionEntity

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

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

the class DefaultHistoryEventProducer method createFormPropertyUpdateEvt.

// form Properties ///////////////////////////
public HistoryEvent createFormPropertyUpdateEvt(ExecutionEntity execution, String propertyId, String propertyValue, String taskId) {
    final IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator();
    HistoricFormPropertyEventEntity historicFormPropertyEntity = newHistoricFormPropertyEvent();
    historicFormPropertyEntity.setId(idGenerator.getNextId());
    historicFormPropertyEntity.setEventType(HistoryEventTypes.FORM_PROPERTY_UPDATE.getEventName());
    historicFormPropertyEntity.setTimestamp(ClockUtil.getCurrentTime());
    historicFormPropertyEntity.setActivityInstanceId(execution.getActivityInstanceId());
    historicFormPropertyEntity.setExecutionId(execution.getId());
    historicFormPropertyEntity.setProcessDefinitionId(execution.getProcessDefinitionId());
    historicFormPropertyEntity.setProcessInstanceId(execution.getProcessInstanceId());
    historicFormPropertyEntity.setPropertyId(propertyId);
    historicFormPropertyEntity.setPropertyValue(propertyValue);
    historicFormPropertyEntity.setTaskId(taskId);
    historicFormPropertyEntity.setTenantId(execution.getTenantId());
    historicFormPropertyEntity.setUserOperationId(Context.getCommandContext().getOperationId());
    ProcessDefinitionEntity definition = execution.getProcessDefinition();
    if (definition != null) {
        historicFormPropertyEntity.setProcessDefinitionKey(definition.getKey());
    }
    // initialize sequence counter
    initSequenceCounter(execution, historicFormPropertyEntity);
    return historicFormPropertyEntity;
}
Also used : IdGenerator(org.camunda.bpm.engine.impl.cfg.IdGenerator) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 48 with ProcessDefinitionEntity

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

the class MigrateProcessInstanceBatchCmd method execute.

@Override
public Batch execute(CommandContext commandContext) {
    MigrationPlan migrationPlan = executionBuilder.getMigrationPlan();
    Collection<String> processInstanceIds = collectProcessInstanceIds(commandContext);
    ensureNotNull(BadUserRequestException.class, "Migration plan cannot be null", "migration plan", migrationPlan);
    ensureNotEmpty(BadUserRequestException.class, "Process instance ids cannot empty", "process instance ids", processInstanceIds);
    ensureNotContainsNull(BadUserRequestException.class, "Process instance ids cannot be null", "process instance ids", processInstanceIds);
    ProcessDefinitionEntity sourceProcessDefinition = resolveSourceProcessDefinition(commandContext);
    ProcessDefinitionEntity targetProcessDefinition = resolveTargetProcessDefinition(commandContext);
    checkAuthorizations(commandContext, sourceProcessDefinition, targetProcessDefinition, processInstanceIds);
    writeUserOperationLog(commandContext, sourceProcessDefinition, targetProcessDefinition, processInstanceIds.size(), true);
    BatchEntity batch = createBatch(commandContext, migrationPlan, processInstanceIds, sourceProcessDefinition);
    batch.createSeedJobDefinition();
    batch.createMonitorJobDefinition();
    batch.createBatchJobDefinition();
    batch.fireHistoricStartEvent();
    batch.createSeedJob();
    return batch;
}
Also used : BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 49 with ProcessDefinitionEntity

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

the class MigrationBatchJobHandler method postProcessJob.

@Override
protected void postProcessJob(MigrationBatchConfiguration configuration, JobEntity job) {
    CommandContext commandContext = Context.getCommandContext();
    String sourceProcessDefinitionId = configuration.getMigrationPlan().getSourceProcessDefinitionId();
    ProcessDefinitionEntity processDefinition = getProcessDefinition(commandContext, sourceProcessDefinitionId);
    job.setDeploymentId(processDefinition.getDeploymentId());
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 50 with ProcessDefinitionEntity

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

the class UserOperationLogContextEntryBuilder method inContextOf.

public UserOperationLogContextEntryBuilder inContextOf(ExecutionEntity execution) {
    entry.setProcessInstanceId(execution.getProcessInstanceId());
    entry.setProcessDefinitionId(execution.getProcessDefinitionId());
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) execution.getProcessDefinition();
    entry.setProcessDefinitionKey(processDefinition.getKey());
    entry.setDeploymentId(processDefinition.getDeploymentId());
    return this;
}
Also used : ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)75 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)15 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)14 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)13 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)10 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)10 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)8 ArrayList (java.util.ArrayList)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)4 Deployment (org.camunda.bpm.engine.test.Deployment)4 InputStream (java.io.InputStream)3 ProcessInstanceModificationBuilderImpl (org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl)3 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)3 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)3 IncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity)3 ProcessInstanceWithVariablesImpl (org.camunda.bpm.engine.impl.persistence.entity.ProcessInstanceWithVariablesImpl)3 Element (org.camunda.bpm.engine.impl.util.xml.Element)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2