use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager 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.JobDefinitionManager in project camunda-bpm-platform by camunda.
the class BatchEntity method delete.
public void delete(boolean cascadeToHistory) {
CommandContext commandContext = Context.getCommandContext();
deleteSeedJob();
deleteMonitorJob();
getBatchJobHandler().deleteJobs(this);
JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
jobDefinitionManager.delete(getSeedJobDefinition());
jobDefinitionManager.delete(getMonitorJobDefinition());
jobDefinitionManager.delete(getBatchJobDefinition());
commandContext.getBatchManager().delete(this);
configuration.deleteByteArrayValue();
fireHistoricEndEvent();
if (cascadeToHistory) {
HistoricIncidentManager historicIncidentManager = commandContext.getHistoricIncidentManager();
historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(seedJobDefinitionId);
historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(monitorJobDefinitionId);
historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(batchJobDefinitionId);
HistoricJobLogManager historicJobLogManager = commandContext.getHistoricJobLogManager();
historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(seedJobDefinitionId);
historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(monitorJobDefinitionId);
historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(batchJobDefinitionId);
commandContext.getHistoricBatchManager().deleteHistoricBatchById(id);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager 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.JobDefinitionManager 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.JobDefinitionManager in project camunda-bpm-platform by camunda.
the class AbstractSetJobDefinitionStateCmd method updateSuspensionState.
@Override
protected void updateSuspensionState(CommandContext commandContext, SuspensionState suspensionState) {
JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
JobManager jobManager = commandContext.getJobManager();
if (jobDefinitionId != null) {
jobDefinitionManager.updateJobDefinitionSuspensionStateById(jobDefinitionId, suspensionState);
} else if (processDefinitionId != null) {
jobDefinitionManager.updateJobDefinitionSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState);
jobManager.updateStartTimerJobSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState);
} else if (processDefinitionKey != null) {
if (!isProcessDefinitionTenantIdSet) {
jobDefinitionManager.updateJobDefinitionSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState);
jobManager.updateStartTimerJobSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState);
} else {
jobDefinitionManager.updateJobDefinitionSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState);
jobManager.updateStartTimerJobSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState);
}
}
}
Aggregations