|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.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()
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()
IStorage,
ColumnMetaData,
RemoteDataBook,
DBAccess| Constructor Summary | |
|---|---|
DBStorage()
Constructs a DBStorage. |
|
| Method Summary | |
|---|---|
static void |
clearMetaData()
Clears the meta data cache. |
void |
close()
It close the DBStorage. |
void |
createAutomaticLinkReference(String[] pColumns,
DBStorage pDBStorage,
String[] pReferenceColumns)
Creates and sets a new StorageReferenceDefinition with the specified DBStorage and
columns and reference columns on all pColumns. |
void |
createAutomaticLinkReference(String[] pColumns,
String pFromClause,
String[] pReferenceColumns)
Creates and sets a new StorageReferenceDefinition with the specified FromClause and
columns and reference columns on all pColumns. |
IFileHandle |
createCSVFile(String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort)
Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle. |
IFileHandle |
createCSVFile(String pFilename,
String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort)
Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle. |
IBean |
createEmptyBean()
Creates a bean with the column names as allowed properties. |
void |
delete(Object[] pDeleteDataRow)
Deletes the specified row from the storage. |
void |
deleteBean(IBean pDeleteDataRow)
Deletes the specified row from the Storage. |
List<Object[]> |
fetch(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested rows as List[Object[]]. |
List<Object[]> |
fetch(String pGroup,
String pName,
ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested rows as List[Object[]]. |
IBean |
fetchBean(ICondition pFilter)
Returns the requested row as single IBean. |
List<IBean> |
fetchBean(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested rows as list of IBean. |
String |
getAfterWhereClause()
Returns the string to place in the SELECT statement after the WHERE clause and before the ORDER BY clause. |
String |
getBeforeQueryColumns()
Returns the string to place in the SELECT statement between the SELECT and the first query column. |
String[] |
getColumnNames()
Gets an array of column names as defined in the metadata. |
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. |
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. |
static Hashtable<String,MetaData> |
getMetaData(String pGroup)
Gets meta data which are cached under a specific name. |
MetaData |
getMetaData(String pGroup,
String pName)
Returns the meta data for this AbstractStorage from the storage as MetaData and places
the MetaData to the cache with a group name and meta data name. |
Hashtable<String,MetaData> |
getMetaDataFromCache(String pGroup)
Returns all available meta data from the cache for a specific cache group. |
String[] |
getQueryColumns()
Returns the query columns of the SELECT statement. |
ICondition |
getRestrictCondition()
Returns the restrict condition. |
Map<String,IStorage> |
getSubStorages()
Gets all known sub storages as key / value pair. |
String |
getWhereClause()
Returns the string to place in the SELECT statement after the last WHERE condition from the Filter or MasterReference (Master-Detail Condition). |
String[] |
getWritebackColumns()
Returns the list of write back columns to use in the INSERT, UPDATE statements. |
String |
getWritebackTable()
Returns the WritebackTable, which is used for the INSERT, UPDATE, DELETE calls. |
Object[] |
insert(Object[] pDataRow)
Returns the newly inserted row for this IStorage. |
IBean |
insertBean(IBean pDataRow)
Returns the newly inserted row for this Storage. |
boolean |
isAllowedValues()
Returns the allowed value detection mode. |
boolean |
isAutoLinkReference()
Returns if the automatic LinkReference mode is on or off. |
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 |
isOpen()
Returns if the DBStorage is open. |
boolean |
isRefetch()
Returns if this DBStorage refetchs after insert and update. |
void |
open()
Opens the DBStorage and checks if the StorageDataSource is ! |
protected void |
openInternal(boolean pUseRepresentationColumnsAsQueryColumns)
Opens the DBStorage and checks if the StorageDataSource is ! |
Object[] |
refetchRow(Object[] pDataRow)
It refetchs the specified row and returns it as Object[] from the storage. |
protected Object[] |
refetchRow(Object[] pDataRow,
boolean pLock)
Refetch and optional locks the specified DataRow via PK. |
IBean |
refetchRowBean(IBean pDataRow)
It refetchs the specified row and returns it as IBean from the Storage. |
void |
removeLinkReference(String pColumnName)
Removes the link reference for an server side Dropdown list (automatic linked celleditor). |
void |
setAfterWhereClause(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(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(String pFromClause)
Sets the query tables to use in the SELECT statement to get the data from the storage. |
void |
setQueryColumns(String[] pQueryColumns)
Sets the query columns of the SELECT statement. |
void |
setRefetch(boolean pRefetch)
Sets if this DBStorage refetchs after insert and update. |
void |
setRestrictCondition(ICondition pRestrictCondition)
Sets the restrict condition. |
void |
setWhereClause(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(String[] pWritebackColumns)
Sets the list of write back columns to use in the INSERT, UPDATE statements. |
void |
setWritebackTable(String pWritebackTable)
Sets the WritebackTable, which is used for the INSERT, UPDATE, DELETE calls. |
String |
toString()
|
Object[] |
update(Object[] pOldDataRow,
Object[] pNewDataRow)
Return the updated row as Object[]. |
IBean |
updateBean(IBean pNewDataRow)
Updates a row with provided values and returns the updated row as IBean. |
void |
writeCSV(OutputStream pOutputStream,
String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort)
Write the current DBStorage with the specified filter and sort into the given output stream as CSV Format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DBStorage()
DBStorage.
| Method Detail |
|---|
public MetaData getMetaData()
throws DataSourceException
MetaData.
getMetaData in interface IStorageMetaData.
DataSourceException - if an Exception occur during getting the meta data from the storage
public MetaData getMetaData(String pGroup,
String pName)
throws DataSourceException
MetaData and places
the MetaData to the cache with a group name and meta data name.
getMetaData in interface ICachedStoragepGroup - the cache group namepName - the name for the meta data in the cache group
MetaData.
DataSourceException - if an Exception occur during getting the meta data from the storagepublic Hashtable<String,MetaData> getMetaDataFromCache(String pGroup)
getMetaDataFromCache in interface ICachedStoragepGroup - the cache group name
Hashtable with the name of the meta data in the cache group and the meta data as value
public int getEstimatedRowCount(ICondition pFilter)
throws DataSourceException
ICondition to count the rows.
getEstimatedRowCount in interface IStoragepFilter - the ICondition to use.
DataSourceException - if an Exception occur during interacting with the storage.
public List<Object[]> fetch(String pGroup,
String pName,
ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
throws DataSourceException
List[Object[]]. Optimization can also return
more then the minimum row count. If possible all in a certain time.
fetch in interface ICachedStoragepGroup - the cache group namepName - the name for the meta data in the cache grouppFilter - the ICondition to usepSort - the SortDefinition to usepFromRow - the from row index to request from storagepMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
List[Object[]].
DataSourceException - if an Exception occur during interacting with the storage.
public List<Object[]> fetch(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
throws DataSourceException
List[Object[]]. Optimization can also return
more then the minimum row count. If possible all in a certain time.
fetch in interface IStoragepFilter - the ICondition to usepSort - the SortDefinition to usepFromRow - the from row index to request from storagepMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
List[Object[]].
DataSourceException - if an Exception occur during interacting with the storage.
public Object[] refetchRow(Object[] pDataRow)
throws DataSourceException
Object[] from the storage.
refetchRow in interface IStoragepDataRow - the specified row as Object[] to lock
Object[] from the storage.
DataSourceException - if an Exception occur during interacting with the storage.
public Object[] insert(Object[] pDataRow)
throws DataSourceException
insert in interface IStoragepDataRow - the new row as Object[] to insert.
DataSourceException - if an Exception occur during insert the row
to the storage
public Object[] update(Object[] pOldDataRow,
Object[] pNewDataRow)
throws DataSourceException
Object[].
update in interface IStoragepOldDataRow - the old row as Object[]pNewDataRow - the new row as Object[] to update
Object[].
DataSourceException - if an Exception occur during updating the row.
public void delete(Object[] pDeleteDataRow)
throws DataSourceException
delete in interface IStoragepDeleteDataRow - 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 deletedpublic String toString()
toString in class Object
public void open()
throws DataSourceException
DataSourceException - if the StorageDataSource 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 StorageDataSource is null.
public void createAutomaticLinkReference(String[] pColumns,
String pFromClause,
String[] pReferenceColumns)
throws ModelException
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.pFromClause - the FromClause. e.g. VIEW name.pReferenceColumns - the reference columns to use.
ModelException - if the StorageReferenceDefinition couldn't created.
public void createAutomaticLinkReference(String[] pColumns,
DBStorage pDBStorage,
String[] pReferenceColumns)
throws ModelException
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.
ModelException - if the StorageReferenceDefinition couldn't created.
public void removeLinkReference(String pColumnName)
throws ModelException
pColumnName - the column name to use, where the link reference will be removed
ModelException - if the column doesn't exists.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 String getFromClause()
public void setFromClause(String pFromClause)
pFromClause - the queryTables to set.public String[] getQueryColumns()
public void setQueryColumns(String[] pQueryColumns)
pQueryColumns - the queryColumns to setpublic String getBeforeQueryColumns()
public void setBeforeQueryColumns(String pBeforeQueryColumns)
pBeforeQueryColumns - the beforeQueryColumns to setpublic String getWhereClause()
public void setWhereClause(String pWhereClause)
pWhereClause - the last Where Condition to setpublic String getAfterWhereClause()
public void setAfterWhereClause(String pAfterWhereClause)
pAfterWhereClause - the afterWhereClause to setpublic String[] getWritebackColumns()
public void setWritebackColumns(String[] pWritebackColumns)
pWritebackColumns - the pWritebackColumns to setpublic String getWritebackTable()
public void setWritebackTable(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 boolean isRefetch()
public void setRefetch(boolean pRefetch)
pRefetch - true if this DBStorage refetchs after insert and update.public void setAutoLinkReference(boolean pAutoLinkReference)
pAutoLinkReference - true if the automatic LinkReference mode is on, false to disable
auto link reference modepublic boolean isAutoLinkReference()
trueif the automatic LinkReference mode is on, otherwise falsesetAutoLinkReference(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 boolean isDefaultAllowedValues()
true if the default allowed value detection is enabled, false otherwisesetDefaultAllowedValues(boolean)
public IFileHandle createCSVFile(String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort)
throws Exception
SessionContext.
pColumnNames - the column names to include in the exportpLabels - the labels to show as header in the exportpFilter - the filter to use on the DBStoragepSort - the sort to use
Exception - if the CSV output couldn't written to stream.
public IFileHandle createCSVFile(String pFilename,
String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort)
throws Exception
pFilename - the filename to use.pColumnNames - the column names to include in the exportpLabels - the labels to show as header in the exportpFilter - the filter to use on the DBStoragepSort - the sort to use
Exception - if the CSV output couldn't written to stream.
public void writeCSV(OutputStream pOutputStream,
String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort)
throws Exception
pOutputStream - the output stream to use for the CSV stream.pColumnNames - the column names to include in the exportpLabels - the labels to show as header in the exportpFilter - the filter to use on the DBStoragepSort - the sort to use
Exception - if the CSV output couldn't written to stream.
protected Object[] refetchRow(Object[] pDataRow,
boolean pLock)
throws DataSourceException
pDataRow - the DataRow to refetchpLock - true if the row is locked before.
DataSourceException - if the refetch failspublic String[] getColumnNames()
getMetaData()
public List<IBean> fetchBean(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
throws DataSourceException
IBean.
pFilter - the ICondition to usepSort - the SortDefinition to usepFromRow - the from row index to request from storagepMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
IBeans.
DataSourceException - if an Exception occur during interacting with the storage.
public IBean fetchBean(ICondition pFilter)
throws DataSourceException
IBean.
pFilter - the ICondition to use
IBeans, or null if no row was found
DataSourceException - if an Exception occur during interacting with the storage or
more than one row were found
public IBean refetchRowBean(IBean pDataRow)
throws DataSourceException
IBean from the Storage.
Before the user starts editing in the GUI, the IDataRow in the storage should be locked for updates.
pDataRow - the specified row as IBean to lock
IBean from the Storage.
DataSourceException - if an Exception occur during interacting with the Storage.
public IBean insertBean(IBean pDataRow)
throws DataSourceException
pDataRow - the new row as IBean to insert.
DataSourceException - if an Exception occur during insert the row
to the storage
public IBean updateBean(IBean pNewDataRow)
throws DataSourceException
IBean.
pNewDataRow - the new row as IBean to update
IBean
DataSourceException - if an Exception occur during updating the row
public void deleteBean(IBean pDeleteDataRow)
throws DataSourceException
pDeleteDataRow - the row as IBean 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 deletedpublic IBean createEmptyBean()
IBean implementationpublic Map<String,IStorage> getSubStorages()
null if no substorages are
knownpublic static Hashtable<String,MetaData> getMetaData(String pGroup)
pGroup - the cache name
null if there are no meta data with the namepublic static void clearMetaData()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||