public class ProteinTreeComponentsFactory extends Object
Modifier and Type | Field and Description |
---|---|
static String |
dbName
The name of the db to use.
|
static String |
folderSeparator
The splitter in the key between database name and database version.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the factory, closes all connection and deletes the file.
|
boolean |
delete()
Sets the currently loaded database as corrupted and tries to delete it.
|
static void |
deletOutdatedTrees()
Deletes the outdated trees.
|
ObjectsCache |
getCache()
Returns the cache used to store the nodes.
|
File |
getDbFolder()
Returns the folder where the db in the sequence factory is stored.
|
String |
getDbFolderName()
Returns the folder name where to store information about the protein
sequence database loaded in the sequence factory.
|
static String |
getDefaultDbFolderPath()
Returns the default folder to use when storing the trees.
|
String |
getFastaFilePath()
Returns the FASTA file path.
|
static String |
getFastaFilePath(ObjectsDB objectsDB)
Returns the FASTA file path.
|
Integer |
getInitialSize()
Retrieves the initial tag size from the db.
|
static ProteinTreeComponentsFactory |
getInstance()
Static method returning the instance of the factory.
|
Node |
getNode(String tag)
Retrieves the node of the given tag.
|
String |
getVersion()
Returns the version.
|
static String |
getVersion(ObjectsDB objectsDB)
Returns the version.
|
boolean |
importComplete()
Returns a boolean indicating whether the import was complete.
|
boolean |
initiate()
Initiates the connection to the database and indicates whether the
corresponding folder is already created.
|
boolean |
isCorrupted()
Returns a boolean indicating whether the database is corrupted.
|
void |
loadNodes(ArrayList<String> tags,
WaitingHandler waitingHandler)
Loads nodes in the cache.
|
void |
loadParameters()
Loads all tree parameters.
|
void |
loadTags()
Loads the tags implemented in the database.
|
void |
saveInitialSize(int size)
Saves the initial tag size in the parameters table of the DB.
|
void |
saveNode(String tag,
Node node)
Adds a node to the database.
|
void |
saveNodes(HashMap<String,Object> nodes,
WaitingHandler waitingHandler)
Adds nodes to the database.
|
void |
setCorrupted(boolean corrupted)
Sets whether the database is corrupted.
|
static void |
setDefaultDbFolderPath(String defaultDbFolderPath)
Sets the default folder to use when storing the trees.
|
void |
setFastaFilePath(String fastaFilePath)
Sets the FASTA file path.
|
void |
setImportComplete(boolean completed)
Sets whether the import was completed.
|
void |
setVersion(String version)
Sets the version.
|
public static final String folderSeparator
public static final String dbName
public static ProteinTreeComponentsFactory getInstance() throws IOException
IOException
- if an IOException occurspublic boolean initiate() throws SQLException, IOException, ClassNotFoundException, InterruptedException
SQLException
- exception thrown whenever an error occurs while
interacting with the databaseIOException
- exception thrown whenever an error occurs while
reading or writing a fileClassNotFoundException
- exception thrown whenever an error
occurred while deserializing a file from the databaseInterruptedException
- exception thrown if a threading error occurs
while interacting with the databasepublic boolean delete() throws IOException, SQLException, InterruptedException
IOException
- exception thrown whenever an error occurs
while interacting with a fileSQLException
- exception thrown whenever an error occurs
while interacting with the databaseInterruptedException
- exception thrown whenever a
threading error occurs while attempting to delete the database filepublic void close() throws IOException, SQLException
IOException
- if an IOException occursSQLException
- exception thrown if closing the db failedpublic String getDbFolderName()
public File getDbFolder() throws IOException
IOException
- if an IOException occurspublic void saveNode(String tag, Node node) throws SQLException, IOException, InterruptedException
tag
- the tag referring to the node of interestnode
- the nodeSQLException
- exception thrown whenever an error occurred while
loading data in the databaseIOException
- exception thrown whenever an error occurred while
loading data in the databaseInterruptedException
- if an InterruptedException occurspublic void saveNodes(HashMap<String,Object> nodes, WaitingHandler waitingHandler) throws SQLException, IOException
nodes
- map of the nodeswaitingHandler
- the waiting handlerSQLException
- exception thrown whenever an error occurred while
loading data in the databaseIOException
- exception thrown whenever an error occurred while
loading data in the databasepublic Node getNode(String tag) throws SQLException, ClassNotFoundException, IOException, InterruptedException
tag
- the tag of interestIOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void loadNodes(ArrayList<String> tags, WaitingHandler waitingHandler) throws SQLException, IOException, ClassNotFoundException, InterruptedException
tags
- list of tags corresponding to the nodes to loadwaitingHandler
- the waiting handler allowing displaying progress and cancelling the processIOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void saveInitialSize(int size) throws SQLException, IOException, InterruptedException
size
- the initial tag sizeIOException
- if an IOException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic Integer getInitialSize() throws SQLException, IOException, ClassNotFoundException, InterruptedException
IOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void loadParameters() throws SQLException, ClassNotFoundException, IOException, InterruptedException
IOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void setImportComplete(boolean completed) throws SQLException, IOException, InterruptedException
completed
- whether the import was completedIOException
- if an IOException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic boolean importComplete() throws SQLException, IOException, ClassNotFoundException, InterruptedException
IOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void setCorrupted(boolean corrupted) throws SQLException, IOException, InterruptedException
corrupted
- whether the database is corruptedIOException
- if an IOException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic boolean isCorrupted() throws SQLException, IOException, ClassNotFoundException, InterruptedException
IOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void setVersion(String version) throws SQLException, IOException, InterruptedException
version
- the versionIOException
- if an IOException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic static String getVersion(ObjectsDB objectsDB) throws SQLException, IOException, ClassNotFoundException, InterruptedException
objectsDB
- the objects db to look intoIOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic String getVersion() throws SQLException, IOException, ClassNotFoundException, InterruptedException
IOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void setFastaFilePath(String fastaFilePath) throws SQLException, IOException, InterruptedException
fastaFilePath
- the FASTA file pathIOException
- if an IOException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic String getFastaFilePath() throws SQLException, IOException, ClassNotFoundException, InterruptedException
IOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic static String getFastaFilePath(ObjectsDB objectsDB) throws SQLException, IOException, ClassNotFoundException, InterruptedException
objectsDB
- the objects DB to look intoIOException
- if an IOException occursClassNotFoundException
- if a ClassNotFoundException occursInterruptedException
- if an InterruptedException occursSQLException
- if an SQLException occurspublic void loadTags() throws SQLException
SQLException
- if an SQLException occurspublic static String getDefaultDbFolderPath()
public static void setDefaultDbFolderPath(String defaultDbFolderPath)
defaultDbFolderPath
- the default folder to use when storing the
treespublic ObjectsCache getCache()
public static void deletOutdatedTrees() throws IOException
IOException
- if an IOException occursCopyright © 2016. All rights reserved.