dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16866
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6535: Data mart, clearing notifications on new task
------------------------------------------------------------
revno: 6535
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-04-10 21:37:24 +0200
message:
Data mart, clearing notifications on new task
modified:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
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/Notifier.java
--
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-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2012-02-14 12:53:25 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2012-04-10 19:37:24 +0000
@@ -204,7 +204,7 @@
final int cpuCores = SystemUtils.getCpuCores();
Clock clock = new Clock().startClock().logTime( "Data mart export process started, number of CPU cores: " + cpuCores + ", " + SystemUtils.getMemoryString() );
- notifier.notify( DATAMART, "Process started" );
+ notifier.clear( DATAMART ).notify( DATAMART, "Process started" );
// ---------------------------------------------------------------------
// Replace null with empty collection
=== 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-02-14 12:53:25 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/InMemoryNotifier.java 2012-04-10 19:37:24 +0000
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import javax.annotation.PostConstruct;
@@ -54,13 +55,13 @@
// -------------------------------------------------------------------------
@Override
- public void notify( NotificationCategory category, String message )
+ public Notifier notify( NotificationCategory category, String message )
{
- notify( NotificationLevel.INFO, category, message, false );
+ return notify( NotificationLevel.INFO, category, message, false );
}
@Override
- public void notify( NotificationLevel level, NotificationCategory category, String message, boolean completed )
+ public Notifier notify( NotificationLevel level, NotificationCategory category, String message, boolean completed )
{
Notification notification = new Notification( level, category, new Date(), message, completed );
@@ -70,6 +71,8 @@
{
notifications.remove( MAX_SIZE );
}
+
+ return this;
}
@Override
@@ -85,19 +88,41 @@
{
List<Notification> list = new ArrayList<Notification>();
- for ( Notification notification : notifications )
+ if ( category != null && max > 0 )
{
- if ( list.size() == max )
+ for ( Notification notification : notifications )
{
- break;
+ if ( list.size() == max )
+ {
+ break;
+ }
+
+ if ( category.equals( notification.getCategory() ) )
+ {
+ list.add( notification );
+ }
}
+ }
+
+ return list;
+ }
+
+ @Override
+ public Notifier clear( NotificationCategory category )
+ {
+ if ( category != null )
+ {
+ Iterator<Notification> iter = notifications.iterator();
- if ( category.equals( notification.getCategory() ) )
+ while ( iter.hasNext() )
{
- list.add( notification );
+ if ( category.equals( iter.next() ) )
+ {
+ iter.remove();
+ }
}
}
- return list;
+ return this;
}
}
=== 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-02-14 12:53:25 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/notification/Notifier.java 2012-04-10 19:37:24 +0000
@@ -34,11 +34,13 @@
*/
public interface Notifier
{
- void notify( NotificationCategory category, String message );
+ Notifier notify( NotificationCategory category, String message );
- void notify( NotificationLevel level, NotificationCategory category, String message, boolean completed );
+ Notifier notify( NotificationLevel level, NotificationCategory category, String message, boolean completed );
List<Notification> getNotifications( int max );
List<Notification> getNotifications( NotificationCategory category, int max );
+
+ Notifier clear( NotificationCategory category );
}