summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common
diff options
context:
space:
mode:
authorManoop Talasila <talasila@research.att.com>2019-04-11 13:44:32 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-11 13:44:32 +0000
commit3825afb074f3a44391473a1fa20859d796724913 (patch)
treea21e76d0c8f40f84811aedea045a233f091a9020 /ecomp-portal-BE-common
parentd350340d41cc5e53d0b212c3fd2c3f80cae60a51 (diff)
parent7c291e0d10e63f403f016ede7d8e4ee47dcbf8a9 (diff)
Merge "Add multi-language APIs into BE-common"
Diffstat (limited to 'ecomp-portal-BE-common')
-rw-r--r--ecomp-portal-BE-common/pom.xml11
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java2
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java53
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/DisplayText.java27
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUser.java12
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/Language.java26
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java26
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java30
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java75
-rw-r--r--ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml43
10 files changed, 302 insertions, 3 deletions
diff --git a/ecomp-portal-BE-common/pom.xml b/ecomp-portal-BE-common/pom.xml
index 6cb1279a..b8787f78 100644
--- a/ecomp-portal-BE-common/pom.xml
+++ b/ecomp-portal-BE-common/pom.xml
@@ -720,6 +720,17 @@
</dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>fastjson</artifactId>
+ <version>1.2.7</version>
+ </dependency>
</dependencies>
</project>
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java
index 289c8279..b5bd02bc 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java
@@ -233,7 +233,7 @@ public class AppsController extends EPRestrictedBaseController {
* @return JSON with left menu
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
- @RequestMapping(value = { "/portalApi/leftmenuItems" }, method = RequestMethod.GET, produces = "application/json")
+ @RequestMapping(value = { "/portalApi/leftmenuItems" }, method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public String getLeftMenuItems(HttpServletRequest request, HttpServletResponse response) {
String menuList = null;
Set menuSet = (Set) AppUtils.getSession(request)
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java
new file mode 100644
index 00000000..f3a79285
--- /dev/null
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.portalapp.portal.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import org.onap.portalapp.portal.domain.Language;
+import org.onap.portalapp.portal.service.LanguageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+@RestController
+@RequestMapping("/auxapi")
+public class LanguageController {
+
+ @Autowired
+ private LanguageService languageService;
+
+ @RequestMapping(value = "/language",method = RequestMethod.GET)
+ public JSONObject getLanguageList() {
+ return languageService.getLanguages();
+ }
+
+ @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.POST)
+ public void setUpUserLanguage(@RequestBody JSONObject jsonLanguageId,
+ @PathVariable("loginId") String loginId) throws Exception {
+ Integer languageId = jsonLanguageId.getInteger("languageId");
+ languageService.setUpUserLanguage(languageId,loginId);
+ }
+
+ @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.GET)
+ public JSONObject getUserLanguage(HttpServletRequest request, HttpServletResponse response,
+ @PathVariable("loginId") String loginId) {
+ return languageService.getUserLanguage(loginId);
+ }
+
+}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/DisplayText.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/DisplayText.java
new file mode 100644
index 00000000..d375c020
--- /dev/null
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/DisplayText.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.portalapp.portal.domain;
+
+import lombok.Data;
+
+@Data
+public class DisplayText {
+
+ private Integer id;
+ private Integer languageId;
+ private Long textId;
+ private String label;
+}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUser.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUser.java
index d7cce0ec..ce7495f7 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUser.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUser.java
@@ -98,7 +98,7 @@ public class EPUser extends User {
private Long timeZoneId;
private boolean online;
private String chatId;
-
+ private Integer languageId;
private static final long serialVersionUID = 1L;
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class);
@@ -491,8 +491,16 @@ public class EPUser extends User {
public void setChatId(String chatId) {
this.chatId = chatId;
}
-
+
+ public Integer getLanguageId() {
+ return languageId;
+ }
+
+ public void setLanguageId(Integer languageId) {
+ this.languageId = languageId;
+ }
+
public void setPseudoEPRoles(SortedSet<EPRole> pseudoRoles) {
this.pseudoRoles = pseudoRoles;
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/Language.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/Language.java
new file mode 100644
index 00000000..f26488b7
--- /dev/null
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/Language.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.portalapp.portal.domain;
+
+import lombok.Data;
+
+@Data
+public class Language {
+
+ private String languageId;
+ private String languageName;
+ private String languageAlias;
+}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java
index 97c2b74c..96db8e32 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPLeftMenuServiceImpl.java
@@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -51,6 +52,7 @@ import java.util.TreeSet;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.portalapp.portal.domain.CentralizedApp;
+import org.onap.portalapp.portal.domain.DisplayText;
import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.logging.aop.EPMetricsLog;
import org.onap.portalsdk.core.domain.MenuData;
@@ -117,6 +119,30 @@ public class EPLeftMenuServiceImpl implements EPLeftMenuService {
}
}
+ //mulitilanguage impl
+ String loginId = user.getLoginId();
+ HashMap loginParams = new HashMap();
+ loginParams.put("login_id",loginId);
+ List<EPUser> epUsers = dataAccessService.executeNamedQuery("getEPUserByLoginId", loginParams, new HashMap());
+ Integer languageId = 1;
+ for (EPUser epUser : epUsers) {
+ languageId = epUser.getLanguageId();
+ }
+ Iterator<MenuData> iterator = fullMenuSet.iterator();
+ HashMap params = new HashMap();
+ params.put("language_id",languageId);
+ List<DisplayText> displayTexts = dataAccessService.executeNamedQuery("displayText",params,new HashMap());
+ while (iterator.hasNext()) {
+ MenuData menuData = iterator.next();
+ for (int index = 0;index<displayTexts.size();index++) {
+ DisplayText displayText = displayTexts.get(index);
+ if (menuData.getId()==displayText.getTextId()) {
+ menuData.setLabel(displayText.getLabel());
+ break;
+ }
+ }
+ }
+
SortedSet<MenuData> sortMenuSet = new TreeSet<MenuData>(new SortOrderComparator());
for (MenuData mn : fullMenuSet) {
sortMenuSet.add(mn);
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java
new file mode 100644
index 00000000..570d1e92
--- /dev/null
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.portalapp.portal.service;
+
+import com.alibaba.fastjson.JSONObject;
+import org.onap.portalapp.portal.domain.Language;
+
+import java.util.List;
+
+public interface LanguageService {
+
+ JSONObject getLanguages();
+
+ String setUpUserLanguage(Integer languageId,String loginId) throws Exception;
+
+ JSONObject getUserLanguage(String loginId);
+}
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
new file mode 100644
index 00000000..b0d8c424
--- /dev/null
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.portalapp.portal.service;
+
+import com.alibaba.fastjson.JSONObject;
+import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.domain.Language;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class LanguageServiceImpl implements LanguageService {
+
+ @Autowired
+ private DataAccessService dataAccessService;
+
+ @Override
+ public JSONObject getLanguages() {
+ List<Language> languages = (List<Language>) dataAccessService.executeNamedQuery("queryLanguage",null,new HashMap());
+ JSONObject result = new JSONObject();
+ result.put("languageList",languages);
+ return result;
+ }
+
+ @Override
+ public String setUpUserLanguage(Integer languageId, String loginId) throws Exception{
+ Map<String,Object> params = new HashMap<>();
+ params.put("login_id",loginId);
+ params.put("language_id",languageId);
+ dataAccessService.executeNamedQuery("updateFnUser",params,new HashMap());
+ return "success";
+ }
+
+ @Override
+ 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);
+
+ List<EPUser> list = null;
+ list = dataAccessService.executeNamedQuery("getEPUserByLoginId",params,new HashMap());
+ for (EPUser user : list) {
+ int languageId = user.getLanguageId();
+ HashMap<String,String> params1 = new HashMap();
+ params1.put("language_id", String.valueOf(languageId));
+ List<Language> languages = dataAccessService.executeNamedQuery("queryLanguageByLanguageId",params1,new HashMap());
+ for (Language language : languages) {
+ result.put("languageId",languageId);
+ result.put("languageName",language.getLanguageName());
+ result.put("languageAlias",language.getLanguageAlias());
+ }
+ return result;
+ }
+ return null;
+ }
+}
diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml
index 50264215..4e8943ce 100644
--- a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml
+++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml
@@ -43,6 +43,29 @@
<!-- Publishes mappings and queries specific to the ONAP Portal application. -->
<hibernate-mapping package="org.onap.portalapp.portal.domain">
+ <!-- multilanguage -->
+ <class name="Language" table="fn_language">
+ <id name="languageId" column="language_id">
+ <generator class="native">
+ <param name="sequence"></param>
+ </generator>
+ </id>
+ <property name="languageName" column="language_name" />
+ <property name="languageAlias" column="language_alias" />
+ </class>
+
+ <class name="DisplayText" table="fn_display_text">
+ <id name="id" column="id">
+ <generator class="native">
+ <param name="sequence"></param>
+ </generator>
+ </id>
+
+ <property name="languageId" column="language_id" />
+ <property name="textId" column="text_id" />
+ <property name="label" column="text_label" />
+ </class>
+
<!-- Widget class mapping details -->
<class name="Widget" table="FN_WIDGET">
<id name="id" column="WIDGET_ID">
@@ -206,6 +229,7 @@
<property name="createdId" column="created_id" />
<property name="modifiedId" column="modified_id" />
<property name="timeZoneId" column="timezone" />
+ <property name="languageId" column="language_id" />
<set name="EPUserApps" table="FN_USER_ROLE" lazy="false" sort="natural"
inverse="true">
@@ -528,6 +552,25 @@
</many-to-one>
</class>
+ <!-- multilanguage -->
+ <query name="queryLanguage">
+ <![CDATA[
+ from Language
+ ]]>
+ </query>
+
+ <query name="displayText">
+ <![CDATA[
+ from DisplayText where languageId = :language_id
+ ]]>
+ </query>
+
+ <query name="queryLanguageByLanguageId">
+ <![CDATA[
+ from Language where languageId = :language_id
+ ]]>
+ </query>
+
<!-- show the current user plus related users -->
<sql-query name="relatedUsers">
<return-scalar column="org_user_id" type="java.lang.String" />