dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17635
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7088: Impl new interpretation notification in dashboard
------------------------------------------------------------
revno: 7088
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-05-29 23:23:47 +0200
message:
Impl new interpretation notification in dashboard
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.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/webapp/dhis-web-dashboard-integration/javascript/interpretation.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.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/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2012-05-28 22:32:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2012-05-29 21:23:47 +0000
@@ -108,10 +108,18 @@
List<T> getByUid( Collection<String> uids );
/**
- * Returns all objects that are equal to or newer than given date
- *
- * @param lastUpdated Date to compare to
- * @return All objects equal or newer than given date
- */
- List<T> getByLastUpdated(Date lastUpdated);
+ * Returns all objects that are equal to or newer than given date.
+ *
+ * @param lastUpdated Date to compare to.
+ * @return All objects equal or newer than given date.
+ */
+ List<T> getByLastUpdated( Date lastUpdated );
+
+ /**
+ * Returns the number of objects that are equal to or newer than given date.
+ *
+ * @param lastUpdated Date to compare to.
+ * @return the number of objects equal or newer than given date.
+ */
+ long getCountByLastUpdated( Date lastUpdated );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java 2012-05-29 19:08:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java 2012-05-29 21:23:47 +0000
@@ -45,4 +45,8 @@
List<Interpretation> getInterpretations( int first, int max );
void addInterpretationComment( String uid, String text );
+
+ void updateCurrentUserLastChecked();
+
+ long getNewInterpretationCount();
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-05-29 12:04:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-05-29 21:23:47 +0000
@@ -45,6 +45,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import java.util.Collection;
+import java.util.Date;
import java.util.HashSet;
import java.util.Set;
@@ -73,6 +74,8 @@
private String email;
private String phoneNumber;
+
+ private Date lastCheckedInterpretations;
private UserCredentials userCredentials;
@@ -315,6 +318,16 @@
this.phoneNumber = phoneNumber;
}
+ public Date getLastCheckedInterpretations()
+ {
+ return lastCheckedInterpretations;
+ }
+
+ public void setLastCheckedInterpretations( Date lastCheckedInterpretations )
+ {
+ this.lastCheckedInterpretations = lastCheckedInterpretations;
+ }
+
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2012-02-05 13:27:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2012-05-29 21:23:47 +0000
@@ -43,7 +43,6 @@
/**
* @author Kristian Nordal
- * @version $Id: HibernateDataSetStore.java 3303 2007-05-14 13:39:34Z larshelg $
*/
public class HibernateDataSetStore
extends HibernateIdentifiableObjectStore<DataSet>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2012-03-13 07:30:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2012-05-29 21:23:47 +0000
@@ -26,6 +26,8 @@
<property name="phoneNumber" length="80" />
+ <property name="lastCheckedInterpretations" type="timestamp" />
+
<one-to-one name="userCredentials" class="org.hisp.dhis.user.UserCredentials" foreign-key="fk_userinfo_userid" />
<set name="organisationUnits" table="usermembership">
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java 2012-05-29 19:08:34 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java 2012-05-29 21:23:47 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.interpretation.InterpretationService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserService;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -63,6 +64,13 @@
{
this.currentUserService = currentUserService;
}
+
+ private UserService userService;
+
+ public void setUserService( UserService userService )
+ {
+ this.userService = userService;
+ }
// -------------------------------------------------------------------------
// InterpretationService implementation
@@ -119,4 +127,31 @@
interpretationStore.update( interpretation );
}
+
+ public void updateCurrentUserLastChecked()
+ {
+ User user = currentUserService.getCurrentUser();
+
+ user.setLastCheckedInterpretations( new Date() );
+
+ userService.updateUser( user );
+ }
+
+ public long getNewInterpretationCount()
+ {
+ User user = currentUserService.getCurrentUser();
+
+ long count = 0;
+
+ if ( user != null && user.getLastCheckedInterpretations() != null )
+ {
+ count = interpretationStore.getCountByLastUpdated( user.getLastCheckedInterpretations() );
+ }
+ else
+ {
+ count = interpretationStore.getCount();
+ }
+
+ return count;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-05-29 12:04:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-05-29 21:23:47 +0000
@@ -252,7 +252,8 @@
<bean id="org.hisp.dhis.interpretation.InterpretationService" class="org.hisp.dhis.interpretation.impl.DefaultInterpretationService">
<property name="interpretationStore" ref="org.hisp.dhis.interpretation.InterpretationStore" />
- <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="userService" ref="org.hisp.dhis.user.UserService" />
</bean>
<bean id="org.hisp.dhis.interpretation.InterpretationStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java 2012-05-29 19:08:34 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java 2012-05-29 21:23:47 +0000
@@ -155,4 +155,16 @@
assertNotNull( interpretationA.getComments() );
assertEquals( 2, interpretationA.getComments().size() );
}
+
+ @Test
+ public void testGetNewCount()
+ {
+ interpretationService.saveInterpretation( interpretationA );
+ interpretationService.saveInterpretation( interpretationB );
+ interpretationService.saveInterpretation( interpretationC );
+
+ long count = interpretationService.getNewInterpretationCount();
+
+ assertEquals( 3, count );
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2012-05-28 22:32:37 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2012-05-29 21:23:47 +0000
@@ -353,4 +353,12 @@
{
return getCriteria().add( Restrictions.ge( "lastUpdated", lastUpdated ) ).list();
}
+
+ @Override
+ public long getCountByLastUpdated( Date lastUpdated )
+ {
+ Object count = getCriteria().add( Restrictions.ge( "lastUpdated", lastUpdated ) ).setProjection( Projections.rowCount() ).list().get( 0 );
+
+ return count != null ? (Long) count : -1;
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2012-05-05 16:46:31 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2012-05-29 21:23:47 +0000
@@ -68,21 +68,20 @@
}
/**
- * Formats a Date to the IXF date format which is YYYY-MM-DD'T'HH:MM:SS.
+ * Formats a Date to the format yyyy-MM-dd HH:mm:ss.
*
* @param date the Date to parse.
* @return A formatted date string.
*/
public static String getLongDateString( Date date )
{
- final SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" );
+ final SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
return date != null ? format.format( date ) : null;
}
/**
- * Formats the current Date to the IXF date format which is
- * YYYY-MM-DD'T'HH:MM:SS.
+ * Formats a Date to the format yyyy-MM-dd HH:mm:ss.
*
* @return A formatted date string.
*/
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java 2012-03-05 10:43:47 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/ProvideContentAction.java 2012-05-29 21:23:47 +0000
@@ -40,6 +40,7 @@
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dashboard.DashboardManager;
+import org.hisp.dhis.interpretation.InterpretationService;
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.user.UserSettingService;
@@ -84,6 +85,13 @@
{
this.messageService = messageService;
}
+
+ private InterpretationService interpretationService;
+
+ public void setInterpretationService( InterpretationService interpretationService )
+ {
+ this.interpretationService = interpretationService;
+ }
// -------------------------------------------------------------------------
// Output
@@ -116,6 +124,13 @@
{
return messageCount;
}
+
+ private long interpretationCount;
+
+ public long getInterpretationCount()
+ {
+ return interpretationCount;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -150,6 +165,8 @@
}
messageCount = messageService.getUnreadMessageConversationCount();
+
+ interpretationCount = interpretationService.getNewInterpretationCount();
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java 2012-05-29 19:08:34 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/interpretation/action/GetInterpretationsAction.java 2012-05-29 21:23:47 +0000
@@ -68,7 +68,9 @@
public String execute()
{
- interpretations = interpretationService.getInterpretations( 0, 10 );
+ interpretationService.updateCurrentUserLastChecked();
+
+ interpretations = interpretationService.getInterpretations( 0, 20 );
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 2012-05-29 12:04:07 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml 2012-05-29 21:23:47 +0000
@@ -11,6 +11,7 @@
<property name="userSettingService" ref="org.hisp.dhis.user.UserSettingService" />
<property name="chartService" ref="org.hisp.dhis.chart.ChartService" />
<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
+ <property name="interpretationService" ref="org.hisp.dhis.interpretation.InterpretationService" />
</bean>
<bean id="org.hisp.dhis.dashboard.action.SetAreaItemAction" class="org.hisp.dhis.dashboard.action.SetAreaItemAction"
=== 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 2012-05-29 19:44:34 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2012-05-29 21:23:47 +0000
@@ -38,4 +38,6 @@
interpretations=Interpretations
share_your_own_interpretations_from=Share your own interpretations from
data_visualizer=Data Visualizer
-add_a_comment=Add a comment
\ No newline at end of file
+add_a_comment=Add a comment
+new_interpretations=new interpretations
+new_interpretation=new interpretation
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-05-29 19:30:37 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-05-29 21:23:47 +0000
@@ -35,6 +35,8 @@
"<div class=\"interpretationText\">${text}<\/div>";
$.tmpl( template, { "userId": currentUser.id, "userName": currentUser.name, created: created, text: text } ).appendTo( "#comments" + uid );
+
+ $( "#commentArea" + uid ).val( "" );
}
} );
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm 2012-04-16 14:54:22 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm 2012-05-29 21:23:47 +0000
@@ -54,7 +54,9 @@
<h3>$i18n.getString( "dashboard" ) #openHelp( "dashboards_setup" )
• <a href="showSendFeedback.action">$i18n.getString( "write_feedback" )</a>
-#if( $messageCount > 0 )• <a href="message.action">$messageCount #if( $messageCount > 1 )$i18n.getString( "unread_messages" )#else$i18n.getString( "unread_message" )#end</a> #end</h3>
+#if( $messageCount > 0 )• <a href="message.action">$messageCount #if( $messageCount > 1 )$i18n.getString( "unread_messages" )#else$i18n.getString( "unread_message" )#end</a> #end
+#if( $interpretationCount > 0 )• <a href="interpretation.action">$interpretationCount #if( $interpretationCount > 1 )$i18n.getString( "new_interpretations" )#else$i18n.getString( "new_interpretation" )#end</a> #end
+</h3>
<table cellspacing="0" cellpadding="0" style="width:960px">
<tr>