Search in sources :

Example 1 with JobDefinitionManager

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);
}
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 2 with JobDefinitionManager

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);
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) HistoricJobLogManager(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogManager) HistoricIncidentManager(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentManager)

Example 3 with JobDefinitionManager

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);
            }
        }
    }
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 4 with JobDefinitionManager

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());
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)

Example 5 with JobDefinitionManager

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);
        }
    }
}
Also used : JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager)

Aggregations

JobDefinitionManager (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)7 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)5 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)2 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 HistoricIncidentManager (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentManager)1 HistoricJobLogManager (org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogManager)1 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)1 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)1 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)1