dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37810
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19310: Messages, added user association to MessageConversation. Displaying creator and last sender in me...
------------------------------------------------------------
revno: 19310
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-06-08 12:05:46 +0200
message:
Messages, added user association to MessageConversation. Displaying creator and last sender in message list UI.
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/DefaultMessageService.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/resources/org/hisp/dhis/message/hibernate/MessageConversation.hbm.xml
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.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/MessageConversation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2015-02-26 15:21:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2015-06-08 10:05:46 +0000
@@ -34,6 +34,8 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
+import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
@@ -83,6 +85,10 @@
private transient boolean read;
private transient boolean followUp;
+
+ private transient String userSurname;
+
+ private transient String userFirstname;
private transient String lastSenderSurname;
@@ -109,7 +115,6 @@
// Logic
// --------------------------------------------------------------------------
-
@Override
public String toString()
{
@@ -272,12 +277,23 @@
{
userMessages.clear();
}
-
- public String getLastSenderName()
+
+ public String getSenderDisplayName()
{
- boolean hasName = lastSenderFirstname != null || lastSenderSurname != null;
+ boolean hasUser = userFirstname != null || userSurname != null;
+
+ String displayName = hasUser ? ( userFirstname + " " + userSurname ) : StringUtils.EMPTY;
+
+ boolean hasLastSender = lastSenderFirstname != null || lastSenderSurname != null;
- return hasName ? (lastSenderFirstname + " " + lastSenderSurname) : null;
+ String lastSenderName = hasLastSender ? ( lastSenderFirstname + " " + lastSenderSurname ) : StringUtils.EMPTY;
+
+ if ( hasLastSender && !lastSenderName.equals( displayName ) )
+ {
+ displayName += ", " + lastSenderName;
+ }
+
+ return StringUtils.trimToNull( displayName );
}
public Set<User> getTopRecipients()
@@ -411,6 +427,30 @@
@JsonProperty
@JacksonXmlProperty( isAttribute = true )
+ public String getUserSurname()
+ {
+ return userSurname;
+ }
+
+ public void setUserSurname( String userSurname )
+ {
+ this.userSurname = userSurname;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getUserFirstname()
+ {
+ return userFirstname;
+ }
+
+ public void setUserFirstname( String userFirstname )
+ {
+ this.userFirstname = userFirstname;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
public String getLastSenderSurname()
{
return lastSenderSurname;
=== 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 2015-05-28 18:00:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2015-06-08 10:05:46 +0000
@@ -304,13 +304,6 @@
@Override
public MessageConversation getMessageConversation( String uid )
{
- /*
- * TODO:
- * This is a temporary workaround to ensure transient fields followUp and read
- * are set correctly (and not just to false). Issue should be tackled in
- * HibernateIdentifiableObjectStore and/or HibernateMessageConversationStore.
- */
-
MessageConversation mc = messageConversationStore.getByUid( uid );
if ( mc == null )
@@ -365,7 +358,6 @@
Collection<MessageConversation> conversations = messageConversationStore.getMessageConversations( messageConversationUids );
// Set transient properties
- // TODO See getMessageConversation(String)
for ( MessageConversation mc : conversations )
{
=== 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 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2015-06-08 10:05:46 +0000
@@ -72,12 +72,13 @@
{
SqlHelper sh = new SqlHelper();
- String sql = "select mc.messageconversationid, mc.uid, mc.subject, mc.lastmessage, ui.surname, ui.firstname, um.isread, um.isfollowup, (" +
+ String sql = "select mc.messageconversationid, mc.uid, mc.subject, ui.surname, ui.firstname, mc.lastmessage, ls.surname, ls.firstname, um.isread, um.isfollowup, (" +
"select count(messageconversationid) from messageconversation_messages mcm where mcm.messageconversationid=mc.messageconversationid) as messagecount " +
", mc.created, mc.lastupdated from messageconversation mc " +
"inner join messageconversation_usermessages mu on mc.messageconversationid=mu.messageconversationid " +
"inner join usermessage um on mu.usermessageid=um.usermessageid " +
- "left join userinfo ui on mc.lastsenderid=ui.userinfoid ";
+ "left join userinfo ui on mc.userid=ui.userinfoid " +
+ "left join userinfo ls on mc.lastsenderid=ls.userinfoid ";
if ( user != null )
{
@@ -112,14 +113,16 @@
conversation.setId( resultSet.getInt( 1 ) );
conversation.setUid( resultSet.getString( 2 ) );
conversation.setSubject( resultSet.getString( 3 ) );
- conversation.setLastMessage( resultSet.getDate( 4 ) );
- conversation.setLastSenderSurname( resultSet.getString( 5 ) );
- conversation.setLastSenderFirstname( resultSet.getString( 6 ) );
- conversation.setRead( resultSet.getBoolean( 7 ) );
- conversation.setFollowUp( resultSet.getBoolean( 8 ) );
- conversation.setMessageCount( resultSet.getInt( 9 ) );
- conversation.setCreated( resultSet.getTimestamp( 10 ) );
- conversation.setLastUpdated( resultSet.getTimestamp( 11 ) );
+ conversation.setUserSurname( resultSet.getString( 4 ) );
+ conversation.setUserFirstname( resultSet.getString( 5 ) );
+ conversation.setLastMessage( resultSet.getDate( 6 ) );
+ conversation.setLastSenderSurname( resultSet.getString( 7 ) );
+ conversation.setLastSenderFirstname( resultSet.getString( 8 ) );
+ conversation.setRead( resultSet.getBoolean( 9 ) );
+ conversation.setFollowUp( resultSet.getBoolean( 10 ) );
+ conversation.setMessageCount( resultSet.getInt( 11 ) );
+ conversation.setCreated( resultSet.getTimestamp( 12 ) );
+ conversation.setLastUpdated( resultSet.getTimestamp( 13 ) );
return conversation;
}
=== 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 2015-04-21 18:32:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/MessageConversation.hbm.xml 2015-06-08 10:05:46 +0000
@@ -38,5 +38,7 @@
<property name="lastMessage" column="lastmessage" index="messageconversation_lastmessage" />
+ <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_messageconversation_userid" />
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java 2015-06-08 06:22:39 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java 2015-06-08 10:05:46 +0000
@@ -28,9 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.importexport.ImportStrategy;
@@ -38,12 +41,9 @@
import org.springframework.util.StreamUtils;
import org.springframework.util.StringUtils;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java 2015-06-05 12:58:08 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java 2015-06-08 10:05:46 +0000
@@ -28,12 +28,22 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.google.common.base.Function;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Maps;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
import org.apache.commons.io.IOUtils;
-import org.hibernate.Hibernate;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.common.IdentifiableProperty;
import org.hisp.dhis.common.MergeStrategy;
@@ -48,19 +58,10 @@
import org.springframework.core.io.ClassPathResource;
import org.springframework.transaction.annotation.Transactional;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import com.google.common.base.Function;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Maps;
/**
* @author Halvdan Hoem Grelland
=== 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 2015-01-07 13:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm 2015-06-08 10:05:46 +0000
@@ -47,8 +47,8 @@
</td>
<td style="width:40px;padding-left:5px;" onclick="toggleFollowUp( '${conversation.id}' )" class="followup-icon">
<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.uid}' )">
- #if( $conversation.lastSenderName )$!encoder.htmlEncode( $conversation.lastSenderName )#else $i18n.getString( "system_notification" )#end
+ <td style="width:220px" onclick="read( '${conversation.uid}' )">
+ #if( $conversation.senderDisplayName )$!encoder.htmlEncode( $conversation.senderDisplayName )#else $i18n.getString( "system_notification" )#end
#if( $conversation.messageCount > 1 ) <span class="normal">(${conversation.messageCount})</span>#end
</td>
<td onclick="read( '${conversation.uid}' )">$!encoder.htmlEncode( $conversation.subject )</td>