com.im.df.api 5.9

com.im.df.api.dml
Interface DFResultSet


public interface DFResultSet

This object is used for managing data for a particular DFDataTree.

The ResultSet encapsulates a particular snapshot of data for the DataTree. This can be all data, or a subset. The snapshot can be updated by applying a particular query or list of IDs, and the IDs at each position in the DataTree hierarchy can be sorted with custom sort directives.

Views (grid view, form view...) get their data from a particular ResultSet. Multiple views from the same DataTree use the same ResultSet, which means their contents will be coordinated (apply a sort in one view and data in the other view will also be re-sorted accordingly).

The DFResultSet itself does not have much functionality, but provides set of DFResultSet.VertexStates. Each VertexState then contain the data for one vertex of related DFDataTree. This typically (in database implementation) means that one VertexState represents data for one database table subset.

To obtain DFResultSet for a particular DFDataTree use DFSchemaDataProvider.getDefaultResultSet(com.im.df.api.ddl.DFDataTree, boolean, com.im.commons.progress.DFEnvironmentRO) method. This DFResultSet instance is shared. First you need to have DFSchema instance which is the root object (use DIFUtilities.findSchema(com.im.df.api.ddl.DFItem) to find schema from any DFItem). Then use DFSchema.getDataProvider().

So the final code can look like:

     DFDataTree dt = ...;
     DFschema schema = DIFUtilities.findSchema(dt);
     DFEnvironmentRO env = EnvUtils.createDefaultEnvironmentRO("Loading data", false);
     DFResultSet rs = schema.getDataProvider().getDefaultResultSet(dt, true, env);
     env.getFeedback().finish();
 


Nested Class Summary
static interface DFResultSet.VertexState
          This object represent state of data of one DFDataTree.Vertex.
 
Field Summary
static String PROP_LAST_EXECUTED_QUERY
           
static String PROP_SEARCH_DOMAIN
           
static String PROP_WORKING_QUERY
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Register property change listener to be notified about prop.
 void applyList(List<? extends Comparable<?>> ids, DFEnvironmentRW env)
          Sets ids on master level of this result set's data tree.
 void applyQuery(DFTermExpression term, DFEnvironmentRW env)
           
 void applyWorkingQuery(DFEnvironmentRW env)
          Apply the current working query to result set.
 DFDataTree getDataTree()
          Get the DFDataTree which this result set was created for.
 DFTermExpression getLastExecutedQuery()
          Return the last executed query - the query which was working when applyWorkingQuery(DFEnvironmentRW) was called last time.
 DFLockable getLockable()
          Get private lockable for modifying this result set's state.
 DFResultSet.VertexState getRootVertexState()
          Get vertex state for the root vertex.
 DFSearchDomain getSearchDomain()
          Get the current search domain.
 DFResultSet.VertexState getVertexState(DFDataTree.Vertex vertex)
          Get the state of this result set for particular vertex from the DFDataTree.
 DFTermExpression getWorkingQuery()
          Get current working query expression.
 void reload(DFEnvironmentRW env)
          Reload row ids (primary keys) and data for this DFResultSet.
 void removePropertyChangeListener(PropertyChangeListener l)
          Unregister property change listener.
 void setSearchDomain(DFSearchDomain searchDomain, DFEnvironmentRW env)
          Make a ids constraint for query (only subset of DB table given by domain is searched).
 void setWorkingQuery(DFTermExpression workingQuery, DFEnvironmentRW env)
          Set the query which will be used in next applyWorkingQuery(DFEnvironmentRW) method call.
 

Field Detail

PROP_WORKING_QUERY

static final String PROP_WORKING_QUERY
See Also:
Constant Field Values

PROP_LAST_EXECUTED_QUERY

static final String PROP_LAST_EXECUTED_QUERY
See Also:
Constant Field Values

PROP_SEARCH_DOMAIN

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

getDataTree

DFDataTree getDataTree()
Get the DFDataTree which this result set was created for.

Returns:
The data tree

setWorkingQuery

void setWorkingQuery(DFTermExpression workingQuery,
                     DFEnvironmentRW env)
Set the query which will be used in next applyWorkingQuery(DFEnvironmentRW) method call. The query is called 'working' because it is supposed different visualizations can cooperate on it's editing - for example query in form, standard query builder, etc.

Parameters:
workingQuery - The working query
env - The environment

getWorkingQuery

DFTermExpression getWorkingQuery()
Get current working query expression. Never returns null, but instead of null it returns DFTermExpression.ALL_DATA constant.

Returns:
The current working query expression

applyWorkingQuery

void applyWorkingQuery(DFEnvironmentRW env)
Apply the current working query to result set. The list of ids will be updated in root vertex state. This usually causes selection update, and so regeneration of content of detail vertex states, etc.

Parameters:
env - The environment

applyQuery

void applyQuery(DFTermExpression term,
                DFEnvironmentRW env)

getLastExecutedQuery

DFTermExpression getLastExecutedQuery()
Return the last executed query - the query which was working when applyWorkingQuery(DFEnvironmentRW) was called last time. Never returns null, but instead of null it returns DFTermExpression.ALL_DATA constant - for example if applyList was called after last applyWorkingQuery method call.

Returns:
The last executed query

applyList

void applyList(List<? extends Comparable<?>> ids,
               DFEnvironmentRW env)
Sets ids on master level of this result set's data tree. The list of ids is set to root vertex entity. This usually causes selection update, and so regeneration of content of detail vertex states, etc.

Parameters:
ids - The ids list
env - The environment

reload

void reload(DFEnvironmentRW env)
Reload row ids (primary keys) and data for this DFResultSet. This method does not re-execute the current (last executed) query, but it just applies the current list of ids instead. It can cause that some ids will disappear if these rows were deleted from DB, but newly added rows are not added to result set. This method also calls DFEntityDataProvider.reloadData() for each VertexState's entity of this result set.

Parameters:
env - The environment

setSearchDomain

void setSearchDomain(DFSearchDomain searchDomain,
                     DFEnvironmentRW env)
Make a ids constraint for query (only subset of DB table given by domain is searched).

Parameters:
searchDomain - The search domain for this DFResultSet. Never put null as parameter, use DFSearchDomain.DEFAULT instead.
env - The environment

getSearchDomain

DFSearchDomain getSearchDomain()
Get the current search domain. Never returns null. If whole DB is searched then DFSearchDomain.DEFAULT is used as domain.

Returns:
The current search domain

getLockable

DFLockable getLockable()
Get private lockable for modifying this result set's state. This lockable must be used to lock DFResultSet when setting new sort, running new query, applying list of ids or changing the selection (selected ids) in any vertex state.

Returns:
The lockable

getVertexState

DFResultSet.VertexState getVertexState(DFDataTree.Vertex vertex)
Get the state of this result set for particular vertex from the DFDataTree.

Parameters:
vertex -
Returns:
The state of this result set

getRootVertexState

DFResultSet.VertexState getRootVertexState()
Get vertex state for the root vertex. It allows to simplify code like resultSet.getVertexState(resultSet.getDataTree().getRootVertex()) to resultSet.getRootVertexState().

Returns:
The vertex state for the root DFDataTree.Vertex.

addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener l)
Register property change listener to be notified about prop. changes of this DFResultSet

Parameters:
l - The property change listener

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener l)
Unregister property change listener.

Parameters:
l - The property change listener

com.im.df.api 5.9