com.im.df.api 5.9

com.im.df.api.dml
Interface DFResultSet.VertexState

Enclosing interface:
DFResultSet

public static interface DFResultSet.VertexState

This object represent state of data of one DFDataTree.Vertex. Each VertexState has these properties: all ids, sort directive, row selection.


Field Summary
static String PROP_IDS
           
static String PROP_SELECTION
           
static String PROP_SORT
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Register PropertyChangeListener to this VertexState to be notified about ids, sort and selection changes.
 Map<Comparable<?>,Map<String,Object>> getData(List<? extends Comparable<?>> ids, DFEnvironmentRO env)
          Fetch data for these IDs.
 Comparable<?> getIdAt(int index)
          Get id (primary key) at the specific position.
 List<? extends Comparable<?>> getIds()
          Get list of all IDs (primary keys values) of all rows in this VertexState.
 List<? extends Comparable<?>> getIdsForParentId(Comparable<?> parentRowId, DFEnvironmentRO env)
          Get list of all IDs (primary key values) of rows in this VertexState for specific parent row ID.
 DFResultSet getResultSet()
          Get the DFResultSet this VertexState belongs to.
 List<? extends Comparable<?>> getSelectedRowsIds()
          Get the list of row IDs for selected rows.
 SelectionDescription getSelection()
          Get the current selection descriptor.
 int getSize()
          Get number of rows at this level of result set at this moment.
 SortDirective getSort()
          Get the current sort directive.
 DFDataTree.Vertex getVertex()
          Get the vertex (static DDL object) for this VertexState (dynamic data DML object).
 Map<Comparable<?>,Map<String,Object>> getWrappedData(List<? extends Comparable<?>> ids, DFEnvironmentRO env)
           
 int indexOfId(Comparable<?> id)
          Return the index of the given id, if it's part of current vertex state.
 void insertId(Comparable<?> id, boolean selectIt, DFEnvironmentRW env)
          Insert a new row (with the specified id = primary key) to this VertexState.
 void removeIds(List<? extends Comparable<?>> idsToRemove, DFEnvironmentRW env)
          Remove the rows (with the specified ids = primary key) from this VertexState.
 void removePropertyChangeListener(PropertyChangeListener l)
          Unregister PropertyChangeListener from this VertexState.
 void setSelection(SelectionDescription selection, DFEnvironmentRW env)
          Set selection on this level of result set.
 void setSort(SortDirective sort, DFEnvironmentRW env)
          Set sort on this level of result set.
 

Field Detail

PROP_IDS

static final String PROP_IDS
See Also:
Constant Field Values

PROP_SORT

static final String PROP_SORT
See Also:
Constant Field Values

PROP_SELECTION

static final String PROP_SELECTION
See Also:
Constant Field Values
Method Detail

getResultSet

DFResultSet getResultSet()
Get the DFResultSet this VertexState belongs to.

Returns:
The DFResultSet

getVertex

DFDataTree.Vertex getVertex()
Get the vertex (static DDL object) for this VertexState (dynamic data DML object).

Returns:
The vertex for this VertexState

getSize

int getSize()
Get number of rows at this level of result set at this moment. This changes when master entity's (upper vertex's entity) vertex state changes selection for example.

Returns:
The number of rows

getIds

List<? extends Comparable<?>> getIds()
Get list of all IDs (primary keys values) of all rows in this VertexState. Note that it is ensured that resulting list never contains duplicates. I.e. it rather corresponds to LinkedHashSet.

Returns:
The unique list of all IDs

getIdsForParentId

List<? extends Comparable<?>> getIdsForParentId(Comparable<?> parentRowId,
                                                DFEnvironmentRO env)
Get list of all IDs (primary key values) of rows in this VertexState for specific parent row ID. This method allows you to read relational data from a detail table without changing selection in master.

Parameters:
parentRowId - Parent row ID (primary key value)
env - The environment
Returns:
List of IDs for given parent's (master) row id.
Throws:
IllegalStateException - when it's called for the root VertexState (for which it has no meaning). It only works for detail VertexStates.
IllegalArgumentException - when parentRowId is of wrong type or is null

getSelectedRowsIds

List<? extends Comparable<?>> getSelectedRowsIds()
Get the list of row IDs for selected rows. Note that it is ensured that resulting list never contains duplicates. I.e. it rather corresponds to LinkedHashSet.

Returns:
The unique list of primary keys for currently selected rows. Never returns null.

getIdAt

Comparable<?> getIdAt(int index)
Get id (primary key) at the specific position.

Parameters:
index -
Returns:
The id at index

indexOfId

int indexOfId(Comparable<?> id)
Return the index of the given id, if it's part of current vertex state. If it's not there (or id is not in DB), then return -1.

Parameters:
id - The row id which you are looking for
Returns:
The index or -1

insertId

void insertId(Comparable<?> id,
              boolean selectIt,
              DFEnvironmentRW env)
Insert a new row (with the specified id = primary key) to this VertexState. This method is not supposed to be called for adding new rows to data source (DFEntityDataProvider should be used instead), but it should just add existing id. The new id (row) is added and will be in vertex state just till whole ids list is set again. For root vertex it means when applyList or applyQuery is called, for any child vertex it means when parent vertex changes the selection.

Parameters:
id - The primary key of the row to be added to VertexState
selectIt - If true, the newly added row will be selected (PROP_SELECTION)
env - The environment

removeIds

void removeIds(List<? extends Comparable<?>> idsToRemove,
               DFEnvironmentRW env)
Remove the rows (with the specified ids = primary key) from this VertexState. This method doesn't delete rows from database, but just delete them from result set. To delete rows from database use (DFEntityDataProvider.deleteIds(List, DFEnvironmentRW) method instead.

This change is not permanent. If you remove row using this method from root vertex then it's added again when query is executed again. For detail vertex (detail entity) row is added again only if you change selection in parent vertex (e.g. you go one row down and back up in master table).

Parameters:
idsToRemove - The primary key values of the rows to be removed from VertexState
env - The environment

setSort

void setSort(SortDirective sort,
             DFEnvironmentRW env)
Set sort on this level of result set.

Parameters:
sort - The sort directive
env - The environment

getSort

SortDirective getSort()
Get the current sort directive.

Returns:
The current sort directive

setSelection

void setSelection(SelectionDescription selection,
                  DFEnvironmentRW env)
Set selection on this level of result set. Selection change has impact on detail tables related to this vertex - it means detail VertexStates (from this VertexStates point of view) will update their list of ids and typically also selection.

Parameters:
selection - The selection descriptor
env - The environment

getSelection

SelectionDescription getSelection()
Get the current selection descriptor. Note that SelectionDescription uses indexes so should be used carefully. Selection[min=0, max=1] change the meaning when DFResultSet rows are updated, e.g. after a query is executed.

Returns:
The current selection descriptor

getData

Map<Comparable<?>,Map<String,Object>> getData(List<? extends Comparable<?>> ids,
                                              DFEnvironmentRO env)
Fetch data for these IDs. Data are cached in VertexState (opposite to DFEntityDataProvider.getData(..) which calls directly to DB.

Parameters:
ids - The IDs
env - The environment
Returns:
A map of the data, keyed by the ID. The values are an Map[DFField's Id, Object] containing data for each field.

getWrappedData

Map<Comparable<?>,Map<String,Object>> getWrappedData(List<? extends Comparable<?>> ids,
                                                     DFEnvironmentRO env)

addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener l)
Register PropertyChangeListener to this VertexState to be notified about ids, sort and selection changes.

Parameters:
l - The PropertyChangeListener

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener l)
Unregister PropertyChangeListener from this VertexState.

Parameters:
l - The PropertyChangeListener

com.im.df.api 5.9