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