Search in sources :

Example 1 with JobEntity

use of io.zeebe.monitor.entity.JobEntity in project zeebe-simple-monitor by camunda-community-hub.

the class JobsViewController method jobList.

@GetMapping("/views/jobs")
public String jobList(final Map<String, Object> model, final Pageable pageable) {
    final long count = jobRepository.countByStateNotIn(JOB_COMPLETED_INTENTS);
    final List<JobDto> dtos = new ArrayList<>();
    for (final JobEntity jobEntity : jobRepository.findByStateNotIn(JOB_COMPLETED_INTENTS, pageable)) {
        final JobDto dto = toDto(jobEntity);
        dtos.add(dto);
    }
    model.put("jobs", dtos);
    model.put("count", count);
    addPaginationToModel(model, pageable, count);
    addDefaultAttributesToModel(model);
    return "job-list-view";
}
Also used : JobEntity(io.zeebe.monitor.entity.JobEntity) JobDto(io.zeebe.monitor.rest.dto.JobDto) ArrayList(java.util.ArrayList) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with JobEntity

use of io.zeebe.monitor.entity.JobEntity in project zeebe-simple-monitor by camunda-community-hub.

the class JobImporter method importJob.

public void importJob(final Schema.JobRecord record) {
    final JobIntent intent = JobIntent.valueOf(record.getMetadata().getIntent());
    final long key = record.getMetadata().getKey();
    final long timestamp = record.getMetadata().getTimestamp();
    final JobEntity entity = jobRepository.findById(key).orElseGet(() -> {
        final JobEntity newEntity = new JobEntity();
        newEntity.setKey(key);
        newEntity.setProcessInstanceKey(record.getProcessInstanceKey());
        newEntity.setElementInstanceKey(record.getElementInstanceKey());
        newEntity.setJobType(record.getType());
        return newEntity;
    });
    entity.setState(intent.name().toLowerCase());
    entity.setTimestamp(timestamp);
    entity.setWorker(record.getWorker());
    entity.setRetries(record.getRetries());
    jobRepository.save(entity);
}
Also used : JobEntity(io.zeebe.monitor.entity.JobEntity) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent)

Example 3 with JobEntity

use of io.zeebe.monitor.entity.JobEntity in project zeebe-simple-monitor by camunda-community-hub.

the class JobResource method activateJob.

private ActivatedJob activateJob(final long key, final ZeebeClient client) {
    final JobEntity job = getJob(key);
    final String jobType = job.getJobType();
    return activateJob(client, key, jobType);
}
Also used : JobEntity(io.zeebe.monitor.entity.JobEntity)

Aggregations

JobEntity (io.zeebe.monitor.entity.JobEntity)3 JobIntent (io.camunda.zeebe.protocol.record.intent.JobIntent)1 JobDto (io.zeebe.monitor.rest.dto.JobDto)1 ArrayList (java.util.ArrayList)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1