Search in sources :

Example 1 with TaskNotFoundException

use of org.motechproject.tasks.exception.TaskNotFoundException in project motech by motech.

the class TaskServiceImpl method deleteTask.

@Override
@Transactional
public void deleteTask(Long taskId) {
    Task t = getTask(taskId);
    if (t == null) {
        throw new TaskNotFoundException(taskId);
    }
    LOGGER.info("Deleted task: {} with ID: {}", t.getName(), taskId);
    tasksDataService.delete(t);
}
Also used : Task(org.motechproject.tasks.domain.mds.task.Task) TaskNotFoundException(org.motechproject.tasks.exception.TaskNotFoundException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with TaskNotFoundException

use of org.motechproject.tasks.exception.TaskNotFoundException in project motech by motech.

the class TaskServiceImpl method exportTask.

@Override
@Transactional
public String exportTask(Long taskId) {
    Task task = getTask(taskId);
    if (null != task) {
        LOGGER.info("Exporting task: {} with ID: {}", task.getName(), task.getId());
        JsonNode node = new ObjectMapper().valueToTree(task.toDto());
        removeIgnoredFields(node);
        return node.toString();
    } else {
        throw new TaskNotFoundException(taskId);
    }
}
Also used : Task(org.motechproject.tasks.domain.mds.task.Task) TaskNotFoundException(org.motechproject.tasks.exception.TaskNotFoundException) JsonNode(org.codehaus.jackson.JsonNode) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Task (org.motechproject.tasks.domain.mds.task.Task)2 TaskNotFoundException (org.motechproject.tasks.exception.TaskNotFoundException)2 Transactional (org.springframework.transaction.annotation.Transactional)2 JsonNode (org.codehaus.jackson.JsonNode)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1