use of org.motechproject.tasks.exception.TaskNameAlreadyExistsException in project motech by motech.
the class TaskServiceImpl method validateName.
private void validateName(Task task) {
Long taskId = task.getId();
List<Task> tasksWithName = tasksDataService.findTasksByName(task.getName());
if (taskId == null && tasksWithName.size() > 0) {
throw new TaskNameAlreadyExistsException(task.getName());
} else if (taskId != null && tasksWithName.size() > 0 && !tasksWithName.get(0).getId().equals(taskId)) {
throw new TaskNameAlreadyExistsException(task.getName());
}
}
Aggregations