Search in sources :

Example 1 with IdmScheduledTaskFilter

use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmScheduledTaskFilter in project CzechIdMng by bcvsolutions.

the class DefaultIdmScheduledTaskService method findByQuartzTaskName.

@Transactional(readOnly = true)
@Override
public IdmScheduledTaskDto findByQuartzTaskName(String taskName) {
    IdmScheduledTaskFilter filter = new IdmScheduledTaskFilter();
    filter.setQuartzTaskName(taskName);
    Page<IdmScheduledTaskDto> results = find(filter, new PageRequest(0, 1));
    if (results.getTotalElements() == 0) {
        return null;
    } else if (results.getTotalElements() == 1) {
        return results.iterator().next();
    }
    throw new SchedulerException(CoreResultCode.SEARCH_ERROR, ImmutableMap.of("reason", "Multiple tasks found for " + getClass().getSimpleName() + " task."));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) SchedulerException(eu.bcvsolutions.idm.core.scheduler.exception.SchedulerException) IdmScheduledTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmScheduledTaskFilter) IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmScheduledTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto)1 IdmScheduledTaskFilter (eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmScheduledTaskFilter)1 SchedulerException (eu.bcvsolutions.idm.core.scheduler.exception.SchedulerException)1 PageRequest (org.springframework.data.domain.PageRequest)1 Transactional (org.springframework.transaction.annotation.Transactional)1