diff options
author | 2019-04-30 22:51:51 +0800 | |
---|---|---|
committer | 2019-04-30 22:51:52 +0800 | |
commit | 3b08ba8bbe81c5615c9be6090e3092598aa85f35 (patch) | |
tree | 83a93d6690c13b3ad6809c43010e457ab8d98a5a /ecomp-portal-BE-common/src/main/java | |
parent | c0a6b04ff93ff4e45a443a932feeaadf7ca24c7f (diff) |
Fix no name language option bug
Change-Id: I0bfc185ea41324d040ffa23c831bbbaa8f51ef3c
Issue-ID: PORTAL-566
Signed-off-by: shentao999 <shentao@chinamobile.com>
Diffstat (limited to 'ecomp-portal-BE-common/src/main/java')
-rw-r--r-- | ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java index 13d7097b..1aa12b21 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java @@ -16,6 +16,9 @@ package org.onap.portalapp.portal.service; import com.alibaba.fastjson.JSONObject; + +import antlr.StringUtils; + import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.Language; import org.onap.portalsdk.core.service.DataAccessService; @@ -53,18 +56,31 @@ public class LanguageServiceImpl implements LanguageService { public JSONObject getUserLanguage(String loginId) { // get language_id from fn_user by loginId JSONObject result = new com.alibaba.fastjson.JSONObject(); - HashMap params = new HashMap(); - params.put("login_id",loginId); - - EPUser user = (EPUser) dataAccessService.executeNamedQuery("getEPUserByLoginId",params,new HashMap()).get(0); - int languageId = user.getLanguageId(); - HashMap<String,String> params1 = new HashMap(); - params1.put("language_id", String.valueOf(languageId)); - Language language = (Language) dataAccessService.executeNamedQuery("queryLanguageByLanguageId",params1,new HashMap()); - result.put("languageId",languageId); - result.put("languageName",language.getLanguageName()); - result.put("languageAlias",language.getLanguageAlias()); + HashMap getUserParams = new HashMap(); + getUserParams.put("login_id", loginId); + List<EPUser> userList= null; + + try { + userList = dataAccessService.executeNamedQuery("getEPUserByLoginId", getUserParams, new HashMap()); + if (userList != null && userList.size() > 0) { + EPUser user = userList.get(0); + int languageId = user.getLanguageId(); + result.put("languageId", languageId); + + // get language name and alias from fn_language by languageId + HashMap<String,String> getLangParams = new HashMap(); + getLangParams.put("language_id", String.valueOf(languageId)); + List<Language> languageList = null; + languageList = dataAccessService.executeNamedQuery("queryLanguageByLanguageId", getLangParams, new HashMap()); + if (languageList != null && languageList.size() > 0) { + result.put("languageName", languageList.get(0).getLanguageName()); + result.put("languageAlias", languageList.get(0).getLanguageAlias()); + } + } + } catch (Exception e) { + e.printStackTrace(); + } return result; } } |