public final class OntologyDatabase extends Object implements AutoCloseable
Constructor and Description |
---|
OntologyDatabase(OntologyDatabaseDriver driver)
Constructor of the OntologyDatabase class.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Shuts down the database.
|
void |
deleteNode(NodeDescriptor node)
Deletes the node the given descriptor refers to from the database and
removes all corresponding dictionary entries.
|
void |
deleteNode(NodeHandle node)
Deletes the node the given handle refers to from the database and deletes
all corresponding dictionary entries.
|
void |
deleteOntology(OntologyHandle ontology)
Deletes the ontology with the given handle.
|
List<Node> |
descriptorsToNodeList(Collection<NodeDescriptor> nodes)
Converts a list of NodeDesciptor instances to high-level "Node"
instances.
|
OntologyHandle |
getEmptyOntology(String name)
Returns an ontology handle for an ontology with the given name, if such
an ontology does not exist yet, it is created and the new ontology handle
is returned.
|
Node |
getNode(NodeDescriptor node)
Returns a "Node" instance for the given node handle.
|
Node |
getNode(NodeHandle node)
Returns a "Node" instance for the given node handle.
|
Collection<OntologyHandle> |
getOntologies()
Returns a list containing handles to all currently available ontologies.
|
OntologyHandle |
getOntology(String name)
Returns an ontology handle for an ontology with the given name, if such
an ontology does not exist yet, it is created and the new ontology handle
is returned.
|
OntologyHandle |
getOntology(String name,
boolean create)
Returns an ontology handle for an ontology with the given name, if such
an ontology does not exist yet and the "create" flag is set to true, it
is created and the new ontology handle is returned.
|
Date |
getOntologyModificationDate(OntologyHandle ontology)
Returns the modification date of the given ontology.
|
Collection<Node> |
getRootNodes(OntologyHandle ontology)
Returns all the nodes that were marked as "root node" in the given
ontology.
|
List<Node> |
handlesToNodeList(Collection<NodeHandle> nodes)
Converts a list of NodeHandle instances to high-level "Node" instances.
|
Map<String,Collection<DictionaryMatch>> |
query(Collection<String> words)
Queries a set of words from the database an returns a map between these
words and the corresponding dictionary entries.
|
Collection<DictionaryMatch> |
query(String word)
Queries a single word from the dictionary.
|
boolean |
queryOntologyExists(String name)
Returns true if the given ontology exists.
|
void |
storeNode(NodeDescriptor node)
Stores the given NodeDescriptor in the database.
|
void |
updateOntologyModificationDate(OntologyHandle ontology)
Updates the modification date of the given ontology to now.
|
public OntologyDatabase(OntologyDatabaseDriver driver)
driver
- is a reference to the OntologyDatabaseDriver instance that
should be used as a storage backend.public Collection<OntologyHandle> getOntologies()
public OntologyHandle getOntology(String name, boolean create) throws InvalidNameException
name
- is the name of the queried ontology. Note that the name has
to be of the following pattern: [A-Za-z][A-Za-z0-9_]create
- specifies whether the ontology should be created if it does
not exist.InvalidNameException
- if the name is not of the pattern listed
above.public OntologyHandle getOntology(String name) throws InvalidNameException
name
- is the name of the queried ontology. Note that the name has
to be of the following pattern: [A-Za-z][A-Za-z0-9_]InvalidNameException
- if the name is not of the pattern listed
above.public OntologyHandle getEmptyOntology(String name) throws InvalidNameException
name
- is the name of the queried ontology. Note that the name has
to be of the following pattern: [A-Za-z][A-Za-z0-9_]InvalidNameException
- if the name is not of the pattern listed
above.public boolean queryOntologyExists(String name) throws InvalidNameException
name
- is the name of the queried ontology. Note that the name has
to be of the following pattern: [A-Za-z][A-Za-z0-9_]InvalidNameException
- if the name is not of the pattern listed
above.public void deleteOntology(OntologyHandle ontology)
ontology
- is the handle of the ontology that should be deleted.public Date getOntologyModificationDate(OntologyHandle ontology)
ontology
- is the ontology handle.public void updateOntologyModificationDate(OntologyHandle ontology)
ontology
- is the ontology handle.public Collection<Node> getRootNodes(OntologyHandle ontology)
ontology
- is the ontology for which the root nodes should be
returned.public Node getNode(NodeHandle node)
node
- is an arbitrary node handle.public Node getNode(NodeDescriptor node)
node
- is a high-level node instance.public List<Node> handlesToNodeList(Collection<NodeHandle> nodes)
nodes
- a list of NodeHandles.public List<Node> descriptorsToNodeList(Collection<NodeDescriptor> nodes)
nodes
- a list of NodeHandles.public void storeNode(NodeDescriptor node)
node
- is the NodeDescriptor instance that should be stored in the
database.public void deleteNode(NodeHandle node)
node
- is the node that should be deleted.public void deleteNode(NodeDescriptor node)
node
- is the node that should be deleted.public Map<String,Collection<DictionaryMatch>> query(Collection<String> words)
words
- is a collection of strings (single words) that should be
queried.public Collection<DictionaryMatch> query(String word)
word
- is the word that should be queried.public void close()
close
in interface AutoCloseable
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