From 200a40b332420f94992eb39a6d0ea1cf1490ffc4 Mon Sep 17 00:00:00 2001 From: coreyg Date: Fri, 21 Nov 2014 09:30:19 +0000 Subject: Adding tuscany's website to their svn repo for svnpubsub git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1640879 13f79535-47bb-0310-9956-ffa450edef68 --- site/trunk/site-publish/workingwithpaging.html | 166 +++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 site/trunk/site-publish/workingwithpaging.html (limited to 'site/trunk/site-publish/workingwithpaging.html') diff --git a/site/trunk/site-publish/workingwithpaging.html b/site/trunk/site-publish/workingwithpaging.html new file mode 100644 index 0000000000..ffced67df1 --- /dev/null +++ b/site/trunk/site-publish/workingwithpaging.html @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + Apache Tuscany : WorkingWithPaging + + + + + + + + + + + + + + + +
+ + + + +   + +
+ + +
+
+ + + + + + + + + +
+  Apache Tuscany > Home > DAS Overview > DAS Java > DAS Java Documentation Menu > DAS Java Developer Guide > RDB DAS Java > RDB DAS - User Guide > WorkingWithPaging + + User List | Dev List | Issue Tracker   +
+ + + + + + + +
+ + +
+ +
+
+

WorkingWithPaging

+

The RDB DAS provides a mechanism for working with the result of large queries one chunk (page) at a time. This capability is modeled after the behavior of web search engines. For example, if I Google "RDB DAS" I am presented with a page representing the first ten references. I am also told that there were close to 500,000 matches and I am given the opportunity to go to the next page or directly to pages two through ten. After moving from the first page I am also provided the opportunity to move back to some previous page.

+ +

The DAS "Pager" is a wrapper around a provided read command and provides the APIs for paging. Here is the Pager interface:

+
+
+public interface Pager {
+
+    /**
+     * Get the next page of data
+     */
+    DataObject next();
+
+    /**
+     * Get the page prior to the last page returned
+     */
+    DataObject previous();
+
+    /**
+     * Return a specific identified page.
+     */
+    DataObject getPage(int page);
+
+}
+
+
+

A Pager is instantiated on a given read Command and the constructor is used to specify the desired page size (number of database rows per page). The following example illustrates construction and use of a pager:

+
+
+DAS das = DAS.FACTORY.createDAS(getConnection());
+   // Build command to read all customers
+   Command custCommand = das.createCommand("select * from CUSTOMER order by ID");
+
+   // Create a pager with the command
+   Pager pager = new PagerImpl(custCommand, 2);
+
+   // Get and work with first page
+   DataObject root = pager.next();
+   DataObject customer1 = root.getDataObject("CUSTOMER[1]");
+   DataObject customer2 = root.getDataObject("CUSTOMER[2]");
+
+   // Get and work with the second page
+   root = pager.next();
+   customer1 = root.getDataObject("CUSTOMER[1]");
+   customer2 = root.getDataObject("CUSTOMER[2]");
+
+   // First page again
+   root = pager.previous();
+   customer1 = root.getDataObject("CUSTOMER[1]");
+   customer2 = root.getDataObject("CUSTOMER[2]");
+
+
+

The current Pager specification and implementation are very preliminary and will likely change in significant ways! For instance, the pager is intended to work in completely disconnected scenarios so there should be no connection context maintained between invocations of the pager. Currently the Pager references a Command that, in turn, references a connection (oops!). Some work must be done to make the pager lightweight as it will likely be stored in session.

+ +

We probably should also create a Factory rather than using the impl constructor.

+
+
+
+ + +
+ + + + + + website stats + + + + + + -- cgit v1.2.3