← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2250: Implement pagination in dataElementGroupSet.

 

------------------------------------------------------------
revno: 2250
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Thu 2010-12-02 01:00:37 +0700
message:
  Implement pagination in dataElementGroupSet.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/ListDataElementGroupSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSet.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/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2010-12-01 18:00:37 +0000
@@ -512,6 +512,14 @@
     Collection<DataElementGroupSet> getAllDataElementGroupSets();
 
     Collection<DataElementGroupSet> getDataElementGroupSets( Collection<Integer> identifiers );
+    
+    Collection<DataElementGroupSet> getDataElementGroupSetsBetween( int first, int max );
+    
+    Collection<DataElementGroupSet> getDataElementGroupSetsBetweenByName( String name, int first, int max );
+    
+    int getDataElementGroupSetCount();
+    
+    int getDataElementGroupSetCountByName( String name );
 
     // -------------------------------------------------------------------------
     // DataElementOperand

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2010-12-01 18:00:37 +0000
@@ -671,6 +671,25 @@
         } );
     }
 
+    public int getDataElementGroupSetCount()
+    {
+        return dataElementGroupSetStore.getCount();
+    }
+
+    public int getDataElementGroupSetCountByName( String name )
+    {
+        return dataElementGroupSetStore.getCountByName( name );
+    }
+
+    public Collection<DataElementGroupSet> getDataElementGroupSetsBetween( int first, int max )
+    {
+        return dataElementGroupSetStore.getBetween( first, max );
+    }
+
+    public Collection<DataElementGroupSet> getDataElementGroupSetsBetweenByName( String name, int first, int max )
+    {
+        return dataElementGroupSetStore.getBetweenByName( name, first, max );
+    }
     // -------------------------------------------------------------------------
     // DataElementOperand
     // -------------------------------------------------------------------------
@@ -684,4 +703,6 @@
     {
         return dataElementStore.getAllGeneratedOperands( dataElements );
     }
+
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/ListDataElementGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/ListDataElementGroupSetAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroupset/ListDataElementGroupSetAction.java	2010-12-01 18:00:37 +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.DataElement;
 import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataelement.comparator.DataElementGroupSetNameComparator;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
 
 /**
  * @author Tran Thanh Tri
  * @version $Id$
  */
 public class ListDataElementGroupSetAction
-    implements Action
+    extends ActionPagingSupport<DataElementGroupSet>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -56,7 +58,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
+    // Input & Output
     // -------------------------------------------------------------------------
 
     private List<DataElementGroupSet> dataElementGroupSets;
@@ -66,13 +68,37 @@
         return dataElementGroupSets;
     }
 
+    private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
-        dataElementGroupSets = new ArrayList<DataElementGroupSet>( dataElementService.getAllDataElementGroupSets() );
+        if ( isNotBlank( key ) ) // Filter on key only if set
+        {
+            this.paging = createPaging( dataElementService.getDataElementGroupSetCountByName( key ) );
+            
+            dataElementGroupSets = new ArrayList<DataElementGroupSet>( dataElementService.getDataElementGroupSetsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        }
+        else
+        {
+            this.paging = createPaging( dataElementService.getDataElementGroupSetCount() );
+            
+            dataElementGroupSets = new ArrayList<DataElementGroupSet>( dataElementService.getDataElementGroupSetsBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
         
         Collections.sort( dataElementGroupSets, new DataElementGroupSetNameComparator() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml	2010-11-27 07:46:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml	2010-12-01 18:00:37 +0000
@@ -257,6 +257,7 @@
 			<param name="page">/dhis-web-maintenance-datadictionary/dataElementGroupSet.vm</param>
 			<param name="menu">/dhis-web-maintenance-datadictionary/menu.vm</param>
 			<param name="javascripts">javascript/dataElementGroupSet.js</param>
+			<param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
 		</action>
 
 		<action name="openAddDataElementGroupSet"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSet.vm	2010-09-21 06:16:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSet.vm	2010-12-01 18:00:37 +0000
@@ -6,7 +6,7 @@
 		<td style="vertical-align:top">
 			<table width="100%">
 				<tr>
-                    <td>$i18n.getString( "filter_by_name" ): <form style="display:inline" action="none" onsubmit="return false"><div style="inline"><input type="text" onkeyup="filterValues( this.value )"/></div></form></td>
+                    <td>#filterDiv( "dataElementGroupSet" )</td>
 					<td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location='openAddDataElementGroupSet.action'"/></td>
 				</tr>
 			</table>
@@ -33,7 +33,9 @@
 					</tr>
 					#end
 				</tbody>
-			</table>	
+			</table>
+			<p></p>
+			#parse( "/dhis-web-commons/paging/paging.vm" )
 		</td>
 		
 		<td style="width:20em; padding-left:2em; vertical-align:top">