dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43729
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22168: Moved flag i18n method to controller
------------------------------------------------------------
revno: 22168
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-03-07 22:51:08 +0100
message:
Moved flag i18n method to controller
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
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.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 2016-01-06 19:24:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2016-03-07 21:51:08 +0000
@@ -69,8 +69,6 @@
List<String> getFlags();
- List<StyleObject> getFlagObjects();
-
String getFlagImage();
String getEmailHostName();
=== 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 2016-03-07 15:16:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultSystemSettingManager.java 2016-03-07 21:51:08 +0000
@@ -32,12 +32,9 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.i18n.I18nManager;
import org.hisp.dhis.system.util.SystemUtils;
import org.hisp.dhis.system.util.ValidationUtils;
import org.jasypt.encryption.pbe.PBEStringEncryptor;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@@ -85,9 +82,6 @@
this.flags = flags;
}
- @Autowired
- private I18nManager i18nManager;
-
@Resource( name = "stringEncryptor" )
private PBEStringEncryptor pbeStringEncryptor;
@@ -300,26 +294,6 @@
}
@Override
- public List<StyleObject> getFlagObjects()
- {
- Collections.sort( flags );
-
- I18n i18n = i18nManager.getI18n();
-
- List<StyleObject> list = Lists.newArrayList();
-
- for ( String flag : flags )
- {
- String name = i18n.getString( flag );
- String file = flag + ".png";
-
- list.add( new StyleObject( name, flag, file ) );
- }
-
- return list;
- }
-
- @Override
public String getFlagImage()
{
String flag = (String) getSystemSetting( SettingKey.FLAG );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java 2016-03-02 16:55:48 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java 2016-03-07 21:51:08 +0000
@@ -30,6 +30,8 @@
import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.dxf2.metadata.ImportSummary;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nManager;
import org.hisp.dhis.render.RenderService;
import org.hisp.dhis.node.exception.InvalidTypeException;
import org.hisp.dhis.node.types.CollectionNode;
@@ -56,6 +58,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import com.google.common.collect.Lists;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -89,10 +93,13 @@
@Autowired
private RenderService renderService;
+
+ @Autowired
+ private I18nManager i18nManager;
- //--------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// UID Generator
- //--------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
@RequestMapping( value = { "/uid", "/id" }, method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE } )
public @ResponseBody RootNode getUid( @RequestParam( required = false, defaultValue = "1" ) Integer limit )
@@ -200,7 +207,7 @@
@RequestMapping( value = "/flags", method = RequestMethod.GET, produces = { "application/json" } )
public @ResponseBody List<StyleObject> getFlags()
{
- return systemSettingManager.getFlagObjects();
+ return getFlagObjects();
}
@RequestMapping( value = "/styles", method = RequestMethod.GET, produces = { "application/json" } )
@@ -208,4 +215,26 @@
{
return styleManager.getStyles();
}
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ private List<StyleObject> getFlagObjects()
+ {
+ List<String> flags = systemSettingManager.getFlags();
+
+ I18n i18n = i18nManager.getI18n();
+
+ List<StyleObject> list = Lists.newArrayList();
+
+ for ( String flag : flags )
+ {
+ String file = flag + ".png";
+
+ list.add( new StyleObject( i18n.getString( flag ), flag, file ) );
+ }
+
+ return list;
+ }
}