diff options
author | Artur Signell <artur@vaadin.com> | 2016-09-16 14:49:07 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-09-27 07:37:43 +0000 |
commit | 057fe21b68206fd15b3fc894924dced3b368dd22 (patch) | |
tree | 776761cb8be85bbcbc0b8c86562f04030c74c534 /documentation/datamodel | |
parent | 7e78d52dfe72678cf275585bc552b1612844da44 (diff) | |
download | vaadin-framework-057fe21b68206fd15b3fc894924dced3b368dd22.tar.gz vaadin-framework-057fe21b68206fd15b3fc894924dced3b368dd22.zip |
Remove documentation for cursors in data sources
This will not be implemented for 8.0
Change-Id: Ida33b3de74c7a14def66fac6f0363a12105d8087
Diffstat (limited to 'documentation/datamodel')
-rw-r--r-- | documentation/datamodel/datamodel-datasources.asciidoc | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/documentation/datamodel/datamodel-datasources.asciidoc b/documentation/datamodel/datamodel-datasources.asciidoc index 997ad20207..f8cf2fe6b9 100644 --- a/documentation/datamodel/datamodel-datasources.asciidoc +++ b/documentation/datamodel/datamodel-datasources.asciidoc @@ -468,66 +468,3 @@ Yet another case that benefits from custom querying options is backends that per To help with this, the provided query object will automatically contain a reference to the item immediately before the start of the first new item to fetch if available. The item immediately after the end of the range to fetch might also be available in some cases if the user is scrolling through the data backwards. There are, however, no guarantees that either item will be available in all queries, so the implementation should always also support fetching by offset. - -Some backends may also use a "cursor" object that encapsulates exactly where the next page of data would continue if continuing from where the previous query ended. -The data provider implementation can pass such instances to the [interfacename]#FetchResult# object so that the framework can include the appropriate cursor in a query that continues from where the previous query ended. - -As an example, a backend with such functionality could look like this: - -[source, java] ----- -public interface PersonService { - PersonFetchResult fetchPersons( - int pageIndex, - int pageSize); - - PersonFetchResult fetchPersons( - PersonFetchCursor cursor, - int pageSize); - - int getPersonCount(); -} - -public interface PersonFetchResult { - List<Person> getPersons(); - PersonFetchCursor getCursor(); -} ----- - -A data source utilizing the cursor could look like this: -[source, java] ----- -public class PersonDataSource - extends BackendDataSource<Person> { - - @Override - public void fetch(Query<Person> query, - FetchResult<Person> result) { - PersonFetchResult personResult; - - Optional<?> maybeCursor = query.getNextCursor(); - if (maybeCursor.isPresent()) { - PersonFetchCursor cursor = - (PersonFetchCursor) maybeCursor.get(); - personResult = getPersonService().fetchPersons( - cursor, query.getLimit()); - } else { - personResult = getPersonService().fetchPersons( - query.getOffset(), query.getLimit()); - } - - result.setNextCursor(personResult.getCursor()); - result.setItems(personResult.getPersons()); - } - - @Override - public int getCount(Query<Person> query) { - return getPersonService().getPersonCount(); - } -} ----- - -The framework will automatically take care of the cursor instance stored in its [interfacename]#FetchResult# and make it available through the next query if it continues from the end offset of the query for which the cursor was stored. - -[NOTE] -This simple example only uses a cursor for continuing from a previous result if going forward. A real service would also support cursors for continuing backwards. There are corresponding methods for defining a cursor in that direction; [interfacename]#FetchResult#.[methodname]#setPreviousCursor# and [interfacename]#Query#.[methodname]#getPreviousCoursor#. |