=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java 2012-04-10 19:37:24 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java 2012-04-10 20:15:18 +0000 @@ -76,19 +76,11 @@ } @Override - public List getNotifications( int max ) - { - max = max > notifications.size() ? notifications.size() : max; - - return notifications.subList( 0, max ); - } - - @Override public List getNotifications( NotificationCategory category, int max ) { List list = new ArrayList(); - if ( category != null && max > 0 ) + if ( category != null ) { for ( Notification notification : notifications ) { @@ -106,6 +98,30 @@ return list; } + + @Override + public List getNotifications( NotificationCategory category, String lastUid ) + { + List list = new ArrayList(); + + if ( category != null ) + { + for ( Notification notification : notifications ) + { + if ( lastUid != null && lastUid.equals( notification.getUid() ) ) + { + break; + } + + if ( category.equals( notification.getCategory() ) ) + { + list.add( notification ); + } + } + } + + return list; + } @Override public Notifier clear( NotificationCategory category ) === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java 2012-04-10 19:37:24 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java 2012-04-10 20:15:18 +0000 @@ -38,9 +38,9 @@ Notifier notify( NotificationLevel level, NotificationCategory category, String message, boolean completed ); - List getNotifications( int max ); - List getNotifications( NotificationCategory category, int max ); + List getNotifications( NotificationCategory category, String lastUid ); + Notifier clear( NotificationCategory category ); } === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm 2012-01-22 11:28:12 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroups.vm 2012-04-10 20:15:18 +0000 @@ -2,7 +2,7 @@ { "dataElementGroups": [ #foreach( $dataElementGroup in $dataElementGroups ) { - "id": ${dataElementGroup.id} , + "id": ${dataElementGroup.id} , "name": "$!encoder.jsonEncode( ${dataElementGroup.displayName} )" }#if( $velocityCount < $size ),#end #end === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonNotifications.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonNotifications.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonNotifications.vm 2012-04-10 20:15:18 +0000 @@ -0,0 +1,13 @@ +#set( $size = $notifications.size() ) +{ "notifications": [ +#foreach( $notification in $notifications ) + { + "uid": "${notification.uid}", + "level": "${notification.level}", + "category": "${notification.category}", + "time": "${format.formatDate( $notification.time )}", + "message": "${notification.message}", + "completed": "${notification.completed}" + }#if( $velocityCount < $size ),#end +#end +] } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java 2012-02-12 19:23:31 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java 2012-04-10 20:15:18 +0000 @@ -64,6 +64,13 @@ this.category = category; } + private String lastUid; + + public void setLastUid( String lastUid ) + { + this.lastUid = lastUid; + } + private Integer max; public void setMax( Integer max ) @@ -90,17 +97,18 @@ public String execute() throws Exception { - max = max != null ? max : 20; - if ( category != null ) { NotificationCategory notificationCategory = NotificationCategory.valueOf( category.toUpperCase() ); - - notifications = notifier.getNotifications( notificationCategory, max ); - } - else - { - notifications = notifier.getNotifications( max ); + + if ( max != null ) + { + notifications = notifier.getNotifications( notificationCategory, max ); + } + else + { + notifications = notifier.getNotifications( notificationCategory, lastUid ); + } } return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-04-05 13:13:13 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-04-10 20:15:18 +0000 @@ -318,11 +318,6 @@ - - /dhis-web-commons/ajax/htmlNotifications.vm - plainTextError - - /dhis-web-commons/ajax/xmlCategoryOptionCombos.vm @@ -462,6 +457,11 @@ + + /dhis-web-commons/ajax/htmlNotifications.vm + plainTextError + + /dhis-web-commons/ajax/htmlUser.vm @@ -474,6 +474,11 @@ + + + /dhis-web-commons/ajax/jsonNotifications.vm + plainTextError + === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js 2012-02-12 19:23:31 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataMart.js 2012-04-10 20:15:18 +0000 @@ -20,7 +20,7 @@ function pingNotifications() { - $( '#notificationDiv' ).load( '../dhis-web-commons-ajax/getNotifications.action?category=DATAMART' ); + $( '#notificationDiv' ).load( '../dhis-web-commons-ajax-html/getNotifications.action?category=DATAMART&max=20' ); } function pingNotificationsTimeout()