|
Parkinson Disease Database | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectspirals.motol.database.Database
public class Database
Root class for storing database.
Each time database is exported all pacients are stored in random order without surname and firstname. No corespondence between database and exported data should be found.
Database contains Pacients. Pacients have Visits and Visits consist of Data. Database is stored in directory 'data' containing root file and direcotries of pacients. Only root file is loaded on application startup. Each pacient directory contains xml files representing visits and zip archives with captured tablet data for visits.
Copyright: Copyright (c) 2005 Jan Dolezel
Company: ÈVUT FEL, Prague
TabletData
,
Data
,
Pacient
,
Visit
Nested Class Summary | |
---|---|
static class |
Database.SORT
Enumerates sorting possibilities |
Field Summary | |
---|---|
static java.lang.String |
backupAttr
name of backup date attribute |
private java.util.HashMap<java.lang.String,Pacient> |
database
main database content |
static java.lang.String |
databaseTag
database tag (root element) |
private Engine |
engine
engine |
private Database.SORT |
howSort
current algorithm for sorting |
private java.util.Date |
lastBackup
date of last backup |
private java.util.List<Pacient> |
listAll
sorted list of all pacients |
private java.util.List<Pacient> |
listRestricted
sorted list of choosen pacients |
private boolean |
restricted
whether show all or only choosen pacients |
private java.io.File |
rootFile
root file of stored database |
Constructor Summary | |
---|---|
Database(Engine engine)
create new database or load content from file Check if database exist. |
Method Summary | |
---|---|
void |
addPacient(Pacient pacient)
add pacient to database and save Updates or inserts information about pacient, sort lists of pacients and saves database to disk. |
void |
backuped()
must be called when database is backuped |
void |
clearRestricted()
clear list with choosen pacients |
private void |
createDB()
create new database Creates new database directory and root file. |
void |
export()
exports data from database to user choosen file All database data are read, new hash string for pacients are generated. |
java.util.List<Pacient> |
getAll()
return list of all pacients in database |
long |
getDatabaseSize()
return size of database stored on disk |
org.jdom.Element |
getElement()
return XML representation of database Stores all pacient information. |
Engine |
getEngine()
return engine |
java.util.Date |
getLastBackup()
return date of last database backup |
java.lang.String |
getNextID()
generates next unused hash string for new pacient Output is something that nears md5 hash output. |
long |
getPacientCount()
return number of all pacients |
java.util.List<Pacient> |
getRestricted()
returns list of choosen pacients |
int |
getTreeCount()
return size of actual list of pacients |
int |
getTreeIndex(Pacient pacient)
return index of pacient in actual list of pacients |
Pacient |
getTreePacient(int index)
return pacient on specified position in actual list of pacients |
private void |
loadFromFile(java.io.File file)
load database from file Load database root file. |
private java.lang.String |
makeID(long id)
create text representation of long |
void |
save()
save database to disk Calls getElement() to produce XML representation and store it to disk. |
void |
setRestricted(boolean restricted)
sets all or only choosen pacients |
void |
setRestrictedBorn(java.util.Date dateBegin,
java.util.Date dateEnd)
add pacients to list of choosen which were born between dateBegin and dateEnd |
void |
setRestrictedName(java.lang.String nameBegin,
java.lang.String nameEnd)
add pacients to list of choosen which surname is between nameBegin and nameEnd |
void |
setRestrictedVisit(java.util.Date dateBegin,
java.util.Date dateEnd)
add pacients to list of choosen which have visit between dateBegin and dateEnd |
void |
sort()
sort both lists of pacients |
private void |
sort(java.util.Comparator c)
sort both lists of pacients with specified comparator |
void |
sort(Database.SORT how)
sort both lists of pacients with specified criteria |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Engine engine
private java.util.HashMap<java.lang.String,Pacient> database
private java.util.List<Pacient> listAll
private java.util.List<Pacient> listRestricted
private boolean restricted
private Database.SORT howSort
private java.io.File rootFile
private java.util.Date lastBackup
public static final java.lang.String databaseTag
public static final java.lang.String backupAttr
Constructor Detail |
---|
public Database(Engine engine)
Check if database exist. If so, load it from disk, otherwise create new one.
Method Detail |
---|
private void createDB()
Creates new database directory and root file.
private void loadFromFile(java.io.File file)
Load database root file. All other files ar loaded after first need of them. Main file consist only from pacient names, their born date, right-hand attribute and hash representation. Hash identifies pacient in database and in directory structure on disk.
public void save()
Calls getElement() to produce XML representation and store it to disk.
getElement()
public org.jdom.Element getElement()
Stores all pacient information.
public java.util.List<Pacient> getAll()
public java.util.List<Pacient> getRestricted()
public void clearRestricted()
public void setRestrictedVisit(java.util.Date dateBegin, java.util.Date dateEnd)
public void setRestrictedBorn(java.util.Date dateBegin, java.util.Date dateEnd)
public void setRestrictedName(java.lang.String nameBegin, java.lang.String nameEnd)
public void setRestricted(boolean restricted)
public int getTreeCount()
public Pacient getTreePacient(int index)
public int getTreeIndex(Pacient pacient)
public void sort()
public void sort(Database.SORT how)
private void sort(java.util.Comparator c)
public java.lang.String getNextID()
Output is something that nears md5 hash output.
public void addPacient(Pacient pacient)
Updates or inserts information about pacient, sort lists of pacients and saves database to disk.
public long getPacientCount()
public long getDatabaseSize()
public java.util.Date getLastBackup()
public Engine getEngine()
public void backuped()
public void export()
All database data are read, new hash string for pacients are generated.
These 'hash' strings are from numbered sequence form zero to number of pacients.
Each pacient recieves random number from this sequence. In each export the same
pacient will have another number from sequence. The links in file structure
based on these hash strings must be updated.
Exported database is saved in zip archive.
private java.lang.String makeID(long id)
|
Parkinson Disease Database | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |