Search in sources :

Example 1 with JobState

use of org.camunda.bpm.engine.history.JobState in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method initHistoricJobLogEvent.

protected void initHistoricJobLogEvent(HistoricJobLogEventEntity evt, Job job, HistoryEventType eventType) {
    evt.setTimestamp(ClockUtil.getCurrentTime());
    JobEntity jobEntity = (JobEntity) job;
    evt.setJobId(jobEntity.getId());
    evt.setJobDueDate(jobEntity.getDuedate());
    evt.setJobRetries(jobEntity.getRetries());
    evt.setJobPriority(jobEntity.getPriority());
    JobDefinition jobDefinition = jobEntity.getJobDefinition();
    if (jobDefinition != null) {
        evt.setJobDefinitionId(jobDefinition.getId());
        evt.setJobDefinitionType(jobDefinition.getJobType());
        evt.setJobDefinitionConfiguration(jobDefinition.getJobConfiguration());
    } else {
        // in case of async signal there does not exist a job definition
        // but we use the jobHandlerType as jobDefinitionType
        evt.setJobDefinitionType(jobEntity.getJobHandlerType());
    }
    evt.setActivityId(jobEntity.getActivityId());
    evt.setExecutionId(jobEntity.getExecutionId());
    evt.setProcessInstanceId(jobEntity.getProcessInstanceId());
    evt.setProcessDefinitionId(jobEntity.getProcessDefinitionId());
    evt.setProcessDefinitionKey(jobEntity.getProcessDefinitionKey());
    evt.setDeploymentId(jobEntity.getDeploymentId());
    evt.setTenantId(jobEntity.getTenantId());
    // initialize sequence counter
    initSequenceCounter(jobEntity, evt);
    JobState state = null;
    if (HistoryEventTypes.JOB_CREATE.equals(eventType)) {
        state = JobState.CREATED;
    } else if (HistoryEventTypes.JOB_FAIL.equals(eventType)) {
        state = JobState.FAILED;
    } else if (HistoryEventTypes.JOB_SUCCESS.equals(eventType)) {
        state = JobState.SUCCESSFUL;
    } else if (HistoryEventTypes.JOB_DELETE.equals(eventType)) {
        state = JobState.DELETED;
    }
    evt.setState(state.getStateCode());
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) JobState(org.camunda.bpm.engine.history.JobState) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Aggregations

JobState (org.camunda.bpm.engine.history.JobState)1 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)1 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)1