=== 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 getByUid( Collection 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 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 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 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 === 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 @@ + + === 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 @@ - + + === 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 @@ + ${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 @@

$i18n.getString( "dashboard" ) #openHelp( "dashboards_setup" ) • $i18n.getString( "write_feedback" ) -#if( $messageCount > 0 )• $messageCount #if( $messageCount > 1 )$i18n.getString( "unread_messages" )#else$i18n.getString( "unread_message" )#end #end

+#if( $messageCount > 0 )• $messageCount #if( $messageCount > 1 )$i18n.getString( "unread_messages" )#else$i18n.getString( "unread_message" )#end #end +#if( $interpretationCount > 0 )• $interpretationCount #if( $interpretationCount > 1 )$i18n.getString( "new_interpretations" )#else$i18n.getString( "new_interpretation" )#end #end +