diff options
author | guochuyicmri <guochuyi@chinamobile.com> | 2019-06-12 11:53:34 +0800 |
---|---|---|
committer | guochuyicmri <guochuyi@chinamobile.com> | 2019-06-12 11:53:45 +0800 |
commit | 5768363d8767ba503ef643579331efe8efe61849 (patch) | |
tree | e263f7579ac9566db657a9aacbc0b590c5d2d007 | |
parent | 100d246f138bfcf2f4f06b1b3f6579f4ae8ef408 (diff) |
Use isEmpty()
Change-Id: I881a72ace5b3975abbb15b2ac78172dc2494e529
Issue-ID: USECASEUI-275
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
6 files changed, 0 insertions, 190 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java index 9a86f92f..11f4d010 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java @@ -32,8 +32,6 @@ public interface AlarmsInformationService { int getAllCount(AlarmsInformation alarmsInformation, int currentPage, int pageSize); - Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation, int currentPage, int pageSize); - List<AlarmsInformation> queryId(String[] id); int queryDateBetween(String sourceId, String startTime, String endTime,String level); diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java index 83991a24..f6a8d1d9 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java @@ -28,10 +28,6 @@ public interface PerformanceInformationService { String updatePerformanceInformation(PerformanceInformation performanceInformation); - int getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize); - - Page<PerformanceInformation> queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize); - List<PerformanceInformation> queryId(String[] id); List<PerformanceInformation> queryDateBetween(String eventId, Date startDate, Date endDate); diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java index 00c9a51c..720d3ca4 100755 --- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java @@ -122,55 +122,6 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService { @SuppressWarnings("unchecked")
@Override
- public Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation, int currentPage,
- int pageSize) {
- Page<AlarmsInformation> page = new Page<AlarmsInformation>();
- int allRow =this.getAllCount(alarmsInformation,currentPage,pageSize);
- int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = getSession()){
- StringBuffer hql =new StringBuffer("from AlarmsInformation a where 1=1");
- if (null == alarmsInformation) {
- //logger.error("AlarmsInformationServiceImpl queryAlarmsInformation alarmsInformation is null!");
- }else {
- if(null!=alarmsInformation.getName()) {
- String ver=alarmsInformation.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }
- if(null!=alarmsInformation.getValue()) {
- String ver=alarmsInformation.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }
- if(null!=alarmsInformation.getSourceId()) {
- String ver=alarmsInformation.getSourceId();
- hql.append(" and a.sourceId = '"+ver+"'");
- }
- if(null!=alarmsInformation.getStartEpochMicroSec() || alarmsInformation.getLastEpochMicroSec()!= null) {
- hql.append(" and a.startEpochMicrosec between :startTime and :endTime");
- }
- }
- Query query = session.createQuery(hql.toString());
- if(null!=alarmsInformation.getStartEpochMicroSec() || alarmsInformation.getLastEpochMicroSec()!= null) {
- query.setString("startTime",alarmsInformation.getStartEpochMicroSec());
- query.setString("endTime",alarmsInformation.getLastEpochMicroSec());
- }
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<AlarmsInformation> list= query.list();
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- return page;
- } catch (Exception e) {
- logger.error("exception occurred while performing AlarmsInformationServiceImpl queryAlarmsInformation. Details:" + e.getMessage());
- return null;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
public List<AlarmsInformation> queryId(String[] id) {
try {
if(id.length==0) {
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java index a1d55616..64ab23f4 100755 --- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java @@ -88,90 +88,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation }
}
- public int getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize) {
- try(Session session = getSession()){
- StringBuffer hql = new StringBuffer("select count(*) from PerformanceInformation a where 1=1");
- if (null == performanceInformation) {
- }else {
- if(null!=performanceInformation.getName()) {
- String ver=performanceInformation.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }
- if(null!=performanceInformation.getValue()) {
- String ver=performanceInformation.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }
- if(null!=performanceInformation.getSourceId()) {
- String ver=performanceInformation.getSourceId();
- hql.append(" and a.sourceId = '"+ver+"'");
- }
- if(null!=performanceInformation.getStartEpochMicrosec() || performanceInformation.getLastEpochMicroSec()!= null) {
- hql.append(" and a.startEpochMicrosec between :startTime and :endTime");
- }
- }
- Query query = session.createQuery(hql.toString());
- if(null!=performanceInformation.getStartEpochMicrosec() || performanceInformation.getLastEpochMicroSec()!= null) {
- query.setString("startTime",performanceInformation.getStartEpochMicrosec());
- query.setString("endTime",performanceInformation.getLastEpochMicroSec());
- }
- long q=(long) query.uniqueResult();
- session.flush();
- return (int)q;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<PerformanceInformation> queryPerformanceInformation(PerformanceInformation performanceInformation,
- int currentPage, int pageSize) {
- Page<PerformanceInformation> page = new Page<PerformanceInformation>();
- int allRow =this.getAllCount(performanceInformation,currentPage,pageSize);
- int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = getSession()){
- StringBuffer hql =new StringBuffer("from PerformanceInformation a where 1=1 ");
- if (null == performanceInformation) {
- }else {
- if(null!=performanceInformation.getName()) {
- String ver=performanceInformation.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }
- if(null!=performanceInformation.getValue()) {
- String ver=performanceInformation.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }
- if(null!=performanceInformation.getSourceId()) {
- String ver=performanceInformation.getSourceId();
- hql.append(" and a.sourceId = '"+ver+"'");
- }
- if(null!=performanceInformation.getStartEpochMicrosec() || performanceInformation.getLastEpochMicroSec()!= null) {
- hql.append(" and a.startEpochMicrosec between :startTime and :endTime");
- }
- }
- Query query = session.createQuery(hql.toString());
- if(null!=performanceInformation.getStartEpochMicrosec() || performanceInformation.getLastEpochMicroSec()!= null) {
- query.setString("startTime",performanceInformation.getStartEpochMicrosec());
- query.setString("endTime",performanceInformation.getLastEpochMicroSec());
- }
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<PerformanceInformation> list= query.list();
-
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- return page;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationServiceImpl queryPerformanceInformation. Details:" + e.getMessage());
- return null;
- }
- }
-
@SuppressWarnings("unchecked")
@Override
public List<PerformanceInformation> queryId(String[] id) {
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java index 49d3fa46..61aba39d 100644 --- a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java @@ -177,21 +177,6 @@ public class AlarmsInformationServiceImplTest { } @Test - public void testQueryAlarmsInformation() throws Exception { - try { - AlarmsInformation ai = new AlarmsInformation(); - ai.setName(""); - ai.setValue(""); - ai.setSourceId(""); - ai.setStartEpochMicroSec("");; - ai.setLastEpochMicroSec("");; - alarmsInformationServiceImpl.queryAlarmsInformation(ai, 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test public void testQueryId() throws Exception { try { String[] id = {"1", "2", "3"}; diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java index 08a9c8b2..79bbf18d 100644 --- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java @@ -156,42 +156,6 @@ public class PerformanceInformationServiceImplTest { } @Test - public void testGetAllCount() throws Exception { - new MockUp<Query>() { - @Mock - public Object uniqueResult() { - return "1"; - } - }; - try { - PerformanceInformation pi = new PerformanceInformation(); - pi.setName(""); - pi.setValue(""); - pi.setSourceId(""); - pi.setStartEpochMicrosec("");; - pi.setLastEpochMicroSec("");; - performanceInformationServiceImpl.getAllCount(pi, 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testQueryPerformanceInformation() throws Exception { - try { - PerformanceInformation pi = new PerformanceInformation(); - pi.setName(""); - pi.setValue(""); - pi.setSourceId(""); - pi.setStartEpochMicrosec("");; - pi.setLastEpochMicroSec("");; - performanceInformationServiceImpl.queryPerformanceInformation(pi, 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test public void testQueryId() throws Exception { try { String[] id = {"1", "2", "3"}; |