← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20540: Settings, move from string to enum

 

------------------------------------------------------------
revno: 20540
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-06 20:35:24 +0200
message:
  Settings, move from string to enum
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java
  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
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java
  dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultCaseAggregateConditionSchedulingManager.java
  dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultProgramSchedulingManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleCaseAggregateConditionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleSendMessageTasksAction.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/Setting.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java	2015-10-06 18:24:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java	2015-10-06 18:35:24 +0000
@@ -58,7 +58,8 @@
     EMAIL_PASSWORD( "keyEmailPassword" ),
     EMAIL_TLS( "keyEmailTls", Boolean.TRUE, Boolean.class ),
     EMAIL_SENDER( "keyEmailSender" ),
-    INSTANCE_BASE_URL( "keyInstanceBaseUrl", ListMap.class ),
+    INSTANCE_BASE_URL( "keyInstanceBaseUrl" ),
+    SCHEDULED_TASKS( "keySchedTasks", ListMap.class ),
     SMS_CONFIG( "keySmsConfig", SmsConfiguration.class ),
     CACHE_STRATEGY( "keyCacheStrategy", "CACHE_6AM_TOMORROW", String.class ),
     TIME_FOR_SENDING_MESSAGE( "timeSendingMessage", "08:00", String.class ),

=== 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	2015-10-06 18:24:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2015-10-06 18:35:24 +0000
@@ -131,6 +131,8 @@
 
     Serializable getSystemSetting( Setting setting );
     
+    Serializable getSystemSetting( Setting setting, Serializable defaultValue );
+    
     List<SystemSetting> getAllSystemSettings();
 
     void deleteSystemSetting( String name );

=== 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	2015-10-06 17:53:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java	2015-10-06 18:35:24 +0000
@@ -122,6 +122,12 @@
     }
 
     @Override
+    public Serializable getSystemSetting( Setting setting, Serializable defaultValue )
+    {
+        return getSystemSetting( setting.getName(), defaultValue );
+    }
+
+    @Override
     public List<SystemSetting> getAllSystemSettings()
     {
         return systemSettingStore.getAll();

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java	2015-10-04 20:52:33 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java	2015-10-06 18:35:24 +0000
@@ -29,14 +29,12 @@
  */
 
 import static org.apache.commons.lang3.StringUtils.trimToNull;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_DATA_SYNC;
 
 import java.io.IOException;
 import java.util.Date;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.system.util.CodecUtils;
 import org.hisp.dhis.configuration.Configuration;
 import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.datavalue.DataValueService;
@@ -48,7 +46,9 @@
 import org.hisp.dhis.dxf2.importsummary.ImportSummary;
 import org.hisp.dhis.dxf2.metadata.ImportService;
 import org.hisp.dhis.dxf2.metadata.MetaData;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.util.CodecUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.joda.time.DateTime;
@@ -236,7 +236,7 @@
     @Override
     public Date getLastSynchSuccess()
     {
-        return (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_DATA_SYNC );
+        return (Date) systemSettingManager.getSystemSetting( Setting.LAST_SUCCESSFUL_DATA_SYNC );
     }
 
     @Override
@@ -278,7 +278,7 @@
     {
         Date fallback = new DateTime().minusDays( 3 ).toDate();
 
-        return (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_DATA_SYNC, fallback );
+        return (Date) systemSettingManager.getSystemSetting( Setting.LAST_SUCCESSFUL_DATA_SYNC, fallback );
     }
 
     /**
@@ -286,7 +286,7 @@
      */
     private void setLastSynchSuccess( Date time )
     {
-        systemSettingManager.saveSystemSetting( KEY_LAST_SUCCESSFUL_DATA_SYNC, time );
+        systemSettingManager.saveSystemSetting( Setting.LAST_SUCCESSFUL_DATA_SYNC, time );
     }
 
     /**

=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultCaseAggregateConditionSchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultCaseAggregateConditionSchedulingManager.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultCaseAggregateConditionSchedulingManager.java	2015-10-06 18:35:24 +0000
@@ -28,12 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS;
 import static org.hisp.dhis.system.scheduling.Scheduler.STATUS_NOT_STARTED;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.scheduling.Scheduler;
 
@@ -95,7 +95,7 @@
     @Override
     public void scheduleTasks( Map<String, String> keyCronMap )
     {
-        systemSettingManager.saveSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS,
+        systemSettingManager.saveSystemSetting( Setting.SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS,
             new HashMap<>( keyCronMap ) );
 
         scheduleTasks();
@@ -104,7 +104,7 @@
     @Override
     public void stopTasks()
     {
-        systemSettingManager.saveSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS, null );
+        systemSettingManager.saveSystemSetting( Setting.SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS , null );
 
         scheduler.stopAllTasks();
     }
@@ -129,7 +129,7 @@
     @SuppressWarnings( "unchecked" )
     public Map<String, String> getScheduledTasks()
     {
-        return (Map<String, String>) systemSettingManager.getSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS,
+        return (Map<String, String>) systemSettingManager.getSystemSetting( Setting.SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS,
             new HashMap<String, String>() );
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultProgramSchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultProgramSchedulingManager.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/DefaultProgramSchedulingManager.java	2015-10-06 18:35:24 +0000
@@ -28,12 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SEND_MESSAGE_SCHEDULED_TASKS;
 import static org.hisp.dhis.system.scheduling.Scheduler.STATUS_NOT_STARTED;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.scheduling.Scheduler;
 
@@ -93,7 +93,7 @@
     @Override
     public void scheduleTasks( Map<String, String> keyCronMap )
     {
-        systemSettingManager.saveSystemSetting( KEY_SEND_MESSAGE_SCHEDULED_TASKS, new HashMap<>( keyCronMap ) );
+        systemSettingManager.saveSystemSetting( Setting.SEND_MESSAGE_SCHEDULED_TASKS, new HashMap<>( keyCronMap ) );
         
         scheduleTasks();
     }
@@ -101,7 +101,7 @@
     @Override
     public void stopTasks()
     {
-        systemSettingManager.saveSystemSetting( KEY_SEND_MESSAGE_SCHEDULED_TASKS, null );
+        systemSettingManager.saveSystemSetting( Setting.SEND_MESSAGE_SCHEDULED_TASKS, null );
         
         scheduler.stopAllTasks();
     }
@@ -126,7 +126,7 @@
     @SuppressWarnings("unchecked")
     public Map<String, String> getScheduledTasks()
     {
-        return (Map<String, String>) systemSettingManager.getSystemSetting( KEY_SEND_MESSAGE_SCHEDULED_TASKS, new HashMap<String, String>() );
+        return (Map<String, String>) systemSettingManager.getSystemSetting( Setting.SEND_MESSAGE_SCHEDULED_TASKS, new HashMap<String, String>() );
     }
     
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java	2015-10-06 18:35:24 +0000
@@ -28,7 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_TASKS;
 import static org.hisp.dhis.system.scheduling.Scheduler.STATUS_NOT_STARTED;
 
 import java.util.HashMap;
@@ -37,6 +36,7 @@
 import java.util.Set;
 
 import org.hisp.dhis.common.ListMap;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.scheduling.Scheduler;
 
@@ -99,7 +99,7 @@
     @Override
     public void scheduleTasks( ListMap<String, String> cronKeyMap )
     {
-        systemSettingManager.saveSystemSetting( KEY_SCHEDULED_TASKS, new ListMap<>( cronKeyMap ) );
+        systemSettingManager.saveSystemSetting( Setting.SCHEDULED_TASKS, new ListMap<>( cronKeyMap ) );
         
         scheduleTasks();
     }
@@ -107,7 +107,7 @@
     @Override
     public void stopTasks()
     {
-        systemSettingManager.saveSystemSetting( KEY_SCHEDULED_TASKS, null );
+        systemSettingManager.saveSystemSetting( Setting.SCHEDULED_TASKS, null );
         
         scheduler.stopAllTasks();
     }
@@ -116,7 +116,7 @@
     @SuppressWarnings("unchecked")
     public ListMap<String, String> getCronKeyMap()
     {
-        return (ListMap<String, String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_TASKS, new ListMap<String, String>() );
+        return (ListMap<String, String>) systemSettingManager.getSystemSetting( Setting.SCHEDULED_TASKS, new ListMap<String, String>() );
     }
     
     @Override

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java	2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtilsImpl.java	2015-10-06 18:35:24 +0000
@@ -53,6 +53,7 @@
 import org.hisp.dhis.period.CalendarPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.YearlyPeriodType;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.filter.OrganisationUnitWithDataSetsFilter;
 import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
@@ -153,8 +154,7 @@
     {
         Map<String, DeflatedDataValue> validationErrorMap = new HashMap<>();
 
-        Double factor = (Double) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_FACTOR_OF_DEVIATION,
-            2.0 );
+        Double factor = (Double) systemSettingManager.getSystemSetting( Setting.FACTOR_OF_DEVIATION );
 
         Date from = new DateTime( period.getStartDate() ).minusYears( 2 ).toDate();
         

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleCaseAggregateConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleCaseAggregateConditionAction.java	2015-05-29 18:36:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleCaseAggregateConditionAction.java	2015-10-06 18:35:24 +0000
@@ -28,12 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY;
-
 import java.util.HashMap;
 import java.util.Map;
 
 import org.hisp.dhis.scheduling.CaseAggregateConditionSchedulingManager;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.scheduling.Scheduler;
 
@@ -121,7 +120,7 @@
             }
             else
             {
-                systemSettingManager.saveSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY,
+                systemSettingManager.saveSystemSetting( Setting.SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY,
                     taskStrategy );
 
                 Map<String, String> keyCronMap = new HashMap<>();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleSendMessageTasksAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleSendMessageTasksAction.java	2015-10-06 17:44:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/schedule/ScheduleSendMessageTasksAction.java	2015-10-06 18:35:24 +0000
@@ -28,10 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_MESSAGE_TASKS;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SEND_MESSAGE_SCHEDULED_TASKS;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_TIME_FOR_SENDING_MESSAGE;
-
 import java.util.HashMap;
 import java.util.Map;
 
@@ -141,7 +137,7 @@
         notifier.clear( taskId );
         sendMessageScheduled.setTaskId( taskId );
 
-        systemSettingManager.saveSystemSetting( KEY_TIME_FOR_SENDING_MESSAGE, timeSendingMessage );
+        systemSettingManager.saveSystemSetting( Setting.TIME_FOR_SENDING_MESSAGE, timeSendingMessage );
 
         if ( execute )
         {
@@ -174,8 +170,8 @@
                 
                 String cron = "0 " + Integer.parseInt( minute ) + " " + Integer.parseInt( hour ) + " ? * *";
 
-                keyCronMap.put( KEY_SEND_MESSAGE_SCHEDULED_TASKS, cron );
-                keyCronMap.put( KEY_SCHEDULE_MESSAGE_TASKS, "0 0 0 * * ?" );
+                keyCronMap.put( Setting.SEND_MESSAGE_SCHEDULED_TASKS.getName(), cron );
+                keyCronMap.put( Setting.SCHEDULE_MESSAGE_TASKS.getName(), "0 0 0 * * ?" );
 
                 schedulingManager.scheduleTasks( keyCronMap );
             }