dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16023
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5960: Implemented paging for message conversations
------------------------------------------------------------
revno: 5960
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-02-14 20:19:27 +0100
message:
Implemented paging for message conversations
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversationStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessagesAction.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.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/message/MessageConversationStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversationStore.java 2012-01-11 19:25:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversationStore.java 2012-02-14 19:19:27 +0000
@@ -49,6 +49,8 @@
*/
List<MessageConversation> getMessageConversations( User user, Integer first, Integer max );
+ int getMessageConversationCount( User user );
+
long getUnreadUserMessageConversationCount( User user );
int deleteMessages( User sender );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java 2012-01-11 19:25:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java 2012-02-14 19:19:27 +0000
@@ -64,6 +64,8 @@
List<MessageConversation> getMessageConversations( int first, int max );
+ int getMessageConversationCount();
+
List<MessageConversation> getAllMessageConversations();
void deleteMessages( User sender );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2012-01-11 19:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2012-02-14 19:19:27 +0000
@@ -216,6 +216,11 @@
return messageConversationStore.getMessageConversations( currentUserService.getCurrentUser(), first, max );
}
+ public int getMessageConversationCount()
+ {
+ return messageConversationStore.getMessageConversationCount( currentUserService.getCurrentUser() );
+ }
+
public List<MessageConversation> getAllMessageConversations()
{
return messageConversationStore.getMessageConversations( null, null, null );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2012-01-11 19:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2012-02-14 19:19:27 +0000
@@ -104,6 +104,17 @@
return conversations;
}
+
+ public int getMessageConversationCount( User user )
+ {
+ String sql =
+ "select count(*) from messageconversation mc " +
+ "left join messageconversation_usermessages mu on mc.messageconversationid=mu.messageconversationid " +
+ "left join usermessage um on mu.usermessageid=um.usermessageid " +
+ "where um.userid=" + user.getId();
+
+ return jdbcTemplate.queryForInt( sql );
+ }
public long getUnreadUserMessageConversationCount( User user )
{
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessagesAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessagesAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessagesAction.java 2012-02-14 19:19:27 +0000
@@ -31,14 +31,13 @@
import org.hisp.dhis.message.MessageConversation;
import org.hisp.dhis.message.MessageService;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Lars Helge Overland
*/
public class GetMessagesAction
- implements Action
+ extends ActionPagingSupport<MessageConversation>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -68,7 +67,9 @@
public String execute()
{
- conversations = messageService.getMessageConversations( 0, 300 );
+ this.paging = createPaging( messageService.getMessageConversationCount() );
+
+ conversations = messageService.getMessageConversations( paging.getStartPos(), paging.getPageSize() );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm 2011-08-04 10:06:15 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm 2012-02-14 19:19:27 +0000
@@ -29,3 +29,6 @@
</tr>
#end
</table>
+<p></p>
+#parse( "/dhis-web-commons/paging/paging.vm" )
+