TaskService

public interface TaskService

Service interface for managing tasks.

Methods

deleteTask

void deleteTask(Long taskId)

Deletes the task with the given ID.

Parameters:
  • taskId – the ID of the task, not null

exportTask

String exportTask(Long taskId)

Exports the task with the given ID as a JSON String.

Parameters:
  • taskId – the ID of the task, not null
Returns:

the JSON as a String

findActiveTasksForTrigger

List<Task> findActiveTasksForTrigger(TriggerEvent trigger)

Returns the list of active tasks with the given trigger. Used for retrieving tasks to execute when a given trigger fires.

Parameters:
  • trigger – the trigger, null returns empty list
Returns:

the list of active tasks

findActiveTasksForTriggerSubject

List<Task> findActiveTasksForTriggerSubject(String subject)

Returns the list of active tasks for the given trigger subject. Used for retrieving tasks to execute when a given trigger fires.

Parameters:
  • subject – the subject of the trigger, null returns empty list
Returns:

the list of active tasks

findCustomParser

TasksEventParser findCustomParser(String name)

Looks for implementations of the org.motechproject.commons.api.TasksEventParser that have been exposed as OSGi services by bundles. For all found implementations, this method will match names returned by the getName() method of the TasksEventParser and passed as parameter to this method. If a match is found, the implementation is returned.

Parameters:
  • name – A name of the parser, that will be matched with getName() of the implementations
Returns:

Implementation of the org.motechproject.commons.api.TasksEventParser that returns the same name via getName() method as the name passed to the method

findTasksByName

List<Task> findTasksByName(String name)

Return the list of tasks with the given name.

Parameters:
  • name – the task name, null returns null
Returns:

the list of tasks meeting the given condition

findTasksDependentOnModule

List<Task> findTasksDependentOnModule(String moduleName)

Returns the list of task dependent on the module with the given name.

Parameters:
  • moduleName – the name of the module, not null
Returns:

the list of tasks

findTrigger

TriggerEvent findTrigger(String subject)

Returns a trigger with the given subject.

Parameters:
  • subject – the trigger subject, not null
Throws:
Returns:

the trigger with the given subject

getActionEventFor

ActionEvent getActionEventFor(TaskActionInformation taskActionInformation)

Returns the action event that matches the given information about the task action.

Parameters:
  • taskActionInformation – the action information, not null
Throws:
Returns:

the action event matching the given information

getAllTasks

List<Task> getAllTasks()

Returns the list of all tasks.

Returns:the list of all tasks

getTask

Task getTask(Long taskId)

Returns the task with the given ID.

Parameters:
  • taskId – the ID of the task, null returns null
Returns:

the task with the given ID, null if task with the given ID wasn’t found

importTask

Task importTask(String json)

Imports the task from JSON String.

Parameters:
  • json – the task in JSON format
Throws:
  • IOException – when there were problems while parsing the JSON
Returns:

the imported task, not null

save

void save(Task task)

Saves the given task in the database.

Parameters:
  • task – the task to be saved, not null