net.sf.borg.model
Class TaskModel

java.lang.Object
  extended by net.sf.borg.model.Model
      extended by net.sf.borg.model.TaskModel
All Implemented Interfaces:
CategoryModel.CategorySource, Model.Listener, Searchable<KeyedEntity>

public class TaskModel
extends Model
implements Model.Listener, CategoryModel.CategorySource, Searchable<KeyedEntity>

TaksModel manages all of the task related entities - Task, Project, Subtask, and Tasklog


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.borg.model.Model
Model.Listener
 
Method Summary
 void addLog(int taskid, String desc)
          Add a task log entry.
 void beginTransaction()
           
 void close(int num)
          close a task
 void closeProject(int num)
          Close a project.
 void commitTransaction()
           
static int daysBetween(Date start, Date dd)
          determine the number fo days between two dates
static int daysLeft(Date dd)
          return the number of days left before a given date.
 void delete(int tasknum)
          Delete a task
 void delete(int tasknum, boolean undo)
          Delete a task
 void deleteProject(int id)
          Delete a project.
 void deleteSubTask(int id)
          Delete a sub task.
 void deleteSubTask(int id, boolean undo)
          Delete a sub task.
 void export(Writer fw)
          export the task data for all tasks to XML.
 Collection<Project> get_projects(Date d)
          Get all projects due on a particular date
 Collection<Subtask> get_subtasks(Date d)
          Get all subtasks due on a particular date
 Vector<Task> get_tasks()
          Get all open tasks with a due date
 Collection<Task> get_tasks(Date d)
          Get all tasks due on a particular date
 Collection<Project> getAllSubProjects(int projectid)
          Gets the entire project tree for a project
 Collection<String> getCategories()
          Gets the list of all categories from all entities in the source model
 TaskDB getDB()
          Gets the dB.
 Collection<Tasklog> getLogs()
          Get all task logs.
 Collection<Tasklog> getLogs(int taskid)
          Get all task logs for a task.
 Project getProject(int id)
          Get a project by id.
 Collection<Project> getProjects()
          Get all projects.
static TaskModel getReference()
          Gets the singleton.
 Collection<Project> getSubProjects(int projectid)
          Get sub projects for a project - direct children only
 Subtask getSubTask(int id)
          Get a sub task by id.
 Collection<Subtask> getSubTasks()
          Get all sub tasks.
 Collection<Subtask> getSubTasks(int taskid)
          Get the sub tasks for a task
 Task getTask(int num)
          Gets a task by id.
 Collection<Task> getTasks()
          Get all tasks.
 Collection<Task> getTasks(int projectid)
          Get all tasks for a project.
 TaskTypes getTaskTypes()
          Gets the task types.
 void importXml(String fileName)
          Import xml.
static boolean isClosed(Project p)
          Checks if a project is closed.
static boolean isClosed(Task t)
          Checks if a task is closed.
 Task newMR()
          create a new task
 void refresh()
          Called to notify Listener when the Model is changed.
 void rollbackTransaction()
           
 void saveProject(Project p)
          Save a project.
 void saveProject(Project p, boolean undo)
          Save a project.
 void saveSubTask(Subtask s)
          Save a sub task.
 void saveSubTask(Subtask s, boolean undo)
          Save a sub task.
 void savetask(Task task)
          Save a task.
 void savetask(Task task, boolean undo)
          Save a task.
 void saveTaskTypes(TaskTypes tt)
          save the task types to the db
 Collection<KeyedEntity> search(SearchCriteria criteria)
          Return a collection of all records that match the given search criteria
 void sync()
          sync with db
 
Methods inherited from class net.sf.borg.model.Model
addListener, refreshListeners, remove, removeListener, removeListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDB

public TaskDB getDB()
Gets the dB.

Returns:
the dB

get_tasks

public Collection<Task> get_tasks(Date d)
Get all tasks due on a particular date

Parameters:
d - the date
Returns:
the tasks

get_subtasks

public Collection<Subtask> get_subtasks(Date d)
Get all subtasks due on a particular date

Parameters:
d - the date
Returns:
the subtasks

get_projects

public Collection<Project> get_projects(Date d)
Get all projects due on a particular date

Parameters:
d - the date
Returns:
the projects

get_tasks

public Vector<Task> get_tasks()
Get all open tasks with a due date

Returns:
the tasks

getReference

public static TaskModel getReference()
Gets the singleton.

Returns:
the singleton

getTaskTypes

public TaskTypes getTaskTypes()
Gets the task types.

Returns:
the task types

saveTaskTypes

public void saveTaskTypes(TaskTypes tt)
                   throws Exception
save the task types to the db

Parameters:
tt - the task types
Throws:
Exception - the exception

getCategories

public Collection<String> getCategories()
Description copied from interface: CategoryModel.CategorySource
Gets the list of all categories from all entities in the source model

Specified by:
getCategories in interface CategoryModel.CategorySource
Returns:
the categories

getTasks

public Collection<Task> getTasks()
                          throws Exception
Get all tasks.

Returns:
the tasks
Throws:
Exception - the exception

delete

public void delete(int tasknum)
            throws Exception
Delete a task

Parameters:
tasknum - the task id
Throws:
Exception - the exception

delete

public void delete(int tasknum,
                   boolean undo)
            throws Exception
Delete a task

Parameters:
tasknum - the task id
undo - true if we are executing an undo
Throws:
Exception - the exception

deleteProject

public void deleteProject(int id)
                   throws Exception
Delete a project.

Parameters:
id - the project id
Throws:
Exception - the exception

savetask

public void savetask(Task task)
              throws Exception
Save a task.

Parameters:
task - the task
Throws:
Exception - the exception

savetask

public void savetask(Task task,
                     boolean undo)
              throws Exception
Save a task.

Parameters:
task - the task
undo - true if we are executing an undo
Throws:
Exception - the exception

newMR

public Task newMR()
create a new task

Returns:
the task

getTask

public Task getTask(int num)
             throws Exception
Gets a task by id.

Parameters:
num - the id
Returns:
the task
Throws:
Exception - the exception

close

public void close(int num)
           throws Exception,
                  Warning
close a task

Parameters:
num - the task id
Throws:
Exception - the exception
Warning - the warning

closeProject

public void closeProject(int num)
                  throws Exception,
                         Warning
Close a project.

Parameters:
num - the project id
Throws:
Exception - the exception
Warning - the warning

export

public void export(Writer fw)
            throws Exception
export the task data for all tasks to XML. Also exports the options

Parameters:
fw - the writer to send XML to
Throws:
Exception - the exception

getProjects

public Collection<Project> getProjects()
                                throws Exception
Get all projects.

Returns:
the projects
Throws:
Exception - the exception

getProject

public Project getProject(int id)
                   throws Exception
Get a project by id.

Parameters:
id - the id
Returns:
the project
Throws:
Exception - the exception

importXml

public void importXml(String fileName)
               throws Exception
Import xml.

Parameters:
fileName - the file name of the file containing the XML
Throws:
Exception - the exception

sync

public void sync()
sync with db


refresh

public void refresh()
Description copied from interface: Model.Listener
Called to notify Listener when the Model is changed.

Specified by:
refresh in interface Model.Listener

getSubTasks

public Collection<Subtask> getSubTasks(int taskid)
                                throws Exception
Get the sub tasks for a task

Parameters:
taskid - the task id
Returns:
the sub tasks
Throws:
Exception - the exception

getSubTasks

public Collection<Subtask> getSubTasks()
                                throws Exception
Get all sub tasks.

Returns:
the sub tasks
Throws:
Exception - the exception

getSubTask

public Subtask getSubTask(int id)
                   throws Exception
Get a sub task by id.

Parameters:
id - the subtask id
Returns:
the sub task
Throws:
Exception - the exception

getTasks

public Collection<Task> getTasks(int projectid)
                          throws Exception
Get all tasks for a project.

Parameters:
projectid - the projectid
Returns:
the tasks
Throws:
Exception - the exception

getSubProjects

public Collection<Project> getSubProjects(int projectid)
                                   throws Exception
Get sub projects for a project - direct children only

Parameters:
projectid - the project id
Returns:
the sub projects
Throws:
Exception - the exception

getAllSubProjects

public Collection<Project> getAllSubProjects(int projectid)
                                      throws Exception
Gets the entire project tree for a project

Parameters:
projectid - the root project id
Returns:
the all sub projects
Throws:
Exception - the exception

deleteSubTask

public void deleteSubTask(int id)
                   throws Exception
Delete a sub task.

Parameters:
id - the subtask id
Throws:
Exception - the exception

deleteSubTask

public void deleteSubTask(int id,
                          boolean undo)
                   throws Exception
Delete a sub task.

Parameters:
id - the subtask id
undo - true if we are executing an undo
Throws:
Exception - the exception

saveSubTask

public void saveSubTask(Subtask s)
                 throws Exception
Save a sub task.

Parameters:
s - the subtask
Throws:
Exception - the exception

saveSubTask

public void saveSubTask(Subtask s,
                        boolean undo)
                 throws Exception
Save a sub task.

Parameters:
s - the subtask
undo - true if we are executing an undo
Throws:
Exception - the exception

addLog

public void addLog(int taskid,
                   String desc)
            throws Exception
Add a task log entry.

Parameters:
taskid - the task id
desc - the log message
Throws:
Exception - the exception

getLogs

public Collection<Tasklog> getLogs(int taskid)
                            throws Exception
Get all task logs for a task.

Parameters:
taskid - the task id
Returns:
the logs
Throws:
Exception - the exception

getLogs

public Collection<Tasklog> getLogs()
                            throws Exception
Get all task logs.

Returns:
the logs
Throws:
Exception - the exception

daysLeft

public static int daysLeft(Date dd)
return the number of days left before a given date.

Parameters:
dd - the date
Returns:
the number of days left

daysBetween

public static int daysBetween(Date start,
                              Date dd)
determine the number fo days between two dates

Parameters:
start - the first date
dd - the later date
Returns:
the int

beginTransaction

public void beginTransaction()
                      throws Exception
Throws:
Exception

commitTransaction

public void commitTransaction()
                       throws Exception
Throws:
Exception

rollbackTransaction

public void rollbackTransaction()
                         throws Exception
Throws:
Exception

saveProject

public void saveProject(Project p)
                 throws Exception
Save a project.

Parameters:
p - the project
Throws:
Exception - the exception

saveProject

public void saveProject(Project p,
                        boolean undo)
                 throws Exception
Save a project.

Parameters:
p - the project
undo - true if we are executing an undo
Throws:
Exception - the exception

isClosed

public static boolean isClosed(Task t)
Checks if a task is closed.

Parameters:
t - the task
Returns:
true, if the task is closed

isClosed

public static boolean isClosed(Project p)
Checks if a project is closed.

Parameters:
p - the project
Returns:
true, if a project is closed

search

public Collection<KeyedEntity> search(SearchCriteria criteria)
Description copied from interface: Searchable
Return a collection of all records that match the given search criteria

Specified by:
search in interface Searchable<KeyedEntity>
Parameters:
criteria - the search criteria
Returns:
collection of matching records


Generated September 24 2010 by mbb using Apache Ant version 1.7.1 compiled on June 27 2008 and Java version 1.6.0_20 from Sun Microsystems Inc. on Linux i386 2.6.24-28-generic