Search in sources :

Example 1 with JobDefinitionEntity

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

the class BatchEntity method createBatchJobDefinition.

public JobDefinitionEntity createBatchJobDefinition() {
    batchJobDefinition = new JobDefinitionEntity(getBatchJobHandler().getJobDeclaration());
    batchJobDefinition.setJobConfiguration(id);
    batchJobDefinition.setTenantId(tenantId);
    Context.getCommandContext().getJobDefinitionManager().insert(batchJobDefinition);
    batchJobDefinitionId = batchJobDefinition.getId();
    return batchJobDefinition;
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)

Example 2 with JobDefinitionEntity

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

the class BatchEntity method createSeedJobDefinition.

public JobDefinitionEntity createSeedJobDefinition() {
    seedJobDefinition = new JobDefinitionEntity(BATCH_SEED_JOB_DECLARATION);
    seedJobDefinition.setJobConfiguration(id);
    seedJobDefinition.setTenantId(tenantId);
    Context.getCommandContext().getJobDefinitionManager().insert(seedJobDefinition);
    seedJobDefinitionId = seedJobDefinition.getId();
    return seedJobDefinition;
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)

Example 3 with JobDefinitionEntity

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

the class SetProcessDefinitionVersionCmd method execute.

public Void execute(CommandContext commandContext) {
    ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
    // check that the new process definition is just another version of the same
    // process definition that the process instance is using
    ExecutionManager executionManager = commandContext.getExecutionManager();
    final ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
    if (processInstance == null) {
        throw new ProcessEngineException("No process instance found for id = '" + processInstanceId + "'.");
    } else if (!processInstance.isProcessInstanceExecution()) {
        throw new ProcessEngineException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id.");
    }
    ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();
    DeploymentCache deploymentCache = configuration.getDeploymentCache();
    ProcessDefinitionEntity currentProcessDefinition;
    if (currentProcessDefinitionImpl instanceof ProcessDefinitionEntity) {
        currentProcessDefinition = (ProcessDefinitionEntity) currentProcessDefinitionImpl;
    } else {
        currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(currentProcessDefinitionImpl.getId());
    }
    ProcessDefinitionEntity newProcessDefinition = deploymentCache.findDeployedProcessDefinitionByKeyVersionAndTenantId(currentProcessDefinition.getKey(), processDefinitionVersion, currentProcessDefinition.getTenantId());
    validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);
    HistoryLevel historyLevel = configuration.getHistoryLevel();
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance)) {
        HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

            @Override
            public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                return producer.createProcessInstanceUpdateEvt(processInstance);
            }
        });
    }
    // switch all sub-executions of the process instance to the new process definition version
    List<ExecutionEntity> childExecutions = executionManager.findExecutionsByProcessInstanceId(processInstanceId);
    for (ExecutionEntity executionEntity : childExecutions) {
        validateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
    }
    // switch all jobs to the new process definition version
    List<JobEntity> jobs = commandContext.getJobManager().findJobsByProcessInstanceId(processInstanceId);
    List<JobDefinitionEntity> currentJobDefinitions = commandContext.getJobDefinitionManager().findByProcessDefinitionId(currentProcessDefinition.getId());
    List<JobDefinitionEntity> newVersionJobDefinitions = commandContext.getJobDefinitionManager().findByProcessDefinitionId(newProcessDefinition.getId());
    Map<String, String> jobDefinitionMapping = getJobDefinitionMapping(currentJobDefinitions, newVersionJobDefinitions);
    for (JobEntity jobEntity : jobs) {
        switchVersionOfJob(jobEntity, newProcessDefinition, jobDefinitionMapping);
    }
    // switch all incidents to the new process definition version
    List<IncidentEntity> incidents = commandContext.getIncidentManager().findIncidentsByProcessInstance(processInstanceId);
    for (IncidentEntity incidentEntity : incidents) {
        switchVersionOfIncident(commandContext, incidentEntity, newProcessDefinition);
    }
    // add an entry to the op log
    PropertyChange change = new PropertyChange("processDefinitionVersion", currentProcessDefinition.getVersion(), processDefinitionVersion);
    commandContext.getOperationLogManager().logProcessInstanceOperation(UserOperationLogEntry.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, processInstanceId, null, null, Collections.singletonList(change));
    return null;
}
Also used : ExecutionManager(org.camunda.bpm.engine.impl.persistence.entity.ExecutionManager) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) IncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity) HistoryEventProducer(org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer) HistoryEvent(org.camunda.bpm.engine.impl.history.event.HistoryEvent) JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) HistoryEventProcessor(org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 4 with JobDefinitionEntity

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

the class SetJobRetriesCmd method setJobRetriesByJobDefinitionId.

protected void setJobRetriesByJobDefinitionId(CommandContext commandContext) {
    JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
    JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);
    if (jobDefinition != null) {
        String processDefinitionId = jobDefinition.getProcessDefinitionId();
        for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
            checker.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
        }
    }
    commandContext.getJobManager().updateFailedJobRetriesByJobDefinitionId(jobDefinitionId, retries);
    PropertyChange propertyChange = new PropertyChange(RETRIES, null, retries);
    commandContext.getOperationLogManager().logJobOperation(getLogEntryOperation(), null, jobDefinitionId, null, null, null, propertyChange);
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 5 with JobDefinitionEntity

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

the class DefaultJobPriorityProvider method getSpecificPriority.

@Override
protected Long getSpecificPriority(ExecutionEntity execution, JobDeclaration<?, ?> param, String jobDefinitionId) {
    Long specificPriority = null;
    JobDefinitionEntity jobDefinition = getJobDefinitionFor(jobDefinitionId);
    if (jobDefinition != null)
        specificPriority = jobDefinition.getOverridingJobPriority();
    if (specificPriority == null) {
        ParameterValueProvider priorityProvider = param.getJobPriorityProvider();
        if (priorityProvider != null) {
            specificPriority = evaluateValueProvider(priorityProvider, execution, describeContext(param, execution));
        }
    }
    return specificPriority;
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)

Aggregations

JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)16 JobDefinitionManager (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)5 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)5 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 MigratingJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance)2 IncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)1 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)1 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)1 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)1 HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 TimerDeclarationImpl (org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl)1 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)1 MigratingAsyncJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingAsyncJobInstance)1