← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2595: Map views with start-end dates removed from dashboard when aggregation strategy = batch.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2595 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-01-17 14:39:16 +0100
message:
  Map views with start-end dates removed from dashboard when aggregation strategy = batch.
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.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-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java	2011-01-17 13:36:43 +0000
@@ -27,6 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.options.SystemSettingManager.AGGREGATION_STRATEGY_BATCH;
+import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_AGGREGATION_STRATEGY;
+import static org.hisp.dhis.options.SystemSettingManager.KEY_AGGREGATION_STRATEGY;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -36,6 +40,9 @@
 import org.hisp.dhis.dashboard.DashboardService;
 import org.hisp.dhis.mapping.MapView;
 import org.hisp.dhis.mapping.comparator.MapViewNameComparator;
+import org.hisp.dhis.options.SystemSettingManager;
+import org.hisp.dhis.system.filter.MapViewFixedDateTypeFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 
@@ -63,9 +70,16 @@
     {
         this.dashboardService = dashboardService;
     }
-    
+
+    private SystemSettingManager systemSettingManager;
+
+    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+    {
+        this.systemSettingManager = systemSettingManager;
+    }
+
     private String key;
-    
+
     public void setKey( String key )
     {
         this.key = key;
@@ -80,18 +94,26 @@
         Map<String, Object> content = new HashMap<String, Object>();
 
         User user = currentUserService.getCurrentUser();
-        
+
         if ( user != null )
         {
             DashboardContent dashboardContent = dashboardService.getDashboardContent( user );
-            
+
             List<MapView> mapViews = dashboardContent.getMapViews();
-            
+
+            String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY,
+                DEFAULT_AGGREGATION_STRATEGY );
+
+            if ( aggregationStrategy.equals( AGGREGATION_STRATEGY_BATCH ) )
+            {
+                FilterUtils.filter( mapViews, new MapViewFixedDateTypeFilter() );
+            }
+
             Collections.sort( mapViews, new MapViewNameComparator() );
-            
+
             content.put( key, mapViews );
         }
-        
+
         return content;
     }
 }

=== 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	2010-05-17 14:19:14 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml	2011-01-17 13:36:43 +0000
@@ -40,6 +40,7 @@
     class="org.hisp.dhis.dashboard.provider.MapViewContentProvider">
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
     <property name="dashboardService" ref="org.hisp.dhis.dashboard.DashboardService"/>
+    <property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
     <property name="key" value="mapViews"/>
   </bean>