← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20545: Setting for Calendar and AppManager

 

------------------------------------------------------------
revno: 20545
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-07 00:15:19 +0200
message:
  Setting for Calendar and AppManager
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingManagerTest.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.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/appmanager/AppManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java	2015-09-16 15:14:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java	2015-10-06 22:15:19 +0000
@@ -44,7 +44,6 @@
     String KEY_APP_FOLDER_PATH = "appFolderPath";
     String KEY_APP_BASE_URL = "appBaseUrl";
     String KEY_APP_STORE_URL = "appStoreUrl";
-    String DEFAULT_APP_STORE_URL = "http://www.dhis2.org/appstore";;
     String APPS_DIR = "/apps";
     String APPS_API_PATH = "/api/apps";
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java	2015-09-16 14:49:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java	2015-10-06 22:15:19 +0000
@@ -39,9 +39,6 @@
 {
     String KEY_CALENDAR = "keyCalendar";
     String KEY_DATE_FORMAT = "keyDateFormat";
-
-    String DEFAULT_CALENDAR = "iso8601";
-    String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; // ISO 8601
     
     /**
      * Gets all available calendars as a sorted list.

=== 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 21:55:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/Setting.java	2015-10-06 22:15:19 +0000
@@ -106,7 +106,12 @@
     DATA_IMPORT_REQUIRE_CATEGORY_OPTION_COMBO( "keyDataImportRequireCategoryOptionCombo", Boolean.FALSE, Boolean.class ),
     DATA_IMPORT_REQUIRE_ATTRIBUTE_OPTION_COMBO( "keyDataImportRequireAttributeOptionCombo", Boolean.FALSE, Boolean.class ),
     CUSTOM_JS( "keyCustomJs" ),
-    CUSTOM_CSS( "keyCustomCss" );
+    CUSTOM_CSS( "keyCustomCss" ),
+    CALENDAR( "keyCalendar", "iso8601", String.class ),
+    DATE_FORMAT( "keyDateFormat", "yyyy-MM-dd", String.class ),
+    APP_FOLDER_PATH( "appFolderPath" ),
+    APP_BASE_URL( "appBaseUrl" ),
+    APP_STORE_URL( "appStoreUrl", "http://www.dhis2.org/appstore";, String.class );
     
     private final String name;
     

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java	2015-09-14 07:22:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/appmanager/DefaultAppManager.java	2015-10-06 22:15:19 +0000
@@ -30,12 +30,14 @@
 
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
+
 import org.apache.ant.compress.taskdefs.Unzip;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.datavalue.DefaultDataValueService;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
@@ -43,6 +45,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.annotation.PostConstruct;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -212,7 +215,7 @@
     @Override
     public String getAppFolderPath()
     {
-        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( KEY_APP_FOLDER_PATH ) );
+        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( Setting.APP_FOLDER_PATH ) );
     }
 
     @Override
@@ -240,7 +243,7 @@
     @Override
     public String getAppBaseUrl()
     {
-        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( KEY_APP_BASE_URL ) );
+        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( Setting.APP_BASE_URL ) );
     }
 
     @Override
@@ -252,7 +255,7 @@
     @Override
     public String getAppStoreUrl()
     {
-        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( KEY_APP_STORE_URL, DEFAULT_APP_STORE_URL ) );
+        return StringUtils.trimToNull( (String) appSettingManager.getSystemSetting( Setting.APP_STORE_URL ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java	2015-09-13 17:45:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java	2015-10-06 22:15:19 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.calendar.impl.Iso8601Calendar;
 import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.setting.Setting;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -149,7 +150,7 @@
     public String getSystemCalendarKey()
     {
         String key = keyCache.get( KEY_CALENDAR );        
-        key = !isEmpty( key ) ? key : (String) settingManager.getSystemSetting( KEY_CALENDAR, DEFAULT_CALENDAR );        
+        key = !isEmpty( key ) ? key : (String) settingManager.getSystemSetting( Setting.CALENDAR );        
         keyCache.put( KEY_CALENDAR, key );        
         return key;
     }
@@ -165,7 +166,7 @@
     public String getSystemDateFormatKey()
     {
         String key = keyCache.get( KEY_DATE_FORMAT );
-        key = !isEmpty( key ) ? key : (String) settingManager.getSystemSetting( KEY_DATE_FORMAT, DEFAULT_DATE_FORMAT );
+        key = !isEmpty( key ) ? key : (String) settingManager.getSystemSetting( Setting.DATE_FORMAT );
         keyCache.put( KEY_DATE_FORMAT, key );
         return key;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingManagerTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingManagerTest.java	2015-09-13 17:45:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/setting/SystemSettingManagerTest.java	2015-10-06 22:15:19 +0000
@@ -43,7 +43,6 @@
 /**
  * @author Stian Strandli
  * @author Lars Helge Overland
- * @version $Id: SystemSettingManagerTest.java 4866 2008-04-11 10:40:35Z larshelg $
  */
 public class SystemSettingManagerTest
     extends DhisSpringTest
@@ -62,10 +61,20 @@
     }
 
     @Test
-    public void testGetDefaultSystemSetting()
-    {
-        assertEquals( "valueA", systemSettingManager.getSystemSetting( "settingA", "valueA" ) );
-        assertEquals( "valueB", systemSettingManager.getSystemSetting( "settingB", "valueB" ) );
+    public void testSaveGetSetting()
+    {
+        systemSettingManager.saveSystemSetting( Setting.APPLICATION_INTRO, "valueA" );
+        systemSettingManager.saveSystemSetting( Setting.APPLICATION_NOTIFICATION, "valueB" );
+
+        assertEquals( "valueA", systemSettingManager.getSystemSetting( Setting.APPLICATION_INTRO ) );
+        assertEquals( "valueB", systemSettingManager.getSystemSetting( Setting.APPLICATION_NOTIFICATION ) );
+    }
+
+    @Test
+    public void testSaveGetSettingWithDefault()
+    {
+        assertEquals( Setting.APP_STORE_URL.getDefaultValue(), systemSettingManager.getSystemSetting( Setting.APP_STORE_URL ) );
+        assertEquals( Setting.EMAIL_PORT.getDefaultValue(), systemSettingManager.getSystemSetting( Setting.EMAIL_PORT ) );
     }
 
     @Test

=== 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	2015-10-06 17:44:37 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2015-10-06 22:15:19 +0000
@@ -109,28 +109,28 @@
         map.put( KEY_FLAG_IMAGE, systemSettingManager.getFlagImage() );
         map.put( KEY_START_MODULE, systemSettingManager.getSystemSetting( Setting.START_MODULE ) );
         map.put( KEY_FACTOR_OF_DEVIATION, systemSettingManager.getSystemSetting( Setting.FACTOR_OF_DEVIATION ) );
-        map.put( KEY_PHONE_NUMBER_AREA_CODE, systemSettingManager.getSystemSetting( KEY_PHONE_NUMBER_AREA_CODE, "" ) );
-        map.put( KEY_MULTI_ORGANISATION_UNIT_FORMS, systemSettingManager.getSystemSetting( KEY_MULTI_ORGANISATION_UNIT_FORMS, false ) );
-        map.put( KEY_ACCOUNT_RECOVERY, systemSettingManager.getSystemSetting( KEY_ACCOUNT_RECOVERY, false ) );
+        map.put( KEY_PHONE_NUMBER_AREA_CODE, systemSettingManager.getSystemSetting( Setting.PHONE_NUMBER_AREA_CODE ) );
+        map.put( KEY_MULTI_ORGANISATION_UNIT_FORMS, systemSettingManager.getSystemSetting( Setting.MULTI_ORGANISATION_UNIT_FORMS ) );
+        map.put( KEY_ACCOUNT_RECOVERY, systemSettingManager.getSystemSetting( Setting.ACCOUNT_RECOVERY ) );
         map.put( KEY_CONFIGURATION, configurationService.getConfiguration() );
         map.put( KEY_APP_BASE_URL, systemSettingManager.getSystemSetting( KEY_APP_BASE_URL ) );
         map.put( KEY_INSTANCE_BASE_URL, systemSettingManager.getSystemSetting( KEY_INSTANCE_BASE_URL ) );
-        map.put( KEY_GOOGLE_ANALYTICS_UA, systemSettingManager.getSystemSetting( KEY_GOOGLE_ANALYTICS_UA, "" ) );
+        map.put( KEY_GOOGLE_ANALYTICS_UA, systemSettingManager.getSystemSetting( Setting.GOOGLE_ANALYTICS_UA ) );
         map.put( KEY_CREDENTIALS_EXPIRES, systemSettingManager.credentialsExpires() );
         map.put( KEY_SELF_REGISTRATION_NO_RECAPTCHA, systemSettingManager.selfRegistrationNoRecaptcha() );
         map.put( KEY_OPENID_PROVIDER, systemSettingManager.getSystemSetting( KEY_OPENID_PROVIDER ) );
         map.put( KEY_OPENID_PROVIDER_LABEL, systemSettingManager.getSystemSetting( KEY_OPENID_PROVIDER_LABEL ) );
-        map.put( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, systemSettingManager.getSystemSetting( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, false ) );
-        map.put( KEY_CUSTOM_LOGIN_PAGE_LOGO, systemSettingManager.getSystemSetting( KEY_CUSTOM_LOGIN_PAGE_LOGO, false ) );
-        map.put( KEY_CUSTOM_TOP_MENU_LOGO, systemSettingManager.getSystemSetting( KEY_CUSTOM_TOP_MENU_LOGO, false ) );
-        map.put( KEY_ANALYTICS_MAINTENANCE_MODE, systemSettingManager.getSystemSetting( KEY_ANALYTICS_MAINTENANCE_MODE, false ) );
+        map.put( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, systemSettingManager.getSystemSetting( Setting.CAN_GRANT_OWN_USER_AUTHORITY_GROUPS ) );
+        map.put( KEY_CUSTOM_LOGIN_PAGE_LOGO, systemSettingManager.getSystemSetting( Setting.CUSTOM_LOGIN_PAGE_LOGO ) );
+        map.put( KEY_CUSTOM_TOP_MENU_LOGO, systemSettingManager.getSystemSetting( Setting.CUSTOM_TOP_MENU_LOGO ) );
+        map.put( KEY_ANALYTICS_MAINTENANCE_MODE, systemSettingManager.getSystemSetting( Setting.ANALYTICS_MAINTENANCE_MODE ) );
         map.put( KEY_DATABASE_SERVER_CPUS, systemSettingManager.getSystemSetting( Setting.DATABASE_SERVER_CPUS ) );
         map.put( KEY_HELP_PAGE_LINK, systemSettingManager.getSystemSetting( Setting.HELP_PAGE_LINK ) );
-        map.put( KEY_HIDE_UNAPPROVED_DATA_IN_ANALYTICS, systemSettingManager.getSystemSetting( KEY_HIDE_UNAPPROVED_DATA_IN_ANALYTICS, false ) );
-        map.put( KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL, systemSettingManager.getSystemSetting( KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL, false ) );
+        map.put( KEY_HIDE_UNAPPROVED_DATA_IN_ANALYTICS, systemSettingManager.getSystemSetting( Setting.HIDE_UNAPPROVED_DATA_IN_ANALYTICS, false ) );
+        map.put( KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL, systemSettingManager.getSystemSetting( Setting.ACCEPTANCE_REQUIRED_FOR_APPROVAL ) );
         map.put( KEY_SYSTEM_NOTIFICATIONS_EMAIL, systemSettingManager.getSystemSetting( KEY_SYSTEM_NOTIFICATIONS_EMAIL ) );
-        map.put( KEY_REQUIRE_ADD_TO_VIEW, systemSettingManager.getSystemSetting( KEY_REQUIRE_ADD_TO_VIEW, false ) );
-        map.put( KEY_ALLOW_OBJECT_ASSIGNMENT, systemSettingManager.getSystemSetting( KEY_ALLOW_OBJECT_ASSIGNMENT, false ) );
+        map.put( KEY_REQUIRE_ADD_TO_VIEW, systemSettingManager.getSystemSetting( Setting.REQUIRE_ADD_TO_VIEW ) );
+        map.put( KEY_ALLOW_OBJECT_ASSIGNMENT, systemSettingManager.getSystemSetting( Setting.ALLOW_OBJECT_ASSIGNMENT ) );
         map.put( SYSPROP_PORTAL, defaultIfEmpty( System.getProperty( SYSPROP_PORTAL ), String.valueOf( false ) ) );
 
         invocation.getStack().push( map );