use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity in project camunda-bpm-platform by camunda.
the class BpmnDeployer method updateJobDeclarations.
protected void updateJobDeclarations(List<JobDeclaration<?, ?>> jobDeclarations, ProcessDefinitionEntity processDefinition, boolean isNewDeployment) {
if (jobDeclarations == null || jobDeclarations.isEmpty()) {
return;
}
final JobDefinitionManager jobDefinitionManager = getJobDefinitionManager();
if (isNewDeployment) {
// create new job definitions:
for (JobDeclaration<?, ?> jobDeclaration : jobDeclarations) {
createJobDefinition(processDefinition, jobDeclaration);
}
} else {
// query all job definitions and update the declarations with their Ids
List<JobDefinitionEntity> existingDefinitions = jobDefinitionManager.findByProcessDefinitionId(processDefinition.getId());
LegacyBehavior.migrateMultiInstanceJobDefinitions(processDefinition, existingDefinitions);
for (JobDeclaration<?, ?> jobDeclaration : jobDeclarations) {
boolean jobDefinitionExists = false;
for (JobDefinition jobDefinitionEntity : existingDefinitions) {
// <!> Assumption: there can be only one job definition per activity and type
if (jobDeclaration.getActivityId().equals(jobDefinitionEntity.getActivityId()) && jobDeclaration.getJobHandlerType().equals(jobDefinitionEntity.getJobType())) {
jobDeclaration.setJobDefinitionId(jobDefinitionEntity.getId());
jobDefinitionExists = true;
break;
}
}
if (!jobDefinitionExists) {
// not found: create new definition
createJobDefinition(processDefinition, jobDeclaration);
}
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity in project camunda-bpm-platform by camunda.
the class BpmnDeployer method createJobDefinition.
protected void createJobDefinition(ProcessDefinition processDefinition, JobDeclaration<?, ?> jobDeclaration) {
final JobDefinitionManager jobDefinitionManager = getJobDefinitionManager();
JobDefinitionEntity jobDefinitionEntity = new JobDefinitionEntity(jobDeclaration);
jobDefinitionEntity.setProcessDefinitionId(processDefinition.getId());
jobDefinitionEntity.setProcessDefinitionKey(processDefinition.getKey());
jobDefinitionEntity.setTenantId(processDefinition.getTenantId());
jobDefinitionManager.insert(jobDefinitionEntity);
jobDeclaration.setJobDefinitionId(jobDefinitionEntity.getId());
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity in project camunda-bpm-platform by camunda.
the class SetJobDefinitionPriorityCmd method execute.
public Void execute(CommandContext commandContext) {
ensureNotNull(NotValidException.class, "jobDefinitionId", jobDefinitionId);
JobDefinitionEntity jobDefinition = commandContext.getJobDefinitionManager().findById(jobDefinitionId);
ensureNotNull(NotFoundException.class, "Job definition with id '" + jobDefinitionId + "' does not exist", "jobDefinition", jobDefinition);
checkUpdateProcess(commandContext, jobDefinition);
Long currentPriority = jobDefinition.getOverridingJobPriority();
jobDefinition.setJobPriority(priority);
UserOperationLogContext opLogContext = new UserOperationLogContext();
createJobDefinitionOperationLogEntry(opLogContext, currentPriority, jobDefinition);
if (cascade && priority != null) {
commandContext.getJobManager().updateJobPriorityByDefinitionId(jobDefinitionId, priority);
createCascadeJobsOperationLogEntry(opLogContext, jobDefinition);
}
commandContext.getOperationLogManager().logUserOperations(opLogContext);
return null;
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity in project camunda-bpm-platform by camunda.
the class TransitionInstanceJobHandler method handle.
@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingTransitionInstance transitionInstance, List<JobEntity> elements) {
for (JobEntity job : elements) {
if (!isAsyncContinuation(job)) {
continue;
}
ScopeImpl targetScope = transitionInstance.getTargetScope();
if (targetScope != null) {
JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(transitionInstance.getTargetScope().getId(), job.getJobHandlerType());
MigratingAsyncJobInstance migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity, transitionInstance.getTargetScope());
transitionInstance.setDependentJobInstance(migratingJobInstance);
parseContext.submit(migratingJobInstance);
}
parseContext.consume(job);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity in project camunda-bpm-platform by camunda.
the class AbstractSetJobDefinitionStateCmd method checkAuthorization.
@Override
protected void checkAuthorization(CommandContext commandContext) {
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
if (jobDefinitionId != null) {
JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);
if (jobDefinition != null && jobDefinition.getProcessDefinitionKey() != null) {
String processDefinitionKey = jobDefinition.getProcessDefinitionKey();
checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);
if (includeSubResources) {
checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
}
} else if (processDefinitionId != null) {
checker.checkUpdateProcessDefinitionById(processDefinitionId);
if (includeSubResources) {
checker.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
}
} else if (processDefinitionKey != null) {
checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);
if (includeSubResources) {
checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
}
}
}
Aggregations