← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6305: Web api, Made paging possible for messaqe conversations

 

------------------------------------------------------------
revno: 6305
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-03-19 18:23:02 +0100
message:
  Web api, Made paging possible for messaqe conversations
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java


--
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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java	2012-01-24 14:43:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java	2012-03-19 17:23:02 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserService;
 import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.common.Pager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
@@ -73,7 +74,23 @@
     public String getMessageConversations( IdentifiableObjectParams params, Model model, HttpServletRequest request )
     {
         MessageConversations messageConversations = new MessageConversations();
-        messageConversations.setMessageConversations( new ArrayList<MessageConversation>( messageService.getMessageConversations( 0, 300 ) ) );
+        
+        if ( params.isPaging() )
+        {
+            int total = messageService.getMessageConversationCount();
+            
+            Pager pager = new Pager( params.getPage(), total );
+            messageConversations.setPager( pager );
+            
+            List<MessageConversation> list = new ArrayList<MessageConversation>(
+                messageService.getMessageConversations( pager.getPage(), pager.getPageSize() ) );
+            
+            messageConversations.setMessageConversations( list );
+        }
+        else
+        {
+            messageConversations.setMessageConversations( new ArrayList<MessageConversation>( messageService.getMessageConversations( 0, 1000 ) ) );
+        }
 
         if ( params.hasLinks() )
         {