com.sibvisions.rad.model.mem
Class MemDataBook

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
All Implemented Interfaces:
Serializable, Comparable<IDataRow>, IChangeableDataRow, IDataBook, IDataPage, IDataRow, INamedObject
Direct Known Subclasses:
RemoteDataBook

public class MemDataBook
extends ChangeableDataRow
implements IDataBook

The MemDataBook is a storage independent table, and handles all operations to load, save and manipulate table oriented data.
An MemDataBook has at least one MemDataPage to store all DataRow's of this MemDataBook. If an MemDataBook has detail IDataBook's, it handles for each detail IDataBook the IDataPage's. Thats necessary because every change of the selected IDataRow needs to initiate the change of the corresponding details. So the IDataBook adds the appropriate IDataPage's into the detail IDataBook's.
The MemDataBook is also a IChangeableDataRow, the selected row of the MemDataBook.

See Also:
MemDataPage, IDataPage, IDataBook, IRowDefinition, IChangeableDataRow, IDataSource, 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.ChangeableDataRow
DELETING, DETAILS_CHANGED, INSERTING, INTERNAL_OFFSET, UPDATING, WRITABLE_COLUMN_CHANGED
 
Fields inherited from class com.sibvisions.rad.model.mem.DataRow
oaStorage, rdRowDefinition
 
Constructor Summary
MemDataBook()
          Contructs a new MemDataBook with an empty RowDefinition.
MemDataBook(RowDefinition pRowDefinition)
          Constructs a new MemDataBook with the given RowDefinition.
 
Method Summary
 void addDetailDataBook(IDataBook pDetailDataBook)
          Registered a new detail IDataBook to this master IDataBook.
protected  void clear()
          It clears the AbstractStorage of the MemDataBook.
protected  void clearFilterSortInMemDataPages()
          It clears all mem filter sorts in the MemDataPages.
 void close()
          Closes the IDataBook.
protected  MemDataPage createDataPage(IDataRow pMasterDataRow)
          It constructs a new MemDataPage.
 void delete()
          It deletes the selected DataRow.
 void deleteAllDataRows()
          It deletes all DataRows.
 DataBookHandler eventAfterColumnSelected()
          Gets the EventHandler for after column selected event.
 DataBookHandler eventAfterDeleted()
          Gets the EventHandler for after deleted event.
 DataBookHandler eventAfterDeleting()
          Gets the EventHandler for after deleting event.
 DataBookHandler eventAfterInserted()
          Gets the EventHandler for after inserted event.
 DataBookHandler eventAfterInserting()
          Gets the EventHandler for after inserting event.
 DataBookHandler eventAfterReload()
          Gets the EventHandler for after reload event.
 DataBookHandler eventAfterRestore()
          Gets the EventHandler for after restore event.
 DataBookHandler eventAfterRowSelected()
          Gets the EventHandler for after row selected event.
 DataBookHandler eventAfterUpdated()
          Gets the EventHandler for after updated event.
 DataBookHandler eventAfterUpdating()
          Gets the EventHandler for after updating event.
 DataBookHandler eventBeforeColumnSelected()
          Gets the EventHandler for before column selected event.
 DataBookHandler eventBeforeDeleted()
          Gets the EventHandler for before deleted event.
 DataBookHandler eventBeforeDeleting()
          Gets the EventHandler for before deleting event.
 DataBookHandler eventBeforeInserted()
          Gets the EventHandler for before inserted event.
 DataBookHandler eventBeforeInserting()
          Gets the EventHandler for before inserting event.
 DataBookHandler eventBeforeReload()
          Gets the EventHandler for before reload event.
 DataBookHandler eventBeforeRestore()
          Gets the EventHandler for before restore event.
 DataBookHandler eventBeforeRowSelected()
          Gets the EventHandler for before row selected event.
 DataBookHandler eventBeforeUpdated()
          Gets the EventHandler for before updated event.
 DataBookHandler eventBeforeUpdating()
          Gets the EventHandler for before updating event.
protected  void executeDelete()
          Its called when the deleting DataRow (delete row) should be deleted.
protected  void executeInsert()
          Its called when the inserting DataRow (new row) should be inserted.
protected  void executeLockAndRefetch()
          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 executeUpdate()
          Its called when the updating DataRow (changed row) should be updated Derived classed should override this to implemented the needed functionality.
 void fetchAll()
          It fetches all IDataRow's from the storage.
protected  void finalize()
          
 int[] getChangedDataRows()
          Returns an int array with all changed rows.
 IDataBook getDataBook()
          Returns the IDataBook of the IDataPage.
 IDataPage getDataPage()
          Returns the correspondingIDataPage of the IDataRow.
 IDataPage getDataPage(IDataRow pMasterDataRow)
          Returns the corresponding IDataPage to specified master row from the master DataBook.
 IDataPage getDataPage(IDataRow pRootRow, TreePath pTreePath)
          Gets the IDataPage for the given TreePath and root row.
 IDataPage getDataPage(TreePath pTreePath)
          Gets the IDataPage for the given TreePath.
 IDataPage getDataPageWithRootRow(IDataRow pRootDataRow)
          Returns the corresponding IDataPage to specified root row from the root DataBook.
 IChangeableDataRow getDataRow(int pDataRowIndex)
          Returns a copy of the IDataRow of the specified index.
 IDataSource getDataSource()
          Returns the IDataSource for this IDataBook.
 IDataBook[] getDetailDataBooks()
          Returns all detail IDataBooks to the master IDataBook.
 int getEstimatedRowCount()
          Returns the row count in IDBAccess for this RemoteDataBook.
 ICondition getFilter()
          Returns the filter for this IDataBook.
 IDataRow getMasterDataRow()
          Returns the corresponding master row to this IDataPage in the master DataBook.
 ReferenceDefinition getMasterReference()
          Returns the ReferenceDefinition to the master IDataBook.
 String getName()
          Returns the IDataBook name.
 int[] getOnlyIUDChangedDataRows()
          Returns only all Changed DataRows with the states isInserting(), isUpdating(), isDeleting().
 IDataRow getOriginalRow()
          Returns the original row, before the first change is made.
 int getReadAhead()
          Returns the count of rows which are read ahead from the IDBAccess.
 ReferenceDefinition getRootReference()
          Gets the tree root reference.
 int getRowCount()
          Returns the size.
 int getRowIndex()
          Returns the row index of the IDataRows in the IDataPage.
 String getSelectedColumn()
          Returns the selected column in the IDataBook.
 int getSelectedRow()
          Returns the selected row index in the IDataBook.
 IDataBook.SelectionMode getSelectionMode()
          Returns the selection mode for this IDataBook.
 SortDefinition getSort()
          Returns the sort order for this IDataBook.
 TreePath getTreePath()
          Gets the tree current tree path.
 Object getUID()
          Returns the internal unique identifier for a IChangeableDataRow, which isInserting().
 Object getValue(String pColumnName)
          Returns the value of the named column.
 Object[] getValues(String[] pColumnNames)
          Returns a Object[] of values from the specified columns in this IDataRow.
 IDataBook.WriteBackIsolationLevel getWritebackIsolationLevel()
          Returns the current write back isolation level.
 boolean hasDataPage(IDataRow pMasterDataRow)
          Returns true if an IDataPage to specified master row from the master DataBook exists.
 boolean hasDataPage(IDataRow pRootDataRow, TreePath pTreePath)
          Returns true if an IDataPage to specified root row and TreePath from the master DataBook exists.
 int insert(boolean pBeforeRow)
          It inserts a new IDataRow.
 boolean isAllFetched()
          Returns true if all rows are loaded.
protected  boolean isDataPageRefetchPossible()
          This function is used for rehashing data pages after insert of the master row.
 boolean isDeleteAllowed()
          Returns true if delete is allowed on this IDataBook.
 boolean isDeleteCascade()
          Returns true if all rows of this detail table should be deleted, when the master row is deleted.
 boolean isDeleteEnabled()
          Returns true if delete is enabled on this IDataBook.
 boolean isDeleting()
          Returns if this row is deleted.
 boolean isDetailChanged()
          Returns true if under this row in the detail DataBook one or more changed (isInserting/Updating/Deleting() == true) detail rows existing.
 boolean isInsertAllowed()
          Returns true if insert is allowed on this IDataBook.
 boolean isInsertEnabled()
          Returns true if insert is enabled on this IDataBook.
 boolean isInserting()
          Returns if this row is new.
 boolean isLockAndRefetchEnabled()
          Returns true if lock and refetch is enabled.
protected  boolean isMemFilter()
          Returns true if the filter is handled in memory.
protected  boolean isMemSort()
          Returns true if the sort is handled in memory.
 boolean isOpen()
          Returns true if the IDataBook is opened.
 boolean isOutOfSync()
          Gets true, if the IDataBook is not yet initialized after a reload.
 boolean isReadonly()
          Returns true if this IDataBook is read only.
 boolean isSelfJoined()
          True, if this IDataBook is self joined.
 boolean isUpdateAllowed()
          Returns true if update is allowed on this IDataBook.
 boolean isUpdateEnabled()
          Returns true if update is enabled on this IDataBook.
 boolean isUpdating()
          Returns if this row is changed.
 boolean isWritableColumnChanged()
          Returns true if one isWritableColumnChanged() column is changed.
protected  boolean isWritebackEnabled()
          Returns true if this data book should write its changes to the storage.
 void notifyDetailChanged()
          It sets the selected row in master, that one or more details rows (from DetailDataBooks) are changed.
 void notifyMasterChanged()
          Has to be called from the master, if the master changed, to notify all detail IDataBooks.
 void open()
          Opens the IDataBook.
 void reload()
          It refreshs all IDataRow's in the IDataBook, like the was before the changes, get the data again from the storage It selects the same row (over primary key) if the SelectionMode == CURRENT_ROW in the IDataBook.
 void reload(IDataBook.SelectionMode pSelectionMode)
          It refreshs all IDataRow's in the IDataBook, like the was before the changes, get the data again from the storage and selects the row with the specified SelectionMode.
 void reloadDataPage(IDataBook.SelectionMode pSelectionMode)
          Reload the current DataPage with the pSelectionMode.
 void removeDataPage(IDataRow pMasterDataRow, TreePath pTreePath)
          Removes the DataPage to the specified master DataRow or TreePath.
 void removeDetailDataBook(IDataBook pDetailDataBook)
          Unregister a detail IDataBook from this master IDataBook.
 void restoreAllRows()
          It restores all IDataRow's, like the was before the changes.
 void restoreDataPage()
          Restores all rows in the current DataPage.
 void restoreSelectedRow()
          It restores the selected IDataRow, like the was before the changes.
 void saveAllRows()
          It stores all changes in the IDataRow's to the IDataSource.
 void saveDataPage()
          Saves all rows in the current DataPage.
 void saveSelectedRow()
          It stores all changes in the selected IDataRow.
 int searchNext(ICondition pCondition)
          Searches the given condition.
 int searchNext(ICondition pCondition, int pRowNum)
          Searches the given condition starting at the given position.
 int searchPrevious(ICondition pCondition)
          Searches the given condition.
 int searchPrevious(ICondition pCondition, int pRowNum)
          Searches the given condition starting at the given position.
 void setDataSource(IDataSource pDataSource)
          Sets the IDataSource for this IDataBook.
 void setDeleteCascade(boolean pDeleteCascade)
          Sets if all rows of this detail table should be deleted, when the master row is deleted.
 void setDeleteEnabled(boolean pDeleteEnabled)
          Sets whether delete is enabled on this IDataBook.
 void setFilter(ICondition pFilter)
          Sets the filter for this IDataBook.
 void setInsertEnabled(boolean pInsertEnabled)
          Sets whether insert is enabled on this IDataBook.
 void setLockAndRefetchEnabled(boolean pLockAndRefetchEnabled)
          Sets whether if lock and refetch is enabled.
 void setMasterReference(ReferenceDefinition pMasterReference)
          Sets the master IDataBook to this detail IDataBook over a ReferenceDefinition.
protected  void setMemFilter(boolean pMemFilter)
          Sets if the sort is handled in memory.
protected  void setMemSort(boolean pMemSort)
          Sets if the sort is handled in memory.
 void setName(String pName)
          Set the name of the IDataBook.
 void setReadAhead(int pReadAheadRowCount)
          Sets the count of rows which are read ahead from the IDBAccess.
 void setReadOnly(boolean pReadOnly)
          Sets whether this IDataBook is read only.
 void setReadOnlyWithoutSave(boolean pReadOnly)
          Sets the databook readonly but does not automatically save.
 void setRootReference(ReferenceDefinition pTreeRootReference)
          Sets the tree root reference.
 void setRowDefinition(IRowDefinition pRowDefinition)
          Sets the IRowDefinition of the IDataBook.
 void setSelectedColumn(String pColumnName)
          Sets the selected column in the IDataBook.
 void setSelectedRow(int pDataRowIndex)
          Sets the selected row index in the IDataBook.
protected  void setSelectedRowInternal(int pDataRowIndex)
          Sets the selected row with throwing any changed events.
 void setSelectionMode(IDataBook.SelectionMode pSelectionMode)
          Sets the one of the following selection mode for this IDataBook.
 void setSort(SortDefinition pSort)
          Sets the sort order for this IDataBook.
 void setTreePath(TreePath pTreePath)
          Sets the tree current tree path.
 void setUpdateEnabled(boolean pUpdateEnabled)
          Sets whether update is enabled on this IDataBook.
 void setValue(String pColumnName, Object pValue)
          Sets the value of the named column in this IDataRow.
 void setValues(String[] pColumnNames, Object[] pValues)
          Sets the column's values from the pValues Object[] to the this IDataRow.
protected  void setValuesInternal(String[] pColumnNames, Object[] pValues)
          It sets the values without throwing an event.
protected  void setWritebackEnabled(boolean pWritebackEnabled)
          Sets if this data book should write back its changes to the storage.
 void setWritebackIsolationLevel(IDataBook.WriteBackIsolationLevel pIsolationLevel)
          Sets when the IDataSource needs to write back the data to the storage.
protected  void store()
          It stores the changes in memory as stored.
 String toString()
          
 void update()
          It sets the selected row as UPDATING.
 
Methods inherited from class com.sibvisions.rad.model.mem.ChangeableDataRow
restore, setDeleting, setDetailChanged, setInserting, setUID, setUpdating, setValueDRInternal
 
Methods inherited from class com.sibvisions.rad.model.mem.DataRow
addControl, cancelEditingControls, compareTo, compareTo, createDataRow, createEmptyRow, equals, equals, eventValuesChanged, getControls, getRowDefinition, getValue, getValueAsString, getValuesAsString, hashCode, invokeCancelEditingControls, invokeRepaintListeners, invokeSaveEditingControls, notifyRepaintControls, removeControl, saveEditingControls, setDefaultValues
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.rad.model.IDataRow
addControl, compareTo, createDataRow, createEmptyRow, equals, eventValuesChanged, getControls, getRowDefinition, getValue, getValueAsString, getValuesAsString, removeControl
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

MemDataBook

public MemDataBook()
Contructs a new MemDataBook with an empty RowDefinition.


MemDataBook

public MemDataBook(RowDefinition pRowDefinition)
Constructs a new MemDataBook with the given RowDefinition.

Parameters:
pRowDefinition - the row definition for the data book
Method Detail

getDataBook

public IDataBook getDataBook()
Returns the IDataBook of the IDataPage.

Specified by:
getDataBook in interface IDataPage
Returns:
the IDataBook of the IDataPage.

getName

public String getName()
Returns the IDataBook name.

Specified by:
getName in interface IDataBook
Specified by:
getName in interface INamedObject
Returns:
the IDataBook name.

setName

public void setName(String pName)
             throws ModelException
Set the name of the IDataBook.

Specified by:
setName in interface IDataBook
Specified by:
setName in interface INamedObject
Parameters:
pName - IDataBook name
Throws:
ModelException - if the IDataBook is already opened. -> Not allowed

setWritebackIsolationLevel

public void setWritebackIsolationLevel(IDataBook.WriteBackIsolationLevel pIsolationLevel)
Sets when the IDataSource needs to write back the data to the storage.
The default write back isolation level is DATA_ROW.

Specified by:
setWritebackIsolationLevel in interface IDataBook
Parameters:
pIsolationLevel - the new write back isolation level.
See Also:
IDataBook.WriteBackIsolationLevel

getWritebackIsolationLevel

public IDataBook.WriteBackIsolationLevel getWritebackIsolationLevel()
Returns the current write back isolation level.

Specified by:
getWritebackIsolationLevel in interface IDataBook
Returns:
the current write back isolation level.

setRowDefinition

public void setRowDefinition(IRowDefinition pRowDefinition)
                      throws ModelException
Sets the IRowDefinition of the IDataBook.

Specified by:
setRowDefinition in interface IDataBook
Parameters:
pRowDefinition - the new IRowDefinition
Throws:
ModelException - if the IRowDefinition is empty

getDataSource

public IDataSource getDataSource()
Returns the IDataSource for this IDataBook.

Specified by:
getDataSource in interface IDataBook
Returns:
the IDataSource for this IDataBook.

setDataSource

public void setDataSource(IDataSource pDataSource)
                   throws ModelException
Sets the IDataSource for this IDataBook.
The IDataSource defines the access to the storage like DB, XML, ...

Specified by:
setDataSource in interface IDataBook
Parameters:
pDataSource - the IDataSource to use for load/save data
Throws:
ModelException - if the IDataBook is already opened. -> Not allowed
See Also:
IDataSource

getMasterReference

public ReferenceDefinition getMasterReference()
Returns the ReferenceDefinition to the master IDataBook.

Specified by:
getMasterReference in interface IDataBook
Returns:
the ReferenceDefinition to the master IDataBook.

setMasterReference

public void setMasterReference(ReferenceDefinition pMasterReference)
                        throws ModelException
Sets the master IDataBook to this detail IDataBook over a ReferenceDefinition.

Specified by:
setMasterReference in interface IDataBook
Parameters:
pMasterReference - the ReferenceDefinition to the master IDataBook.
Throws:
ModelException - if the IDataBook is open
See Also:
ReferenceDefinition

isSelfJoined

public boolean isSelfJoined()
True, if this IDataBook is self joined.

Specified by:
isSelfJoined in interface IDataBook
Returns:
True, if this IDataBook is self joined.

getDataPage

public IDataPage getDataPage(TreePath pTreePath)
                      throws ModelException
Gets the IDataPage for the given TreePath.

Specified by:
getDataPage in interface IDataBook
Parameters:
pTreePath - the TreePath.
Returns:
gets the tree root reference.
Throws:
ModelException - if the pRootRow or pTreePath don't contains the master columns from the master ReferenceDefinition

getDataPage

public IDataPage getDataPage(IDataRow pRootRow,
                             TreePath pTreePath)
                      throws ModelException
Gets the IDataPage for the given TreePath and root row.

Specified by:
getDataPage in interface IDataBook
Parameters:
pRootRow - the root row.
pTreePath - the TreePath.
Returns:
gets the tree root reference.
Throws:
ModelException - if the pRootRow or pTreePath don't contains the master columns from the master ReferenceDefinition

getDataPageWithRootRow

public IDataPage getDataPageWithRootRow(IDataRow pRootDataRow)
                                 throws ModelException
Returns the corresponding IDataPage to specified root row from the root DataBook. If it doesn't exists, it will be created and returned.

Specified by:
getDataPageWithRootRow in interface IDataBook
Parameters:
pRootDataRow - the root IDataRow of the root DataBook.
Returns:
the corresponding IDataPage to specified master row from the master DataBook.
Throws:
ModelException - if the pRootRow don't contains the master columns from the master ReferenceDefinition

getRootReference

public ReferenceDefinition getRootReference()
Gets the tree root reference.

Specified by:
getRootReference in interface IDataBook
Returns:
gets the tree root reference.

setRootReference

public void setRootReference(ReferenceDefinition pTreeRootReference)
                      throws ModelException
Sets the tree root reference.

Specified by:
setRootReference in interface IDataBook
Parameters:
pTreeRootReference - the tree root reference.
Throws:
ModelException - if the IDataBook is open

getTreePath

public TreePath getTreePath()
Gets the tree current tree path.

Specified by:
getTreePath in interface IDataBook
Returns:
gets the tree root refernce.

setTreePath

public void setTreePath(TreePath pTreePath)
                 throws ModelException
Sets the tree current tree path.

Specified by:
setTreePath in interface IDataBook
Parameters:
pTreePath - the tree root reference.
Throws:
ModelException - if the IDataBook is open

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.

Returns:
true, the page is dropped, and therefore refetched, if needed.

notifyMasterChanged

public void notifyMasterChanged()
Has to be called from the master, if the master changed, to notify all detail IDataBooks.

Specified by:
notifyMasterChanged in interface IDataBook

removeDataPage

public void removeDataPage(IDataRow pMasterDataRow,
                           TreePath pTreePath)
                    throws ModelException
Removes the DataPage to the specified master DataRow or TreePath. e.g. used to delete all DataPages to the master.

Specified by:
removeDataPage in interface IDataBook
Parameters:
pMasterDataRow - the MasterDataRow to use.
pTreePath - the TreePath to use.
Throws:
ModelException - if the remove of the DataPage didn't worked out.

getSelectionMode

public IDataBook.SelectionMode getSelectionMode()
Returns the selection mode for this IDataBook.

Specified by:
getSelectionMode in interface IDataBook
Returns:
the selection mode for this IDataBook.

setSelectionMode

public void setSelectionMode(IDataBook.SelectionMode pSelectionMode)
Sets the one of the following selection mode for this IDataBook.
DESELECTED means, that after reload or change of the master row, that no row (-1) will be selected.
FIRST_ROW means, that after reload or change of the master row, that the first row (0) will be selected.
CURRENT_ROW means, that after reload or change of the master row, that the current row (last selected row)
or if not possible the first row (0) will be selected.

Specified by:
setSelectionMode in interface IDataBook
Parameters:
pSelectionMode - the selection mode for this IDataBook.

isInsertAllowed

public boolean isInsertAllowed()
Returns true if insert is allowed on this IDataBook. Its the case if isInsertEnabled()==true and a insert is possible.

Specified by:
isInsertAllowed in interface IDataBook
Returns:
true if insert is allowed on this IDataBook.

isInsertEnabled

public boolean isInsertEnabled()
Returns true if insert is enabled on this IDataBook.

Specified by:
isInsertEnabled in interface IDataBook
Returns:
true if insert is enabled on this IDataBook.

setInsertEnabled

public void setInsertEnabled(boolean pInsertEnabled)
Sets whether insert is enabled on this IDataBook.

Specified by:
setInsertEnabled in interface IDataBook
Parameters:
pInsertEnabled - true if insert is allowed on this IDataBook.

isUpdateAllowed

public boolean isUpdateAllowed()
                        throws ModelException
Returns true if update is allowed on this IDataBook. Its the case if isUpdateEnabled()==true and a update is possible. (e.g. getSelectedRow() != -1)

Specified by:
isUpdateAllowed in interface IDataBook
Returns:
true if update is allowed on this IDataBook.
Throws:
ModelException - if update is not possible because row access failed

isUpdateEnabled

public boolean isUpdateEnabled()
                        throws ModelException
Returns true if update is enabled on this IDataBook.

Specified by:
isUpdateEnabled in interface IDataBook
Returns:
true if update is enabled on this IDataBook.
Throws:
ModelException - if update is not possible because row access failed

setUpdateEnabled

public void setUpdateEnabled(boolean pUpdateEnabled)
Sets whether update is enabled on this IDataBook.

Specified by:
setUpdateEnabled in interface IDataBook
Parameters:
pUpdateEnabled - true if update is enabled on this IDataBook.

isLockAndRefetchEnabled

public boolean isLockAndRefetchEnabled()
Returns true if lock and refetch is enabled.

Returns:
true if lock and refetch is enabled.

setLockAndRefetchEnabled

public void setLockAndRefetchEnabled(boolean pLockAndRefetchEnabled)
Sets whether if lock and refetch is enabled.

Parameters:
pLockAndRefetchEnabled - true if lock and refetch is enabled.

isDeleteAllowed

public boolean isDeleteAllowed()
                        throws ModelException
Returns true if delete is allowed on this IDataBook. Its the case if isDeleteEnabled()==true and a delete is possible. (e.g. getSelectedRow() != -1)

Specified by:
isDeleteAllowed in interface IDataBook
Returns:
true if delete is allowed on this IDataBook.
Throws:
ModelException - if delete is not possible because row access failed

isDeleteEnabled

public boolean isDeleteEnabled()
                        throws ModelException
Returns true if delete is enabled on this IDataBook.

Specified by:
isDeleteEnabled in interface IDataBook
Returns:
true if delete is enabled on this IDataBook.
Throws:
ModelException - if delete is not possible because row access failed

setDeleteEnabled

public void setDeleteEnabled(boolean pDeleteEnabled)
Sets whether delete is enabled on this IDataBook.

Specified by:
setDeleteEnabled in interface IDataBook
Parameters:
pDeleteEnabled - true if delete is enabled on this IDataBook.

isReadonly

public boolean isReadonly()
Returns true if this IDataBook is read only.

Specified by:
isReadonly in interface IDataBook
Returns:
true if this IDataBook is read only.

setReadOnly

public void setReadOnly(boolean pReadOnly)
                 throws ModelException
Sets whether this IDataBook is read only.

Specified by:
setReadOnly in interface IDataBook
Parameters:
pReadOnly - true if this IDataBook is read only.
Throws:
ModelException - if the DataBook cannot be set read only.

getReadAhead

public int getReadAhead()
Returns the count of rows which are read ahead from the IDBAccess.

Returns:
the count of rows which are read ahead from the IDBAccess.

setReadAhead

public void setReadAhead(int pReadAheadRowCount)
Sets the count of rows which are read ahead from the IDBAccess.

Parameters:
pReadAheadRowCount - the row count to read ahead from the IDBAccess

isOpen

public boolean isOpen()
Returns true if the IDataBook is opened.

Specified by:
isOpen in interface IDataBook
Returns:
true if the IDataBook is opened.

open

public void open()
          throws ModelException
Opens the IDataBook. AbstractStorage oriented implementations should open the storage (DB, XML, File) and load the Meta data/defaulting the RowDefinition.

Specified by:
open in interface IDataBook
Throws:
ModelException - if the IDataBook couldn't be opened, because of empty storage unit name, empty IDataSource, missing RowDefinition or failed DataPage creation

close

public void close()
Closes the IDataBook. AbstractStorage oriented implementations should close the storage (DB, XML, file).

Specified by:
close in interface IDataBook

getRowCount

public int getRowCount()
                throws ModelException
Returns the size.

Specified by:
getRowCount in interface IDataPage
Returns:
the size.
Throws:
ModelException - if a exception occurs during synchronize.

getSelectedRow

public int getSelectedRow()
                   throws ModelException
Returns the selected row index in the IDataBook.
This should be used from the GUI controls to show which one is selected.

Specified by:
getSelectedRow in interface IDataBook
Returns:
the selected row index in the IDataBook or -1 if no row is selected.
Throws:
ModelException - if a exception occurs during synchronize.

setSelectedRow

public void setSelectedRow(int pDataRowIndex)
                    throws ModelException
Sets the selected row index in the IDataBook.
If the row is not in memory, it is loaded from the storage.

The write back isolation level needs to be considered. This means if the level is WriteBackIsolationLevel.DATA_ROW, the dataSource.storeAllDataBooks() method needs to be called.
Implementations need to handle master-detail IDataBook behavior.

Events:
Before the selected row is changed, the IControl.saveEditing() event is called.
Before the selected row is changed, the IDataBookListener.BEFORE_ROW_SELECTED event is raised.
After the selected row is changed, the IDataBookListener.AFTER_ROW_SELECTED event is raised.
After the selected row is changed, all registered IControls get called the notifyRepaint() method.

Specified by:
setSelectedRow in interface IDataBook
Parameters:
pDataRowIndex - the selected row index in the IDataBook.
Throws:
ModelException - if the row with the iDataRowIndex couldn't get from the storage or if the IDataBook isn't open or the master IDataBook has no selected row.

getSelectedColumn

public String getSelectedColumn()
                         throws ModelException
Returns the selected column in the IDataBook.
This should be used from the GUI controls to show which one is selected.

Specified by:
getSelectedColumn in interface IDataBook
Returns:
the selected column in the IDataBook.
Throws:
ModelException - if a exception occurs during synchronize.

setSelectedColumn

public void setSelectedColumn(String pColumnName)
                       throws ModelException
Sets the selected column in the IDataBook.
Events:
Before the selected column is changed, the IDataBookListener.BEFORE_COLUMN_SELECTED event is raised.
After the selected row is changed, the IDataBookListener.AFTER_COLUMN_SELECTED event is raised.

Specified by:
setSelectedColumn in interface IDataBook
Parameters:
pColumnName - the selected column in the IDataBook.
Throws:
ModelException - if the column does not exist. or if the IDataBook isn't open or the master IDataBook has no selected row.

isDeleteCascade

public boolean isDeleteCascade()
Returns true if all rows of this detail table should be deleted, when the master row is deleted.

Specified by:
isDeleteCascade in interface IDataBook
Returns:
true if all rows of this detail table should be deleted, when the master row is deleted.

setDeleteCascade

public void setDeleteCascade(boolean pDeleteCascade)
Sets if all rows of this detail table should be deleted, when the master row is deleted.

Specified by:
setDeleteCascade in interface IDataBook
Parameters:
pDeleteCascade - the value true means, delete the rows.

insert

public int insert(boolean pBeforeRow)
           throws ModelException
It inserts a new IDataRow. If bBeforeRow is true, it will be inserted before the selected IDataRow, otherwise after that.

Events:
It calls on all registered IControls, the saveEditing() method to store data first from the ui to the IDataBook.
Before the insert of the new row, the IDataBookListener.BEFORE_INSERTING event is raised.
Check the write back isolation level and consider to call saveAllDataBooks(). After the insert of the new row, the IDataBookListener.AFTER_INSERTING event is raised.
After the selected row is changed, the IDataBookListener.AFTER_ROW_SELECTED event is raised.
After the selected row is changed, all registered IControls get called the notifyRepaint() method.
After the selected row is changed, all registered IControls of detail DataBooks get called the notifyRepaint() method.

Specified by:
insert in interface IDataBook
Parameters:
pBeforeRow - specifies if the IDataRow is inserted before or after the selected IDataRow
Returns:
the index where the new IDataRow is placed
Throws:
ModelException - if the IDataRow can not be inserted or the ReferenceDefinition is wrong or if not all changes could be written to the storage (maybe implicit dataSource.storeAllDataBooks(), because of WritebackIsolationLevel insert change the selected row implicit!)

update

public void update()
            throws ModelException
It sets the selected row as UPDATING. That method will be implicit called from from the GUI controls, when the editing is started or when setValue(e)() is called. DB implementations should Lock and refetch the selected row.

Events:
Before the update() is done, the IDataBookListener.BEFORE_UPDATING event is raised.
After the update() is done, the IDataBookListener.AFTER_UPDATING event is raised.

Specified by:
update in interface IDataBook
Throws:
ModelException - if problem with the locking in the storage happens.

delete

public void delete()
            throws ModelException
It deletes the selected DataRow.

Events:
Before the delete of the selected row is done, the IDataBookListener.BEFORE_DELETING event is raised.
Events, if Detail DataBooks with rows exist:
Before the delete each row is done, the IDataBookListener.BEFORE_DELETING event is raised.
After the delete each row is done, the IDataBookListener.AFTER_DELETING event is raised.
After the deletes all registered IControls get called the notifyRepaint() method.
After the delete of the selected row is done, the IDataBookListener.AFTER_DELETING event is raised.
After the delete of the selected row is done, all registered IControls get called the notifyRepaint() method.

If the selected row was before the delete INSERTING, then the IDataBookListener.AFTER_ROW_SELECTED event is raised, because the selected row content wise changed.

Specified by:
delete in interface IDataBook
Throws:
ModelException - if not all changes could be written to the storage (maybe implicit save(), because of WritebackIsolationLevel)

deleteAllDataRows

public void deleteAllDataRows()
                       throws ModelException
It deletes all DataRows.

Before the delete on a row is done, the row will be selected and the usual XX_ROW_SELECTED events will be raised. For each delete will be the same events raised, like at the delete() method.

Specified by:
deleteAllDataRows in interface IDataBook
Throws:
ModelException - if not all changes could be written to the storage (maybe implicit save(), because of WritebackIsolationLevel)
See Also:
IDataBook.setSelectedRow(int), IDataBook.delete()

notifyDetailChanged

public void notifyDetailChanged()
It sets the selected row in master, that one or more details rows (from DetailDataBooks) are changed.

Specified by:
notifyDetailChanged in interface IDataBook

getDataRow

public IChangeableDataRow getDataRow(int pDataRowIndex)
                              throws ModelException
Returns a copy of the IDataRow of the specified index.
If the requested row not in memory it will be fetched from the storage. If the row is also not existing on the storage, it returns null.

Specified by:
getDataRow in interface IDataPage
Parameters:
pDataRowIndex - the index of the requested row
Returns:
a copy of the IDataRow of the specified index.
Throws:
ModelException - if a exception occur during the fetch.

getOriginalRow

public IDataRow getOriginalRow()
                        throws ModelException
Returns the original row, before the first change is made.

Specified by:
getOriginalRow in interface IChangeableDataRow
Overrides:
getOriginalRow in class ChangeableDataRow
Returns:
the original row, before the first change is made.
Throws:
ModelException - if original row couldn't determined

isWritableColumnChanged

public boolean isWritableColumnChanged()
                                throws ModelException
Returns true if one isWritableColumnChanged() column is changed.

Specified by:
isWritableColumnChanged in interface IChangeableDataRow
Overrides:
isWritableColumnChanged in class ChangeableDataRow
Returns:
true if one isWritableColumnChanged() column is changed.
Throws:
ModelException - if writable column changed couldn't determined

isDeleting

public boolean isDeleting()
                   throws ModelException
Returns if this row is deleted.

Specified by:
isDeleting in interface IChangeableDataRow
Overrides:
isDeleting in class ChangeableDataRow
Returns:
if this row is deleted.
Throws:
ModelException - if is deleting couldn't determined

isUpdating

public boolean isUpdating()
                   throws ModelException
Returns if this row is changed.

Specified by:
isUpdating in interface IChangeableDataRow
Overrides:
isUpdating in class ChangeableDataRow
Returns:
if this row is changed.
Throws:
ModelException - if is updating couldn't determined

isInserting

public boolean isInserting()
                    throws ModelException
Returns if this row is new.

Specified by:
isInserting in interface IChangeableDataRow
Overrides:
isInserting in class ChangeableDataRow
Returns:
if this row is new.
Throws:
ModelException - if is inserting couldn't determined

isDetailChanged

public boolean isDetailChanged()
                        throws ModelException
Returns true if under this row in the detail DataBook one or more changed (isInserting/Updating/Deleting() == true) detail rows existing.

Specified by:
isDetailChanged in interface IChangeableDataRow
Overrides:
isDetailChanged in class ChangeableDataRow
Returns:
true if under this row in the detail DataBook one or more changed (isInserting/Updating/Deleting() == true) detail rows existing.
Throws:
ModelException - if is detail changed couldn't determined

getUID

public Object getUID()
              throws ModelException
Returns the internal unique identifier for a IChangeableDataRow, which isInserting().

Specified by:
getUID in interface IChangeableDataRow
Overrides:
getUID in class ChangeableDataRow
Returns:
the internal unique identifier for a IChangeableDataRow, which isInserting().
Throws:
ModelException - if UID couldn't determined

getFilter

public ICondition getFilter()
Returns the filter for this IDataBook.

Specified by:
getFilter in interface IDataBook
Returns:
the filter for this IDataBook.

setFilter

public void setFilter(ICondition pFilter)
               throws ModelException
Sets the filter for this IDataBook.
A filter consist of one ore more ICondition's. It stores first all changes, and then sets the new filter.

Specified by:
setFilter in interface IDataBook
Parameters:
pFilter - the Filter with all ICondition's.
Throws:
ModelException - if the IDataBook couldn't stored.
See Also:
ICondition

getSort

public SortDefinition getSort()
Returns the sort order for this IDataBook.

Specified by:
getSort in interface IDataBook
Returns:
the sort order for this IDataBook.

setSort

public void setSort(SortDefinition pSort)
             throws ModelException
Sets the sort order for this IDataBook.
It stores first all changes, and then sets the new sort order, and get the rows from the storage or sort it in memory.

Specified by:
setSort in interface IDataBook
Parameters:
pSort - the sort order for this IDataBook
Throws:
ModelException - if the IDataBook couldn't stored.
See Also:
SortDefinition

reload

public void reload()
            throws ModelException
It refreshs all IDataRow's in the IDataBook, like the was before the changes, get the data again from the storage It selects the same row (over primary key) if the SelectionMode == CURRENT_ROW in the IDataBook. It selects the first row if the SelectionMode == FIRST_ROW in the IDataBook.

Events:
It calls before the refresh, on all registered IComponents the cancelEditing() method, to cancel the editing mode of the GUI control.
Before the refresh, the IDataBookListener.BEFORE_RELOAD event is raised.
After the refresh, the IDataBookListener.AFTER_RELOAD event is raised.
After the refresh, all registered IControls get called the notifyRepaint() method.

Specified by:
reload in interface IDataBook
Throws:
ModelException - if an DataSourceException happens during get the requested row.

reload

public void reload(IDataBook.SelectionMode pSelectionMode)
            throws ModelException
It refreshs all IDataRow's in the IDataBook, like the was before the changes, get the data again from the storage and selects the row with the specified SelectionMode. It selects the same row (PK, ID) if the specified SelectionMode == CURRENT_ROW. It selects the first row if the specified SelectionMode == FIRST_ROW.

Events:
It calls before the refresh, on all registered IComponents the cancelEditing() method, to cancel the editing mode of the GUI control.
Before the refresh, the IDataBookListener.BEFORE_RELOAD event is raised.
After the refresh, the IDataBookListener.AFTER_RELOAD event is raised.
After the refresh, all registered IControls get called the notifyRepaint() method.

Specified by:
reload in interface IDataBook
Parameters:
pSelectionMode - the Selection mode to use
Throws:
ModelException - if an DataSourceException happens during get the requested row.

reloadDataPage

public void reloadDataPage(IDataBook.SelectionMode pSelectionMode)
                    throws ModelException
Reload the current DataPage with the pSelectionMode.

Parameters:
pSelectionMode - pSelectionMode the Selection mode to use
Throws:
ModelException - if an DataSourceException happens during get the requested row.
See Also:
reload(javax.rad.model.IDataBook.SelectionMode)

restoreSelectedRow

public void restoreSelectedRow()
                        throws ModelException
It restores the selected IDataRow, like the was before the changes.

Events:
It calls before the restore on all registered IComponents the cancelEditing() method, to cancel the editing mode of the GUI control.
Before the restore, the IDataBookListener.BEFORE_RESTORE event is raised.
If the row isInserting then an IDataBookListener.AFTER_ROW_SELECTED will be raised
After the restore, the IDataBookListener.AFTER_RESTORE event is raised.
After the restore, all registered IControls get called the notifyRepaint() method.

Specified by:
restoreSelectedRow in interface IDataBook
Throws:
ModelException - if an ModelException happens during undo the changes.

restoreAllRows

public void restoreAllRows()
                    throws ModelException
It restores all IDataRow's, like the was before the changes.

Events:
It calls before the restore all, on all registered IComponents the cancelEditing() method, to cancel the editing mode of the GUI control.
It calls restore on the current selected row and then for all other changed rows. Before each restore, the setSelectedRow method with all events is called.

That means that for each changed row following Events occur:

After the restore all rows, all registered IControls get called the notifyRepaint() method.

Specified by:
restoreAllRows in interface IDataBook
Throws:
ModelException - if an ModelException happens during undo the changes.

restoreDataPage

public void restoreDataPage()
                     throws ModelException
Restores all rows in the current DataPage.

Throws:
ModelException - - if an ModelException happens during undo the changes.
See Also:
restoreAllRows()

saveSelectedRow

public void saveSelectedRow()
                     throws ModelException
It stores all changes in the selected IDataRow.

Events:
It calls before the store on all registered IComponents the saveEditing() method, to set all changes to the DataBook before the store operation.
If the selected row is INSERTING the IDataBookListener.BEFORE_INSERTED and IDataBookListener.AFTER_INSERTED event will be raised. If the selected row is UPDATING the IDataBookListener.BEFORE_UPDATED and IDataBookListener.AFTER_UPDATED event will be raised. If the selected row is DELETING the IDataBookListener.BEFORE_DELETED and IDataBookListener.AFTER_DELETED event will be raised. After the store, all registered IControls get called the notifyRepaint() method.

Specified by:
saveSelectedRow in interface IDataBook
Throws:
ModelException - if an ModelException happens during store operation.

saveDataPage

public void saveDataPage()
                  throws ModelException
Saves all rows in the current DataPage.

Specified by:
saveDataPage in interface IDataBook
Throws:
ModelException - if saveSelected() fails

saveAllRows

public void saveAllRows()
                 throws ModelException
It stores all changes in the IDataRow's to the IDataSource.

Events:
It calls before the store on all registered IComponents the saveEditing() method, to set all changes to the DataBook before the store operation.
Before the store on a row is done, the row will be selected and the usual XX_ROW_SELECTED events will be raised. For each delete will be the same events raised, like at the saveSelectedRow() method. After the store, all registered IControls get called the notifyRepaint() method.

Specified by:
saveAllRows in interface IDataBook
Throws:
ModelException - if an ModelException happens during store operation.

isOutOfSync

public boolean isOutOfSync()
Gets true, if the IDataBook is not yet initialized after a reload. This can be used by controls to optimize fetch on demand.

Specified by:
isOutOfSync in interface IDataBook
Returns:
true, if the IDataBook is not yet initialized after a reload.

isAllFetched

public boolean isAllFetched()
                     throws ModelException
Returns true if all rows are loaded.

Specified by:
isAllFetched in interface IDataPage
Returns:
true if all rows are loaded.
Throws:
ModelException - if the DataBook isn't open

fetchAll

public void fetchAll()
              throws ModelException
It fetches all IDataRow's from the storage.

Specified by:
fetchAll in interface IDataPage
Throws:
ModelException - if an DataSourceException happens during get all rows

getMasterDataRow

public IDataRow getMasterDataRow()
                          throws ModelException
Returns the corresponding master row to this IDataPage in the master DataBook.

Specified by:
getMasterDataRow in interface IDataPage
Returns:
the corresponding master row to this IDataPage in the master DataBook.
Throws:
ModelException - if a exception occurs during synchronize.

addDetailDataBook

public void addDetailDataBook(IDataBook pDetailDataBook)
Registered a new detail IDataBook to this master IDataBook.

Specified by:
addDetailDataBook in interface IDataBook
Parameters:
pDetailDataBook - the detail DataBook to use

removeDetailDataBook

public void removeDetailDataBook(IDataBook pDetailDataBook)
Unregister a detail IDataBook from this master IDataBook.

Specified by:
removeDetailDataBook in interface IDataBook
Parameters:
pDetailDataBook - the detail IDataBook to use

getDetailDataBooks

public IDataBook[] getDetailDataBooks()
Returns all detail IDataBooks to the master IDataBook.

Specified by:
getDetailDataBooks in interface IDataBook
Returns:
all detail IDataBooks to the master IDataBook.

getOnlyIUDChangedDataRows

public int[] getOnlyIUDChangedDataRows()
                                throws ModelException
Returns only all Changed DataRows with the states isInserting(), isUpdating(), isDeleting(). Rows with isDetailChanged() will not be returned.

Returns:
only all Changed DataRows with the states isInserting(), isUpdating(), isDeleting().
Throws:
ModelException - if the changed rows couldn't determined.

getChangedDataRows

public int[] getChangedDataRows()
                         throws ModelException
Returns an int array with all changed rows.

Specified by:
getChangedDataRows in interface IDataPage
Returns:
an int array with all changed rows.
Throws:
ModelException - if a exception occurs during synchronize.

getDataPage

public IDataPage getDataPage(IDataRow pMasterDataRow)
                      throws ModelException
Returns the corresponding IDataPage to specified master row from the master DataBook. If it doesn't exists, it will be created and returned.

Specified by:
getDataPage in interface IDataBook
Parameters:
pMasterDataRow - the master IDataRow of the master DataBook.
Returns:
the corresponding IDataPage to specified master row from the master DataBook.
Throws:
ModelException - if the pMasterRow don't contains the master columns from the master ReferenceDefinition

hasDataPage

public boolean hasDataPage(IDataRow pMasterDataRow)
                    throws ModelException
Returns true if an IDataPage to specified master row from the master DataBook exists.

Specified by:
hasDataPage in interface IDataBook
Parameters:
pMasterDataRow - the master IDataRow of the master DataBook.
Returns:
true if an IDataPage to specified master row from the master DataBook exists.
Throws:
ModelException - if the pMasterRow don't contains the master columns from the master ReferenceDefinition

hasDataPage

public boolean hasDataPage(IDataRow pRootDataRow,
                           TreePath pTreePath)
                    throws ModelException
Returns true if an IDataPage to specified root row and TreePath from the master DataBook exists.

Parameters:
pRootDataRow - the root IDataRow of the DataBook to check.
pTreePath - the TreePath to use.
Returns:
true if an IDataPage to specified root row and TreePath from the master DataBook exists.
Throws:
ModelException - if the pRootDataRow don't contains the root columns from the DataBook.

eventBeforeRowSelected

public DataBookHandler eventBeforeRowSelected()
Gets the EventHandler for before row selected event.

Specified by:
eventBeforeRowSelected in interface IDataBook
Returns:
the EventHandler for before row selected event.

eventAfterRowSelected

public DataBookHandler eventAfterRowSelected()
Gets the EventHandler for after row selected event.

Specified by:
eventAfterRowSelected in interface IDataBook
Returns:
the EventHandler for after row selected event.

eventBeforeInserting

public DataBookHandler eventBeforeInserting()
Gets the EventHandler for before inserting event.

Specified by:
eventBeforeInserting in interface IDataBook
Returns:
the EventHandler for before inserting event.

eventAfterInserting

public DataBookHandler eventAfterInserting()
Gets the EventHandler for after inserting event.

Specified by:
eventAfterInserting in interface IDataBook
Returns:
the EventHandler for after inserting event.

eventBeforeInserted

public DataBookHandler eventBeforeInserted()
Gets the EventHandler for before inserted event.

Specified by:
eventBeforeInserted in interface IDataBook
Returns:
the EventHandler for before inserted event.

eventAfterInserted

public DataBookHandler eventAfterInserted()
Gets the EventHandler for after inserted event.

Specified by:
eventAfterInserted in interface IDataBook
Returns:
the EventHandler for after inserted event.

eventBeforeUpdating

public DataBookHandler eventBeforeUpdating()
Gets the EventHandler for before updating event.

Specified by:
eventBeforeUpdating in interface IDataBook
Returns:
the EventHandler for before updating event.

eventAfterUpdating

public DataBookHandler eventAfterUpdating()
Gets the EventHandler for after updating event.

Specified by:
eventAfterUpdating in interface IDataBook
Returns:
the EventHandler for after updating event.

eventBeforeUpdated

public DataBookHandler eventBeforeUpdated()
Gets the EventHandler for before updated event.

Specified by:
eventBeforeUpdated in interface IDataBook
Returns:
the EventHandler for before updated event.

eventAfterUpdated

public DataBookHandler eventAfterUpdated()
Gets the EventHandler for after updated event.

Specified by:
eventAfterUpdated in interface IDataBook
Returns:
the EventHandler for after updated event.

eventBeforeDeleting

public DataBookHandler eventBeforeDeleting()
Gets the EventHandler for before deleting event.

Specified by:
eventBeforeDeleting in interface IDataBook
Returns:
the EventHandler for before deleting event.

eventAfterDeleting

public DataBookHandler eventAfterDeleting()
Gets the EventHandler for after deleting event.

Specified by:
eventAfterDeleting in interface IDataBook
Returns:
the EventHandler for after deleting event.

eventBeforeDeleted

public DataBookHandler eventBeforeDeleted()
Gets the EventHandler for before deleted event.

Specified by:
eventBeforeDeleted in interface IDataBook
Returns:
the EventHandler for before deleted event.

eventAfterDeleted

public DataBookHandler eventAfterDeleted()
Gets the EventHandler for after deleted event.

Specified by:
eventAfterDeleted in interface IDataBook
Returns:
the EventHandler for after deleted event.

eventBeforeRestore

public DataBookHandler eventBeforeRestore()
Gets the EventHandler for before restore event.

Specified by:
eventBeforeRestore in interface IDataBook
Returns:
the EventHandler for before restore event.

eventAfterRestore

public DataBookHandler eventAfterRestore()
Gets the EventHandler for after restore event.

Specified by:
eventAfterRestore in interface IDataBook
Returns:
the EventHandler for after restore event.

eventBeforeReload

public DataBookHandler eventBeforeReload()
Gets the EventHandler for before reload event.

Specified by:
eventBeforeReload in interface IDataBook
Returns:
the EventHandler for before reload event.

eventAfterReload

public DataBookHandler eventAfterReload()
Gets the EventHandler for after reload event.

Specified by:
eventAfterReload in interface IDataBook
Returns:
the EventHandler for after reload event.

eventBeforeColumnSelected

public DataBookHandler eventBeforeColumnSelected()
Gets the EventHandler for before column selected event.

Specified by:
eventBeforeColumnSelected in interface IDataBook
Returns:
the EventHandler for before column selected event.

eventAfterColumnSelected

public DataBookHandler eventAfterColumnSelected()
Gets the EventHandler for after column selected event.

Specified by:
eventAfterColumnSelected in interface IDataBook
Returns:
the EventHandler for after column selected event.

searchNext

public int searchNext(ICondition pCondition)
               throws ModelException
Searches the given condition. It returns -1 if the condition can not be found.

Specified by:
searchNext in interface IDataPage
Parameters:
pCondition - the condition.
Returns:
the row number or -1 if the condition can not be found.
Throws:
ModelException - if a ModelException occurs.

searchNext

public int searchNext(ICondition pCondition,
                      int pRowNum)
               throws ModelException
Searches the given condition starting at the given position. It returns -1 if the condition can not be found.

Specified by:
searchNext in interface IDataPage
Parameters:
pCondition - the condition.
pRowNum - the starting row.
Returns:
the row number or -1 if the condition can not be found.
Throws:
ModelException - if a ModelException occurs.

searchPrevious

public int searchPrevious(ICondition pCondition)
                   throws ModelException
Searches the given condition. It returns -1 if the condition can not be found.

Specified by:
searchPrevious in interface IDataPage
Parameters:
pCondition - the condition.
Returns:
the row number or -1 if the condition can not be found.
Throws:
ModelException - if a ModelException occurs.

searchPrevious

public int searchPrevious(ICondition pCondition,
                          int pRowNum)
                   throws ModelException
Searches the given condition starting at the given position. It returns -1 if the condition can not be found.

Specified by:
searchPrevious in interface IDataPage
Parameters:
pCondition - the condition.
pRowNum - the starting row.
Returns:
the row number or -1 if the condition can not be found.
Throws:
ModelException - if a ModelException occurs.

getRowIndex

public int getRowIndex()
Returns the row index of the IDataRows in the IDataPage. That returns != -1 only if the IDataRow is from a IDataPage

Specified by:
getRowIndex in interface IChangeableDataRow
Overrides:
getRowIndex in class ChangeableDataRow
Returns:
the row index of the IDataRows in the IDataPage.

getDataPage

public IDataPage getDataPage()
Returns the correspondingIDataPage of the IDataRow. That returns != null only if the IDataRow is from a IDataBook

Specified by:
getDataPage in interface IChangeableDataRow
Overrides:
getDataPage in class ChangeableDataRow
Returns:
the correspondingIDataPage of the IDataRow.

finalize

protected void finalize()
                 throws Throwable

Overrides:
finalize in class Object
Throws:
Throwable

getValue

public Object getValue(String pColumnName)
                throws ModelException
Returns the value of the named column.

Specified by:
getValue in interface IDataRow
Overrides:
getValue in class DataRow
Parameters:
pColumnName - the name of the column
Returns:
the value of the named column.
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow

setValue

public void setValue(String pColumnName,
                     Object pValue)
              throws ModelException
Sets the value of the named column in this IDataRow.

Events:
After the value is changed, the IDataRowListener.changed(this, new String[] { pColumnName }, drOldRow) method is called.
After the value is changed, all registered IControls get called the notifyRepaint() method.

Specified by:
setValue in interface IDataRow
Overrides:
setValue in class DataRow
Parameters:
pColumnName - the column name
pValue - the new value for the column in this IDataRow
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow or the pValue is not convertible/too large to/for the IDataType of the column

getValues

public Object[] getValues(String[] pColumnNames)
                   throws ModelException
Returns a Object[] of values from the specified columns in this IDataRow.

Specified by:
getValues in interface IDataRow
Overrides:
getValues in class DataRow
Parameters:
pColumnNames - a String[] of column names
Returns:
a Object[] of values from the specified columns in this IDataRow
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow

setValues

public void setValues(String[] pColumnNames,
                      Object[] pValues)
               throws ModelException
Sets the column's values from the pValues Object[] to the this IDataRow.
It finds the corresponding target column over the column name in the pColumnNames String[].

Events:
After the value is changed, the IDataRowListener.changed(this, pColumnNames, drOldRow) method is called.
After the value is changed, all registered IControls get called the notifyRepaint() method.

Specified by:
setValues in interface IDataRow
Overrides:
setValues in class DataRow
Parameters:
pColumnNames - a String[] of column names
pValues - a Object[] of values to set in the corresponding columns of the IDataRow
Throws:
ModelException - if the ColumnDefinition name is not in this IDataRow or the pValue is not convertible/too large to/for the DataType of the column

toString

public String toString()

Overrides:
toString in class ChangeableDataRow

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.

Parameters:
pMasterDataRow - the master IDataRow for this IDataPage.
Returns:
the new MemDataPage to use.

isMemSort

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

Returns:
true if the sort is handled in memory.

setMemSort

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

Parameters:
pMemSort - true if the sort is handled in memory.

isMemFilter

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

Returns:
true if the filter is handled in memory.

setMemFilter

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

Parameters:
pMemFilter - true if the filter is handled in memory.

isWritebackEnabled

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

Returns:
true to write back all changes, false otherwise.

setWritebackEnabled

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

Parameters:
pWritebackEnabled - determines if changes should be written to the store.

getEstimatedRowCount

public int getEstimatedRowCount()
                         throws ModelException
Returns the row count in IDBAccess for this RemoteDataBook.

Returns:
the row count of the DataBook.
Throws:
ModelException - the the detail DataBook couldn't synchronized with the master DataBook

executeInsert

protected void executeInsert()
                      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.

Throws:
ModelException - if an ModelException occur during insert.

executeUpdate

protected void executeUpdate()
                      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.

Throws:
ModelException - if an ModelException occur during update.

executeDelete

protected void executeDelete()
                      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.

Throws:
ModelException - if an ModelException occur during delete.

executeLockAndRefetch

protected void executeLockAndRefetch()
                              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

Throws:
ModelException - if an ModelException occur during insert.

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.

Throws:
ModelException - if an ModelExcpetion happen during refresh

clear

protected void clear()
It clears the AbstractStorage of the MemDataBook. Derived classed maybe need it.


setSelectedRowInternal

protected void setSelectedRowInternal(int pDataRowIndex)
                               throws ModelException
Sets the selected row with throwing any changed events.

Parameters:
pDataRowIndex - the new row index to use.
Throws:
ModelException - if new row couldn't determined or selected.

setValuesInternal

protected void setValuesInternal(String[] pColumnNames,
                                 Object[] pValues)
                          throws ModelException
It sets the values without throwing an event.

Parameters:
pColumnNames - the column names to use.
pValues - the values to use
Throws:
ModelException - if the value couldn't set into the memory.

store

protected void store()
              throws ModelException
It stores the changes in memory as stored. That means the changes will be made and the change state of the current DataRow (the DataBook it self) will be removed.

Overrides:
store in class ChangeableDataRow
Throws:
ModelException - if a ModelException occurs.

clearFilterSortInMemDataPages

protected void clearFilterSortInMemDataPages()
                                      throws ModelException
It clears all mem filter sorts in the MemDataPages.

Throws:
ModelException - if a ModelException occurs.

setReadOnlyWithoutSave

public void setReadOnlyWithoutSave(boolean pReadOnly)
Sets the databook readonly but does not automatically save.

Parameters:
pReadOnly - true to set the databook readonly, false otherwise


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.