Interface DFResultSet


  • public interface DFResultSet
    This object is used for managing data for a particular DFDataTree.

    The DFResultSet encapsulates a particular snapshot of data for the DFDataTree. 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 DFDataTree hierarchy can be sorted with custom sort directives.

    Views (grid view, form view, …) get their data from a particular DFResultSet. Multiple views from the same DFDataTree use the same DFResultSet, 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 DFResultSets.forDataTree(com.im.df.api.ddl.DFDataTree)

         DFDataTree dt = ...;
         DFResultSet rs = DFResultSets.forDataTree(dt);
     

    Or lower-level API - DFSchemaDataProvider.getDefaultResultSet(com.im.df.api.ddl.DFDataTree, boolean, com.im.commons.progress.DFEnvironmentRO) method; can be used if more control over the process is needed. First you need to have DFSchema instance which is the root object (use DFSchemas.find(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 = DFSchemas.find(dt);
         DFEnvironmentRO env = EnvUtils.createDefaultEnvironmentRO("Loading data", false);
         DFResultSet rs = schema.getDataProvider().getDefaultResultSet(dt, true, env);
         env.getFeedback().finish();
     

    The resulting DFResultSet instance is shared.

    Author:
    Tim Dudgeon
    • Method Detail

      • getDataTree

        DFDataTree getDataTree()
        Get the DFDataTree which this result set was created for.
        Returns:
        The data tree
      • setWorkingQuery

        void setWorkingQuery​(DFTermExpression workingQuery,
                             com.im.commons.progress.DFEnvironmentRW env)
        Sets 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()
        Gets 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​(com.im.commons.progress.DFEnvironmentRW env)
        Applies 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,
                        com.im.commons.progress.DFEnvironmentRW env)
      • getLastExecutedQuery

        DFTermExpression getLastExecutedQuery()
        Returns 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​(java.util.List<? extends java.lang.Comparable<?>> ids,
                       com.im.commons.progress.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​(com.im.commons.progress.DFEnvironmentRW env)
        Reloads 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,
                             com.im.commons.progress.DFEnvironmentRW env)
        Makes an 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
      • enableFilterSearchResults

        @Deprecated
        void enableFilterSearchResults​(boolean b,
                                       com.im.commons.progress.DFEnvironmentRW env)
        Enables or disables the filter search results functionality. If it is enabled the child data are filtered to fulfill for the query.
        Parameters:
        b - Enable or disable the filter.
        env - The environment
        Since:
        15.10.19
      • setLoadAllChildRows

        @Deprecated
        void setLoadAllChildRows​(boolean b,
                                 com.im.commons.progress.DFEnvironmentRW env)
        Enables or disables the loading all convergent child functionality. If it is enabled all child connected to parent data is loaded to convergent child.
        Parameters:
        b - Enable or disable loading all data..
        env - The environment
        Since:
        16.7.25
      • getSearchDomain

        DFSearchDomain getSearchDomain()
        Gets 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

        com.im.commons.progress.DFLockable getLockable()
        Gets 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
      • isQueryRunning

        boolean isQueryRunning()
        Is query execution running now? It is also possible to register a PropertyChangeListener to this DFResultSet and listen to PROP_QUERY_IS_RUNNING property changes.
        Returns:
        true if the query is running otherwise false
      • isQueryCancelRequested

        boolean isQueryCancelRequested()
        When query is running (isQueryRunning() returns true) then this method returns provides information whether "stop query" request was already sent (using requestStopQuery()). When query is not running it returns false.
        Returns:
        true if query is running and stopping the query was requested already
      • requestStopQuery

        void requestStopQuery()
        If query is currently running (see also isQueryRunning() then it is possible to request stop query execution. It doesn't mean that query is stopped immediately. Query engine is just requested to stop running the query as soon as possible. When query is actually stopped depends on type of query (structure search, standard DB search) and also specific database (Oracle cartridge, local db, etc.). See also isQueryRunning() and isQueryCancelRequested().
      • getVertexState

        DFResultSet.VertexState getVertexState​(DFDataTree.Vertex vertex)
        Gets the state of this result set for particular vertex from the DFDataTree.
        Parameters:
        vertex - the Vertex
        Returns:
        The state of this result set
      • getRootVertexState

        DFResultSet.VertexState getRootVertexState()
        Gets 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​(java.beans.PropertyChangeListener l)
        Registers property change listener to be notified about prop. changes of this DFResultSet
        Parameters:
        l - The property change listener
      • removePropertyChangeListener

        void removePropertyChangeListener​(java.beans.PropertyChangeListener l)
        Unregisters property change listener.
        Parameters:
        l - The property change listener
      • createCopy

        DFResultSet createCopy()
        Creates copy from the result set. The copy shares only the data tree.
        Returns:
        The copied result set.
        Since:
        14.10.20
      • ensureLoaded

        void ensureLoaded​(com.im.commons.progress.DFEnvironmentRO env)
        Ensures that the result set is fully initialized. Loads all ids for the root entity if no query has been run before, otherwise does nothing. Loading is done only once.

        As loading can be slow this should not be called from EDT.

        Parameters:
        env - environment used during data loading
        Since:
        15.10.19