|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
org.chorem.jtimer.io.AbstractSaver
org.chorem.jtimer.io.GTimerIncrementalSaver
public class GTimerIncrementalSaver
Charge et sauve les fichiers au format gTimer. Le format de fichier utilisé ici est 1.2. => Format: 1.2 Changes: - contrairement à la premiere version, ce Saver sauve les projets/taches/annotations seulement si elles ont été modifiées.
Field Summary | |
---|---|
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. |
Fields inherited from class org.chorem.jtimer.io.AbstractSaver |
---|
BACKUP_EXTENSION |
Constructor Summary | |
---|---|
GTimerIncrementalSaver()
Constructor. |
Method Summary | |
---|---|
void |
addProject(TimerProject project)
Add project event. |
void |
addTask(TimerTask task)
Add task event. |
protected void |
backupGTimerFiles()
For development. |
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 task,
TimerTask taskToMoveTo)
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 |
postChangeClosedState(TimerTask task)
Post change task state. |
void |
postMergeTasks(TimerTask destinationTask,
List<TimerTask> otherTasks)
Post merge task. |
void |
preChangeClosedState(TimerTask task)
Pre change task state. |
void |
preDeleteProject(TimerProject project)
Before delete project. |
void |
preDeleteTask(TimerTask task)
Before delete 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. |
Methods inherited from class org.chorem.jtimer.io.AbstractSaver |
---|
deleteBackupFile, makeBackupFile, restoreBackupFile |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public GTimerIncrementalSaver()
Method Detail |
---|
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
load
in interface Saver
protected Collection<TimerProject> gTimerLoad()
protected TimerProject getProjectFromFile(File projectFile) throws IOException
projectFile
- project file
IOException
- 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 process
IOException
- if ioexception occursprotected void parseAnnotations(TimerTask task) throws IOException
task
- task to load annotations
IOException
- if can't read ann fileprotected void parseAlerts(TimerTask task) throws IOException
Properties#load(java.io.InputStream)
.
Constains duplicated keys.
task
- task to load alert
IOException
- 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
- names
protected void backupGTimerFiles()
protected boolean isGTimerFile(String filename)
filename
- filename
protected 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 preDeleteProject(TimerProject project)
DataEventListener
preDeleteProject
in interface DataEventListener
project
- deleted projectpublic void preDeleteTask(TimerTask task)
DataEventListener
preDeleteTask
in interface DataEventListener
task
- deleted taskpublic 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 postChangeClosedState(TimerTask task)
DataEventListener
postChangeClosedState
in interface DataEventListener
task
- taskpublic void preChangeClosedState(TimerTask task)
DataEventListener
preChangeClosedState
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 taskpublic void run()
run
in interface Runnable
run
in class TimerTask
protected void saveRunningTasks()
public void checkSetAnnotation(TimerTask task, Date date, String value)
checkSetAnnotation
in interface VetoableDataEventListener
task
- task to updatedate
- day of changevalue
- new annotationpublic void checkAddProject(TimerProject project)
checkAddProject
in interface VetoableDataEventListener
project
- project to addpublic void checkAddTask(TimerTask parent, TimerTask task)
checkAddTask
in interface VetoableDataEventListener
parent
- parent tasktask
- task to addprotected void checkName(TimerTask task)
task
- task to checkpublic void checkChangeClosedState(TimerTask task)
checkChangeClosedState
in interface VetoableDataEventListener
task
- taskpublic void checkDeleteProject(TimerProject project)
checkDeleteProject
in interface VetoableDataEventListener
project
- deleted projectpublic void checkDeleteTask(TimerTask task)
checkDeleteTask
in interface VetoableDataEventListener
task
- deleted taskpublic void checkModifyProject(TimerProject project)
checkModifyProject
in interface VetoableDataEventListener
project
- modified projectpublic void checkModifyTask(TimerTask task)
checkModifyTask
in interface VetoableDataEventListener
task
- modified taskpublic void checkMoveTask(TimerTask task, TimerTask taskToMoveTo)
checkMoveTask
in interface VetoableDataEventListener
task
- task to movetaskToMoveTo
- task to move topublic void checkSetTaskTime(TimerTask task, Date date, Long value)
checkSetTaskTime
in interface VetoableDataEventListener
task
- task to updatedate
- day of changevalue
- new time in secondspublic void checkMergeTasks(TimerTask destinationTask, List<TimerTask> otherTasks)
checkMergeTasks
in interface VetoableDataEventListener
destinationTask
- task result of mergeotherTasks
- other task to merge
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |