dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09471
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2518: (GIS) Start-end dates not allowed when aggregation strategy is set to 'batch'.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2518 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-01-11 12:04:08 +0100
message:
(GIS) Start-end dates not allowed when aggregation strategy is set to 'batch'.
added:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/MapViewFixedDateTypeFilter.java
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesAction.java
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.java
dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
--
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
=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/MapViewFixedDateTypeFilter.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/MapViewFixedDateTypeFilter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/MapViewFixedDateTypeFilter.java 2011-01-11 09:59:19 +0000
@@ -0,0 +1,45 @@
+package org.hisp.dhis.system.filter;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.mapping.MapView;
+import org.hisp.dhis.mapping.MappingService;
+import org.hisp.dhis.system.util.Filter;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public class MapViewFixedDateTypeFilter
+ implements Filter<MapView>
+{
+ @Override
+ public boolean retain( MapView object )
+ {
+ return object != null && object.getMapDateType().equals( MappingService.MAP_DATE_TYPE_FIXED );
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesAction.java 2011-01-10 14:35:40 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesAction.java 2011-01-11 10:12:49 +0000
@@ -127,7 +127,12 @@
public String execute()
throws Exception
{
- Period period = periodService.getPeriod( periodId );
+ Period period = null;
+
+ if ( periodId != null )
+ {
+ period = periodService.getPeriod( periodId );
+ }
object = mappingService.getIndicatorMapValues( id, period, DateUtils.getMediumDate( startDate ), DateUtils
.getMediumDate( endDate ), parentId, level );
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.java 2010-11-29 16:36:25 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapViewsByFeatureTypeAction.java 2011-01-11 09:59:19 +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.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -34,6 +38,9 @@
import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.mapping.MappingService;
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 com.opensymphony.xwork2.Action;
@@ -55,6 +62,13 @@
this.mappingService = mappingService;
}
+ private SystemSettingManager systemSettingManager;
+
+ public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+ {
+ this.systemSettingManager = systemSettingManager;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -85,6 +99,14 @@
{
object = new ArrayList<MapView>( mappingService.getMapViewsByFeatureType( featureType ) );
+ String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY,
+ DEFAULT_AGGREGATION_STRATEGY );
+
+ if ( aggregationStrategy.equals( AGGREGATION_STRATEGY_BATCH ) )
+ {
+ FilterUtils.filter( object, new MapViewFixedDateTypeFilter() );
+ }
+
Collections.sort( object, new MapViewNameComparator() );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2011-01-10 16:07:53 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2011-01-11 09:59:19 +0000
@@ -181,6 +181,7 @@
<bean id="org.hisp.dhis.mapping.action.GetMapViewsByFeatureTypeAction"
class="org.hisp.dhis.mapping.action.GetMapViewsByFeatureTypeAction" scope="prototype">
<property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+ <property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
</bean>
<bean id="org.hisp.dhis.mapping.action.AddMapViewToDashboardAction"
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-01-07 10:58:35 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-01-11 10:41:42 +0000
@@ -55,6 +55,8 @@
map_feature_type_multipolygon: 'MultiPolygon',
map_feature_type_polygon: 'Polygon',
map_feature_type_point: 'Point',
+ aggregation_strategy_real_time: 'real_time',
+ aggregation_strategy_batch: 'batch',
// MapFish
@@ -350,11 +352,15 @@
exportValues: null,
- topLevelUnit: null,
-
- user: {
- isAdmin: false
- }
+ topLevelUnit: null
+};
+
+G.user = {
+ isAdmin: false
+};
+
+G.system = {
+ aggregationStrategy: null
};
G.func = {
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-01-10 14:35:40 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-01-11 11:00:36 +0000
@@ -17,8 +17,10 @@
G.vars.parameter.mapView = init.mapView;
G.vars.parameter.baseLayers = init.baseLayers;
G.vars.parameter.overlays = init.overlays;
- G.vars.mapDateType.value = init.userSettings.mapDateType;
- G.vars.user.isAdmin = init.security.isAdmin;
+ G.user.isAdmin = init.security.isAdmin;
+ G.system.aggregationStrategy = init.systemSettings.aggregationStrategy;
+ G.vars.mapDateType.value = G.system.aggregationStrategy == G.conf.aggregation_strategy_batch ?
+ G.conf.map_date_type_fixed : init.userSettings.mapDateType;
/* Section: stores */
var mapViewStore = new Ext.data.JsonStore({
@@ -589,7 +591,7 @@
Ext.Ajax.request({
url: G.conf.path_mapping + 'addMapViewToDashboard' + G.conf.type,
method: 'POST',
- params: {id:v},
+ params: {id: v},
success: function(r) {
Ext.message.msg(true, G.i18n.favorite + ' <span class="x-msg-hl">' + rv + '</span> ' + G.i18n.added_to_dashboard);
Ext.getCmp('favorite_cb').clearValue();
@@ -1838,6 +1840,7 @@
id: 'mapdatetype_cb',
fieldLabel: G.i18n.date_type,
labelSeparator: G.conf.labelseparator,
+ disabled: G.system.aggregationStrategy == G.conf.aggregation_strategy_batch,
editable: false,
valueField: 'value',
displayField: 'text',
@@ -1863,7 +1866,7 @@
method: 'POST',
params: {mapDateType: G.vars.mapDateType.value},
success: function() {
- Ext.message.msg(true, '<span class="x-msg-hl">' + cb.getRawValue() + '</span> '+G.i18n.saved_as_date_type);
+ Ext.message.msg(true, '<span class="x-msg-hl">' + cb.getRawValue() + '</span> '+ G.i18n.saved_as_date_type);
choropleth.prepareMapViewDateType();
symbol.prepareMapViewDateType();
}
@@ -1873,7 +1876,7 @@
}
}
]
- }
+ }
]
});
@@ -2299,7 +2302,7 @@
var favoritesButton = new Ext.Button({
iconCls: 'icon-favorite',
tooltip: G.i18n.favorite_map_views,
- disabled: !G.vars.user.isAdmin,
+ disabled: !G.user.isAdmin,
handler: function() {
var x = Ext.getCmp('center').x + 15;
var y = Ext.getCmp('center').y + 41;
@@ -2353,7 +2356,7 @@
var predefinedMapLegendSetButton = new Ext.Button({
iconCls: 'icon-predefinedlegendset',
tooltip: G.i18n.create_predefined_legend_sets,
- disabled: !G.vars.user.isAdmin,
+ disabled: !G.user.isAdmin,
handler: function() {
var x = Ext.getCmp('center').x + 15;
var y = Ext.getCmp('center').y + 41;
@@ -2374,7 +2377,7 @@
var adminButton = new Ext.Button({
iconCls: 'icon-admin',
tooltip: 'Administrator settings',
- disabled: !G.vars.user.isAdmin,
+ disabled: !G.user.isAdmin,
handler: function() {
var x = Ext.getCmp('center').x + 15;
var y = Ext.getCmp('center').y + 41;