dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11413
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3238: Work in progress in message user interface
------------------------------------------------------------
revno: 3238
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-03-31 17:54:20 +0200
message:
Work in progress in message user interface
added:
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/
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
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/Message.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateUserMessageStore.java
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/UserMessage.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MessageServiceTest.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.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/Message.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/Message.java 2011-03-30 16:14:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/Message.java 2011-03-31 15:54:20 +0000
@@ -31,6 +31,8 @@
import java.util.Set;
import java.util.UUID;
+import org.hisp.dhis.user.User;
+
/**
* @author Lars Helge Overland
*/
@@ -40,9 +42,11 @@
private String key;
- private String title;
+ private String subject;
private String text;
+
+ private User sender;
private Set<UserMessage> userMessages = new HashSet<UserMessage>();
@@ -51,11 +55,12 @@
this.key = UUID.randomUUID().toString();
}
- public Message( String title, String text )
+ public Message( String subject, String text, User sender )
{
this.key = UUID.randomUUID().toString();
- this.title = title;
+ this.subject = subject;
this.text = text;
+ this.sender = sender;
}
public int getId()
@@ -78,14 +83,14 @@
this.key = key;
}
- public String getTitle()
+ public String getSubject()
{
- return title;
+ return subject;
}
- public void setTitle( String title )
+ public void setSubject( String subject )
{
- this.title = title;
+ this.subject = subject;
}
public String getText()
@@ -98,6 +103,16 @@
this.text = text;
}
+ public User getSender()
+ {
+ return sender;
+ }
+
+ public void setSender( User sender )
+ {
+ this.sender = sender;
+ }
+
public Set<UserMessage> getUserMessages()
{
return userMessages;
@@ -140,6 +155,6 @@
@Override
public String toString()
{
- return "[Title: " + title + ", text: " + text + "]";
+ return "[Subject: " + subject + ", text: " + text + "]";
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java 2011-03-30 16:14:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java 2011-03-31 15:54:20 +0000
@@ -45,9 +45,10 @@
private boolean read;
private Date messageDate;
-
+
public UserMessage()
{
+ this.messageDate = new Date();
}
public UserMessage( User user, Message message )
@@ -97,7 +98,7 @@
{
this.read = read;
}
-
+
public Date getMessageDate()
{
return messageDate;
@@ -147,6 +148,6 @@
@Override
public String toString()
{
- return "[User: " + user + ", message: " + message + ", read: " + read + ", date: " + messageDate + "]";
+ return "[User: " + user + ", message: " + message + ", read: " + read + "]";
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateUserMessageStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateUserMessageStore.java 2011-03-31 11:45:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateUserMessageStore.java 2011-03-31 15:54:20 +0000
@@ -52,6 +52,7 @@
criteria.setFirstResult( first );
criteria.setMaxResults( max );
criteria.addOrder( Order.desc( "messageDate" ) );
+ //TODO eager-fetch message
return criteria.list();
}
=== 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-03-31 11:45:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/Message.hbm.xml 2011-03-31 15:54:20 +0000
@@ -13,8 +13,11 @@
</id>
<property name="key" column="key" not-null="true"/>
- <property name="title" column="title" not-null="true"/>
+ <property name="subject" column="subject" not-null="true"/>
<property name="text" column="text"/>
+
+ <many-to-one name="sender" class="org.hisp.dhis.user.User"
+ column="userid" foreign-key="fk_message_user" not-null="true"/>
<set name="userMessages" table="message_usermessages" cascade="save-update">
<key column="messageid"/>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/UserMessage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/UserMessage.hbm.xml 2011-03-31 11:45:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/UserMessage.hbm.xml 2011-03-31 15:54:20 +0000
@@ -12,15 +12,15 @@
<generator class="native"/>
</id>
- <property name="read" column="read" not-null="true"/>
- <property name="messageDate" column="messageDate" not-null="true"/>
-
<many-to-one name="user" class="org.hisp.dhis.user.User"
column="userid" foreign-key="fk_usermessage_user" not-null="true"/>
+ <property name="read" column="read" not-null="true"/>
+ <property name="messageDate" column="messageDate" not-null="true"/>
+
<join table="message_usermessages" inverse="true">
<key column="usermessageid"/>
- <many-to-one column="messageid" name="message"/>
+ <many-to-one column="messageid" name="message" not-null="true"/>
</join>
</class>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MessageServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MessageServiceTest.java 2011-03-31 11:45:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MessageServiceTest.java 2011-03-31 15:54:20 +0000
@@ -42,6 +42,7 @@
public class MessageServiceTest
extends DhisSpringTest
{
+ private User sender;
private User userA;
private User userB;
@@ -63,14 +64,16 @@
userService = (UserService) getBean( UserService.ID );
messageService = (MessageService) getBean( MessageService.ID );
+ sender = createUser( 'S');
userA = createUser( 'A' );
userB = createUser( 'B' );
-
+
+ userService.addUser( sender );
userService.addUser( userA );
userService.addUser( userB );
- messageA = new Message( "TitleA", "TextA" );
- messageB = new Message( "TitleB", "TextB" );
+ messageA = new Message( "SubjectA", "TextA", sender );
+ messageB = new Message( "SubjectB", "TextB", sender );
userMessageA = new UserMessage( userA, messageA );
userMessageB = new UserMessage( userB, messageA );
@@ -91,7 +94,7 @@
messageA = messageService.getMessage( idA );
assertNotNull( messageA );
- assertEquals( "TitleA", messageA.getTitle() );
+ assertEquals( "SubjectA", messageA.getSubject() );
assertEquals( "TextA", messageA.getText() );
assertEquals( 2, messageA.getUserMessages().size() );
assertTrue( messageA.getUserMessages().contains( userMessageA ) );
=== added directory 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message'
=== added directory 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action'
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessagesAction.java 2011-03-31 15:54:20 +0000
@@ -0,0 +1,35 @@
+package org.hisp.dhis.dashboard.message.action;
+
+import java.util.List;
+
+import org.hisp.dhis.message.MessageService;
+import org.hisp.dhis.message.UserMessage;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetMessagesAction
+ implements Action
+{
+ private MessageService messageService;
+
+ public void setMessageService( MessageService messageService )
+ {
+ this.messageService = messageService;
+ }
+
+ private List<UserMessage> messages;
+
+ public List<UserMessage> getMessages()
+ {
+ return messages;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ messages = messageService.getUserMessages( 1, 1000 );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml 2011-03-24 02:10:56 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml 2011-03-31 15:54:20 +0000
@@ -4,7 +4,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
- <!-- Actions -->
+ <!-- Dashboard -->
<bean id="org.hisp.dhis.dashboard.action.ProvideContentAction"
class="org.hisp.dhis.dashboard.action.ProvideContentAction"
@@ -71,4 +71,12 @@
<property name="mappingService" ref="org.hisp.dhis.mapping.MappingService"/>
</bean>
+ <!-- Message -->
+
+ <bean id="org.hisp.dhis.dashboard.message.action.GetMessagesAction"
+ class="org.hisp.dhis.dashboard.message.action.GetMessagesAction"
+ scope="prototype">
+ <property name="messageService" ref="org.hisp.dhis.message.MessageService"/>
+ </bean>
+
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2011-01-21 16:22:50 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2011-03-31 15:54:20 +0000
@@ -13,4 +13,11 @@
map_view = Map views
this_is_a_link_area = This is a link area
-this_is_a_chart_area = This is a chart area
\ No newline at end of file
+this_is_a_chart_area = This is a chart area
+
+messages = Messages
+sender = Sender
+date = Date
+subject = Subject
+remove = Remove
+new_message = New message
\ No newline at end of file
=== 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 2011-01-21 16:22:50 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml 2011-03-31 15:54:20 +0000
@@ -8,6 +8,8 @@
<package name="dhis-web-dashboard-integration" extends="dhis-web-commons" namespace="/dhis-web-dashboard-integration">
+ <!-- Dashboard -->
+
<action name="index" class="org.hisp.dhis.dashboard.action.ProvideContentAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-dashboard-integration/mainForm.vm</param>
@@ -53,5 +55,13 @@
<result name="success" type="redirect">index.action</result>
</action>
+ <!-- Message -->
+
+ <action name="message" class="org.hisp.dhis.dashboard.message.action.GetMessagesAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-dashboard-integration/message.vm</param>
+ <param name="menu">/dhis-web-commons/about/menu.vm</param>
+ </action>
+
</package>
</struts>
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm 2011-03-31 15:54:20 +0000
@@ -0,0 +1,21 @@
+
+<h3>$i18n.getString( "messages" )</h3>
+
+<div style="margin-bottom:15px"><input type="button" value="$i18n.getString( 'new_message' )"></div>
+
+<table class="listTable" style="width:75%">
+ <tr>
+ <th>$i18n.getString( "sender" )</th>
+ <th>$i18n.getString( "date" )</th>
+ <th>$i18n.getString( "subject" )</th>
+ <th></th>
+ </tr>
+ #foreach( $message in $messages )
+ <tr>
+ <td>$encoder.htmlEncode( $message.message.sender )</td>
+ <td>$encoder.htmlEncode( $message.message.messageDate )</td>
+ <td>$encoder.htmlEncode( $message.message.subject )</td>
+ <td><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/>
+ </tr>
+ #end
+</table>
\ No newline at end of file