|
||||||||||
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 mechanism for different types of Storages.
It is the abstract base class for storages which needs a trigger mechanism.
Nested Class Summary | |
---|---|
protected static class |
AbstractStorage.AllFetchedList<E>
The AllFetchedList is an ArrayUtil wrapper that implements the marker interface
IAllFetched . |
Constructor Summary | |
---|---|
AbstractStorage()
|
Method Summary | ||
---|---|---|
protected IBean |
createBean(java.lang.Object[] pValues)
Creates a bean with given values. |
|
protected BeanType |
createBeanType(java.lang.String[] pColumnNames)
Creates a BeanType for the given column names. |
|
IFileHandle |
createCSV(java.lang.String[] pColumnNames,
java.lang.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(java.lang.String[] pColumnNames,
java.lang.String[] pLabels,
ICondition pFilter,
SortDefinition pSort,
java.lang.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(java.lang.String pFileName,
java.lang.String[] pColumnNames,
java.lang.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(java.lang.Class<T> pClass,
IBean pBean)
Creates a POJO from the given type and with the values from a bean. |
|
protected
|
createPOJO(java.lang.Class<T> pClass,
java.lang.Object[] pValues)
Creates a POJO from the given type and with given values. |
|
protected void |
debug(java.lang.Object... pInfo)
Logs debug information. |
|
void |
delete(java.lang.Object[] pDeleteDataRow)
Deletes the specified row from the storage. |
|
|
delete(T pObject)
Deletes the specified bean/POJO from the storage. |
|
protected void |
error(java.lang.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. |
|
StorageHandler |
eventInsteadOfDelete()
Gets the EventHandler for instead-of delete event. |
|
StorageHandler |
eventInsteadOfInsert()
Gets the EventHandler for instead-of insert event. |
|
StorageHandler |
eventInsteadOfUpdate()
Gets the EventHandler for instead-of update event. |
|
protected abstract 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 void |
executeDeleteAsBean(java.lang.Object[] pDeleteDataRow)
This method will be used if delete(Object) was called. |
|
protected abstract 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.util.List<java.lang.Object[]> |
executeFetchAsBean(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
This method will be used if fetchBean(ICondition, SortDefinition, int, int) was called. |
|
protected abstract 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[] |
executeInsertAsBean(java.lang.Object[] pDataRow)
This method will be used if insert(Object) was called. |
|
protected abstract 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[] |
executeRefetchRowAsBean(java.lang.Object[] pDataRow)
This method will be used if refetch(Object) was called. |
|
protected abstract 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. |
|
protected java.lang.Object[] |
executeUpdateAsBean(java.lang.Object[] pOldDataRow,
java.lang.Object[] pNewDataRow)
This method will be used if update(Object) was called. |
|
|
fetch(java.lang.Class<T> pClass,
ICondition pFilter)
Returns the requested bean/POJO from the storage. |
|
|
fetch(java.lang.Class<T> pClass,
ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested list of beans/POJOs from the storage. |
|
java.util.List<java.lang.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. |
|
java.util.List<IBean> |
fetchBean(ICondition pFilter,
SortDefinition pSort,
int pFromRow,
int pMinimumRowCount)
Returns the requested list of beans from the storage. |
|
protected IBeanType |
getAndInitBeanType()
Gets the bean type based on the meta data. |
|
BeanConverter |
getBeanConverter()
Gets the BeanConverter for this storage and also initializes
it with the metadata from this storage. |
|
java.lang.String |
getName()
Gets the storage name. |
|
java.lang.String |
getPropertyNameForColumn(java.lang.String pColumnName)
Gets the property name (Java standard) for the given column name. |
|
protected boolean |
hasInsteadOfDeleteEventHandler()
Gets whether an insteadOf delete event was assigned. |
|
protected boolean |
hasInsteadOfInsertEventHandler()
Gets whether an insteadOf insert event was assigned. |
|
protected boolean |
hasInsteadOfUpdateEventHandler()
Gets whether an insteadOf update event was assigned. |
|
protected void |
info(java.lang.Object... pInfo)
Logs information. |
|
java.lang.Object[] |
insert(java.lang.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. |
|
protected boolean |
isLogEnabled(ILogger.LogLevel pLevel)
Gets whether the given log level is enabled. |
|
boolean |
isRefetch()
Returns if this Storage refetches after insert and update. |
|
|
refetch(T pObject)
Refetches the specified bean/POJO and returns a bean/POJO with current values from the storage. |
|
java.lang.Object[] |
refetchRow(java.lang.Object[] pDataRow)
It refetchs the specified row and returns it as Object[] from the storage. |
|
void |
setName(java.lang.String pName)
Sets the storage name. |
|
void |
setPropertyNameForColumn(java.lang.String pColumnName,
java.lang.String pPropertyName)
Sets the property name (Java standard) for a given column name. |
|
void |
setRefetch(boolean pRefetch)
Sets if this Storage refetches after insert and update. |
|
java.lang.Object[] |
update(java.lang.Object[] pOldDataRow,
java.lang.Object[] pNewDataRow)
Return the updated row as Object[] . |
|
|
update(T pObject)
Updates a bean/POJO with the PrimaryKey columns and provides values. |
|
|
update(T pOldObject,
T pNewObject)
Updates a bean/POJO with the PrimaryKey columns and provides values. |
|
abstract void |
writeCSV(java.io.OutputStream pStream,
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.rad.persist.IStorage |
---|
getEstimatedRowCount, getMetaData |
Methods inherited from interface com.sibvisions.util.ICloseable |
---|
close |
Constructor Detail |
---|
public AbstractStorage()
Method Detail |
---|
public final java.util.List<java.lang.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 java.lang.Object[] refetchRow(java.lang.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 java.lang.Object[] insert(java.lang.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 java.lang.Object[] update(java.lang.Object[] pOldDataRow, java.lang.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(java.lang.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(java.io.OutputStream pStream, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort, java.lang.String pSeparator) throws java.lang.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
java.lang.Exception
- if the CSV output couldn't written to streamprotected abstract java.lang.Object[] executeRefetchRow(java.lang.Object[] pDataRow) throws DataSourceException
pDataRow
- the specified row as Object[]
.
Object[]
.
DataSourceException
- if an Exception
occur during interacting with the storage.IStorage.refetchRow(Object[])
protected abstract java.util.List<java.lang.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)
protected abstract java.lang.Object[] executeInsert(java.lang.Object[] pDataRow) throws DataSourceException
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 abstract java.lang.Object[] executeUpdate(java.lang.Object[] pOldDataRow, java.lang.Object[] pNewDataRow) throws DataSourceException
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 abstract void executeDelete(java.lang.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 BeanConverter getBeanConverter() throws DataSourceException
BeanConverter
for this storage and also initializes
it with the metadata from this storage.
BeanConverter
.
DataSourceException
- if initializing the BeanConverter
with the metadata failed.public void setName(java.lang.String pName)
setName
in interface INamedObject
pName
- the namepublic java.lang.String getName()
getName
in interface INamedObject
public boolean isRefetch()
public void setRefetch(boolean pRefetch)
pRefetch
- true
if this Storage refetches after insert and update.protected boolean isLogEnabled(ILogger.LogLevel pLevel)
pLevel
- the level to check
true
if the log level is enabled, false
otherwiseprotected void debug(java.lang.Object... pInfo)
pInfo
- the debug informationprotected void info(java.lang.Object... pInfo)
pInfo
- the informationprotected void error(java.lang.Object... pInfo)
pInfo
- the error informationpublic IFileHandle createCSV(java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort) throws java.lang.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
java.lang.Exception
- if the CSV output couldn't written to stream.public IFileHandle createCSV(java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort, java.lang.String pLanguage) throws java.lang.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
java.lang.Exception
- if the CSV output couldn't written to stream.public IFileHandle createCSV(java.lang.String pFileName, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort) throws java.lang.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
java.lang.Exception
- if the CSV output couldn't written to stream.public StorageHandler eventCalculateRow()
public StorageHandler eventInsteadOfInsert()
public StorageHandler eventBeforeInsert()
public StorageHandler eventAfterInsert()
public StorageHandler eventInsteadOfUpdate()
public StorageHandler eventBeforeUpdate()
public StorageHandler eventAfterUpdate()
public StorageHandler eventInsteadOfDelete()
public StorageHandler eventBeforeDelete()
public StorageHandler eventAfterDelete()
protected boolean hasInsteadOfInsertEventHandler()
true
if an insteadOf insert event was added, false
otherwiseprotected boolean hasInsteadOfUpdateEventHandler()
true
if an insteadOf update event was added, false
otherwiseprotected boolean hasInsteadOfDeleteEventHandler()
true
if an insteadOf delete event was added, false
otherwiseprotected IBeanType getAndInitBeanType() throws DataSourceException
DataSourceException
- if an Exception
occurs during
interacting with the storageprotected BeanType createBeanType(java.lang.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(java.lang.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(java.lang.Class<T> pClass, java.lang.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(java.lang.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 setPropertyNameForColumn(java.lang.String pColumnName, java.lang.String pPropertyName)
pColumnName
- the column namepPropertyName
- the java property name e.g. firstName instead of FIRST_NAMEpublic java.lang.String getPropertyNameForColumn(java.lang.String pColumnName)
pColumnName
- the column name e.g. FIRST_NAME
public IBean fetchBean(ICondition pFilter) throws DataSourceException
pFilter
- the filter as ICondition
to get exactly one Bean.
IBean
, 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(java.lang.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 java.util.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> java.util.List<T> fetch(java.lang.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> T update(T pOldObject, T pNewObject) throws DataSourceException
T
- the type of the POJO or bean.pOldObject
- the old IBean/POJO to use for the updatepNewObject
- 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.protected java.lang.Object[] executeRefetchRowAsBean(java.lang.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[])
protected java.util.List<java.lang.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)
protected java.lang.Object[] executeInsertAsBean(java.lang.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[])
protected java.lang.Object[] executeUpdateAsBean(java.lang.Object[] pOldDataRow, java.lang.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[])
protected void executeDeleteAsBean(java.lang.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 |