Class DerbyFhirDatabase
- java.lang.Object
-
- org.linuxforhealth.fhir.schema.derby.DerbyFhirDatabase
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,IConnectionProvider
public class DerbyFhirDatabase extends java.lang.Object implements java.lang.AutoCloseable, IConnectionProvider
An Apache Derby implementation of the IBM FHIR Server database (useful for supporting unit tests).
-
-
Constructor Summary
Constructors Constructor Description DerbyFhirDatabase()
The default constructor will initialize the database at "derby/fhirDB".DerbyFhirDatabase(java.lang.String dbPath)
Initialize the database using the given file-system path and build tables for all the resource typesDerbyFhirDatabase(java.lang.String dbPath, java.util.Set<java.lang.String> resourceTypeNames)
Construct a Derby database at the specified path and deploy the IBM FHIR Server schema.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
commitTransaction()
Commit the current transaction if there's an actual connection associated with this thread (i.e.VersionHistoryService
createVersionHistoryService()
Create the version history table and a simple service which is used to access information from it.void
describe(java.lang.String arg0, java.lang.StringBuilder arg1, java.lang.String arg2)
Describe self, for writing configuration information to log file for test record purposesjava.sql.Connection
getConnection()
Obtain a new connection to a data-source which this provider has been configured for.java.lang.String
getSchemaName()
Get the FHIR data schema nameIDatabaseTranslator
getTranslator()
Get the translator associated with this connection provider.void
populateResourceTypeAndParameterNameTableEntries()
prepopulates the bootstrapped derby database with static lookup data.void
rollbackTransaction()
Roll back the transaction for the connection associated with this thread, if one exists-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.linuxforhealth.fhir.database.utils.api.IConnectionProvider
getPoolSize
-
-
-
-
Constructor Detail
-
DerbyFhirDatabase
public DerbyFhirDatabase() throws java.sql.SQLException
The default constructor will initialize the database at "derby/fhirDB".- Throws:
java.sql.SQLException
-
DerbyFhirDatabase
public DerbyFhirDatabase(java.lang.String dbPath) throws java.sql.SQLException
Initialize the database using the given file-system path and build tables for all the resource types- Parameters:
dbPath
-- Throws:
java.sql.SQLException
-
DerbyFhirDatabase
public DerbyFhirDatabase(java.lang.String dbPath, java.util.Set<java.lang.String> resourceTypeNames) throws java.sql.SQLException
Construct a Derby database at the specified path and deploy the IBM FHIR Server schema.- Throws:
java.sql.SQLException
-
-
Method Detail
-
getSchemaName
public java.lang.String getSchemaName()
Get the FHIR data schema name- Returns:
-
populateResourceTypeAndParameterNameTableEntries
public void populateResourceTypeAndParameterNameTableEntries() throws java.sql.SQLException
prepopulates the bootstrapped derby database with static lookup data.- Throws:
java.sql.SQLException
-
createVersionHistoryService
public VersionHistoryService createVersionHistoryService() throws java.sql.SQLException
Create the version history table and a simple service which is used to access information from it.- Throws:
java.sql.SQLException
-
close
public void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
commitTransaction
public void commitTransaction() throws java.sql.SQLException
Description copied from interface:IConnectionProvider
Commit the current transaction if there's an actual connection associated with this thread (i.e. if getConnection() has been called at least once), otherwise do nothing.- Specified by:
commitTransaction
in interfaceIConnectionProvider
- Throws:
java.sql.SQLException
-
describe
public void describe(java.lang.String arg0, java.lang.StringBuilder arg1, java.lang.String arg2)
Description copied from interface:IConnectionProvider
Describe self, for writing configuration information to log file for test record purposes- Specified by:
describe
in interfaceIConnectionProvider
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException
Description copied from interface:IConnectionProvider
Obtain a new connection to a data-source which this provider has been configured for.- Specified by:
getConnection
in interfaceIConnectionProvider
- Returns:
- Throws:
java.sql.SQLException
-
getTranslator
public IDatabaseTranslator getTranslator()
Description copied from interface:IConnectionProvider
Get the translator associated with this connection provider. Supports interpretation of SQLExceptions and the ability to tweak SQL statements to handle differences between databases- Specified by:
getTranslator
in interfaceIConnectionProvider
- Returns:
-
rollbackTransaction
public void rollbackTransaction() throws java.sql.SQLException
Description copied from interface:IConnectionProvider
Roll back the transaction for the connection associated with this thread, if one exists- Specified by:
rollbackTransaction
in interfaceIConnectionProvider
- Throws:
java.sql.SQLException
-
-