← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2304: Apply pagination in DataMart list.

 

------------------------------------------------------------
revno: 2304
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Tue 2010-12-07 15:30:02 +0700
message:
  Apply pagination in DataMart list.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datamart/DataMartService.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java
  dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/GetAllDataMartExportsAction.java
  dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewExportForm.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/datamart/DataMartService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datamart/DataMartService.java	2010-08-31 05:47:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datamart/DataMartService.java	2010-12-07 08:30:02 +0000
@@ -29,6 +29,7 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.period.RelativePeriods;
 
 /**
@@ -115,4 +116,12 @@
      * @return the DataMartExport.
      */
     DataMartExport getDataMartExportByName( String name );    
+
+    Collection<DataMartExport> getDataMartExportsBetween( int first, int max );
+    
+    Collection<DataMartExport> getDataMartExportsBetweenByName( String name, int first, int max );
+    
+    int getDataMartExportCount();
+    
+    int getDataMartExportCountByName( String name );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java	2010-08-31 05:47:11 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java	2010-12-07 08:30:02 +0000
@@ -152,4 +152,24 @@
     {
         return dataMartExportStore.getByName( name );
     }
+
+    public int getDataMartExportCount()
+    {
+        return dataMartExportStore.getCount();
+    }
+
+    public int getDataMartExportCountByName( String name )
+    {
+        return dataMartExportStore.getCountByName( name );
+    }
+
+    public Collection<DataMartExport> getDataMartExportsBetween( int first, int max )
+    {
+        return dataMartExportStore.getBetween( first, max );
+    }
+
+    public Collection<DataMartExport> getDataMartExportsBetweenByName( String name, int first, int max )
+    {
+        return dataMartExportStore.getBetweenByName( name, first, max );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/GetAllDataMartExportsAction.java'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/GetAllDataMartExportsAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/GetAllDataMartExportsAction.java	2010-12-07 08:30:02 +0000
@@ -27,22 +27,24 @@
  * 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.Collections;
 import java.util.List;
 
+import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.datamart.DataMartExport;
 import org.hisp.dhis.datamart.DataMartService;
 import org.hisp.dhis.datamart.comparator.DataMartExportComparator;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
 
 /**
  * @author Lars Helge Overland
  * @version $Id$
  */
 public class GetAllDataMartExportsAction
-    implements Action
+    extends ActionPagingSupport<DataMartExport>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -56,7 +58,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
+    // Input & Output
     // -------------------------------------------------------------------------
 
     private List<DataMartExport> exports;
@@ -66,13 +68,38 @@
         return exports;
     }
 
+    private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
-        exports = new ArrayList<DataMartExport>( dataMartService.getAllDataMartExports() );
+        if ( isNotBlank( key ) )
+        {
+            this.paging = createPaging( dataMartService.getDataMartExportCountByName( key ) );
+            
+            exports = new ArrayList<DataMartExport>( dataMartService.getDataMartExportsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        }
+        else
+        {
+            this.paging = createPaging( dataMartService.getDataMartExportCount() );
+
+            exports = new ArrayList<DataMartExport>( dataMartService.getDataMartExportsBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
+
+//        exports = new ArrayList<DataMartExport>( dataMartService.getAllDataMartExports() );
         
         Collections.sort( exports, new DataMartExportComparator() );
         

=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml	2010-06-23 22:12:43 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml	2010-12-07 08:30:02 +0000
@@ -50,6 +50,7 @@
       <param name="page">/dhis-web-datamart/viewExportForm.vm</param>
       <param name="menu">/dhis-web-datamart/menu.vm</param>
       <param name="javascripts">javascript/datamart.js</param>
+	  <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
     </action>
     
     <action name="addDataMartExportToDashboard" class="org.hisp.dhis.datamart.action.AddDataMartExportToDashboardAction">

=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewExportForm.vm'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewExportForm.vm	2010-09-25 20:13:04 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewExportForm.vm	2010-12-07 08:30:02 +0000
@@ -6,7 +6,8 @@
         <td style="vertical-align:top">
 			<table width="100%">
 				<tr>
-                    <td colspan="6" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='getOptions.action'"/></td>
+					<td>#filterDiv( "getDataMartExports" )</td>
+                    <td colspan="5" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='getOptions.action'"/></td>
                 </tr>
 			</table>
             <table class="listTable" id="listTable">
@@ -36,7 +37,8 @@
                 #end
                 </tbody>
             </table>
-
+			<p></p>
+	  		#parse( "/dhis-web-commons/paging/paging.vm" )
         </td>        
         <td style="width:20em; padding-left:2em; vertical-align:top">