aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguochuyicmri <guochuyi@chinamobile.com>2018-11-08 14:31:20 +0800
committerguochuyicmri <guochuyi@chinamobile.com>2018-11-08 14:31:27 +0800
commit8af2752b1dd509cddf737fc5198531cdf487f1a5 (patch)
tree16542c4987422aefec742fdbc6518fa74c6a1276
parent672ca1d0ec9dfd237612b091200fd950d3ba833a (diff)
Fix VNF Performance Query Bugs
Change-Id: I56288e86a7295d4c946a0e6ccedd5d8a1e1beeae Issue-ID: USECASEUI-166 Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java20
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java78
2 files changed, 17 insertions, 81 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
index d113f164..6b7eecca 100755
--- a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
@@ -32,7 +32,6 @@ import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.constant.Constant;
import org.onap.usecaseui.server.service.PerformanceHeaderService;
import org.onap.usecaseui.server.service.PerformanceInformationService;
-import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
import org.onap.usecaseui.server.util.UuiCommonUtil;
import org.slf4j.Logger;
@@ -42,6 +41,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -72,11 +72,11 @@ public class PerformanceController {
private ObjectMapper omPerformance = new ObjectMapper();
- @RequestMapping(value = {"/performance/{currentPage}/{pageSize}","/performance/{currentPage}/{pageSize}/{sourceName}/{startTime}/{endTime}"},method = RequestMethod.GET, produces = "application/json")
+ @RequestMapping(value = {"/performance/{currentPage}/{pageSize}"},method = RequestMethod.GET, produces = "application/json")
public String getPerformanceData(@PathVariable String currentPage,
@PathVariable String pageSize,
- @PathVariable(required = false) String sourceName,
- @PathVariable(required = false) String startTime,@PathVariable(required = false) String endTime) throws JsonProcessingException, ParseException {
+ @RequestParam(required = false) String sourceName,
+ @RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime) throws JsonProcessingException, ParseException {
Page<PerformanceHeader> pa = new Page<PerformanceHeader>();
PerformanceHeader performanceHeader = new PerformanceHeader();
performanceHeader.setSourceName(sourceName);
@@ -122,9 +122,9 @@ public class PerformanceController {
return string;
}
- @RequestMapping(value = {"/performanceSsourceNames/{currentPage}/{pageSize}/{sourceName}"},method = RequestMethod.GET, produces = "application/json")
- public String getPerformanceSourceNames(@PathVariable int currentPage,@PathVariable int pageSize,
- @PathVariable(required = false) String sourceName) throws JsonProcessingException{
+ @RequestMapping(value = {"/performance/getSourceNames/{currentPage}/{pageSize}"},method = RequestMethod.GET, produces = "application/json")
+ public String getPerformanceSourceNames(@PathVariable String currentPage,@PathVariable String pageSize,
+ @RequestParam(required = false) String sourceName) throws JsonProcessingException{
PerformanceHeader performanceHeader = new PerformanceHeader();
Page<PerformanceHeader> page = new Page<PerformanceHeader>();
Set<String> names = new HashSet<String>();
@@ -144,8 +144,8 @@ public class PerformanceController {
names.add(name);
}
Map<String,Object> map = new HashMap<>();
- map.put("names",names);
- map.put("totalRecords",UuiCommonUtil.getPageList(new ArrayList(names), currentPage, pageSize));
- return omPerformance.writeValueAsString(names);
+ map.put("names",names.size());
+ map.put("totalRecords",UuiCommonUtil.getPageList(new ArrayList(names), Integer.parseInt(currentPage),Integer.parseInt(pageSize)));
+ return omPerformance.writeValueAsString(map);
}
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
index effd2fae..3b49a7ee 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
@@ -93,76 +93,12 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
if (null == performanceHeder) {
return 0;
}else {
- if(null!=performanceHeder.getVersion()) {
- String ver=performanceHeder.getVersion();
- hql.append(" and a.version like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getEventName()) {
- String ver=performanceHeder.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getDomain()) {
- String ver=performanceHeder.getDomain();
- hql.append(" and a.domain like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getEventId()) {
- String ver=performanceHeder.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceHeder.getNfcNamingCode()) {
- String ver=performanceHeder.getNfcNamingCode();
- hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getNfNamingCode()) {
- String ver=performanceHeder.getNfNamingCode();
- hql.append(" and a.nfNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getSourceId()) {
- String ver =performanceHeder.getSourceId();
- hql.append(" and a.sourceId like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getSourceName()) {
+ if(UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getSourceName())) {
String ver =performanceHeder.getSourceName();
hql.append(" and a.sourceName like '%"+ver+"%'");
}
- if(null!=performanceHeder.getReportingEntityId()) {
- String ver =performanceHeder.getReportingEntityId();
- hql.append(" and a.reportingEntityId like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getReportingEntityName()) {
- String ver =performanceHeder.getReportingEntityName();
- hql.append(" and a.reportingEntityName like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getPriority()) {
- String ver =performanceHeder.getPriority();
- hql.append(" and a.priority like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getStartEpochMicrosec()) {
- String ver =performanceHeder.getStartEpochMicrosec();
- hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getLastEpochMicroSec()) {
- String ver =performanceHeder.getLastEpochMicroSec();
- hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getSequence()) {
- String ver =performanceHeder.getSequence();
- hql.append(" and a.sequence like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getMeasurementsForVfScalingVersion()) {
- String ver =performanceHeder.getMeasurementsForVfScalingVersion();
- hql.append(" and a.measurementsForVfScalingVersion like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getMeasurementInterval()) {
- String ver =performanceHeder.getMeasurementInterval();
- hql.append(" and a.measurementInterval like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getEventType()) {
- String ver =performanceHeder.getEventType();
- hql.append(" and a.eventType like '%"+ver+"%'");
- }
- if(null!=performanceHeder.getStartEpochMicrosec() && null!=performanceHeder.getLastEpochMicroSec()) {
- hql.append(" and a.startEpochMicrosec between :startTime and :endTime ");
+ if(UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getStartEpochMicrosec())&& UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getLastEpochMicroSec())) {
+ hql.append(" and (CASE WHEN a.startEpochMicrosec=0 THEN a.lastEpochMicroSec ELSE a.startEpochMicrosec END) between :startTime and :endTime ");
}
}
Query query = session.createQuery(hql.toString());
@@ -187,15 +123,15 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
try(Session session = getSession()){
StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");
- if(null!=performanceHeder.getSourceName()) {
+ if(UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getSourceName())) {
String ver =performanceHeder.getSourceName();
hql.append(" and a.sourceName like '%"+ver+"%'");
}
- if(null!=performanceHeder.getStartEpochMicrosec() && null!=performanceHeder.getLastEpochMicroSec()) {
- hql.append(" and a.startEpochMicrosec between :startTime and :endTime ");
+ if(UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getStartEpochMicrosec())&& UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getLastEpochMicroSec())) {
+ hql.append(" and (CASE WHEN a.startEpochMicrosec=0 THEN a.lastEpochMicroSec ELSE a.startEpochMicrosec END) between :startTime and :endTime ");
}
Query query = session.createQuery(hql.toString());
- if(null!=performanceHeder.getStartEpochMicrosec() && null!=performanceHeder.getLastEpochMicroSec()) {
+ if(UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getStartEpochMicrosec())&& UuiCommonUtil.isNotNullOrEmpty(performanceHeder.getLastEpochMicroSec())) {
query.setString("startTime",performanceHeder.getStartEpochMicrosec()).setString("endTime",performanceHeder.getLastEpochMicroSec());
}
query.setFirstResult(offset);