← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4783: Simplification in SystemSettingManager

 

------------------------------------------------------------
revno: 4783
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-09-30 15:18:24 +0200
message:
  Simplification in SystemSettingManager
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java
  dhis-2/dhis-services/dhis-service-options/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/menu.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/menu.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.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/options/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-08-02 10:55:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-09-30 13:18:24 +0000
@@ -30,7 +30,6 @@
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
-import java.util.SortedMap;
 
 /**
  * @author Stian Strandli
@@ -42,7 +41,8 @@
     
     final String KEY_SYSTEM_IDENTIFIER = "keySystemIdentifier";
     final String KEY_APPLICATION_TITLE = "applicationTitle";
-    final String KEY_FLAG = "flag";
+    final String KEY_FLAG = "keyFlag";
+    final String KEY_FLAG_IMAGE = "keyFlagImage";
     final String KEY_START_MODULE = "startModule";
     final String KEY_FORUM_INTEGRATION = "forumIntegration";
     final String KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART = "omitIndicatorsZeroNumeratorDataMart";
@@ -78,9 +78,11 @@
 
     void deleteSystemSetting( String name );
     
-    SortedMap<String, String> getFlags();
+    List<String> getFlags();
     
     List<String> getAggregationStrategies();
     
     String getSystemIdentifier();
+    
+    String getFlagImage();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java'
--- dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java	2011-09-30 12:21:59 +0000
+++ dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/setting/DefaultSystemSettingManager.java	2011-09-30 13:18:24 +0000
@@ -30,8 +30,8 @@
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
-import java.util.SortedMap;
 
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.options.SystemSetting;
@@ -57,9 +57,9 @@
         this.systemSettingStore = systemSettingStore;
     }
     
-    private SortedMap<String, String> flags;
+    private List<String> flags;
 
-    public void setFlags( SortedMap<String, String> flags )
+    public void setFlags( List<String> flags )
     {
         this.flags = flags;
     }
@@ -122,8 +122,9 @@
     // Specific methods
     // -------------------------------------------------------------------------
     
-    public SortedMap<String, String> getFlags()
+    public List<String> getFlags()
     {
+        Collections.sort( flags );        
         return flags;
     }
     
@@ -136,4 +137,11 @@
     {
         return (String) getSystemSetting( KEY_SYSTEM_IDENTIFIER );
     }
+    
+    public String getFlagImage()
+    {
+        String flag = (String) getSystemSetting( KEY_FLAG );
+        
+        return flag != null ? flag + ".png" : null;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-options/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-options/src/main/resources/META-INF/dhis/beans.xml	2011-09-30 12:21:59 +0000
+++ dhis-2/dhis-services/dhis-service-options/src/main/resources/META-INF/dhis/beans.xml	2011-09-30 13:18:24 +0000
@@ -21,260 +21,50 @@
   <bean id="org.hisp.dhis.options.SystemSettingManager" class="org.hisp.dhis.options.setting.DefaultSystemSettingManager">
     <property name="systemSettingStore" ref="org.hisp.dhis.options.SystemSettingStore" />
     <property name="flags">
-      <map>
-        <entry>
-          <key>
-            <value>armenia</value>
-          </key>
-          <value>armenia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>bangladesh</value>
-          </key>
-          <value>bangladesh.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>bening</value>
-          </key>
-          <value>benin.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>botswana</value>
-          </key>
-          <value>botswana.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>burkina_faso</value>
-          </key>
-          <value>burkina_faso.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>cambodia</value>
-          </key>
-          <value>cambodia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>ethiopia</value>
-          </key>
-          <value>ethiopia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>gambia</value>
-          </key>
-          <value>gambia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>ghana</value>
-          </key>
-          <value>ghana.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>guinea</value>
-          </key>
-          <value>guinea.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>guinea_bissau</value>
-          </key>
-          <value>guinea_bissau.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>india</value>
-          </key>
-          <value>india.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>indonesia</value>
-          </key>
-          <value>indionesia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>irc</value>
-          </key>
-          <value>irc.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>ivory_coast</value>
-          </key>
-          <value>ivory_coast.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>kenya</value>
-          </key>
-          <value>kenya.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>lesotho</value>
-          </key>
-          <value>lesotho.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>liberia</value>
-          </key>
-          <value>liberia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>malawi</value>
-          </key>
-          <value>malawi.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>mali</value>
-          </key>
-          <value>mali.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>mozambique</value>
-          </key>
-          <value>mozambique.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>namibia</value>
-          </key>
-          <value>namibia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>nigeria</value>
-          </key>
-          <value>nigeria.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>norway</value>
-          </key>
-          <value>norway.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>philippines</value>
-          </key>
-          <value>philippines.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>rwanda</value>
-          </key>
-          <value>rwanda.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>senegal</value>
-          </key>
-          <value>senegal.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>sierra_leone</value>
-          </key>
-          <value>sierra_leone.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>sierra_leone_coat_of_arms</value>
-          </key>
-          <value>sierra_leone_coat_of_arms.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>south_africa</value>
-          </key>
-          <value>south_africa.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>south_africa_department_of_health</value>
-          </key>
-          <value>south_africa_department_of_health.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>sri_lanka</value>
-          </key>
-          <value>sri_lanka.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>swaziland</value>
-          </key>
-          <value>swaziland.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>tajikistan</value>
-          </key>
-          <value>tajikistan.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>tanzania</value>
-          </key>
-          <value>tanzania.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>togo</value>
-          </key>
-          <value>togo.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>uganda</value>
-          </key>
-          <value>uganda.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>vietnam</value>
-          </key>
-          <value>vietnam.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>zambia</value>
-          </key>
-          <value>zambia.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>zanzibar</value>
-          </key>
-          <value>zanzibar.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>zimbabwe</value>
-          </key>
-          <value>zimbabwe.png</value>
-        </entry>
-        <entry>
-          <key>
-            <value>who</value>
-          </key>
-          <value>who.png</value>
-        </entry>
-      </map>
+      <list>
+        <value>armenia</value>
+        <value>bangladesh</value>
+        <value>benin</value>
+        <value>botswana</value>
+        <value>burkina_faso</value>
+        <value>cambodia</value>
+        <value>ethiopia</value>
+        <value>gambia</value>
+        <value>ghana</value>
+        <value>guinea</value>
+        <value>guinea_bissau</value>
+        <value>india</value>
+        <value>indonesia</value>
+        <value>irc</value>
+        <value>ivory_coast</value>
+        <value>kenya</value>
+        <value>lesotho</value>
+        <value>liberia</value>
+        <value>malawi</value>
+        <value>mali</value>
+        <value>mozambique</value>
+        <value>namibia</value>
+        <value>nigeria</value>
+        <value>norway</value>
+        <value>philippines</value>
+        <value>rwanda</value>
+        <value>senegal</value>
+        <value>sierra_leone</value>
+        <value>sierra_leone_coat_of_arms</value>
+        <value>south_africa</value>
+        <value>south_africa_department_of_health</value>
+        <value>sri_lanka</value>
+        <value>swaziland</value>
+        <value>tajikistan</value>
+        <value>tanzania</value>
+        <value>togo</value>
+        <value>uganda</value>
+        <value>vietnam</value>
+        <value>zambia</value>
+        <value>zanzibar</value>
+        <value>zimbabwe</value>
+        <value>who</value>
+      </list>
     </property>
   </bean>
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/menu.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/menu.vm	2011-04-01 13:46:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/menu.vm	2011-09-30 13:18:24 +0000
@@ -1,6 +1,6 @@
 
-#if ( $flag )
-<img src="../dhis-web-commons/flags/$flag" style="margin-top: 16px; margin-left: 16px; border: 1px solid #D0D0D0;">
+#if ( $keyFlag )
+<img src="../dhis-web-commons/flags/${keyFlagImage}" style="margin-top: 16px; margin-left: 16px; border: 1px solid #D0D0D0;">
 #end
 
 <h2>$i18n.getString( "dhis2_online" )&nbsp;</h2>

=== 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	2011-08-02 10:55:30 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2011-09-30 13:18:24 +0000
@@ -88,6 +88,7 @@
         map.put( KEY_SYSTEM_IDENTIFIER, systemSettingManager.getSystemIdentifier() );
         map.put( KEY_APPLICATION_TITLE, systemSettingManager.getSystemSetting( KEY_APPLICATION_TITLE ) );
         map.put( KEY_FLAG, systemSettingManager.getSystemSetting( KEY_FLAG ) );
+        map.put( KEY_FLAG_IMAGE, systemSettingManager.getFlagImage() );
         map.put( KEY_START_MODULE, systemSettingManager.getSystemSetting( KEY_START_MODULE ) );
         map.put( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, systemSettingManager.getSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, false ) );
         map.put( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, systemSettingManager.getSystemSetting( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, false ) );

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/menu.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/menu.vm	2011-04-01 15:44:51 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/menu.vm	2011-09-30 13:18:24 +0000
@@ -1,6 +1,6 @@
 
-#if ( $flag )
-<img src="../dhis-web-commons/flags/$flag" style="margin-top: 16px; margin-left: 16px; border: 1px solid #D0D0D0;">
+#if ( $keyFlag )
+<img src="../dhis-web-commons/flags/${keyFlagImage}" style="margin-top: 16px; margin-left: 16px; border: 1px solid #D0D0D0;">
 #end
 
 <h2>$i18n.getString( "dashboard" )&nbsp;</h2>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java	2011-09-30 12:21:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetSystemSettingsAction.java	2011-09-30 13:18:24 +0000
@@ -119,9 +119,9 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private SortedMap<String, String> flags;
+    private List<String> flags;
 
-    public SortedMap<String, String> getFlags()
+    public List<String> getFlags()
     {
         return flags;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm	2011-08-02 10:55:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm	2011-09-30 13:18:24 +0000
@@ -38,8 +38,8 @@
 <p>
 <select name="flag" style="width:30em">
 	<option value="NO_FLAG">$i18n.getString( "no_flag" )</option>
-	#foreach ( $f in $flags.entrySet() )
-	<option value="$f.value" #if( $f.value == $flag )selected="selected"#end>$i18n.getString( $f.key )</option>
+	#foreach ( $flag in $flags )
+	<option value="$flag" #if( $flag == $keyFlag )selected="selected"#end>$i18n.getString( $flag )</option>
     #end
 </select>
 </p>