dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15198
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5391: Made MessageConversation an identifiable object
------------------------------------------------------------
revno: 5391
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-13 17:29:31 +0100
message:
Made MessageConversation an identifiable object
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/common/IdentityPopulator.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
--
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 2011-09-30 17:01:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2011-12-13 16:29:31 +0000
@@ -33,27 +33,22 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.UUID;
+import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.user.User;
/**
* @author Lars Helge Overland
*/
public class MessageConversation
+ extends BaseIdentifiableObject
{
- private int id;
-
- private String key;
-
private String subject;
private Set<UserMessage> userMessages = new HashSet<UserMessage>();
private List<Message> messages = new ArrayList<Message>();
- private Date lastUpdated;
-
private User lastSender;
private transient boolean read;
@@ -64,18 +59,20 @@
public MessageConversation()
{
- this.key = UUID.randomUUID().toString();
- this.lastUpdated = new Date();
}
public MessageConversation( String subject, User lastSender )
{
- this.key = UUID.randomUUID().toString();
this.subject = subject;
- this.lastUpdated = new Date();
this.lastSender = lastSender;
}
+ @Override
+ public String getName()
+ {
+ return subject;
+ }
+
public void addUserMessage( UserMessage userMessage )
{
this.userMessages.add( userMessage );
@@ -124,7 +121,7 @@
addMessage( message );
- this.lastUpdated = new Date();
+ this.setLastUpdated( new Date() );
this.lastSender = sender;
}
@@ -172,16 +169,6 @@
this.id = id;
}
- public String getKey()
- {
- return key;
- }
-
- public void setKey( String key )
- {
- this.key = key;
- }
-
public String getSubject()
{
return subject;
@@ -212,16 +199,6 @@
this.messages = messages;
}
- public Date getLastUpdated()
- {
- return lastUpdated;
- }
-
- public void setLastUpdated( Date lastUpdated )
- {
- this.lastUpdated = lastUpdated;
- }
-
public User getLastSender()
{
return lastSender;
@@ -265,7 +242,7 @@
@Override
public int hashCode()
{
- return key.hashCode();
+ return uid.hashCode();
}
@Override
@@ -288,7 +265,7 @@
final MessageConversation other = (MessageConversation) object;
- return key.equals( other.key );
+ return uid.equals( other.uid );
}
@Override
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java 2011-12-13 14:04:12 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java 2011-12-13 16:29:31 +0000
@@ -52,7 +52,8 @@
private static String[] tables = { "chart", "constant", "attribute", "indicatortype", "indicatorgroupset", "indicator",
"indicatorgroup", "datadictionary", "validationrulegroup", "validationrule", "dataset", "orgunitlevel", "document",
"organisationunit", "orgunitgroup", "orgunitgroupset", "dataelementcategoryoption", "dataelementgroup", "sqlview",
- "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo", "categoryoptioncombo", "mapview", "reporttable", "report" };
+ "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo", "categoryoptioncombo", "mapview",
+ "reporttable", "report", "messageconversation" };
// -------------------------------------------------------------------------
// Dependencies
=== 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 2011-08-04 10:06:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2011-12-13 16:29:31 +0000
@@ -32,7 +32,7 @@
import java.util.List;
import org.hibernate.Query;
-import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
import org.hisp.dhis.message.MessageConversation;
import org.hisp.dhis.message.MessageConversationStore;
import org.hisp.dhis.user.User;
@@ -42,12 +42,12 @@
* @author Lars Helge Overland
*/
public class HibernateMessageConversationStore
- extends HibernateGenericStore<MessageConversation> implements MessageConversationStore
+ extends HibernateIdentifiableObjectStore<MessageConversation> implements MessageConversationStore
{
public List<MessageConversation> getMessageConversations( User user, int first, int max )
{
final String sql =
- "select mc.messageconversationid, mc.messageconversationkey, mc.subject, mc.lastupdated, ui.surname, ui.firstname, ( " +
+ "select mc.messageconversationid, mc.uid, mc.subject, mc.lastupdated, ui.surname, ui.firstname, ( " +
"select isread from usermessage " +
"where usermessage.usermessageid=mu.usermessageid " +
"and mu.messageconversationid=mc.messageconversationid ) as isread " +
@@ -66,7 +66,7 @@
MessageConversation conversation = new MessageConversation();
conversation.setId( resultSet.getInt( 1 ) );
- conversation.setKey( resultSet.getString( 2 ) );
+ conversation.setUid( resultSet.getString( 2 ) );
conversation.setSubject( resultSet.getString( 3 ) );
conversation.setLastUpdated( resultSet.getDate( 4 ) );
conversation.setLastSenderSurname( resultSet.getString( 5 ) );
=== 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 2011-12-13 09:43:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2011-12-13 16:29:31 +0000
@@ -287,6 +287,7 @@
// message
+ executeSql( "ALTER TABLE messageconversation DROP COLUMN messageconversationkey" );
executeSql( "ALTER TABLE message DROP COLUMN messagesubject" );
executeSql( "ALTER TABLE usermessage DROP COLUMN messagedate" );
executeSql( "DROP TABLE message_usermessages" );
=== 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-08-04 10:32:02 +0000
+++ 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
@@ -11,8 +11,10 @@
<id name="id" column="messageconversationid">
<generator class="native" />
</id>
+
+ <property name="uid" column="uid" length="11" />
+ <property name="lastUpdated" type="timestamp"/>
- <property name="key" column="messageconversationkey" not-null="true" />
<property name="subject" column="subject" not-null="true" />
<set name="userMessages" table="messageconversation_usermessages" cascade="all,delete-orphan">
@@ -27,9 +29,7 @@
<many-to-many class="org.hisp.dhis.message.Message" column="messageid"
unique="true" foreign-key="fk_messageconversation_messages_messageid" />
</list>
-
- <property name="lastUpdated"/>
-
+
<many-to-one name="lastSender" class="org.hisp.dhis.user.User" column="lastsenderid"
foreign-key="fk_messageconversation_userid" />