public class GTimerIncrementalSaver extends AbstractSaver implements Saver, DataEventListener
Modifier and Type | Field and Description |
---|---|
protected long |
autoSaveDelay
Auto save delay.
|
protected Timer |
autoSaveTimer
Timer used for autosave.
|
protected FileChannel |
channel
Resource used by lock.
|
protected static String |
GTIMER_ALERT_EXTENSION
Extension alert.
|
protected static String |
GTIMER_ANNOTATION_EXTENSION
Extension annotation.
|
protected static String |
GTIMER_EMPTY_PROJECT_NAME
Empty gtimer project name.
|
protected static String |
GTIMER_FILE_VERSION
Version du format de fichier.
|
protected static String |
GTIMER_PROJECT_EXTENSION
Extension project.
|
protected static String |
GTIMER_SUBTASK_SEPARATOR
Separateur pour les sous taches.
|
protected static String |
GTIMER_TASK_EXTENSION
Extension task.
|
protected FileLock |
lock
Resource used by lock.
|
protected static String |
LOCK_FILE_NAME
Lock filename.
|
protected RandomAccessFile |
raf
Resource used by lock.
|
protected Collection<TimerTask> |
runningTasks
Running task list.
|
protected String |
saveDirectory
Save directory.
|
BACKUP_EXTENSION
Constructor and Description |
---|
GTimerIncrementalSaver()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addProject(TimerProject project)
Add project event.
|
void |
addTask(TimerTask task)
Add task event.
|
protected void |
backupGTimerFiles()
For development.
|
void |
changeClosedState(TimerTask task)
Change task state.
|
void |
checkAddProject(TimerProject project)
Check add project.
|
void |
checkAddTask(TimerTask parent,
TimerTask task)
Check add task.
|
void |
checkChangeClosedState(TimerTask task)
Check change task state.
|
void |
checkDeleteProject(TimerProject project)
Check delete project.
|
void |
checkDeleteTask(TimerTask task)
Check delete task.
|
void |
checkMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
Check merge task.
|
void |
checkModifyProject(TimerProject project)
Check modify project.
|
void |
checkModifyTask(TimerTask task)
Check modify task.
|
void |
checkMoveTask(TimerTask destination,
Collection<TimerTask> tasksToMove)
Check move task.
|
protected void |
checkName(TimerTask task)
Check task name.
|
protected void |
checkSaveDirectory()
Check that save directory exists.
|
void |
checkSetAnnotation(TimerTask task,
Date date,
String value)
Check update task annotation.
|
void |
checkSetTaskTime(TimerTask task,
Date date,
Long value)
Check update task time.
|
void |
dataLoaded(Collection<TimerProject> projects)
All data loaded.
|
void |
deleteProject(TimerProject project)
Delete project.
|
void |
deleteTask(TimerTask task)
Delete task.
|
protected void |
deleteTaskOrProject(TimerTask taskOrProject,
String extension)
Delete associated file or project files on disk.
|
protected TimerTask |
findTask(TimerTask parentTask,
String[] taskNames)
Find a task in task's subtask
|
protected TimerProject |
getProjectFromFile(File projectFile)
Load a project in his file.
|
protected int |
getUnusedNumber(String extension)
Explore directory and find a non used number for project.
|
protected Collection<TimerProject> |
gTimerLoad()
Load from gtimer file format.
|
protected boolean |
isGTimerFile(String filename)
Check if a file denoted by his name is a gtimer file.
|
Collection<TimerProject> |
load()
Load a project list.
|
void |
lock()
Try to lock current saver directory.
|
void |
modifyProject(TimerProject project)
Modify project.
|
void |
modifyTask(TimerTask task)
Modify task.
|
void |
moveTask(TimerTask task)
Post move task.
|
protected void |
parseAlerts(TimerTask task)
Find task alert and load it.
|
protected void |
parseAnnotations(TimerTask task)
Try to find and load annotations from task.
|
protected TimerTask |
parseTaskFromFile(Map<String,TimerProject> mapNumberProject,
File taskFile,
SortedMap<TimerTask,TimerProject> taskToManage)
Parse task file.
|
protected void |
parseTaskFromSavedMap(SortedMap<TimerTask,TimerProject> taskToManage)
Post process task to manage subtask loaded before parent task.
|
void |
postMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
Post merge task.
|
void |
preMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
Pre merge task.
|
void |
preMoveTask(TimerTask task)
Pre move task.
|
void |
run() |
protected void |
saveAlerts(TimerTask task)
Save task alerts.
|
protected void |
saveProject(TimerProject project)
Save a unique project.
|
protected void |
saveRunningTasks()
Save runing tasks.
|
protected void |
saveTask(TimerTask task)
Save task, found correct prefix, and project.
|
protected void |
saveTask(TimerTask task,
int associatedToProject,
String taskPrefixName)
Save a task.
|
protected void |
saveTaskAnnotation(TimerTask task)
Save annotation for a task.
|
void |
setAnnotation(TimerTask task,
Date date,
String annotation)
Add annotation.
|
void |
setAutoSaveDelay(long autoSaveDelay)
Set auto save delay (in milliseconds).
|
void |
setSaveDirectory(String directory)
Set file directory.
|
void |
setTaskTime(TimerTask task,
Date date,
Long time)
Set task time.
|
void |
startTask(TimerTask task)
Start task.
|
void |
stopTask(TimerTask task)
Stop task.
|
void |
unlock()
Try to unlock current saver directory.
|
deleteBackupFile, makeBackupFile, restoreBackupFile
cancel, scheduledExecutionTime
protected static final String GTIMER_SUBTASK_SEPARATOR
protected static final String GTIMER_FILE_VERSION
protected static final String GTIMER_PROJECT_EXTENSION
protected static final String GTIMER_TASK_EXTENSION
protected static final String GTIMER_ANNOTATION_EXTENSION
protected static final String GTIMER_ALERT_EXTENSION
protected static final String GTIMER_EMPTY_PROJECT_NAME
protected static final String LOCK_FILE_NAME
protected String saveDirectory
protected FileLock lock
protected RandomAccessFile raf
protected FileChannel channel
protected Timer autoSaveTimer
protected long autoSaveDelay
protected Collection<TimerTask> runningTasks
public void setSaveDirectory(String directory)
Saver
setSaveDirectory
in interface Saver
directory
- directorypublic void setAutoSaveDelay(long autoSaveDelay)
Saver
setAutoSaveDelay
in interface Saver
autoSaveDelay
- delay in millisecondsprotected void checkSaveDirectory()
public void lock() throws DataLockingException
Saver
lock
in interface Saver
DataLockingException
- if can't obtain lockpublic void unlock() throws DataLockingException
Saver
unlock
in interface Saver
DataLockingException
- if there is no lockpublic Collection<TimerProject> load()
Saver
protected Collection<TimerProject> gTimerLoad()
protected TimerProject getProjectFromFile(File projectFile) throws IOException
projectFile
- project fileIOException
- if ioexception occursprotected TimerTask parseTaskFromFile(Map<String,TimerProject> mapNumberProject, File taskFile, SortedMap<TimerTask,TimerProject> taskToManage) throws IOException
mapNumberProject
- map entre les projets reels et leur numero gtimertaskFile
- gtimer task filetaskToManage
- sorted map to remember task to post processIOException
- if ioexception occursprotected void parseAnnotations(TimerTask task) throws IOException
task
- task to load annotationsIOException
- if can't read ann fileprotected void parseAlerts(TimerTask task) throws IOException
Properties#load(java.io.InputStream)
.
Constains duplicated keys.task
- task to load alertIOException
- if can't read ann fileprotected void parseTaskFromSavedMap(SortedMap<TimerTask,TimerProject> taskToManage)
taskToManage
- sorted map of those taskprotected TimerTask findTask(TimerTask parentTask, String[] taskNames)
parentTask
- tasktaskNames
- namesprotected void backupGTimerFiles()
protected boolean isGTimerFile(String filename)
filename
- filenameprotected void saveProject(TimerProject project)
project
- project to saveprotected void saveTask(TimerTask task)
saveTask(TimerTask, int, String)
task
- task to saveprotected void saveTask(TimerTask task, int associatedToProject, String taskPrefixName)
task
- task to saveassociatedToProject
- associated project numbertaskPrefixName
- task prefix nameprotected void saveTaskAnnotation(TimerTask task)
task
- task to save annotationprotected void saveAlerts(TimerTask task)
task
- task to save alertpublic void addProject(TimerProject project)
DataEventListener
addProject
in interface DataEventListener
project
- project to addpublic void addTask(TimerTask task)
DataEventListener
addTask
in interface DataEventListener
task
- task to addprotected int getUnusedNumber(String extension)
extension
- to check (ie ".project" or ".task")public void dataLoaded(Collection<TimerProject> projects)
DataEventListener
dataLoaded
in interface DataEventListener
projects
- projects collectionpublic void deleteProject(TimerProject project)
DataEventListener
deleteProject
in interface DataEventListener
project
- deleted projectpublic void deleteTask(TimerTask task)
DataEventListener
deleteTask
in interface DataEventListener
task
- deleted taskprotected void deleteTaskOrProject(TimerTask taskOrProject, String extension)
taskOrProject
- task or project to delete fileextension
- extension without .public void modifyProject(TimerProject project)
DataEventListener
modifyProject
in interface DataEventListener
project
- modified projectpublic void modifyTask(TimerTask task)
DataEventListener
modifyTask
in interface DataEventListener
task
- modified taskpublic void setAnnotation(TimerTask task, Date date, String annotation)
DataEventListener
setAnnotation
in interface DataEventListener
task
- task where annotation is changeddate
- dateannotation
- new annotation valuepublic void setTaskTime(TimerTask task, Date date, Long time)
DataEventListener
setTaskTime
in interface DataEventListener
task
- task where time is changeddate
- datetime
- task timepublic void changeClosedState(TimerTask task)
DataEventListener
changeClosedState
in interface DataEventListener
task
- taskpublic void preMoveTask(TimerTask task)
DataEventListener
preMoveTask
in interface DataEventListener
task
- taskpublic void moveTask(TimerTask task)
DataEventListener
moveTask
in interface DataEventListener
task
- taskpublic void postMergeTasks(TimerTask destinationTask, List<TimerTask> otherTasks)
DataEventListener
postMergeTasks
in interface DataEventListener
destinationTask
- task where all other task will be mergedotherTasks
- other tasks to mergepublic void preMergeTasks(TimerTask destinationTask, List<TimerTask> otherTasks)
DataEventListener
preMergeTasks
in interface DataEventListener
destinationTask
- task where all other task will be mergedotherTasks
- other tasks to mergepublic void startTask(TimerTask task)
DataEventListener
startTask
in interface DataEventListener
task
- started taskpublic void stopTask(TimerTask task)
DataEventListener
stopTask
in interface DataEventListener
task
- stoped taskprotected void saveRunningTasks()
public void checkSetAnnotation(TimerTask task, Date date, String value)
VetoableDataEventListener
checkSetAnnotation
in interface VetoableDataEventListener
task
- task to updatedate
- day of changevalue
- new annotationpublic void checkAddProject(TimerProject project)
VetoableDataEventListener
checkAddProject
in interface VetoableDataEventListener
project
- project to addpublic void checkAddTask(TimerTask parent, TimerTask task)
VetoableDataEventListener
checkAddTask
in interface VetoableDataEventListener
parent
- parent tasktask
- task to addprotected void checkName(TimerTask task)
task
- task to checkpublic void checkChangeClosedState(TimerTask task)
VetoableDataEventListener
checkChangeClosedState
in interface VetoableDataEventListener
task
- taskpublic void checkDeleteProject(TimerProject project)
VetoableDataEventListener
checkDeleteProject
in interface VetoableDataEventListener
project
- deleted projectpublic void checkDeleteTask(TimerTask task)
VetoableDataEventListener
checkDeleteTask
in interface VetoableDataEventListener
task
- deleted taskpublic void checkModifyProject(TimerProject project)
VetoableDataEventListener
checkModifyProject
in interface VetoableDataEventListener
project
- modified projectpublic void checkModifyTask(TimerTask task)
VetoableDataEventListener
checkModifyTask
in interface VetoableDataEventListener
task
- modified taskpublic void checkMoveTask(TimerTask destination, Collection<TimerTask> tasksToMove)
VetoableDataEventListener
checkMoveTask
in interface VetoableDataEventListener
destination
- task to move totasksToMove
- tasks to movepublic void checkSetTaskTime(TimerTask task, Date date, Long value)
VetoableDataEventListener
checkSetTaskTime
in interface VetoableDataEventListener
task
- task to updatedate
- day of changevalue
- new time in secondspublic void checkMergeTasks(TimerTask destinationTask, List<TimerTask> otherTasks)
VetoableDataEventListener
checkMergeTasks
in interface VetoableDataEventListener
destinationTask
- task result of mergeotherTasks
- other task to mergeCopyright © 2007–2013 CodeLutin. All rights reserved.