Search in sources :

Example 1 with JobDto

use of io.zeebe.monitor.rest.dto.JobDto 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 JobDto

use of io.zeebe.monitor.rest.dto.JobDto in project zeebe-simple-monitor by camunda-community-hub.

the class JobsViewController method toDto.

static JobDto toDto(final JobEntity job) {
    final JobDto dto = new JobDto();
    dto.setKey(job.getKey());
    dto.setJobType(job.getJobType());
    dto.setProcessInstanceKey(job.getProcessInstanceKey());
    dto.setElementInstanceKey(job.getElementInstanceKey());
    dto.setState(job.getState());
    dto.setRetries(job.getRetries());
    Optional.ofNullable(job.getWorker()).ifPresent(dto::setWorker);
    dto.setTimestamp(Instant.ofEpochMilli(job.getTimestamp()).toString());
    return dto;
}
Also used : JobDto(io.zeebe.monitor.rest.dto.JobDto)

Aggregations

JobDto (io.zeebe.monitor.rest.dto.JobDto)2 JobEntity (io.zeebe.monitor.entity.JobEntity)1 ArrayList (java.util.ArrayList)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1