← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2461: Apply pagination in UserGroup list

 

------------------------------------------------------------
revno: 2461
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Tue 2011-01-04 22:43:33 +0700
message:
  Apply pagination in UserGroup list
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/userGroupList.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/user/UserGroupService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java	2010-12-23 12:27:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupService.java	2011-01-04 15:43:33 +0000
@@ -18,4 +18,12 @@
     Collection<UserGroup> getAllUserGroups();
     
     UserGroup getUserGroupByName( String name );
+
+    Collection<UserGroup> getUserGroupsBetween( int first, int max );
+    
+    Collection<UserGroup> getUserGroupsBetweenByName( String name, int first, int max );
+    
+    int getUserGroupCount();
+    
+    int getUserGroupCountByName( String name );    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java	2010-12-23 12:27:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserGroupService.java	2011-01-04 15:43:33 +0000
@@ -60,4 +60,28 @@
         return userGroupStore.getByName( name );
     }
 
+    @Override
+    public int getUserGroupCount()
+    {
+        return userGroupStore.getCount();
+    }
+
+    @Override
+    public int getUserGroupCountByName( String name )
+    {
+        return userGroupStore.getCountByName( name );
+    }
+
+    @Override
+    public Collection<UserGroup> getUserGroupsBetween( int first, int max )
+    {
+        return userGroupStore.getBetween( first, max );
+    }
+
+    @Override
+    public Collection<UserGroup> getUserGroupsBetweenByName( String name, int first, int max )
+    {
+        return userGroupStore.getBetweenByName( name, first, max );
+    }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java	2010-12-29 20:53:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java	2011-01-04 15:43:33 +0000
@@ -27,16 +27,20 @@
  * 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.datadictionary.DataDictionary;
+import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
 
 import com.opensymphony.xwork2.Action;
 
 public class GetUserGroupListAction
-    implements Action
+    extends ActionPagingSupport<UserGroup>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -60,6 +64,17 @@
         return userGroupList;
     }
 
+    private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -67,7 +82,20 @@
     public String execute()
         throws Exception
     {
-        userGroupList = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
+        if ( isNotBlank( key ) ) // Filter on key only if set
+        {
+            this.paging = createPaging( userGroupService.getUserGroupCountByName( key ) );
+            
+            userGroupList = new ArrayList<UserGroup>( userGroupService.getUserGroupsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        }
+        else
+        {
+            this.paging = createPaging( userGroupService.getUserGroupCount() );
+            
+            userGroupList = new ArrayList<UserGroup>( userGroupService.getUserGroupsBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
+        
+//        userGroupList = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/struts.xml	2010-12-30 04:29:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/struts.xml	2011-01-04 15:43:33 +0000
@@ -165,6 +165,7 @@
     <param name="menu">/dhis-web-maintenance-user/menu.vm</param>
     <param name="stylesheets">css/receiveImportPage.css</param>
     <param name="javascripts">javascript/user.js</param>
+	<param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
   </action>
 
   <action name="getUserGroup" class="org.hisp.dhis.user.action.GetUserGroupAction">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/userGroupList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/userGroupList.vm	2010-12-30 09:59:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/userGroupList.vm	2011-01-04 15:43:33 +0000
@@ -5,7 +5,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( "getAllUserGroups" )</td>
                 <td colspan="9" style="text-align:right">
                     <input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='addUserGroupForm.action'" style="width:80px"/></a>
                 </td>
@@ -33,6 +33,8 @@
             #end
           </tbody>
         </table>
+		<p></p>
+		#parse( "/dhis-web-commons/paging/paging.vm" )
     </td>
         <td style="width:20em; padding-left:2em; vertical-align:top">
             <div id="detailsArea" style="display:none">