From e331b40199af2e2e795eaaa4b4eb093cb4d8887c Mon Sep 17 00:00:00 2001 From: guochuyicmri Date: Mon, 8 Apr 2019 16:53:48 +0800 Subject: Change backend Code for LCM UI page of service creation Change-Id: I41d1a2db2ed1e9af41d74c663c00417386887179 Issue-ID: USECASEUI-221 Signed-off-by: guochuyicmri --- .../usecaseui/server/controller/AlarmController.java | 11 +++++++++++ .../usecaseui/server/service/AlarmsHeaderService.java | 3 +++ .../server/service/impl/AlarmsHeaderServiceImpl.java | 19 +++++++++++++++++++ .../impl/PerformanceHeaderServiceImplTest.java | 16 +++++++++------- 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> map = new HashMap<>(); + List operationTypes = alarmsHeaderService.listSortMasters("operationType"); + List 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 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 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 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 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) { -- cgit 1.2.3-korg