dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16030
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5966: Messages: updating last message date only on reply, not when reading message
------------------------------------------------------------
revno: 5966
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-02-15 18:10:29 +0100
message:
Messages: updating last message date only on reply, not when reading message
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java
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/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/MessageConversation.hbm.xml
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml
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/MessageConversation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-02-14 20:27:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-02-15 17:10:29 +0000
@@ -54,6 +54,8 @@
private User lastSender;
+ private Date lastMessage;
+
private transient boolean read;
private transient boolean followUp;
@@ -70,6 +72,7 @@
{
this.subject = subject;
this.lastSender = lastSender;
+ this.lastMessage = new Date();
}
@Override
@@ -154,8 +157,8 @@
addMessage( message );
- this.setLastUpdated( new Date() );
this.lastSender = sender;
+ this.setLastMessage( new Date() );
}
public void remove( User user )
@@ -236,6 +239,18 @@
this.lastSender = lastSender;
}
+ @XmlElement
+ @JsonProperty
+ public Date getLastMessage()
+ {
+ return lastMessage;
+ }
+
+ public void setLastMessage( Date lastMessage )
+ {
+ this.lastMessage = lastMessage;
+ }
+
public boolean isRead()
{
return read;
=== 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-02-14 20:27:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2012-02-15 17:10:29 +0000
@@ -63,7 +63,7 @@
public List<MessageConversation> getMessageConversations( User user, Integer first, Integer max )
{
String sql =
- "select mc.messageconversationid, mc.uid, mc.subject, mc.lastupdated, ui.surname, ui.firstname, ( " +
+ "select mc.messageconversationid, mc.uid, mc.subject, mc.lastmessage, ui.surname, ui.firstname, ( " +
"select isread from usermessage " +
"where usermessage.usermessageid=mu.usermessageid " +
"and mu.messageconversationid=mc.messageconversationid ) as isread, ( " +
@@ -80,7 +80,7 @@
sql += "where um.userid=" + user.getId() + " ";
}
- sql += "order by mc.lastupdated desc ";
+ sql += "order by mc.lastmessage desc ";
if ( first != null && max != null )
{
@@ -96,7 +96,7 @@
conversation.setId( resultSet.getInt( 1 ) );
conversation.setUid( resultSet.getString( 2 ) );
conversation.setSubject( resultSet.getString( 3 ) );
- conversation.setLastUpdated( resultSet.getDate( 4 ) );
+ conversation.setLastMessage( resultSet.getDate( 4 ) );
conversation.setLastSenderSurname( resultSet.getString( 5 ) );
conversation.setLastSenderFirstname( resultSet.getString( 6 ) );
conversation.setRead( resultSet.getBoolean( 7 ) );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-02-14 20:27:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-02-15 17:10:29 +0000
@@ -320,6 +320,8 @@
// message
executeSql( "ALTER TABLE messageconversation DROP COLUMN messageconversationkey" );
+ executeSql( "UPDATE messageconversation SET lastmessage=lastupdated WHERE lastmessage is null" );
+ executeSql( "ALTER TABLE messageconversation DROP COLUMN lastupdated" );
executeSql( "ALTER TABLE message DROP COLUMN messagesubject" );
executeSql( "ALTER TABLE message DROP COLUMN messagekey" );
executeSql( "ALTER TABLE message DROP COLUMN sentdate" );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/MessageConversation.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/MessageConversation.hbm.xml 2011-12-13 16:29:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/MessageConversation.hbm.xml 2012-02-15 17:10:29 +0000
@@ -13,7 +13,6 @@
</id>
<property name="uid" column="uid" length="11" />
- <property name="lastUpdated" type="timestamp"/>
<property name="subject" column="subject" not-null="true" />
@@ -32,6 +31,8 @@
<many-to-one name="lastSender" class="org.hisp.dhis.user.User" column="lastsenderid"
foreign-key="fk_messageconversation_userid" />
+
+ <property name="lastMessage" column="lastmessage"/>
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml 2012-02-14 20:27:19 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml 2012-02-15 17:10:29 +0000
@@ -101,7 +101,7 @@
</action>
<action name="unreadMessage" class="org.hisp.dhis.dashboard.message.action.UnreadMessageAction">
- <result name="success" type="redirect">message.action</result>
+ <result name="success" type="redirect">message.action?currentPage=${keyCurrentPage}</result>
</action>
<action name="removeMessage" class="org.hisp.dhis.dashboard.message.action.RemoveMessageAction">
@@ -111,7 +111,7 @@
</action>
<action name="removeMessageRedirect" class="org.hisp.dhis.dashboard.message.action.RemoveMessageAction">
- <result name="success" type="redirect">message.action</result>
+ <result name="success" type="redirect">message.action?currentPage=${keyCurrentPage}</result>
</action>
<action name="toggleFollowUp" class="org.hisp.dhis.dashboard.message.action.ToggleFollowUpAction">
=== 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 2012-02-14 20:27:19 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm 2012-02-15 17:10:29 +0000
@@ -22,9 +22,9 @@
<tr id="tr${conversation.id}" #if( !$conversation.read )class="unread bold"#end>
<td style="width:40px" onclick="toggleFollowUp( '${conversation.id}' )">
<img id="followUp${conversation.id}" #if( $conversation.followUp ) src="../images/marked.png"#else src="../images/unmarked.png"#end></td>
- <td style="width:200px" onclick="read( '${conversation.id}' )">$encoder.htmlEncode( $conversation.lastSenderName )</td>
- <td onclick="read( '${conversation.id}' )">$encoder.htmlEncode( $conversation.subject )</td>
- <td onclick="read( '${conversation.id}' )" style="width:80px">$format.formatDate( $conversation.lastUpdated )</td>
+ <td style="width:200px" onclick="read( '${conversation.id}' )">$!encoder.htmlEncode( $conversation.lastSenderName )</td>
+ <td onclick="read( '${conversation.id}' )">$!encoder.htmlEncode( $conversation.subject )</td>
+ <td onclick="read( '${conversation.id}' )" style="width:80px">$!format.formatDate( $conversation.lastMessage )</td>
<td style="width:70px; text-align:center;">
<a href="readMessage.action?id=${conversation.id}"><img src="../images/read.png" title="$i18n.getString( 'read' )"></a>
<a href="javascript:removeMessage( '${conversation.id}' )"><img src="../images/delete.png" title="$i18n.getString( 'delete' )"></a>