public class OracleXMLDBConnection extends java.lang.Object implements DBConnection
This is a wrapper class that acts as a Facade to the Oracle Berkeley XML Database interface.
Modifier and Type | Field and Description |
---|---|
protected static com.sleepycat.db.Environment |
_environment
The environment for the Oracle Berkeley XMLDatabase that defines the
parameters like cache size, locking mechanism, storing mechanism etc.
|
protected static java.lang.String |
_environmentPath
Path for the given environment.
|
protected boolean |
_isConnectionAlive
Denote whether the database connection is active or not.
|
protected boolean |
_isTransactionActive
Denote whether the database connection is active or not.
|
protected DBConnectionParameters |
_params
This object contains the parameters like path, container name etc.
|
protected com.sleepycat.dbxml.XmlContainer |
_xmlContainer
This is the Oracle Berkeley XML DB Container that is used to add and
remove documents.
|
protected com.sleepycat.dbxml.XmlManager |
_xmlManager
This is the Oracle BerkeleyXML DB manager that is used to execute queries
over the opened container.
|
protected com.sleepycat.dbxml.XmlTransaction |
_xmlTransaction
This is the Oracle Berkeley XML DB Transaction that is used to commit or
abort certain transactions.
|
Constructor and Description |
---|
OracleXMLDBConnection(DBConnectionParameters dbConnParams)
Construct an instance that initializes the environment and creates a
database connection based on the given parameters.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.ArrayList<XMLDBModel> |
_getDistinctModelsList(java.util.ArrayList<java.lang.String> modelNamesList)
Create a list of distinct XMLDBModels from the given list that may
contain duplicates.
|
void |
abortConnection()
Abort the connection and roll back the transaction Invoke in case of
errors.
|
void |
closeConnection()
Commit the transaction and close the connection to the database.
|
void |
commitConnection()
Commit the transaction running over the connection.
|
boolean |
doesModelExist(XMLDBModel model)
Check if the given model already exists in the database.
|
java.util.ArrayList<XMLDBModel> |
executeAttributeSearchTask(AttributeSearchTask task)
Search models that contain the given attributes in the database.
|
XMLDBAttribute |
executeCreateAttributeTask(CreateAttributeTask task)
Execute a create attribute task which adds a new attribute to the database.
|
java.lang.String |
executeCreateModelTask(CreateModelTask task)
Execute the necessary commands to create a new model in the database
according to the model specification given in the task parameter.
|
void |
executeDeleteAttributeTask(DeleteAttributeTask task)
Execute delete attribute task which deletes a given attribute from the database.
|
java.util.ArrayList<XMLDBModel> |
executeFetchHierarchyTask(FetchHierarchyTask task)
Fetch the parent model hierarchies for the given models.
|
java.util.ArrayList<XMLDBAttribute> |
executeGetAttributesTask(GetAttributesTask task)
Get the attributes defined from the database.
|
XMLDBModel |
executeGetCompleteModelTask(GetModelTask task)
Execute the get model task and return the model requested as XMLDBModel
object and resolve any references in it.
|
java.util.List<XMLDBModel> |
executeGetFirstLevelParents(GetFirstLevelParentsTask task)
Execute the given task to fetch the first level parents for the given
model.
|
java.util.List<XMLDBModel> |
executeGetListOfAllModels()
Retrieve and return the list of all models in the database.
|
XMLDBModel |
executeGetModelTask(GetModelTask task)
Execute the get model task and return the model requested as XMLDBModel
object as it is represented in the database.
|
java.lang.String |
executeGetReferenceStringTask(GetReferenceStringTask task)
Get the model reference string for the given model name.
|
java.util.ArrayList<XMLDBModel> |
executeGraphSearchTask(GraphSearchTask task)
Search models that contain given graphical pattern in the database.
|
java.util.ArrayList<XMLDBModel> |
executeModelNameSearchTask(ModelNameSearchTask modelNameSearchTask)
Execute the model name search task.
|
void |
executeRemoveModelsTask(RemoveModelsTask task)
Execute remove models task to delete a list of models from the database.
|
void |
executeRenameModelTask(RenameModelTask task)
Execute rename model task which will change the name of the model in
the database and reflect the change in the reference file.
|
java.lang.String |
executeSaveModelTask(SaveModelTask task)
Execute the necessary commands to save/update a model in the database
according to the model specification given in the task parameter.
|
void |
executeUpdateAttributeTask(UpdateAttributeTask task)
Execute update attribute task to update a given attribute in the database.
|
void |
executeUpdateModelInCache(XMLDBModel xmlDBModel)
Execute the necessary commands to update the cache with the given model.
|
void |
executeUpdateParentsToNewVersion(UpdateParentsToNewVersionTask task)
Execute the given task to update the referenced version for the given
parents from the old model to the new model.
|
static void |
initializeDatabase(java.lang.String url)
Create a database environment with the given configuration.
|
java.lang.String |
toString()
Provide information regarding the state of the internal variables useful
for unit testing purposes.
|
protected static com.sleepycat.db.Environment _environment
protected static java.lang.String _environmentPath
protected boolean _isConnectionAlive
protected boolean _isTransactionActive
protected DBConnectionParameters _params
protected com.sleepycat.dbxml.XmlContainer _xmlContainer
protected com.sleepycat.dbxml.XmlManager _xmlManager
protected com.sleepycat.dbxml.XmlTransaction _xmlTransaction
public OracleXMLDBConnection(DBConnectionParameters dbConnParams) throws DBConnectionException
dbConnParams
- Encapsulate the parameters required to create a
database connection.DBConnectionException
- If thrown while creating a connection.public void abortConnection() throws DBConnectionException
abortConnection
in interface DBConnection
DBConnectionException
- If thrown while aborting transaction in
the database.public static void initializeDatabase(java.lang.String url) throws DBConnectionException
url
- Database URLDBConnectionException
- If thrown while creating the environment.public void commitConnection() throws DBConnectionException
commitConnection
in interface DBConnection
DBConnectionException
- If thrown while committing transaction
in the database.public void closeConnection() throws DBConnectionException
If the transaction on this connection is alive/open while closing the connection, the transaction will be aborted.
closeConnection
in interface DBConnection
DBConnectionException
- If thrown while closing database
connection.public java.lang.String executeCreateModelTask(CreateModelTask task) throws DBExecutionException, ModelAlreadyExistException, CircularDependencyException
executeCreateModelTask
in interface DBConnection
task
- The task to be completed. In this case, CreateModelTask. This
will tell the DB layer to create a new model in the database.DBExecutionException
- Thrown if there is a problem executing
the task.ModelAlreadyExistException
- Thrown if the model being created
already exists.CircularDependencyException
- If thrown while creating reference string.public java.util.ArrayList<XMLDBModel> executeFetchHierarchyTask(FetchHierarchyTask task) throws DBExecutionException
executeFetchHierarchyTask
in interface DBConnection
task
- Task that contains the list of models.DBExecutionException
- If thrown while searching in the
database.public java.util.List<XMLDBModel> executeGetListOfAllModels() throws DBExecutionException
executeGetListOfAllModels
in interface DBConnection
DBExecutionException
- thrown if there is an error while reading
the model list from the database.public java.util.ArrayList<XMLDBAttribute> executeGetAttributesTask(GetAttributesTask task) throws DBExecutionException
executeGetAttributesTask
in interface DBConnection
task
- The criteria to get the attribute.DBExecutionException
- Thrown if there is a problem in executing the operation.public java.lang.String executeGetReferenceStringTask(GetReferenceStringTask task) throws DBExecutionException
executeGetReferenceStringTask
in interface DBConnection
task
- Task that contains the model name.DBExecutionException
- If thrown while fetching the reference
string.public java.util.List<XMLDBModel> executeGetFirstLevelParents(GetFirstLevelParentsTask task) throws DBExecutionException
executeGetFirstLevelParents
in interface DBConnection
task
- Task that contains the model for which the first level
parents list needs to be fetched.DBExecutionException
- If thrown while fetching the parents list
from the database.public XMLDBModel executeGetModelTask(GetModelTask task) throws DBExecutionException
executeGetModelTask
in interface DBConnection
task
- The GetModelTask object that contains the model name.DBExecutionException
- Thrown if there is a problem executing
the task.public XMLDBModel executeGetCompleteModelTask(GetModelTask task) throws DBExecutionException
executeGetCompleteModelTask
in interface DBConnection
task
- The GetModelTask object that contains the model name.DBExecutionException
- Thrown if there is a problem executing
the task.public boolean doesModelExist(XMLDBModel model) throws DBExecutionException
model
- XMLDBModel that needs to be looked up in the database.DBExecutionException
- If thrown while getting hte model from the
database.public java.util.ArrayList<XMLDBModel> executeAttributeSearchTask(AttributeSearchTask task) throws DBExecutionException
executeAttributeSearchTask
in interface DBConnection
task
- Task that contains a list of attributes that need to be
searched in the database.DBExecutionException
- If thrown while searching in the
database.public XMLDBAttribute executeCreateAttributeTask(CreateAttributeTask task) throws DBExecutionException
executeCreateAttributeTask
in interface DBConnection
task
- The task that contains the new attribute to be created.DBExecutionException
- Thrown if the operation fails.public void executeDeleteAttributeTask(DeleteAttributeTask task) throws DBExecutionException
executeDeleteAttributeTask
in interface DBConnection
task
- The task that contains the attribute to be deleted.DBExecutionException
- Thrown if the operation fails.public java.util.ArrayList<XMLDBModel> executeGraphSearchTask(GraphSearchTask task) throws DBExecutionException
executeGraphSearchTask
in interface DBConnection
task
- Task that contains the graph search criteria.DBExecutionException
- If thrown while searching in the
database.public java.lang.String executeSaveModelTask(SaveModelTask task) throws DBExecutionException, CircularDependencyException
executeSaveModelTask
in interface DBConnection
task
- a SaveModelTask to be completed.DBExecutionException
- Thrown if there is a problem executing
the task.CircularDependencyException
- If thrown while creating reference
string.public java.util.ArrayList<XMLDBModel> executeModelNameSearchTask(ModelNameSearchTask modelNameSearchTask) throws DBExecutionException
executeModelNameSearchTask
in interface DBConnection
modelNameSearchTask
- Task that contains the model name to be searched for.DBExecutionException
- If thrown while searching the database.public void executeRemoveModelsTask(RemoveModelsTask task) throws DBExecutionException
executeRemoveModelsTask
in interface DBConnection
task
- Contains a list of models to be deleted from the database.DBExecutionException
- Thrown if the operation fails.public void executeRenameModelTask(RenameModelTask task) throws DBConnectionException, DBExecutionException, ModelAlreadyExistException, DBModelNotFoundException
executeRenameModelTask
in interface DBConnection
task
- RenameModelTask object that contains the XMLDBModel
object and the new name.DBConnectionException
- Thrown if there was a problem with the connection.DBExecutionException
- Thrown if there is a problem in executing the task.DBModelNotFoundException
- Thrown if the model with the name to be changed does not exist.ModelAlreadyExistException
- Thrown if the new name is a name of a model that is already in the database.public void executeUpdateAttributeTask(UpdateAttributeTask task) throws DBExecutionException
executeUpdateAttributeTask
in interface DBConnection
task
- The task that holds the attribute to be updated.DBExecutionException
- Thrown if the operation fails with an error.public void executeUpdateModelInCache(XMLDBModel xmlDBModel) throws DBExecutionException
If the model exists, replace it with the new model.
If the model does not exist, save it in the cache.
executeUpdateModelInCache
in interface DBConnection
xmlDBModel
- The model object that needs to be added to the cache.DBExecutionException
- Thrown if the operation fails.
already exists.public void executeUpdateParentsToNewVersion(UpdateParentsToNewVersionTask task) throws DBExecutionException
executeUpdateParentsToNewVersion
in interface DBConnection
task
- Task that contains the list of parents, the old model and the
new model.DBExecutionException
- If thrown while updating the parents in the
database.public java.lang.String toString()
toString
in class java.lang.Object
protected java.util.ArrayList<XMLDBModel> _getDistinctModelsList(java.util.ArrayList<java.lang.String> modelNamesList)
modelNamesList
- List of models that may contain duplicates.