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)
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
public boolean initiate() throws SQLException, IOException
SQLException
- exception thrown whenever an error occurred while
attempting to connect to the databaseIOException
- exception thrown whenever an error occurred while
attempting to connect to the databasepublic boolean delete() throws IOException
IOException
public void close() throws IOException, SQLException
IOException
SQLException
- exception thrown if closing the db failedpublic String getDbFolderName()
public File getDbFolder() throws IOException
IOException
public 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
public 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 interestSQLException
ClassNotFoundException
IOException
InterruptedException
public void loadNodes(ArrayList<String> tags) throws SQLException, IOException, ClassNotFoundException, InterruptedException
tags
- list of tags corresponding to the nodes to loadSQLException
IOException
ClassNotFoundException
InterruptedException
public void saveInitialSize(int size) throws SQLException, IOException, InterruptedException
size
- the initial tag sizeSQLException
IOException
InterruptedException
public Integer getInitialSize() throws SQLException, IOException, ClassNotFoundException, InterruptedException
SQLException
IOException
ClassNotFoundException
InterruptedException
public void loadParameters() throws SQLException, ClassNotFoundException, IOException, InterruptedException
public void setImportComplete(boolean completed) throws SQLException, IOException, InterruptedException
completed
- SQLException
IOException
InterruptedException
public boolean importComplete() throws SQLException, IOException, ClassNotFoundException, InterruptedException
SQLException
IOException
ClassNotFoundException
InterruptedException
public void setCorrupted(boolean corrupted) throws SQLException, IOException, InterruptedException
corrupted
- SQLException
IOException
InterruptedException
public boolean isCorrupted() throws SQLException, IOException, ClassNotFoundException, InterruptedException
SQLException
IOException
ClassNotFoundException
InterruptedException
public void setVersion(String version) throws SQLException, IOException, InterruptedException
version
- the versionSQLException
IOException
InterruptedException
public static String getVersion(ObjectsDB objectsDB) throws SQLException, IOException, ClassNotFoundException, InterruptedException
objectsDB
- the objects db to look intoSQLException
IOException
ClassNotFoundException
InterruptedException
public String getVersion() throws SQLException, IOException, ClassNotFoundException, InterruptedException
SQLException
IOException
ClassNotFoundException
InterruptedException
public void setFastaFilePath(String fastaFilePath) throws SQLException, IOException, InterruptedException
fastaFilePath
- the FASTA file pathSQLException
IOException
InterruptedException
public String getFastaFilePath() throws SQLException, IOException, ClassNotFoundException, InterruptedException
SQLException
IOException
ClassNotFoundException
InterruptedException
public static String getFastaFilePath(ObjectsDB objectsDB) throws SQLException, IOException, ClassNotFoundException, InterruptedException
objectsDB
- the objects DB to look intoSQLException
IOException
ClassNotFoundException
InterruptedException
public void loadTags() throws SQLException
SQLException
public 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
Copyright © 2014. All rights reserved.