|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sibvisions.rad.persist.AbstractStorage
com.sibvisions.rad.persist.AbstractCachedStorage
com.sibvisions.rad.persist.jdbc.DBStorage
public class DBStorage
The DBStorage
is a IStorage for SQL database specific features.
The DBStorage allows to influence the creation of the SELECT statement to get the data.
The following template shows how the SELECT will be constructed out of the specified properties.
SELECT getBeforeQueryColumns() getQueryColumns()
FROM getFromClause()
WHERE getFilter()
AND getMasterReference()
AND getWhereClause()
getAfterWhereClause()
ORDER BY getSort()/getOrderByClause()
Example:
SELECT DISTINCT // ++ comment, optimizer hints
a.COL1 C, b.COL2 D, a.FK_ID FK_ID, ...
FROM TABLE1 a,
TABLE2 b,
...
WHERE C LIKE 'a%' AND D IS NOT NULL ... // getFilter().getSQL
AND FK_ID = 23 // getMasterReference() get all detail rows to a
specific master row in an other DataBook
AND a.ID = b.FK_ID ... // getLastWhereCondition()
GROUP BY C, D // getAfterWhereClause()
ORDER BY C DESC // getSort() or getOrderByClause()
IStorage
,
ColumnMetaData
,
RemoteDataBook
,
DBAccess
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.sibvisions.rad.persist.AbstractStorage |
---|
AbstractStorage.AllFetchedList<E> |
Field Summary | |
---|---|
static java.lang.String |
SUBSTORAGE_PREFIX
The prefix for substorages. |
Constructor Summary | |
---|---|
DBStorage()
Constructs a DBStorage . |
Method Summary | |
---|---|
void |
close()
It close the DBStorage. |
void |
createAutomaticLinkReference(java.lang.String[] pColumns,
DBStorage pDBStorage,
java.lang.String[] pReferenceColumns)
Creates and sets a new StorageReferenceDefinition with the specified DBStorage and
columns and reference columns on all pColumns . |
void |
createAutomaticLinkReference(java.lang.String[] pColumns,
java.lang.String pWritebackTable,
java.lang.String[] pReferenceColumns)
Creates and sets a new StorageReferenceDefinition with the specified FromClause and
columns and reference columns on all pColumns . |
protected void |
createAutomaticLinkStorage(StorageReferenceDefinition pReferenceDefinition,
java.lang.String[] pWritebackColumnNames)
Creates a new DBStorage which is configured for automatic link cell editors. |
protected ServerMetaData |
createMetaData(java.lang.String pBeforeQueryColumns,
java.lang.String[] pQueryColumns,
java.lang.String pFromClause,
java.lang.String pWhereClause,
java.lang.String pAfterWhereClause,
java.lang.String pWritebackTable,
java.lang.String[] pWritebackColumns,
boolean pAutoLinkReference,
boolean pUseRepresentationColumnsAsQueryColumns)
Returns the meta data for the specified DBStorage with all its parameters. |
protected java.lang.String |
createSubStorageName(DBStorage pDBStorage)
Creates the sub storage name for an AutomaticLinkReference. |
protected void |
executeDelete(java.lang.Object[] pDeleteDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the delete method. |
protected java.util.List<java.lang.Object[]> |
executeFetch(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
This method has to be implemented in the Storage implementation and should have the functionality of the fetch method. |
protected java.lang.Object[] |
executeInsert(java.lang.Object[] pDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the insert method. |
protected java.lang.Object[] |
executeRefetchRow(java.lang.Object[] pDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the refetchRow method. |
protected java.lang.Object[] |
executeUpdate(java.lang.Object[] pOldDataRow,
java.lang.Object[] pNewDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the update method. |
java.lang.String[] |
getAdditionalQueryColumns()
Returns the additional query columns of the SELECT statement. |
java.lang.String |
getAfterWhereClause()
Returns the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause. |
java.lang.String |
getBeforeQueryColumns()
Returns the string to place in the SELECT statement between the SELECT and the first query column. |
IDBAccess |
getDBAccess()
Returns the IDBAccess of this DBStorage . |
SortDefinition |
getDefaultSort()
Returns the default sort. |
int |
getEstimatedRowCount(ICondition pFilter)
Returns the number of rows in this AbstractStorage from the storage. |
java.lang.String |
getFromClause()
Returns the query tables to use in the SELECT statement to get the data from the storage. |
MetaData |
getMetaData()
Returns the meta data for this AbstractStorage from the storage as MetaData . |
java.lang.String |
getOrderByClause()
Returns the string to place in the ORDER BY section if no default sort is set. |
java.lang.String[] |
getQueryColumns()
Returns the query columns of the SELECT statement. |
ICondition |
getRestrictCondition()
Returns the restrict condition. |
java.util.Map<java.lang.String,DBStorage> |
getSubStorages()
Gets all known sub storages as key/value pair. |
java.lang.String |
getWhereClause()
Returns the string to place in the SELECT statement after the last WHERE condition from the Filter or MasterReference (Master-Detail Condition). |
java.lang.String[] |
getWritebackColumns()
Returns the list of write back columns to use in the INSERT, UPDATE statements. |
java.lang.String |
getWritebackTable()
Returns the WritebackTable, which is used for the INSERT, UPDATE, DELETE calls. |
protected java.lang.String |
getWritebackTableCatalog()
Gets the catalog name of the writeback table. |
protected java.lang.String |
getWritebackTableSchema()
Gets the schema name of the writeback table. |
protected void |
installAutomaticLinkReferenceIntern(StorageReferenceDefinition pReferenceDefinition)
Creates and sets a new StorageReferenceDefinition with the specified DBStorage (or from clause) and
columns and reference columns on all pColumns . |
boolean |
isAllowedValues()
Returns the allowed value detection mode. |
boolean |
isAutoLinkReference()
Returns if the automatic LinkReference mode is on or off. |
protected boolean |
isAutomaticLinkNullable(java.lang.String[] pColumns,
ServerColumnMetaData[] pColumnMetaData)
True, if one of the writable columns is nullable. |
static boolean |
isDefaultAllowedValues()
Returns the default allowed value detection mode. |
static boolean |
isDefaultAutoLinkReference()
Returns the default automatic LinkReference mode. |
static boolean |
isDefaultDefaultValue()
Returns the default - default value detection mode. |
boolean |
isDefaultValue()
Returns the default value detection mode. |
boolean |
isLazyFetchEnabled()
If lazy fetch should be enabled. |
boolean |
isLockOnRefetch()
True, if refetch should lock the row. |
boolean |
isOpen()
Returns if the DBStorage is open. |
void |
open()
Opens the DBStorage and checks if the DBAssess is ! |
protected void |
openInternal(boolean pUseRepresentationColumnsAsQueryColumns)
Opens the DBStorage and checks if the DBAccess is ! |
protected java.lang.Object[] |
refetchRow(java.lang.Object[] pDataRow,
boolean pLock)
Refetch and optional locks the specified DataRow via PK. |
protected void |
refreshMetaData()
Refreshs the MetaData with initial settings. |
void |
setAdditionalQueryColumns(java.lang.String[] pAdditionalQueryColumns)
Sets the additional query columns of the SELECT statement. |
void |
setAfterWhereClause(java.lang.String pAfterWhereClause)
Sets the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause. |
void |
setAllowedValues(boolean pAllowedValues)
Sets the allowed value detection en- or disabled. |
void |
setAutoLinkReference(boolean pAutoLinkReference)
Sets if the automatic link reference detection is en- or disabled. |
void |
setBeforeQueryColumns(java.lang.String pBeforeQueryColumns)
Sets the string to place in the SELECT statement between the SELECT and the first query column. |
void |
setDBAccess(IDBAccess pDBAccess)
Set the IDBAccess of this DBStorage . |
static void |
setDefaultAllowedValues(boolean pAllowedValues)
Sets the default allowed value detection en- or disabled. |
static void |
setDefaultAutoLinkReference(boolean pDefaultAutoLinkReference)
Sets the default automatic link reference detection mode. |
static void |
setDefaultDefaultValue(boolean pDefaultValue)
Sets the default - default value detection en- or disabled. |
void |
setDefaultSort(SortDefinition pDefaultSort)
Sets the default sort. |
void |
setDefaultValue(boolean pDefaultValue)
Sets the default value detection en- or disabled. |
void |
setFromClause(java.lang.String pFromClause)
Sets the query tables to use in the SELECT statement to get the data from the storage. |
void |
setLazyFetchEnabled(boolean pLazyFetchEnabled)
Sets if lazy fetch should be enabled. |
void |
setLockOnRefetch(boolean pLockOnRefetch)
True, if refetch should lock the row. |
void |
setMetaData(MetaData pMetaData)
Sets a new meta data. |
void |
setOrderByClause(java.lang.String pOrderByClause)
Sets the string to place in the ORDER BY section if no default sort is set. |
void |
setQueryColumns(java.lang.String[] pQueryColumns)
Sets the query columns of the SELECT statement. |
void |
setRestrictCondition(ICondition pRestrictCondition)
Sets the restrict condition. |
void |
setWhereClause(java.lang.String pWhereClause)
Sets the string to place in the SELECT statement after the last WHERE condition from the Filter or MasterReference (Master-Detail Condition). |
void |
setWritebackColumns(java.lang.String[] pWritebackColumns)
Sets the list of write back columns to use in the INSERT, UPDATE statements. |
void |
setWritebackTable(java.lang.String pWritebackTable)
Sets the WritebackTable, which is used for the INSERT, UPDATE, DELETE calls. |
java.lang.String |
toString()
|
void |
writeCSV(java.io.OutputStream pOutputStream,
java.lang.String[] pColumnNames,
java.lang.String[] pLabels,
ICondition pFilter,
SortDefinition pSort,
java.lang.String pSeparator)
Write the current storage with the specified filter and sort into the given output stream as CSV Format. |
Methods inherited from class com.sibvisions.rad.persist.AbstractCachedStorage |
---|
clearMetaData, clearMetaData, getMetaData, getMetaData, getMetaDataCacheGroups, getMetaDataCacheOption, getMetaDataFromCache, getMetaDataFromCache, isGlobalMetaDataCacheEnabled, isMetaDataCacheEnabled, putMetaDataToCache, removeMetaData, setGlobalMetaDataCacheEnabled, setMetaDataCacheOption |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.rad.persist.IStorage |
---|
delete, fetch, insert, refetchRow, update |
Field Detail |
---|
public static final java.lang.String SUBSTORAGE_PREFIX
Constructor Detail |
---|
public DBStorage()
DBStorage
.
Method Detail |
---|
public void writeCSV(java.io.OutputStream pOutputStream, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort, java.lang.String pSeparator) throws java.lang.Exception
writeCSV
in class AbstractStorage
pOutputStream
- the output stream to use for the CSV streampColumnNames
- the column names to include in the exportpLabels
- the labels to show as header in the exportpFilter
- the conditionpSort
- the sort definitionpSeparator
- the column separator
java.lang.Exception
- if the CSV output couldn't written to stream@Accessible public MetaData getMetaData() throws DataSourceException
MetaData
.
MetaData
.
DataSourceException
- if an Exception
occur during getting the meta data from the storage.public int getEstimatedRowCount(ICondition pFilter) throws DataSourceException
ICondition
to count the rows.
pFilter
- the ICondition
to use.
DataSourceException
- if an Exception
occur during interacting with the storage.protected java.util.List<java.lang.Object[]> executeFetch(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount) throws DataSourceException
executeFetch
in class AbstractStorage
pFilter
- the ICondition
to use.pSort
- the SortDefinition
to use.pFromRow
- the from row index to request from storage.pMinimumRowCount
- the minimum row count to request, beginning from the pFromRow.
List[Object[]]
.
DataSourceException
- if an Exception
occur during interacting with the storage.IStorage.fetch(ICondition, SortDefinition, int, int)
protected java.lang.Object[] executeRefetchRow(java.lang.Object[] pDataRow) throws DataSourceException
executeRefetchRow
in class AbstractStorage
pDataRow
- the specified row as Object[]
.
Object[]
.
DataSourceException
- if an Exception
occur during interacting with the storage.IStorage.refetchRow(Object[])
protected java.lang.Object[] executeInsert(java.lang.Object[] pDataRow) throws DataSourceException
executeInsert
in class AbstractStorage
pDataRow
- the new row as Object[]
to insert.
null
if no insert operation was performed.
DataSourceException
- if an Exception
occur during insert the row to the storageIStorage.insert(Object[])
protected java.lang.Object[] executeUpdate(java.lang.Object[] pOldDataRow, java.lang.Object[] pNewDataRow) throws DataSourceException
executeUpdate
in class AbstractStorage
pOldDataRow
- the old row as Object[]
pNewDataRow
- the new row as Object[]
to update
Object[]
. null
if no update operation was performed.
DataSourceException
- if an Exception
occur during updating the row.IStorage.update(Object[], Object[])
protected void executeDelete(java.lang.Object[] pDeleteDataRow) throws DataSourceException
executeDelete
in class AbstractStorage
pDeleteDataRow
- the row as Object[]
to delete.
DataSourceException
- if an Exception
occur during deleting the row or
if the storage isn't opened or the PrimaryKey is wrong and more/less
then one row is deleted.IStorage.delete(Object[])
public java.lang.String toString()
toString
in class java.lang.Object
public void setMetaData(MetaData pMetaData) throws DataSourceException
pMetaData
- the new meta data.
DataSourceException
- if the Storage is already open.public void open() throws DataSourceException
DataSourceException
- if the DBAccess is null.protected void openInternal(boolean pUseRepresentationColumnsAsQueryColumns) throws DataSourceException
pUseRepresentationColumnsAsQueryColumns
- yes
if the QueryColumns are set with
all representation columns including the Primary Key columns.
DataSourceException
- if the DBAccess is null.protected void refreshMetaData() throws DataSourceException
DataSourceException
- if the DBAccess is null.public void createAutomaticLinkReference(java.lang.String[] pColumns, java.lang.String pWritebackTable, java.lang.String[] pReferenceColumns) throws DataSourceException
StorageReferenceDefinition
with the specified FromClause and
columns and reference columns on all pColumns
.
e.g. its used to make an automatic linked celleditor from a custom written view and set it on all pColumns
.
pColumns
- the columns to use.pWritebackTable
- the FromClause. e.g. VIEW name.pReferenceColumns
- the reference columns to use.
DataSourceException
- if the StorageReferenceDefinition
couldn't created.public void createAutomaticLinkReference(java.lang.String[] pColumns, DBStorage pDBStorage, java.lang.String[] pReferenceColumns) throws DataSourceException
StorageReferenceDefinition
with the specified DBStorage
and
columns and reference columns on all pColumns
.
pColumns
- the columns to use.pDBStorage
- the DBStorage
to use.pReferenceColumns
- the reference columns to use.
DataSourceException
- if the StorageReferenceDefinition
couldn't created.protected void installAutomaticLinkReferenceIntern(StorageReferenceDefinition pReferenceDefinition) throws DataSourceException
StorageReferenceDefinition
with the specified DBStorage
(or from clause) and
columns and reference columns on all pColumns
.
pReferenceDefinition
- the reference definition
DataSourceException
- if the StorageReferenceDefinition
couldn't created.protected java.lang.String createSubStorageName(DBStorage pDBStorage)
pDBStorage
- the DBStorage
to use.
protected void createAutomaticLinkStorage(StorageReferenceDefinition pReferenceDefinition, java.lang.String[] pWritebackColumnNames) throws DataSourceException
DBStorage
which is configured for automatic link cell editors. The auto link
reference feature is disabled for this storage.
pReferenceDefinition
- the storage definitionpWritebackColumnNames
- the write back columns
DataSourceException
- if the from clause causes errors or the metadata are not availableprotected boolean isAutomaticLinkNullable(java.lang.String[] pColumns, ServerColumnMetaData[] pColumnMetaData)
pColumns
- the columnspColumnMetaData
- the meta data
protected ServerMetaData createMetaData(java.lang.String pBeforeQueryColumns, java.lang.String[] pQueryColumns, java.lang.String pFromClause, java.lang.String pWhereClause, java.lang.String pAfterWhereClause, java.lang.String pWritebackTable, java.lang.String[] pWritebackColumns, boolean pAutoLinkReference, boolean pUseRepresentationColumnsAsQueryColumns) throws DataSourceException
pBeforeQueryColumns
- the before query columnspQueryColumns
- the query columnspFromClause
- the from clause with query tables and join definitionspWhereClause
- the last where condition in querypAfterWhereClause
- the after where clause in querypWritebackTable
- the write back table to use.pWritebackColumns
- the write back columns to use.pAutoLinkReference
- yes
if the LinkReferences
are automatic set.pUseRepresentationColumnsAsQueryColumns
- yes
if the QueryColumns are set with
all representation columns including the Primary Key columns.
DataSourceException
- if the meta data couldn't determined.public boolean isOpen()
public void close()
public void setDBAccess(IDBAccess pDBAccess)
IDBAccess
of this DBStorage
.
pDBAccess
- the IDBAccess
of this DBStorage
.public IDBAccess getDBAccess()
IDBAccess
of this DBStorage
.
IDBAccess
of this DBStorage
.public java.lang.String getFromClause()
public void setFromClause(java.lang.String pFromClause)
pFromClause
- the queryTables to set.public java.lang.String[] getQueryColumns()
public void setQueryColumns(java.lang.String[] pQueryColumns)
pQueryColumns
- the queryColumns to setpublic java.lang.String[] getAdditionalQueryColumns()
public void setAdditionalQueryColumns(java.lang.String[] pAdditionalQueryColumns)
pAdditionalQueryColumns
- the additional queryColumns to setpublic java.lang.String getBeforeQueryColumns()
public void setBeforeQueryColumns(java.lang.String pBeforeQueryColumns)
pBeforeQueryColumns
- the beforeQueryColumns to setpublic java.lang.String getWhereClause()
public void setWhereClause(java.lang.String pWhereClause)
pWhereClause
- the last Where Condition to setpublic java.lang.String getAfterWhereClause()
public void setAfterWhereClause(java.lang.String pAfterWhereClause)
pAfterWhereClause
- the afterWhereClause to setpublic java.lang.String getOrderByClause()
public void setOrderByClause(java.lang.String pOrderByClause)
pOrderByClause
- the string to place in the ORDER BY section if no default sort is set.public java.lang.String[] getWritebackColumns()
public void setWritebackColumns(java.lang.String[] pWritebackColumns)
pWritebackColumns
- the pWritebackColumns to setpublic java.lang.String getWritebackTable()
public void setWritebackTable(java.lang.String pWritebackTable)
pWritebackTable
- the pWritebackTable to setpublic SortDefinition getDefaultSort()
public void setDefaultSort(SortDefinition pDefaultSort)
pDefaultSort
- the default sort.public ICondition getRestrictCondition()
public void setRestrictCondition(ICondition pRestrictCondition)
pRestrictCondition
- the restrict condition.public void setAutoLinkReference(boolean pAutoLinkReference)
pAutoLinkReference
- true if the automatic LinkReference mode is on, false
to disable
auto link reference modepublic boolean isAutoLinkReference()
true
if the automatic LinkReference mode is on, otherwise false
setAutoLinkReference(boolean)
public static void setDefaultAutoLinkReference(boolean pDefaultAutoLinkReference)
pDefaultAutoLinkReference
- the default automatic LinkReference mode to use.public static boolean isDefaultAutoLinkReference()
setDefaultAutoLinkReference(boolean)
public void setDefaultValue(boolean pDefaultValue)
pDefaultValue
- true
to enable the default value detectionpublic boolean isDefaultValue()
true
if the default value detection is enabled, false
otherwisesetDefaultValue(boolean)
public static void setDefaultDefaultValue(boolean pDefaultValue)
pDefaultValue
- true
to enable the default - default value detectionpublic static boolean isDefaultDefaultValue()
true
if the default - default value detection is enabled, false
otherwisesetDefaultDefaultValue(boolean)
public void setAllowedValues(boolean pAllowedValues)
pAllowedValues
- true
to enable the allowed value detection, false
otherwisepublic boolean isAllowedValues()
true
if the allowed value detection is enabled, false
otherwisesetAllowedValues(boolean)
public static void setDefaultAllowedValues(boolean pAllowedValues)
pAllowedValues
- true
to enable the default allowed value detection, false
otherwisepublic static boolean isDefaultAllowedValues()
true
if the default allowed value detection is enabled, false
otherwisesetDefaultAllowedValues(boolean)
public boolean isLazyFetchEnabled()
true
if lazy fetch should be enabled.public void setLazyFetchEnabled(boolean pLazyFetchEnabled)
pLazyFetchEnabled
- if lazy fetch should be enabled.public boolean isLockOnRefetch()
true
if refetch should lock the row.public void setLockOnRefetch(boolean pLockOnRefetch)
pLockOnRefetch
- if refetch should lock the row.protected java.lang.String getWritebackTableCatalog()
null
if no writeback table is setprotected java.lang.String getWritebackTableSchema()
null
if no writeback table is setprotected java.lang.Object[] refetchRow(java.lang.Object[] pDataRow, boolean pLock) throws DataSourceException
pDataRow
- the DataRow to refetchpLock
- true if the row is locked before.
DataSourceException
- if the refetch fails@Accessible public java.util.Map<java.lang.String,DBStorage> getSubStorages()
null
if no substorages are
known
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |