← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17581: New general setting: default relative period for analysis + PT DV updated.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 17581 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-25 13:42:44 +0100
message:
  New general setting: default relative period for analysis + PT DV updated.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm


--
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-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2014-11-24 18:14:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2014-11-25 12:35:16 +0000
@@ -103,7 +103,8 @@
     final String KEY_HELP_PAGE_LINK = "helpPageLink";
     final String KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL = "keyAcceptanceRequiredForApproval";
     final String KEY_SYSTEM_NOTIFICATIONS_EMAIL = "keySystemNotificationsEmail";
-
+    final String KEY_ANALYSIS_RELATIVE_PERIOD = "keyAnalysisRelativePeriod";
+    
     final String DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "lastMonth";
     final String DEFAULT_FLAG = "dhis2";
     final int DEFAULT_MAX_NUMBER_OF_ATTEMPTS = 20;
@@ -120,6 +121,7 @@
     final int DEFAULT_ANALYTICS_MAX_LIMIT = 50000;
     final int DEFAULT_DATABASE_SERVER_CPUS = 0; // Detect automatically
     final String DEFAULT_HELP_PAGE_LINK = "../dhis-web-commons-about/help.action";
+    final String DEFAULT_ANALYSIS_RELATIVE_PERIOD = "LAST_12_MONTHS";
 	
     final Map<String, Serializable> DEFAULT_SETTINGS_VALUES = new HashMap<String, Serializable>()
     {
@@ -136,6 +138,7 @@
             put( KEY_TIME_FOR_SENDING_MESSAGE, DEFAULT_TIME_FOR_SENDING_MESSAGE );
             put( KEY_CACHE_STRATEGY, DEFAULT_CACHE_STRATEGY );
             put( KEY_ANALYTICS_MAX_LIMIT, DEFAULT_ANALYTICS_MAX_LIMIT );
+            put( KEY_ANALYSIS_RELATIVE_PERIOD, DEFAULT_ANALYSIS_RELATIVE_PERIOD );
         }
     };
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2014-11-17 15:08:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2014-11-25 12:35:16 +0000
@@ -208,6 +208,33 @@
 user_has_critical_authorities=User has critical authorities
 default=Default
 
+#-- Relative periods -----------------------------------------------------------#
+
+LAST_MONTH=Last month
+LAST_BIMONTH=Last bi-month
+LAST_QUARTER=Last quarter
+LAST_SIX_MONTH=Last six-month
+MONTHS_THIS_YEAR=Months this year
+QUARTERS_THIS_YEAR=Quarters this year
+THIS_YEAR=This year
+MONTHS_LAST_YEAR=Months last year
+QUARTERS_LAST_YEAR=Quarters last year
+LAST_YEAR=Last year
+LAST_5_YEARS=Last 5 years
+LAST_12_MONTHS=Last 12 months
+LAST_6_MONTHS=Last 6 months
+LAST_3_MONTHS=Last 3 months
+LAST_6_BIMONTHS=Last 6 bi-months
+LAST_4_QUARTERS=Last 4 quarters
+LAST_2_SIXMONTHS=Last 2 six-months
+THIS_FINANCIAL_YEAR=This financial year
+LAST_FINANCIAL_YEAR=Last financial year
+LAST_5_FINANCIAL_YEARS=Last 5 financial years
+LAST_WEEK=Last week
+LAST_4_WEEKS=Last 4 weeks
+LAST_12_WEEKS=Last 12 weeks
+LAST_52_WEEKS=Last 52 weeks
+
 #-- PeriodTypes ----------------------------------------------------------------#
 
 Daily=Daily

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2014-11-20 16:15:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2014-11-25 12:35:16 +0000
@@ -3947,6 +3947,10 @@
                     if (chb.xtype === 'checkbox') {
                         period.checkboxes.push(chb);
                         relativePeriod.valueComponentMap[chb.relativePeriodId] = chb;
+                        
+                        if (chb.relativePeriodId === ns.core.init.systemInfo.analysisRelativePeriod) {
+                            chb.setValue(true);
+                        }
                     }
                 }
             }
@@ -4026,8 +4030,7 @@
 								{
 									xtype: 'checkbox',
 									relativePeriodId: 'LAST_12_MONTHS',
-									boxLabel: NS.i18n.last_12_months,
-									checked: true
+									boxLabel: NS.i18n.last_12_months
 								}
 							]
 						},
@@ -6388,11 +6391,12 @@
 
                         // date, calendar
                         Ext.Ajax.request({
-                            url: init.contextPath + '/api/systemSettings.json?key=keyCalendar&key=keyDateFormat',
+                            url: init.contextPath + '/api/systemSettings.json?key=keyCalendar&key=keyDateFormat&key=keyAnalysisRelativePeriod',
                             success: function(r) {
                                 var systemSettings = Ext.decode(r.responseText);
                                 init.systemInfo.dateFormat = Ext.isString(systemSettings.keyDateFormat) ? systemSettings.keyDateFormat.toLowerCase() : 'yyyy-mm-dd';
                                 init.systemInfo.calendar = systemSettings.keyCalendar;
+                                init.systemInfo.analysisRelativePeriod = systemSettings.keyAnalysisRelativePeriod || 'LAST_12_MONTHS';
 
                                 // user-account
                                 Ext.Ajax.request({

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js	2014-11-20 16:15:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js	2014-11-25 12:35:16 +0000
@@ -4024,6 +4024,10 @@
                         period.checkboxes.push(chb);
                         relativePeriod.valueComponentMap[chb.relativePeriodId] = chb;
                     }
+                        
+                    if (chb.relativePeriodId === ns.core.init.systemInfo.analysisRelativePeriod) {
+                        chb.setValue(true);
+                    }
                 }
             }
         };
@@ -4102,8 +4106,7 @@
 								{
 									xtype: 'checkbox',
 									relativePeriodId: 'LAST_12_MONTHS',
-									boxLabel: NS.i18n.last_12_months,
-									checked: true
+									boxLabel: NS.i18n.last_12_months
 								}
 							]
 						},
@@ -6334,11 +6337,12 @@
 
                         // date, calendar
                         Ext.Ajax.request({
-                            url: init.contextPath + '/api/systemSettings.json?key=keyCalendar&key=keyDateFormat',
+                            url: init.contextPath + '/api/systemSettings.json?key=keyCalendar&key=keyDateFormat&key=keyAnalysisRelativePeriod',
                             success: function(r) {
                                 var systemSettings = Ext.decode(r.responseText);
                                 init.systemInfo.dateFormat = Ext.isString(systemSettings.keyDateFormat) ? systemSettings.keyDateFormat.toLowerCase() : 'yyyy-mm-dd';
                                 init.systemInfo.calendar = systemSettings.keyCalendar;
+                                init.systemInfo.analysisRelativePeriod = systemSettings.keyAnalysisRelativePeriod || 'LAST_12_MONTHS';
 
                                 // user-account
                                 Ext.Ajax.request({

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2014-11-24 18:14:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2014-11-25 12:35:16 +0000
@@ -98,6 +98,7 @@
         map.put( DATE_FORMAT, calendarService.getSystemDateFormat() );
         map.put( KEY_CACHE_STRATEGY, systemSettingManager.getSystemSetting( KEY_CACHE_STRATEGY, DEFAULT_CACHE_STRATEGY ) );
         map.put( KEY_ANALYTICS_MAX_LIMIT, systemSettingManager.getSystemSetting( KEY_ANALYTICS_MAX_LIMIT, DEFAULT_ANALYTICS_MAX_LIMIT ) );
+        map.put( KEY_ANALYSIS_RELATIVE_PERIOD, systemSettingManager.getSystemSetting( KEY_ANALYSIS_RELATIVE_PERIOD, DEFAULT_ANALYSIS_RELATIVE_PERIOD ) );
         map.put( KEY_APPLICATION_TITLE, systemSettingManager.getSystemSetting( KEY_APPLICATION_TITLE, DEFAULT_APPLICATION_TITLE ) );
         map.put( KEY_APPLICATION_INTRO, systemSettingManager.getSystemSetting( KEY_APPLICATION_INTRO ) );
         map.put( KEY_APPLICATION_NOTIFICATION, systemSettingManager.getSystemSetting( KEY_APPLICATION_NOTIFICATION ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java	2014-11-25 12:35:16 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
 import org.hisp.dhis.user.comparator.UserGroupComparator;
+import org.hisp.dhis.period.RelativePeriodEnum;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -158,6 +159,13 @@
     {
         return configuration;
     }
+    
+    private List<String> relativePeriods;
+    
+    public List<String> getRelativePeriods()
+    {
+        return relativePeriods;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -192,7 +200,9 @@
         organisationUnitLevels = organisationUnitService.getOrganisationUnitLevels();
 
         Collections.sort( organisationUnitLevels, OrganisationUnitLevelComparator.INSTANCE );
-
+        
+        relativePeriods = new ArrayList<>( RelativePeriodEnum.OPTIONS );
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2014-11-18 12:55:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2014-11-25 12:39:54 +0000
@@ -39,6 +39,7 @@
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART;
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE;
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_SYSTEM_NOTIFICATIONS_EMAIL;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_ANALYSIS_RELATIVE_PERIOD;
 
 import org.apache.commons.lang3.StringUtils;
 import org.hisp.dhis.configuration.Configuration;
@@ -143,6 +144,13 @@
     {
         this.infrastructuralPeriodType = infrastructuralPeriodType;
     }
+    
+    private String analysisRelativePeriod;
+    
+    public void setAnalysisRelativePeriod( String analysisRelativePeriod )
+    {
+        this.analysisRelativePeriod = analysisRelativePeriod;
+    }
 
     private Boolean omitIndicatorsZeroNumeratorDataMart;
 
@@ -234,7 +242,7 @@
 
     @Override
     public String execute()
-    {
+    { 
         systemSettingManager.saveSystemSetting( KEY_CACHE_STRATEGY, cacheStrategy );
         systemSettingManager.saveSystemSetting( KEY_ANALYTICS_MAX_LIMIT, analyticsMaxLimit );
         systemSettingManager.saveSystemSetting( KEY_DATABASE_SERVER_CPUS, databaseServerCpus );
@@ -246,6 +254,7 @@
         systemSettingManager.saveSystemSetting( KEY_ANALYTICS_MAINTENANCE_MODE, analyticsMaintenanceMode );
         systemSettingManager.saveSystemSetting( KEY_HELP_PAGE_LINK, StringUtils.trimToNull( helpPageLink ) );
         systemSettingManager.saveSystemSetting( KEY_SYSTEM_NOTIFICATIONS_EMAIL, systemNotificationsEmail );
+        systemSettingManager.saveSystemSetting( KEY_ANALYSIS_RELATIVE_PERIOD, analysisRelativePeriod );
 
         Configuration configuration = configurationService.getConfiguration();
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2014-11-24 18:14:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2014-11-25 12:35:16 +0000
@@ -122,4 +122,5 @@
 detect_based_on_web_server=detect based on web server
 help_page_link = Help page link
 acceptance_required_before_approval=Acceptance required before approval
-system_notifications_email_address=System notifications email address
\ No newline at end of file
+system_notifications_email_address=System notifications email address
+default_analysis_relative_period=Default relative period for analysis
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm	2014-11-18 12:55:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm	2014-11-25 12:35:16 +0000
@@ -7,6 +7,7 @@
         databaseServerCpus: getFieldValue('databaseServerCpus'),
         infrastructuralDataElements: getFieldValue('infrastructuralDataElements'),
         infrastructuralPeriodType: getFieldValue('infrastructuralPeriodType'),
+        analysisRelativePeriod: getFieldValue('analysisRelativePeriod'),
         feedbackRecipients: getFieldValue('feedbackRecipients'),
         offlineOrganisationUnitLevel: getFieldValue('offlineOrganisationUnitLevel'),
         systemNotificationsEmail: getFieldValue('systemNotificationsEmail'),
@@ -87,6 +88,16 @@
 </select>
 </div>
 
+<div class="settingLabel">$i18n.getString( "default_analysis_relative_period" )</div>
+
+<div class="setting">
+<select id="analysisRelativePeriod" name="analysisRelativePeriod">
+    #foreach ( $period in $relativePeriods )
+    <option value="$period" #if( $period == $keyAnalysisRelativePeriod )selected="selected"#end>$i18n.getString( $period )</option>
+    #end
+</select>
+</div>
+
 <div class="settingLabel">$i18n.getString( "feedback_recipients" )</div>
 
 <div class="setting">