← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5399: Made Message an IdentifiableObject

 

------------------------------------------------------------
revno: 5399
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-12-14 10:17:14 +0100
message:
  Made Message an IdentifiableObject
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/Message.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/Message.hbm.xml
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.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/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2011-12-13 18:41:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2011-12-14 09:17:14 +0000
@@ -75,7 +75,7 @@
     /**
      * The date this object was last updated.
      */
-    private Date lastUpdated;
+    protected Date lastUpdated;
 
     // -------------------------------------------------------------------------
     // Constructors

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/Message.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/Message.java	2011-11-01 11:34:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/Message.java	2011-12-14 09:17:14 +0000
@@ -28,26 +28,18 @@
  */
 
 import java.util.Date;
-import java.util.UUID;
 
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.user.User;
 
 /**
  * @author Lars Helge Overland
  */
 public class Message
+    extends BaseIdentifiableObject
 {
     /**
-     * The message internal identifier.
-     */
-    private int id;
-
-    /**
-     * The unique key for the message. Will be auto-generated by the constructors.
-     */
-    private String key;
-    
-    /**
      * The message text.
      */
     private String text;
@@ -62,46 +54,21 @@
      */
     private User sender;
     
-    /**
-     * The date the message was sent.
-     */
-    private Date sentDate;
-
     public Message()
     {
-        this.key = UUID.randomUUID().toString();
-        this.sentDate = new Date();
+        this.uid = CodeGenerator.generateCode();
+        this.lastUpdated = new Date();
     }
     
     public Message( String text, String metaData, User sender )
     {
-        this.key = UUID.randomUUID().toString();
+        this.uid = CodeGenerator.generateCode();
+        this.lastUpdated = new Date();
         this.text = text;
         this.metaData = metaData;
         this.sender = sender;
-        this.sentDate = new Date();
     }
     
-    public int getId()
-    {
-        return id;
-    }
-
-    public void setId( int id )
-    {
-        this.id = id;
-    }
-
-    public String getKey()
-    {
-        return key;
-    }
-
-    public void setKey( String key )
-    {
-        this.key = key;
-    }
-
     public String getText()
     {
         return text;
@@ -132,20 +99,10 @@
         this.sender = sender;
     }
 
-    public Date getSentDate()
-    {
-        return sentDate;
-    }
-
-    public void setSentDate( Date sentDate )
-    {
-        this.sentDate = sentDate;
-    }
-    
     @Override
     public int hashCode()
     {
-        return key.hashCode();
+        return uid.hashCode();
     }
 
     @Override
@@ -168,7 +125,7 @@
         
         final Message other = (Message) 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/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-12-13 16:29:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-12-14 09:17:14 +0000
@@ -289,6 +289,8 @@
 
         executeSql( "ALTER TABLE messageconversation DROP COLUMN messageconversationkey" );
         executeSql( "ALTER TABLE message DROP COLUMN messagesubject" );
+        executeSql( "ALTER TABLE message DROP COLUMN messagekey" );
+        executeSql( "ALTER TABLE message RENAME COLUMN sentdate TO lastupdated" );
         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/Message.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/Message.hbm.xml	2011-10-06 15:39:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/Message.hbm.xml	2011-12-14 09:17:14 +0000
@@ -12,15 +12,14 @@
       <generator class="native" />
     </id>
 	
-	<property name="key" column="messagekey" not-null="true"/>
+    <property name="uid" column="uid" length="11" />
+    <property name="lastUpdated" type="timestamp"/>
+	
 	<property name="text" column="messagetext"/>
 	<property name="metaData" column="metadata"/>
 	
     <many-to-one name="sender" class="org.hisp.dhis.user.User" column="userid" 
 	  foreign-key="fk_message_userid" />
 	
-	<property name="sentDate"/>
-	
   </class>
 </hibernate-mapping>
-	

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm	2011-10-26 06:17:34 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm	2011-12-14 09:17:14 +0000
@@ -54,7 +54,7 @@
 #foreach( $message in $conversation.messages )
 <div class="messageDiv">
 <span class="bold" style="cursor:pointer" onclick="showSenderInfo( ${message.id}, ${message.sender.id} )">$encoder.htmlEncode( $message.sender.name )</span>&nbsp;
-<span style="color:#606060">$format.formatDate( $message.sentDate )</span>
+<span style="color:#606060">$format.formatDate( $message.lastUpdated )</span>
 
 <p>$encoder.htmlEncode( $message.text )</p>
 <span id="metaData${message.id}" style="display:none">$!encoder.htmlEncode( $message.metaData )</span>