|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sibvisions.rad.persist.AbstractStorage
public abstract class AbstractStorage
The AbstractStorage
implements the server side triggers mechnism for different types of Storages.
It is the abstract base class for storages which needs a trigger mechanism.
Constructor Summary | |
---|---|
AbstractStorage()
|
Method Summary | ||
---|---|---|
protected IBean |
createBean(Object[] pValues)
Creates a bean with given values. |
|
protected BeanType |
createBeanType(String[] pColumnNames)
Creates a BeanType for the given column names. |
|
IFileHandle |
createCSV(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 |
createCSV(String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort,
String pLanguage)
Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle. |
|
IFileHandle |
createCSV(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 new bean with all column names from the meta data. |
|
|
createPOJO(Class<T> pClass,
IBean pBean)
Creates a POJO from the tiven type and with the values from a bean. |
|
protected
|
createPOJO(Class<T> pClass,
Object[] pValues)
Creates a POJO from the given type and with given values. |
|
protected void |
debug(Object... pInfo)
Logs debug information. |
|
void |
delete(Object[] pDeleteDataRow)
Deletes the specified row from the storage. |
|
|
delete(T pObject)
Deletes the specified bean/POJO from the storage. |
|
protected void |
error(Object... pInfo)
Logs error information. |
|
StorageHandler |
eventAfterDelete()
Gets the EventHandler for after delete event. |
|
StorageHandler |
eventAfterInsert()
Gets the EventHandler for after insert event. |
|
StorageHandler |
eventAfterUpdate()
Gets the EventHandler for after update event. |
|
StorageHandler |
eventBeforeDelete()
Gets the EventHandler for before delete event. |
|
StorageHandler |
eventBeforeInsert()
Gets the EventHandler for before insert event. |
|
StorageHandler |
eventBeforeUpdate()
Gets the EventHandler for before update event. |
|
StorageHandler |
eventCalculateRow()
Gets the EventHandler for calculate row event. |
|
abstract void |
executeDelete(Object[] pDeleteDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the delete method. |
|
void |
executeDeleteAsBean(Object[] pDeleteDataRow)
This method will be used if delete(Object) was called. |
|
abstract List<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. |
|
List<Object[]> |
executeFetchAsBean(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
This method will be used if fetchBean(ICondition, SortDefinition, int, int) was called. |
|
abstract MetaData |
executeGetMetaData()
This method has to be implemented in the Storage implementation and should have the functionality of the getMetaData method. |
|
abstract Object[] |
executeInsert(Object[] pDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the insert method. |
|
Object[] |
executeInsertAsBean(Object[] pDataRow)
This method will be used if insert(Object) was called. |
|
abstract Object[] |
executeRefetchRow(Object[] pDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the refetchRow method. |
|
Object[] |
executeRefetchRowAsBean(Object[] pDataRow)
This method will be used if refetch(Object) was called. |
|
abstract Object[] |
executeUpdate(Object[] pOldDataRow,
Object[] pNewDataRow)
This method has to be implemented in the Storage implementation and should have the functionality of the update method. |
|
Object[] |
executeUpdateAsBean(Object[] pOldDataRow,
Object[] pNewDataRow)
This method will be used if update(Object) was called. |
|
|
fetch(Class<T> pClass,
ICondition pFilter)
Returns the requested bean/POJO from the storage. |
|
|
fetch(Class<T> pClass,
ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested list of beans/POJOs from the storage. |
|
List<Object[]> |
fetch(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested rows as List[Object[]] . |
|
IBean |
fetchBean(ICondition pFilter)
Returns the requested bean from the storage. |
|
List<IBean> |
fetchBean(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested list of beans from the storage. |
|
protected BeanType |
getAndInitBeanType()
Gets the bean type based on the meta data. |
|
MetaData |
getMetaData()
Returns the meta data for this AbstractStorage from the storage as MetaData . |
|
String |
getName()
Gets the storage name. |
|
protected void |
info(Object... pInfo)
Logs information. |
|
Object[] |
insert(Object[] pDataRow)
Returns the newly inserted row for this IStorage. |
|
|
insert(T pObject)
Inserts the new bean/POJO and returns a bean/POJO with current values from the storage. |
|
|
refetch(T pObject)
Refetchs the specified bean/POJO and returns a bean/POJO with current values from the storage. |
|
Object[] |
refetchRow(Object[] pDataRow)
It refetchs the specified row and returns it as Object[] from the storage. |
|
void |
setName(String pName)
Sets the storage name. |
|
void |
setPropertyNameForColumn(String pColumnName,
String pPropertyName)
Sets the property name (Java standard) for a given column name. |
|
Object[] |
update(Object[] pOldDataRow,
Object[] pNewDataRow)
Return the updated row as Object[] . |
|
|
update(T pObject)
Updates a bean/POJO with the PrimaryKey columns and provides values. |
|
void |
updateBean(IBean pBean,
Object pPOJO)
Updates a bean with values from a POJO. |
|
abstract void |
writeCSV(OutputStream pStream,
String[] pColumnNames,
String[] pLabels,
ICondition pFilter,
SortDefinition pSort,
String pSeparator)
Write the current storage 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, toString, wait, wait, wait |
Methods inherited from interface javax.rad.persist.IStorage |
---|
getEstimatedRowCount |
Constructor Detail |
---|
public AbstractStorage()
Method Detail |
---|
public final MetaData getMetaData() throws DataSourceException
MetaData
.
getMetaData
in interface IStorage
MetaData
.
DataSourceException
- if an Exception
occur during getting the meta data from the storage.public final 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 IStorage
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.public final Object[] refetchRow(Object[] pDataRow) throws DataSourceException
Object[]
from the storage.
refetchRow
in interface IStorage
pDataRow
- the specified row as Object[]
.
Object[]
.
DataSourceException
- if an Exception
occur during interacting with the storage.public final Object[] insert(Object[] pDataRow) throws DataSourceException
insert
in interface IStorage
pDataRow
- the new row as Object[]
to insert.
DataSourceException
- if an Exception
occur during insert the row to the storagepublic final Object[] update(Object[] pOldDataRow, Object[] pNewDataRow) throws DataSourceException
Object[]
.
update
in interface IStorage
pOldDataRow
- the old row as Object[]
pNewDataRow
- the new row as Object[]
to update
Object[]
.
DataSourceException
- if an Exception
occur during updating the row.public final void delete(Object[] pDeleteDataRow) throws DataSourceException
delete
in interface IStorage
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.public abstract void writeCSV(OutputStream pStream, String[] pColumnNames, String[] pLabels, ICondition pFilter, SortDefinition pSort, String pSeparator) throws Exception
pStream
- 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
Exception
- if the CSV output couldn't written to streampublic abstract MetaData executeGetMetaData() throws DataSourceException
MetaData
DataSourceException
- if an Exception
occur during getting the meta data from the storageIStorage.getMetaData()
public abstract Object[] executeRefetchRow(Object[] pDataRow) throws DataSourceException
pDataRow
- the specified row as Object[]
.
Object[]
.
DataSourceException
- if an Exception
occur during interacting with the storage.IStorage.refetchRow(Object[])
public abstract List<Object[]> executeFetch(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount) throws DataSourceException
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)
public abstract Object[] executeInsert(Object[] pDataRow) throws DataSourceException
pDataRow
- the new row as Object[]
to insert.
DataSourceException
- if an Exception
occur during insert the row to the storageIStorage.insert(Object[])
public abstract Object[] executeUpdate(Object[] pOldDataRow, Object[] pNewDataRow) throws DataSourceException
pOldDataRow
- the old row as Object[]
pNewDataRow
- the new row as Object[]
to update
Object[]
.
DataSourceException
- if an Exception
occur during updating the row.IStorage.update(Object[], Object[])
public abstract void executeDelete(Object[] pDeleteDataRow) throws DataSourceException
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 void setName(String pName)
setName
in interface INamedObject
pName
- the namepublic String getName()
getName
in interface INamedObject
protected void debug(Object... pInfo)
pInfo
- the debug informationprotected void info(Object... pInfo)
pInfo
- the informationprotected void error(Object... pInfo)
pInfo
- the error informationpublic IFileHandle createCSV(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 createCSV(String[] pColumnNames, String[] pLabels, ICondition pFilter, SortDefinition pSort, String pLanguage) 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 usepLanguage
- the language to use
Exception
- if the CSV output couldn't written to stream.public IFileHandle createCSV(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 StorageHandler eventCalculateRow()
public StorageHandler eventBeforeInsert()
public StorageHandler eventAfterInsert()
public StorageHandler eventBeforeUpdate()
public StorageHandler eventAfterUpdate()
public StorageHandler eventBeforeDelete()
public StorageHandler eventAfterDelete()
protected BeanType getAndInitBeanType() throws DataSourceException
DataSourceException
- if an Exception
occurs during interacting with the storageprotected BeanType createBeanType(String[] pColumnNames)
BeanType
for the given column names.
pColumnNames
- the column names which are allowed for beans
public IBean createEmptyBean() throws DataSourceException
IBean
implementation
DataSourceException
- if an Exception
occurs during interacting with the storageprotected IBean createBean(Object[] pValues) throws DataSourceException
pValues
- the values in same order as the meta data
DataSourceException
- if an Exception
occurs during interacting with the storageprotected <T> T createPOJO(Class<T> pClass, Object[] pValues) throws DataSourceException
T
- the type of the POJOpClass
- the class of the POJOpValues
- the values for the properties in the same order as the meta data
DataSourceException
- if an Exception
occurs during interacting with the storagepublic <T> T createPOJO(Class<T> pClass, IBean pBean) throws DataSourceException
T
- the type of the POJOpClass
- the class of the POJOpBean
- the bean with values for the POJO
DataSourceException
- if an Exception
occurs during interacting with the storagepublic void updateBean(IBean pBean, Object pPOJO) throws DataSourceException
pBean
- the beanpPOJO
- the POJO
DataSourceException
- if an Exception
occurs during interacting with the storagepublic void setPropertyNameForColumn(String pColumnName, String pPropertyName) throws DataSourceException
pColumnName
- the column namepPropertyName
- the java property name e.g. firstName instead of FIRST_NAME
DataSourceException
- if meta data access failedpublic IBean fetchBean(ICondition pFilter) throws DataSourceException
pFilter
- the filter as ICondition
to get exactly one Bean.
IBean
s, or null
if no row was found
DataSourceException
- if an Exception
occurs during interacting with the storage or
more than one Bean were foundpublic <T> T fetch(Class<T> pClass, ICondition pFilter) throws DataSourceException
T
- the type of the POJO or bean.pClass
- the class of the POJO or bean.pFilter
- the filter as ICondition
to use get exactly one Bean.
null
if no Bean/POJO was found
DataSourceException
- if an Exception
occur during interacting with the storage or
more than one Bean/POJO were foundpublic List<IBean> fetchBean(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount) throws DataSourceException
pFilter
- the filter as 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.
DataSourceException
- if an Exception
occur during interacting with the storage.public <T> List<T> fetch(Class<T> pClass, ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount) throws DataSourceException
T
- the type of the POJO or bean.pClass
- the class of the POJO or bean.pFilter
- the filter as 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.
DataSourceException
- if an Exception
occur during interacting with the storage.public <T> T refetch(T pObject) throws DataSourceException
T
- the type of the POJO or bean.pObject
- the specified bean/POJO to refetch from the storage.
DataSourceException
- if an Exception
occur during interacting with the Storage.public <T> T insert(T pObject) throws DataSourceException
T
- the type of the POJO or bean.pObject
- the new IBean/POJO to insert to the storage.
DataSourceException
- if an Exception
occur during insert into the storagepublic <T> T update(T pObject) throws DataSourceException
T
- the type of the POJO or bean.pObject
- the new IBean/POJO to use for the update
DataSourceException
- if an Exception
occur during updating process in the storage.public <T> void delete(T pObject) throws DataSourceException
T
- the type of the POJO or bean.pObject
- the bean/POJO to delete from the storage.
DataSourceException
- if an Exception
occur during the delete operation in the storage.public Object[] executeRefetchRowAsBean(Object[] pDataRow) throws DataSourceException
refetch(Object)
was called.
pDataRow
- the specified row as Object[]
.
Object[]
.
DataSourceException
- if an Exception
occur during interacting with the storage.IStorage.refetchRow(Object[])
public List<Object[]> executeFetchAsBean(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount) throws DataSourceException
fetchBean(ICondition, SortDefinition, int, int)
was called.
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)
public Object[] executeInsertAsBean(Object[] pDataRow) throws DataSourceException
insert(Object)
was called.
pDataRow
- the new row as Object[]
to insert.
DataSourceException
- if an Exception
occur during insert the row to the storageIStorage.insert(Object[])
public Object[] executeUpdateAsBean(Object[] pOldDataRow, Object[] pNewDataRow) throws DataSourceException
update(Object)
was called.
pOldDataRow
- the old row as Object[]
pNewDataRow
- the new row as Object[]
to update
Object[]
.
DataSourceException
- if an Exception
occur during updating the row.IStorage.update(Object[], Object[])
public void executeDeleteAsBean(Object[] pDeleteDataRow) throws DataSourceException
delete(Object)
was called.
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[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |