dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07654
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2216: Apply paging to user list.
------------------------------------------------------------
revno: 2216
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Thu 2010-09-23 23:02:44 +0700
message:
Apply paging to user list.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserListAction.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/allUser.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/UserStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java 2010-09-23 16:02:44 +0000
@@ -235,4 +235,6 @@
* @param userSetting the UserSetting to delete.
*/
void deleteUserSetting( UserSetting userSetting );
+
+ Collection<User> getAllUsers( int from, int to );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java 2010-05-18 15:42:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java 2010-09-23 16:02:44 +0000
@@ -35,7 +35,9 @@
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.system.util.AuditLogLevel;
import org.hisp.dhis.system.util.AuditLogUtil;
@@ -116,6 +118,14 @@
return session.createQuery( "from User" ).list();
}
+
+ public Collection<User> getAllUsers( int from, int to )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+
+ return session.createQuery( "from User" ).setFirstResult( from ).setMaxResults( to ).list();
+ }
public Collection<User> getUsersByOrganisationUnit( OrganisationUnit organisationUnit )
{
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java 2010-07-22 13:46:44 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java 2010-09-23 16:02:44 +0000
@@ -3,6 +3,7 @@
import java.util.List;
import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.system.paging.Paging;
import com.opensymphony.xwork2.ActionSupport;
@@ -51,4 +52,20 @@
return resultPaging;
}
+
+ protected List getBlockElement( List elementList, int startPos, int pageSize )
+ {
+ List returnList;
+
+ try
+ {
+ returnList = elementList.subList( startPos, startPos + pageSize );
+ }
+ catch ( IndexOutOfBoundsException ex )
+ {
+ returnList = elementList.subList( startPos, elementList.size() );
+ }
+
+ return returnList;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java 2010-07-22 13:46:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java 2010-09-23 16:02:44 +0000
@@ -313,20 +313,4 @@
return result;
}
- private List<DataElement> getBlockElement( List<DataElement> elementList, int startPos, int pageSize )
- {
- List<DataElement> returnList;
-
- try
- {
- returnList = elementList.subList( startPos, startPos + pageSize );
- }
- catch ( IndexOutOfBoundsException ex )
- {
- returnList = elementList.subList( startPos, elementList.size() );
- }
-
- return returnList;
- }
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserListAction.java 2010-04-21 10:42:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserListAction.java 2010-09-23 16:02:44 +0000
@@ -32,6 +32,7 @@
import java.util.Collections;
import java.util.List;
+import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserCredentials;
import org.hisp.dhis.user.UserStore;
@@ -45,7 +46,7 @@
* @version $Id: GetUserListAction.java 2869 2007-02-20 14:26:09Z andegje $
*/
public class GetUserListAction
- implements Action
+ extends ActionPagingSupport
{
// -------------------------------------------------------------------------
// Dependencies
@@ -90,8 +91,10 @@
public String execute()
throws Exception
{
- Collection<User> users = userStore.getAllUsers();
+ this.paging = createPaging( userStore.getAllUsers().size() );
+ Collection<User> users = userStore.getAllUsers( paging.getStartPos(), paging.getPageSize() );
+
userCredentialsList = new ArrayList<UserCredentials>();
for ( User user : users )
=== 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-09-14 09:03:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/struts.xml 2010-09-23 16:02:44 +0000
@@ -31,6 +31,7 @@
<param name="page">/dhis-web-maintenance-user/allUser.vm</param>
<param name="menu">/dhis-web-maintenance-user/menu.vm</param>
<param name="javascripts">javascript/user.js,javascript/filterTable.js</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
<interceptor-ref name="organisationUnitTreeStack"/>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm 2010-09-23 09:52:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm 2010-09-23 16:02:44 +0000
@@ -44,6 +44,10 @@
#end
</tbody>
</table>
+ <p></p>
+ <div class="paging-container">
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+ </div>
</td>
<td style="width:20em; padding-left:2em; vertical-align:top">