diff options
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) { |