com.sibvisions.rad.model.remote
Class RemoteDataBook

java.lang.Object
  extended by com.sibvisions.rad.model.mem.DataRow
      extended by com.sibvisions.rad.model.mem.ChangeableDataRow
          extended by com.sibvisions.rad.model.mem.MemDataBook
              extended by com.sibvisions.rad.model.remote.RemoteDataBook
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<IDataRow>, IChangeableDataRow, IDataBook, IDataPage, IDataRow, INamedObject
Direct Known Subclasses:
StorageDataBook

public class RemoteDataBook
extends MemDataBook

The RemoteDataBook is a storage independent table, and handles all operations based on the the MemDatabook base class. It communicates to the IStorage and uses the storage methods to fetch, insert update, delete the data on server.

See Also:
MemDataBook, IDataPage, IDataBook, IRowDefinition, IChangeableDataRow, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.rad.model.IDataBook
IDataBook.SelectionMode, IDataBook.WriteBackIsolationLevel
 
Field Summary
 
Fields inherited from class com.sibvisions.rad.model.mem.MemDataBook
bMemFilter, bMemSort, rootDataBook, rowInstance1, rowInstance2
 
Fields inherited from class com.sibvisions.rad.model.mem.ChangeableDataRow
DELETING, DETAILS_CHANGED, dpDataPage, INSERTING, INTERNAL_OFFSET, iRowIndex, UPDATING, WRITABLE_COLUMN_CHANGED
 
Fields inherited from class com.sibvisions.rad.model.mem.DataRow
oaStorage, rdRowDefinition
 
Constructor Summary
RemoteDataBook()
          Creates a new instance of RemoteDataBook.
 
Method Summary
 void close()
          Closes this IDataBook.
protected  MemDataPage createDataPage(IDataRow pMasterDataRow)
          It constructs a new MemDataPage.
protected  void executeDelete(IChangeableDataRow pDataRow)
          Its called when the deleting DataRow (delete row) should be deleted.
protected  IDataRow executeInsert(IChangeableDataRow pDataRow)
          Its called when the inserting DataRow (new row) should be inserted.
protected  IDataRow executeLockAndRefetch(IChangeableDataRow pDataRow)
          Its called before the DataRow (existing row) will be changed.
protected  void executeRefresh()
          It will be called, when the MemDataBook will be completely refreshed.
protected  void executeRefreshDataPage()
          It will be called, when the MemDataBook will be completely refreshed.
protected  IDataRow executeUpdate(IChangeableDataRow pDataRow)
          Its called when the updating DataRow (changed row) should be updated Derived classed should override this to implemented the needed functionality.
 java.lang.String[] getBlockFetchColumnNames()
          Returns the block fetch columns.
protected  AbstractConnection getConnection()
          Returns the AbstractConnection of the RemoteDataSource for this StorageDataSource.
 RemoteDataSource getDataSource()
          Gets the IDataSource that is used.
protected  int[] getFetchColumnIndexes()
          Returns the correct column indexes of the fetched data, after opening the data book.
protected  int getFetchedRowsForBlock(IDataRow pMasterDataRow)
          Returns the amount of fetched rows per block.
protected  int[] getMasterColumnIndexesForBlock()
          Returns the correct master column indexes of the fetched data, after opening the data book.
protected  java.lang.String[] getMetaDataColumnNames()
          Returns the server meta data column names.
protected  boolean isCachingStorage()
          Returns whether the server storage is a cached storage or a storage without cache.
protected  boolean isDataPageRefetchPossible()
          This function is used for rehashing data pages after insert of the master row.
 boolean isFetchEnabled()
          This can be used for performance tuning.
 boolean isMemFilter()
          Returns true if the filter is handled in memory.
 boolean isMemSort()
          Returns true if the sort is handled in memory.
 boolean isMetaDataCacheEnabled()
          Gets whether metadata cache is enabled.
 boolean isWritebackEnabled()
          Returns true if this data book should write its changes to the storage.
 void open()
          Opens this IDataBook.
 void setBlockFetchColumnNames(java.lang.String[] pBlockFetchColumnNames)
          Sets the block fetch columns.
 void setDataSource(IDataSource pDataSource)
          Sets the IDataSource to use, which allows the IDataBook to retrieve and set data.
protected  void setFetchedRowsForBlock(IDataRow pMasterDataRow, int pFetchedRows)
          Sets the amount of fetched rows per block.
 void setFetchEnabled(boolean pFetchEnabled)
          This can be used for performance tuning.
 void setMemFilter(boolean pMemFilter)
          Sets if the sort is handled in memory.
 void setMemSort(boolean pMemSort)
          Sets if the sort is handled in memory.
 void setMetaDataCacheEnabled(boolean pCacheEnabled)
          Sets the metadata cache enabled.
 void setWritebackEnabled(boolean pWritebackEnabled)
          Sets if this data book should write back its changes to the storage.
 
Methods inherited from class com.sibvisions.rad.model.mem.MemDataBook
addControl, addDetailDataBook, calculateRow, cancelEditingControls, clear, clearCurrentDataPage, clearFilterSortInCurrentMemDataPage, clearFilterSortInMemDataPages, createAndCacheDataPage, createDataRow, createReadOnlyChecker, createRowCalculator, delete, deleteAllDataRows, deleteAllRows, eventAfterColumnSelected, eventAfterDeleted, eventAfterDeleting, eventAfterFilterChanged, eventAfterInserted, eventAfterInserting, eventAfterReload, eventAfterRestore, eventAfterRowSelected, eventAfterSortChanged, eventAfterUpdated, eventAfterUpdating, eventBeforeColumnSelected, eventBeforeDeleted, eventBeforeDeleting, eventBeforeFilterChanged, eventBeforeInserted, eventBeforeInserting, eventBeforeReload, eventBeforeRestore, eventBeforeRowSelected, eventBeforeSortChanged, eventBeforeUpdated, eventBeforeUpdating, fetchAll, finalize, getAdditionalDataRow, getChangedDataRows, getChangedRows, getDataBook, getDataPage, getDataPage, getDataPage, getDataPage, getDataPageWithRootRow, getDataRow, getDetailDataBooks, getEstimatedRowCount, getFilter, getMasterDataRow, getMasterReference, getName, getOriginalDataRow, getReadAhead, getReadOnlyChecker, getRootDataBook, getRootDataBookIntern, getRootReference, getRowCalculator, getRowCount, getRowDefinition, getRowIndex, getSelectedColumn, getSelectedDataPageRow, getSelectedRow, getSelectionMode, getSort, getTreePath, getUID, getValue, getValue, getValues, getWritebackIsolationLevel, hasChanges, hasDataPage, hasDataPage, insert, invokeTreeCancelEditingControls, invokeTreeSaveEditingControls, isAdditionalDataRowVisible, isAllFetched, isDeleteAllowed, isDeleteCascade, isDeleteEnabled, isDeleting, isDetailChanged, isInsertAllowed, isInsertEnabled, isInserting, isLockAndRefetchEnabled, isOpen, isOutOfSync, isReadOnly, isSelfJoined, isSortDataRowOnSave, isUpdateAllowed, isUpdateEnabled, isUpdating, isWritableColumnChanged, keepSortableColumns, notifyDetailChanged, notifyMasterChanged, notifyRepaintControls, reload, reload, reloadDataPage, reloadIntern, removeDataPage, removeDetailDataBook, restoreAllRows, restoreDataPage, restoreSelectedRow, saveAllRows, saveDataPage, saveEditingControls, saveSelectedRow, searchNext, searchNext, searchPrevious, searchPrevious, setAdditionalDataRowVisible, setDeleteCascade, setDeleteEnabled, setFilter, setInsertEnabled, setLockAndRefetchEnabled, setMasterReference, setName, setReadAhead, setReadOnly, setReadOnlyChecker, setReadOnlyChecker, setReadOnlyWithoutSave, setRootReference, setRowCalculator, setRowCalculator, setRowDefinition, setSelectedColumn, setSelectedDataPageRow, setSelectedRow, setSelectedRowInternal, setSelectionMode, setSort, setSortDataRowOnSave, setTreePath, setUpdateEnabled, setValue, setValues, setWritebackIsolationLevel, store, toString, update
 
Methods inherited from class com.sibvisions.rad.model.mem.ChangeableDataRow
getOriginalRow, restore, setDeleting, setDetailChanged, setInserting, setUID, setUpdating, setValueIntern
 
Methods inherited from class com.sibvisions.rad.model.mem.DataRow
compareTo, compareTo, createEmptyDataRow, createEmptyRow, equals, equals, eventValuesChanged, eventValuesChanged, getControls, getValueAsString, getValuesAsString, hasControls, hashCode, invokeCancelEditingControls, invokeRepaintListeners, invokeSaveEditingControls, removeControl, setDefaultValues, setValuesIntern
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.rad.model.IChangeableDataRow
getOriginalRow
 
Methods inherited from interface javax.rad.model.IDataRow
compareTo, createEmptyDataRow, createEmptyRow, equals, eventValuesChanged, eventValuesChanged, getControls, getValueAsString, getValuesAsString, removeControl
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

RemoteDataBook

public RemoteDataBook()
Creates a new instance of RemoteDataBook.

Method Detail

isDataPageRefetchPossible

protected boolean isDataPageRefetchPossible()
This function is used for rehashing data pages after insert of the master row. If it is true, the page is dropped, and therefore refetched, if needed.

Overrides:
isDataPageRefetchPossible in class MemDataBook
Returns:
true, the page is dropped, and therefore refetched, if needed.

createDataPage

protected MemDataPage createDataPage(IDataRow pMasterDataRow)
It constructs a new MemDataPage. Its every time used, when a new MemDataPage is necessary. Derived classed should override this and create the needed IDataPage.

Overrides:
createDataPage in class MemDataBook
Parameters:
pMasterDataRow - the master IDataRow for this IDataPage.
Returns:
the new MemDataPage to use.

setDataSource

public void setDataSource(IDataSource pDataSource)
                   throws ModelException
Sets the IDataSource to use, which allows the IDataBook to retrieve and set data.

The IDataSource can only be set if the IDataBook is not already open.

Specified by:
setDataSource in interface IDataBook
Overrides:
setDataSource in class MemDataBook
Parameters:
pDataSource - the IDataSource to use.
Throws:
ModelException - if the IDataBook is already open.
See Also:
IDataBook.getDataSource(), IDataSource

getDataSource

public RemoteDataSource getDataSource()
Gets the IDataSource that is used.

Specified by:
getDataSource in interface IDataBook
Overrides:
getDataSource in class MemDataBook
Returns:
the IDataSource that is used.
See Also:
IDataBook.setDataSource(IDataSource), IDataSource

open

public void open()
          throws ModelException
Opens this IDataBook.

"Open" means that all actions are performed which are needed to deliver data to the user, an IDataBook that is open can be used for querying and changing data.

Implementations should perform all needed set up work in this method (like reading metadata from the storage).

Specified by:
open in interface IDataBook
Overrides:
open in class MemDataBook
Throws:
ModelException - if there is no name set, or if there is no column in the row definition, or if there is no IDataBook.getDataSource() set.

close

public void close()
Closes this IDataBook.

A closed IDataBook has the same state as an not open IDataBook. It can't be used to query or change data, but it can be reopened.

Implementations should performs all clean up in this method and the (cached) data can be discarded at this point.

Specified by:
close in interface IDataBook
Overrides:
close in class MemDataBook

executeLockAndRefetch

protected IDataRow executeLockAndRefetch(IChangeableDataRow pDataRow)
                                  throws ModelException
Its called before the DataRow (existing row) will be changed. Derived classed should override this to implemented the needed functionality. e.g. lock and refetch the actual values of the row from storage

Overrides:
executeLockAndRefetch in class MemDataBook
Parameters:
pDataRow - the data row to lock
Returns:
the data row with current values from server, or null if the row is unchanged.
Throws:
ModelException - if an ModelException occur during insert.

executeInsert

protected IDataRow executeInsert(IChangeableDataRow pDataRow)
                          throws ModelException
Its called when the inserting DataRow (new row) should be inserted. Derived classed should override this to implemented the needed functionality. e.g. store the new row in the storage.

Overrides:
executeInsert in class MemDataBook
Parameters:
pDataRow - the data row to insert
Returns:
the data row with current values from server, or null if the row is unchanged.
Throws:
ModelException - if an ModelException occur during insert.

executeUpdate

protected IDataRow executeUpdate(IChangeableDataRow pDataRow)
                          throws ModelException
Its called when the updating DataRow (changed row) should be updated Derived classed should override this to implemented the needed functionality. e.g. update the old row with the new row in the storage.

Overrides:
executeUpdate in class MemDataBook
Parameters:
pDataRow - the data row to update
Returns:
the data row with current values from server, or null if the row is unchanged.
Throws:
ModelException - if an ModelException occur during update.

executeDelete

protected void executeDelete(IChangeableDataRow pDataRow)
                      throws ModelException
Its called when the deleting DataRow (delete row) should be deleted. Derived classed should override this to implemented the needed functionality. e.g. delete the row in the storage.

Overrides:
executeDelete in class MemDataBook
Parameters:
pDataRow - the data row to delete
Throws:
ModelException - if an ModelException occur during delete.

executeRefresh

protected void executeRefresh()
                       throws ModelException
It will be called, when the MemDataBook will be completely refreshed. In the MemDataBook, it does nothing, because all is in memory and not restoreable. Derived classes maybe want to clear the memory.

Overrides:
executeRefresh in class MemDataBook
Throws:
ModelException - if an ModelExcpetion happen during refresh

executeRefreshDataPage

protected void executeRefreshDataPage()
                               throws ModelException
It will be called, when the MemDataBook will be completely refreshed. In the MemDataBook, it does nothing, because all is in memory and not restoreable. Derived classes maybe want to clear the memory.

Overrides:
executeRefreshDataPage in class MemDataBook
Throws:
ModelException - if an ModelExcpetion happen during refresh

setMemSort

public void setMemSort(boolean pMemSort)
Sets if the sort is handled in memory.

Overrides:
setMemSort in class MemDataBook
Parameters:
pMemSort - true if the sort is handled in memory.

isMemSort

public boolean isMemSort()
Returns true if the sort is handled in memory.

Overrides:
isMemSort in class MemDataBook
Returns:
true if the sort is handled in memory.

setMemFilter

public void setMemFilter(boolean pMemFilter)
Sets if the sort is handled in memory.

Overrides:
setMemFilter in class MemDataBook
Parameters:
pMemFilter - true if the filter is handled in memory.

isMemFilter

public boolean isMemFilter()
Returns true if the filter is handled in memory.

Overrides:
isMemFilter in class MemDataBook
Returns:
true if the filter is handled in memory.

setWritebackEnabled

public void setWritebackEnabled(boolean pWritebackEnabled)
Sets if this data book should write back its changes to the storage.

Overrides:
setWritebackEnabled in class MemDataBook
Parameters:
pWritebackEnabled - determines if changes should be written to the store.

isWritebackEnabled

public boolean isWritebackEnabled()
Returns true if this data book should write its changes to the storage.

Overrides:
isWritebackEnabled in class MemDataBook
Returns:
true to write back all changes, false otherwise.

isFetchEnabled

public boolean isFetchEnabled()
This can be used for performance tuning. If false, no fetch will be called on server. All DataPages will be empty. After enable fetching again, the data book has to be reloaded.

Returns:
true, if calling fetch on server is enabled

setFetchEnabled

public void setFetchEnabled(boolean pFetchEnabled)
This can be used for performance tuning. If false, no fetch will be called on server. All DataPages will be empty. After enable fetching again, the data book has to be reloaded.

Parameters:
pFetchEnabled - true, if calling fetch on server is enabled

getBlockFetchColumnNames

public java.lang.String[] getBlockFetchColumnNames()
Returns the block fetch columns. The block fetch columns have to be a subset of the master link columns. The rows are fetched with these columns, and sorted into the corresponding pages.

Returns:
the block fetch columns.

setBlockFetchColumnNames

public void setBlockFetchColumnNames(java.lang.String[] pBlockFetchColumnNames)
                              throws ModelException
Sets the block fetch columns. The block fetch columns have to be a subset of the master link columns. The rows are fetched with these columns, and sorted into the corresponding pages.

Parameters:
pBlockFetchColumnNames - the block fetch columns.
Throws:
ModelException - if the data book is already open.

setMetaDataCacheEnabled

public void setMetaDataCacheEnabled(boolean pCacheEnabled)
Sets the metadata cache enabled. If it is disabled, every open performs a remote call.

Parameters:
pCacheEnabled - true to enable the cache

isMetaDataCacheEnabled

public boolean isMetaDataCacheEnabled()
Gets whether metadata cache is enabled.

Returns:
true if the cache is enabled, false otherwise

getMetaDataColumnNames

protected java.lang.String[] getMetaDataColumnNames()
Returns the server meta data column names.

Returns:
the server meta data column names.

getFetchColumnIndexes

protected int[] getFetchColumnIndexes()
Returns the correct column indexes of the fetched data, after opening the data book.

Returns:
the correct column indexes of the fetched data, after opening the data book.

getMasterColumnIndexesForBlock

protected int[] getMasterColumnIndexesForBlock()
Returns the correct master column indexes of the fetched data, after opening the data book.

Returns:
the correct master column indexes of the fetched data, after opening the data book.

getFetchedRowsForBlock

protected int getFetchedRowsForBlock(IDataRow pMasterDataRow)
                              throws ModelException
Returns the amount of fetched rows per block.

Parameters:
pMasterDataRow - the master data row.
Returns:
the amount of fetched rows per block.
Throws:
ModelException - if it fails.

setFetchedRowsForBlock

protected void setFetchedRowsForBlock(IDataRow pMasterDataRow,
                                      int pFetchedRows)
                               throws ModelException
Sets the amount of fetched rows per block.

Parameters:
pMasterDataRow - the master data row.
pFetchedRows - the amount of fetched rows per block.
Throws:
ModelException - if it fails.

getConnection

protected AbstractConnection getConnection()
Returns the AbstractConnection of the RemoteDataSource for this StorageDataSource.

Returns:
the AbstractConnection of the RemoteDataSource for this StorageDataSource.

isCachingStorage

protected boolean isCachingStorage()
Returns whether the server storage is a cached storage or a storage without cache.

Returns:
true if the server storage uses a cache, false otherwise


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.