← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2361: Apply pagination in static report list.

 

------------------------------------------------------------
revno: 2361
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Mon 2010-12-13 22:18:59 +0700
message:
  Apply pagination in static report list.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/DocumentService.java	2010-12-13 15:18:59 +0000
@@ -29,6 +29,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.datamart.DataMartExport;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -75,4 +77,13 @@
      * @return the Document.
      */
     Document getDocumentByName( String name );
+    
+    Collection<Document> getDocumentsBetween( int first, int max );
+    
+    Collection<Document> getDocumentsBetweenByName( String name, int first, int max );
+    
+    int getDocumentCount();
+    
+    int getDocumentCountByName( String name );
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java	2010-12-13 15:18:59 +0000
@@ -81,4 +81,24 @@
     {
         return documentStore.getByName( name );
     }
+
+    public int getDocumentCount()
+    {
+        return documentStore.getCount();
+    }
+
+    public int getDocumentCountByName( String name )
+    {
+        return documentStore.getCountByName( name );
+    }
+
+    public Collection<Document> getDocumentsBetween( int first, int max )
+    {
+        return documentStore.getBetween( first, max );
+    }
+
+    public Collection<Document> getDocumentsBetweenByName( String name, int first, int max )
+    {
+        return documentStore.getBetweenByName( name, first, max );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/GetAllDocumentsAction.java	2010-12-13 15:18:59 +0000
@@ -27,11 +27,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
 import java.util.ArrayList;
 import java.util.List;
 
+import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.document.DocumentService;
+import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.report.Report;
 
 import com.opensymphony.xwork2.Action;
 
@@ -40,7 +45,7 @@
  * @version $Id$
  */
 public class GetAllDocumentsAction
-    implements Action
+    extends ActionPagingSupport<Document>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -54,7 +59,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
+    // Input & Output
     // -------------------------------------------------------------------------
 
     private List<Document> documents;
@@ -63,6 +68,18 @@
     {
         return documents;
     }
+    
+    private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -70,8 +87,19 @@
 
     public String execute()
     {
-        documents = new ArrayList<Document>( documentService.getAllDocuments() );
-        
+        if ( isNotBlank( key ) )
+        {
+            this.paging = createPaging( documentService.getDocumentCountByName( key ) );
+            
+            documents = new ArrayList<Document>( documentService.getDocumentsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        }
+        else
+        {
+            this.paging = createPaging( documentService.getDocumentCount() );
+
+            documents = new ArrayList<Document>( documentService.getDocumentsBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2010-12-13 14:58:04 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2010-12-13 15:18:59 +0000
@@ -33,6 +33,7 @@
       <param name="page">/dhis-web-reporting/viewDocumentForm.vm</param>
       <param name="menu">/dhis-web-reporting/menu.vm</param>
       <param name="javascripts">javascript/document.js</param>
+	  <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
     </action>
     
     <action name="displayAddDocumentForm" class="org.hisp.dhis.reporting.document.action.GetDocumentAction">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm	2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm	2010-12-13 15:18:59 +0000
@@ -8,6 +8,7 @@
         <td style="vertical-align:top">
             <table width="100%">
 				<tr>
+					<td>#filterDiv( "displayViewDocumentForm" )</td>
                     <td style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='displayAddDocumentForm.action'"></td>
                 </tr>
 			</table>
@@ -39,6 +40,8 @@
                 #end
                 </tbody>
             </table>
+			<p></p>
+			#parse( "/dhis-web-commons/paging/paging.vm" )
                
         </td>
         <td style="width:20em; padding-left:2em; vertical-align:top">