public class DataBaseHandlerService extends java.lang.Object implements Contexed, AppContextService<DataBaseHandlerService>
Modifier and Type | Field and Description |
---|---|
static Feature |
CLEAR_DATABASE |
static Feature |
COMMIT_ON_CREATE |
static java.lang.String |
NO_PROPS_ATTR |
Constructor and Description |
---|
DataBaseHandlerService(AppContext c) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
alterTableText(Repository res,
TableSpecification s,
SQLContext c,
java.util.List<java.lang.Object> args)
produce the SQL to create a table.
|
void |
cleanup()
AppContext is being closed. |
void |
clearDatabase() |
void |
createTable(java.lang.String name,
TableSpecification orig)
Create a database table based on a
TableSpecification
The TableSpecification can be augmented by properties
starting with create_table.table-name using
{@link TableSpecification#setFromParameters(AppContext, String, java.util.Map). |
java.lang.String |
createTableText(boolean check_exists,
java.lang.String name,
TableSpecification s,
SQLContext c,
java.util.List<java.lang.Object> args) |
java.lang.String |
createTableText(java.lang.String name,
TableSpecification s,
SQLContext c,
java.util.List<java.lang.Object> args)
produce the SQL to create a table.
|
void |
deleteTable(java.lang.String name) |
AppContext |
getContext() |
java.util.Set<java.lang.String> |
getTables()
Get a Set of all known table names.
|
java.lang.Class<? super DataBaseHandlerService> |
getType()
Returns the type of service the class should be registered under.
|
protected java.lang.String |
rename(java.lang.String name,
java.lang.String s2) |
boolean |
tableExists(java.lang.String name) |
void |
updateTable(Repository res,
TableSpecification orig) |
public static final Feature CLEAR_DATABASE
public static final Feature COMMIT_ON_CREATE
public static final java.lang.String NO_PROPS_ATTR
public DataBaseHandlerService(AppContext c)
public AppContext getContext()
getContext
in interface Contexed
public boolean tableExists(java.lang.String name)
public java.util.Set<java.lang.String> getTables() throws DataException
DataException
public void createTable(java.lang.String name, TableSpecification orig) throws DataFault
TableSpecification
The TableSpecification
can be augmented by properties
starting with create_table.table-name using
TableSpecification#setFromParameters(AppContext, String, java.util.Map).
In addition fields can be renamed by setting create_table.rename_field.table.field=new-field
This is usually only necessary for unit tests and will have to be combined with rename.new-field=field
so the {@link Repository} maps the field back to the expected name.name
- orig
- DataFault
public java.lang.String createTableText(java.lang.String name, TableSpecification s, SQLContext c, java.util.List<java.lang.Object> args)
name
- s
- c
- args
- public java.lang.String createTableText(boolean check_exists, java.lang.String name, TableSpecification s, SQLContext c, java.util.List<java.lang.Object> args)
protected java.lang.String rename(java.lang.String name, java.lang.String s2)
public void updateTable(Repository res, TableSpecification orig) throws DataFault
DataFault
public java.lang.String alterTableText(Repository res, TableSpecification s, SQLContext c, java.util.List<java.lang.Object> args)
res
- s
- c
- args
- public void deleteTable(java.lang.String name) throws java.lang.Exception
java.lang.Exception
public void clearDatabase() throws java.lang.Exception
java.lang.Exception
public void cleanup()
AppContextCleanup
AppContext
is being closed.
Only use this for cleanup that can't be handled by
normal garbage collection or for state which is never returned by reference.cleanup
in interface AppContextCleanup
public java.lang.Class<? super DataBaseHandlerService> getType()
AppContextService
getType
in interface AppContextService<DataBaseHandlerService>