cluster5.server.datastorage.dao
Class TaskDao

java.lang.Object
  extended by cluster5.server.datastorage.dao.TaskDao

public class TaskDao
extends java.lang.Object


Constructor Summary
TaskDao()
           
 
Method Summary
 void cleanTasksProcessedBy(java.lang.Long terminalId)
          Resets all tasks processed by the specified terminal to NEW with null allocation tag.
 boolean deleteTask(java.lang.Long taskId)
          Deletes a task indentified by its ID from database.
 Task getByAllocationTag(java.lang.String allocationTag)
           
 Task getById(java.lang.Long taskId)
           
 Task.Status getStatus(java.lang.Long taskId)
           
 java.util.List<Task.Status> getTaskStatuses(java.lang.Long projectId)
          Return distinct list of statuses of tasks for specified project id.
 java.util.List<java.lang.Long> listTaskIds(java.lang.Long projectId)
           
 Task save(Task task)
          Saves or updates a Task in(to) the database.
 int tagPendingTask(java.lang.String allocationTag)
          Tags one or more tasks awaiting to be processed with specified allocationTag so we then know which one(s) have been reserved.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskDao

public TaskDao()
Method Detail

getById

public Task getById(java.lang.Long taskId)

getStatus

public Task.Status getStatus(java.lang.Long taskId)

listTaskIds

public java.util.List<java.lang.Long> listTaskIds(java.lang.Long projectId)

deleteTask

public boolean deleteTask(java.lang.Long taskId)
Deletes a task indentified by its ID from database.

Parameters:
taskId -
Returns:
true on operation success

save

public Task save(Task task)
Saves or updates a Task in(to) the database.

Parameters:
task - to be saved
Returns:
instance of Task with the ID set

tagPendingTask

public int tagPendingTask(java.lang.String allocationTag)
Tags one or more tasks awaiting to be processed with specified allocationTag so we then know which one(s) have been reserved. This is to avoid collisions when transactions are not available.

Parameters:
allocationTag -
Returns:
number of records that were successfully tagged

getByAllocationTag

public Task getByAllocationTag(java.lang.String allocationTag)
Parameters:
allocationTag -
Returns:
instance of Task by specified allocationTag or null if there is no such one

getTaskStatuses

public java.util.List<Task.Status> getTaskStatuses(java.lang.Long projectId)
Return distinct list of statuses of tasks for specified project id. Good for determining if a Project has finished or not some Tasks are still being processed.

Parameters:
projectId -
Returns:
distinct list of statuses of tasks for specified project id.

cleanTasksProcessedBy

public void cleanTasksProcessedBy(java.lang.Long terminalId)
Resets all tasks processed by the specified terminal to NEW with null allocation tag.

Parameters:
terminalId - ID of a terminal that just shut down or crashed