aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguochuyicmri <guochuyi@chinamobile.com>2019-04-08 16:53:48 +0800
committerguochuyicmri <guochuyi@chinamobile.com>2019-04-08 16:53:55 +0800
commite331b40199af2e2e795eaaa4b4eb093cb4d8887c (patch)
tree705d9913fdcfc34ff855ff40e21e351746e858f5
parent4c5187d5ff53b9e674f2600dcc0284bae217d3ea (diff)
Change backend Code for LCM UI page of service creation
Change-Id: I41d1a2db2ed1e9af41d74c663c00417386887179 Issue-ID: USECASEUI-221 Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java11
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java3
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java19
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java16
4 files changed, 42 insertions, 7 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
index e217fe77..63bce433 100755
--- a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
@@ -29,6 +29,7 @@ import javax.annotation.Resource;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.bean.SortMaster;
import org.onap.usecaseui.server.constant.Constant;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
import org.onap.usecaseui.server.service.AlarmsInformationService;
@@ -274,4 +275,14 @@ public class AlarmController
String string =omAlarm.writeValueAsString(map);
return string;
}
+
+ @RequestMapping(value="/listSortMasters",method=RequestMethod.GET,produces = "application/json")
+ public String getSortMasterInfo() throws JsonProcessingException{
+ Map<String,List<SortMaster>> map = new HashMap<>();
+ List<SortMaster> operationTypes = alarmsHeaderService.listSortMasters("operationType");
+ List<SortMaster> operationResults = alarmsHeaderService.listSortMasters("operationResult");
+ map.put("operationTypes", operationTypes);
+ map.put("operationResults", operationResults);
+ return omAlarm.writeValueAsString(map);
+ }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
index 570a563f..363e8b31 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
@@ -20,6 +20,7 @@ import java.sql.Timestamp;
import java.util.List;
import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.SortMaster;
import org.onap.usecaseui.server.util.Page;
public interface AlarmsHeaderService {
@@ -61,4 +62,6 @@ public interface AlarmsHeaderService {
* @return
*/
AlarmsHeader getAlarmsHeaderById(String id);
+
+ List<SortMaster> listSortMasters(String sortType);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
index 0f9431bc..0bcba4dd 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
@@ -18,6 +18,8 @@ package org.onap.usecaseui.server.service.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import javax.transaction.Transactional;
@@ -27,6 +29,8 @@ import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.bean.SortMaster;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
import org.onap.usecaseui.server.util.Page;
import org.onap.usecaseui.server.util.UuiCommonUtil;
@@ -254,4 +258,19 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
return null;
}
}
+
+ @Override
+ public List<SortMaster> listSortMasters(String sortType) {
+
+ try(Session session = getSession()){
+ StringBuffer hql =new StringBuffer("from SortMaster a where 1=1 and a.sortType=:sortType");
+ Query query = session.createQuery(hql.toString());
+ query.setString("sortType",sortType);
+ List<SortMaster> list= query.list();
+ return list;
+ } catch (Exception e) {
+ logger.error("exception occurred while performing AlarmsInformationServiceImpl listSortMasters. Details:" + e.getMessage());
+ return Collections.emptyList();
+ }
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
index f2958d4b..8c630625 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
@@ -19,6 +19,8 @@ import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.onap.usecaseui.server.service.impl.PerformanceHeaderServiceImpl;
+import org.onap.usecaseui.server.util.DateUtils;
import java.util.*;
import java.io.*;
@@ -83,7 +85,7 @@ public class PerformanceHeaderServiceImplTest {
}
@Mock
public List<PerformanceHeader> list() {
- PerformanceHeader ph = new PerformanceHeader.PerformanceHeaderBuilder().createPerformanceHeader();
+ PerformanceHeader ph = new PerformanceHeader();
return Arrays.asList(ph);
}
@Mock
@@ -137,7 +139,7 @@ public class PerformanceHeaderServiceImplTest {
public void testSavePerformanceHeader() throws Exception {
try {
PerformanceHeader ph = null;
- PerformanceHeader phNew = new PerformanceHeader.PerformanceHeaderBuilder().createPerformanceHeader();
+ PerformanceHeader phNew = new PerformanceHeader();
performanceHeaderServiceImpl.savePerformanceHeader(ph);
performanceHeaderServiceImpl.savePerformanceHeader(phNew);
} catch (Exception e) {
@@ -149,7 +151,7 @@ public class PerformanceHeaderServiceImplTest {
public void testUpdatePerformanceHeader() throws Exception {
try {
PerformanceHeader ph = null;
- PerformanceHeader phNew = new PerformanceHeader.PerformanceHeaderBuilder().createPerformanceHeader();
+ PerformanceHeader phNew = new PerformanceHeader();
performanceHeaderServiceImpl.updatePerformanceHeader(ph);
performanceHeaderServiceImpl.updatePerformanceHeader(phNew);
} catch (Exception e) {
@@ -166,7 +168,7 @@ public class PerformanceHeaderServiceImplTest {
}
};
try {
- PerformanceHeader ph = new PerformanceHeader.PerformanceHeaderBuilder().createPerformanceHeader();
+ PerformanceHeader ph = new PerformanceHeader();
ph.setVersion("");
ph.setEventName("");
ph.setDomain("");
@@ -188,7 +190,7 @@ public class PerformanceHeaderServiceImplTest {
ph.setLastEpochMicroSec("");;
performanceHeaderServiceImpl.getAllCount(ph, 1, 1);
- PerformanceHeader phNew = new PerformanceHeader.PerformanceHeaderBuilder().createPerformanceHeader();
+ PerformanceHeader phNew = new PerformanceHeader();
performanceHeaderServiceImpl.getAllCount(phNew, 1, 1);
performanceHeaderServiceImpl.getAllCount(null, 1, 1);
} catch (Exception e) {
@@ -199,7 +201,7 @@ public class PerformanceHeaderServiceImplTest {
@Test
public void testQueryPerformanceHeader() throws Exception {
try {
- PerformanceHeader ph = new PerformanceHeader.PerformanceHeaderBuilder().createPerformanceHeader();
+ PerformanceHeader ph = new PerformanceHeader();
ph.setVersion("");
ph.setEventName("");
ph.setDomain("");
@@ -221,7 +223,7 @@ public class PerformanceHeaderServiceImplTest {
ph.setLastEpochMicroSec("");;
performanceHeaderServiceImpl.queryPerformanceHeader(ph, 1, 10);
- PerformanceHeader phNew = new PerformanceHeader.PerformanceHeaderBuilder().createPerformanceHeader();
+ PerformanceHeader phNew = new PerformanceHeader();
performanceHeaderServiceImpl.queryPerformanceHeader(phNew, 1, 1);
performanceHeaderServiceImpl.queryPerformanceHeader(null, 1, 1);
} catch (Exception e) {