← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16442: Adds returning of default values for system settings when they are available

 

Merge authors:
  Mark Polak (markpo)
------------------------------------------------------------
revno: 16442 [merge]
committer: Mark Polak <markpo@xxxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-19 13:06:20 +0200
message:
  Adds returning of default values for system settings when they are available
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.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-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2014-08-08 09:41:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2014-08-14 21:04:34 +0000
@@ -37,6 +37,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.HashMap;
 import java.util.Set;
 
 /**
@@ -119,6 +120,24 @@
     final String DEFAULT_CACHE_STRATEGY = "CACHE_6AM_TOMORROW";
     final int DEFAULT_ANALYTICS_MAX_LIMIT = 50000;
 
+    final Map<String, Serializable> DEFAULT_SETTINGS_VALUES = new HashMap<String, Serializable>()
+    {
+        {
+            put( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY, DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY );
+            put( KEY_FLAG, DEFAULT_FLAG );
+            put( KEY_CALENDAR, DEFAULT_CALENDAR );
+            put( KEY_DATE_FORMAT, DEFAULT_DATE_FORMAT );
+            put( KEY_FACTOR_OF_DEVIATION, DEFAULT_FACTOR_OF_DEVIATION );
+            put( KEY_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );
+            put( KEY_START_MODULE, DEFAULT_START_MODULE );
+            put( KEY_APPLICATION_TITLE, DEFAULT_APPLICATION_TITLE );
+            put( KEY_EMAIL_PORT, DEFAULT_EMAIL_PORT );
+            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 );
+        }
+    };
+
     final String SYSPROP_PORTAL = "runningAsPortal";
 
     final HashSet<String> DEFAULT_SCHEDULED_PERIOD_TYPES = new HashSet<String>()

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2014-08-19 11:06:20 +0000
@@ -200,7 +200,13 @@
 
         for ( SystemSetting systemSetting : systemSettings )
         {
-            settingsMap.put( systemSetting.getName(), systemSetting.getValue() );
+            Serializable settingValue = systemSetting.getValue();
+            if ( settingValue == null )
+            {
+                settingValue = DEFAULT_SETTINGS_VALUES.get( systemSetting.getName() );
+            }
+
+            settingsMap.put( systemSetting.getName(), settingValue );
         }
 
         return settingsMap;
@@ -212,7 +218,7 @@
         
         for ( String name : names )
         {
-            Serializable setting = getSystemSetting( name );
+            Serializable setting = getSystemSetting( name, DEFAULT_SETTINGS_VALUES.get( name ) );
             
             if ( setting != null )
             {