public class JDBCDatabaseDriver extends OntologyDatabaseDriver
Modifier and Type | Class and Description |
---|---|
protected class |
JDBCDatabaseDriver.JDBCDatabaseDriverException
JDBCDatabaseDriverException is a thin wrapper around
DatabaseDriverException that allows for a fast conversion from
SQLException to DatabaseDriverException.
|
protected class |
JDBCDatabaseDriver.JDBCOntologyHandle
The JDBCOntologyHandle class is the OntologyHandle type used by the JDBC
database.
|
Constructor and Description |
---|
JDBCDatabaseDriver(Connection connection,
SQLStatements statements)
Constructor of the JDBCDatabaseDriver class.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the current ontology database.
|
void |
close()
Gives the driver the opportunity to shut down properly.
|
void |
deleteAssociations(Collection<Association> associations)
Deletes the given associations.
|
void |
deleteDictionaryEntries(Collection<NodeHandle> nodes)
Deletes the dictionary entries for the given nodes from the db.
|
void |
deleteNodes(Collection<NodeHandle> nodes)
Deletes the given nodes from the database.
|
void |
deleteOntology(OntologyHandle ontology)
Deletes the ontology with the given ontology handle.
|
List<Collection<Association>> |
getAssociations(Collection<NodeHandle> nodes,
int associationTypes,
AssociationDirection dir)
Returns the associations for a given set of nodes.
|
List<NodeDescriptor> |
getNodes(Collection<NodeHandle> handles)
Returns the node descriptors for the given node handles.
|
Collection<OntologyHandle> |
getOntologies()
Returns a list containing all ontologies in the database and an empty
list if no ontologies are present.
|
OntologyHandle |
getOntology(String name,
boolean create)
Returns a the handle for the ontology with the given name or creates the
ontology if it does not exist.
|
Date |
getOntologyModificationDate(OntologyHandle ontology)
Returns the last update date for the given ontology handle.
|
Collection<NodeDescriptor> |
getRootNodes(OntologyHandle ontology)
Returns a list containing all root nodes in the given ontology.
|
String |
getSchemaVersion()
Gives the driver the opportunity to return a database version number.
|
void |
initializeSchema()
Creates all tables that do not exist yet.
|
Map<String,Collection<NodeDescriptor>> |
queryDictionary(Set<String> keys)
Queries the dictionary for the given keys.
|
List<Boolean> |
queryNodesExist(Collection<NodeHandle> handles)
Checks whether the given nodes exist.
|
void |
setOntologyModificationDate(OntologyHandle ontology,
Date date)
Returns the last update date for the given ontology handle.
|
void |
storeAssociations(Collection<Association> associations)
Stores the given associations.
|
void |
storeDictionaryEntries(Map<NodeHandle,Set<String>> keys)
Stores the given node to key associations in the dictionary.
|
void |
storeNodes(Collection<NodeDescriptor> descriptors)
Stores the given nodes in the database.
|
protected boolean |
tableExists(String table)
Checks whether an table with the given name exist.
|
deleteAssociation, deleteDictionaryEntry, deleteNode, deleteNodeDescriptors, getAssociations, getEmptyOntology, getNode, getOntology, nodeHandlesFromDescriptors, queryAllNodesExist, queryDictionary, queryNodeExists, storeAssociation, storeDictionaryEntry, storeNode
public JDBCDatabaseDriver(Connection connection, SQLStatements statements)
connection
- is a reference to a JDBC database connection.statements
- is a reference to an instance of the SQLStatements
class which is responsible for generating the SQL statements.protected boolean tableExists(String table) throws SQLException
table
- is the name of the table.SQLException
public void initializeSchema() throws SQLException
SQLException
public void clear()
clear
in class OntologyDatabaseDriver
public Collection<OntologyHandle> getOntologies()
OntologyDatabaseDriver
getOntologies
in class OntologyDatabaseDriver
public OntologyHandle getOntology(String name, boolean create)
OntologyDatabaseDriver
getOntology
in class OntologyDatabaseDriver
name
- is the name of the ontology that should be returned/created.create
- if true, the ontology is created if it does not exist yet,
if false, null is returned if the ontology does not exist yet.public Date getOntologyModificationDate(OntologyHandle ontology)
OntologyDatabaseDriver
getOntologyModificationDate
in class OntologyDatabaseDriver
ontology
- is the handle of the ontology for which the modification
date should be returned.public void setOntologyModificationDate(OntologyHandle ontology, Date date)
OntologyDatabaseDriver
setOntologyModificationDate
in class OntologyDatabaseDriver
ontology
- is the handle of the ontology for which the modification
date should be updated.date
- is the date the modification date should be set to.public void deleteOntology(OntologyHandle ontology)
OntologyDatabaseDriver
deleteOntology
in class OntologyDatabaseDriver
ontology
- is the handle of the ontology that should be deleted.public Collection<NodeDescriptor> getRootNodes(OntologyHandle ontology)
OntologyDatabaseDriver
getRootNodes
in class OntologyDatabaseDriver
ontology
- is the ontology for which the root nodes should be
returned.public List<NodeDescriptor> getNodes(Collection<NodeHandle> handles)
OntologyDatabaseDriver
getNodes
in class OntologyDatabaseDriver
handles
- is a list of node handles.public List<Boolean> queryNodesExist(Collection<NodeHandle> handles)
OntologyDatabaseDriver
queryNodesExist
in class OntologyDatabaseDriver
handles
- is a list of node handles.public void storeNodes(Collection<NodeDescriptor> descriptors)
OntologyDatabaseDriver
storeNodes
in class OntologyDatabaseDriver
descriptors
- is a list of node descriptors that should be stored.
Invalid node descriptors (e.g. refering to a non existing ontology) must
be ignored.
TODO: Check this in the unit test/implementation, as this is not done at
the moment (would probably be to costly).public void deleteNodes(Collection<NodeHandle> nodes)
OntologyDatabaseDriver
deleteNodes
in class OntologyDatabaseDriver
nodes
- is a list containing the nodes that should be deleted.public List<Collection<Association>> getAssociations(Collection<NodeHandle> nodes, int associationTypes, AssociationDirection dir)
OntologyDatabaseDriver
getAssociations
in class OntologyDatabaseDriver
nodes
- is a list of nodes.associationTypes
- is a bit field containing the association types
that should be returned.dir
- is the association direction that should be returned.public void storeAssociations(Collection<Association> associations)
OntologyDatabaseDriver
storeAssociations
in class OntologyDatabaseDriver
associations
- is a list of associations that should be stored. The
database does not have to check whether the associations are actually
valid.
TODO: Change this?public void deleteAssociations(Collection<Association> associations)
OntologyDatabaseDriver
deleteAssociations
in class OntologyDatabaseDriver
associations
- is a list of associations that should be deleted.public Map<String,Collection<NodeDescriptor>> queryDictionary(Set<String> keys)
OntologyDatabaseDriver
queryDictionary
in class OntologyDatabaseDriver
keys
- contains a set of keys that should be queried.public void storeDictionaryEntries(Map<NodeHandle,Set<String>> keys)
OntologyDatabaseDriver
storeDictionaryEntries
in class OntologyDatabaseDriver
keys
- is a map from node handles to keys that should be stored in
the dictionary.public void deleteDictionaryEntries(Collection<NodeHandle> nodes)
OntologyDatabaseDriver
deleteDictionaryEntries
in class OntologyDatabaseDriver
nodes
- is a list of nodes for which the dictionary entries should
be deleted.public void close()
OntologyDatabaseDriver
close
in class OntologyDatabaseDriver
public String getSchemaVersion()
OntologyDatabaseDriver
getSchemaVersion
in class OntologyDatabaseDriver
Copyright (C) 2013, 2014 Raphael Dickfelder, Jan Göpfert, Benjamin Paassen, Andreas Stöckel, licensed under the AGPL v. 3: http://openresearch.cit-ec.de/projects/scie