summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshentao <shentao@chinamobile.com>2017-11-13 15:31:11 +0800
committershentao <shentao@chinamobile.com>2017-11-13 15:31:17 +0800
commitb08cc1d19a88e809aca5a3f0a3320dfbf1fcaab1 (patch)
tree9f522211b08e88d777579c25ff5b61d4a70f1b93
parent84fc8dc221558d392998bd9a08085c4297402735 (diff)
Fix dmaap calling bug
Change-Id: I57c63ff3cc237d56ed38fb27d4a8a89f10f6f075 Issue-Id: USECASEUI-54 Signed-off-by: shentao <shentao@chinamobile.com>
-rw-r--r--pom.xml2
-rw-r--r--resources/bin/initDB.sh50
-rw-r--r--resources/dbscripts/mysql/usecase-ui-createdb.sql31
-rw-r--r--resources/dbscripts/mysql/usecase-ui-createobj.sql111
-rw-r--r--server/pom.xml2
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java7
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java6
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java12
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java4
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java69
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java92
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java12
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java3
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java2
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java3
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java37
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java43
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java45
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java35
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java4
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java4
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java15
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgressInformation.java10
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java11
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java30
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java287
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java484
-rw-r--r--server/src/main/resources/dmaap.properties5
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java4
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java9
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java5
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java55
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java158
-rw-r--r--standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql16
34 files changed, 630 insertions, 1033 deletions
diff --git a/pom.xml b/pom.xml
index 0c61226e..9565873c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -191,7 +191,7 @@
<dependency>
<groupId>org.openecomp.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.1.3</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
diff --git a/resources/bin/initDB.sh b/resources/bin/initDB.sh
deleted file mode 100644
index 06d2bfc8..00000000
--- a/resources/bin/initDB.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-DIRNAME=`dirname $0`
-HOME=`cd $DIRNAME/; pwd`
-user=$1
-password=$2
-port=$3
-host=$4
-echo "start create usecase-ui db"
-sql_path=$HOME/../
-mysql -u$user -p$password -P$port -h$host <$sql_path/dbscripts/mysql/usecase-ui-createdb.sql
-sql_result=$?
-if [ $sql_result != 0 ] ; then
- echo "failed to create usecase-ui database"
- exit 1
-fi
-fileFlag=*createobj.sql
-location=$sql_path/dbscripts/mysql
-fileName=""
-for i in `ls $location`
-do
- if [[ $i == ${fileFlag} ]];then
- fileName=${i};
- echo "start create table:${fileName}"
- mysql -u$user -p$password -P$port -h$host <$sql_path/dbscripts/mysql/$fileName
- sql_result=$?
- if [ $sql_result != 0 ] ; then
- echo "failed to init usecase-ui table:${fileName}"
- exit 1
- fi
- fi
-done
-echo "init usecase-ui database success!"
-exit 0
-
diff --git a/resources/dbscripts/mysql/usecase-ui-createdb.sql b/resources/dbscripts/mysql/usecase-ui-createdb.sql
deleted file mode 100644
index 31ab5b5e..00000000
--- a/resources/dbscripts/mysql/usecase-ui-createdb.sql
+++ /dev/null
@@ -1,31 +0,0 @@
---
--- Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
-
-/******************drop old database and user***************************/
-use mysql;
-drop database IF EXISTS usercaseui;
-delete from user where User='usecaseui';
-FLUSH PRIVILEGES;
-
-/******************create new database and user***************************/
-create database usercaseui CHARACTER SET utf8;
-
-GRANT ALL PRIVILEGES ON usercaseui.* TO 'usercaseui'@'%' IDENTIFIED BY 'usercaseui' WITH GRANT OPTION;
-GRANT ALL PRIVILEGES ON mysql.* TO 'usercaseui'@'%' IDENTIFIED BY 'usercaseui' WITH GRANT OPTION;
-
-GRANT ALL PRIVILEGES ON usercaseui.* TO 'usercaseui'@'localhost' IDENTIFIED BY 'usercaseui' WITH GRANT OPTION;
-GRANT ALL PRIVILEGES ON mysql.* TO 'usercaseui'@'localhost' IDENTIFIED BY 'usercaseui' WITH GRANT OPTION;
-FLUSH PRIVILEGES; \ No newline at end of file
diff --git a/resources/dbscripts/mysql/usecase-ui-createobj.sql b/resources/dbscripts/mysql/usecase-ui-createobj.sql
deleted file mode 100644
index 7f839578..00000000
--- a/resources/dbscripts/mysql/usecase-ui-createobj.sql
+++ /dev/null
@@ -1,111 +0,0 @@
---
--- Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
-
-use usercaseui;
-
-SET FOREIGN_KEY_CHECKS=0;
--- ----------------------------
--- Table structure for alarms_additionalinformation
--- ----------------------------
-DROP TABLE IF EXISTS `alarms_additionalinformation`;
-CREATE TABLE `alarms_additionalinformation` (
- `name` varchar(50) NOT NULL,
- `value` varchar(500) NOT NULL,
- `eventId` varchar(30) NOT NULL,
- `createTime` datetime NOT NULL,
- `updateTime` datetime NOT NULL,
- `id` int(10) NOT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Table structure for alarms_commoneventheader
--- ----------------------------
-DROP TABLE IF EXISTS `alarms_commoneventheader`;
-CREATE TABLE `alarms_commoneventheader` (
- `version` varchar(10) NOT NULL,
- `eventName` varchar(50) NOT NULL,
- `domain` varchar(30) NOT NULL,
- `eventId` varchar(30) NOT NULL,
- `eventType` varchar(30) NOT NULL,
- `nfcNamingCode` varchar(30) DEFAULT NULL,
- `nfNamingCode` varchar(30) DEFAULT NULL,
- `sourceId` varchar(50) NOT NULL,
- `sourceName` varchar(50) NOT NULL,
- `reportingEntityId` varchar(30) NOT NULL,
- `reportingEntityName` varchar(30) NOT NULL,
- `priority` varchar(20) NOT NULL,
- `startEpochMicrosec` varchar(20) NOT NULL,
- `lastEpochMicroSec` varchar(20) NOT NULL,
- `sequence` varchar(10) NOT NULL,
- `faultFieldsVersion` varchar(10) NOT NULL,
- `eventServrity` varchar(30) NOT NULL,
- `eventSourceType` varchar(30) NOT NULL,
- `eventCategory` varchar(30) NOT NULL,
- `alarmCondition` varchar(400) NOT NULL,
- `specificProblem` varchar(400) NOT NULL,
- `vfStatus` varchar(10) NOT NULL,
- `alarmInterfaceA` varchar(40) NOT NULL,
- `status` varchar(11) NOT NULL,
- `createTime` datetime NOT NULL,
- `updateTime` datetime NOT NULL,
- PRIMARY KEY (`eventName`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Table structure for performance_additionalinformation
--- ----------------------------
-DROP TABLE IF EXISTS `performance_additionalinformation`;
-CREATE TABLE `performance_additionalinformation` (
- `name` varchar(50) NOT NULL,
- `value` varchar(500) NOT NULL,
- `eventId` varchar(30) NOT NULL,
- `createTime` datetime NOT NULL,
- `updateTime` datetime NOT NULL,
- `id` int(10) NOT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Table structure for performance_commoneventheader
--- ----------------------------
-DROP TABLE IF EXISTS `performance_commoneventheader`;
-CREATE TABLE `performance_commoneventheader` (
- `version` varchar(10) NOT NULL,
- `eventName` varchar(50) NOT NULL,
- `domain` varchar(30) NOT NULL,
- `eventId` varchar(30) NOT NULL,
- `eventType` varchar(30) NOT NULL,
- `nfcNamingCode` varchar(30) DEFAULT NULL,
- `nfNamingCode` varchar(30) DEFAULT NULL,
- `sourceId` varchar(50) NOT NULL,
- `sourceName` varchar(50) NOT NULL,
- `reportingEntityId` varchar(30) NOT NULL,
- `reportingEntityName` varchar(30) NOT NULL,
- `priority` varchar(20) NOT NULL,
- `startEpochMicrosec` varchar(20) NOT NULL,
- `lastEpochMicroSec` varchar(20) NOT NULL,
- `sequence` varchar(10) NOT NULL,
- `measurementsForVfScalingVersion` varchar(10) NOT NULL,
- `measurementInterval` varchar(10) NOT NULL,
- `createTime` datetime NOT NULL,
- `updateTime` datetime NOT NULL,
- PRIMARY KEY (`eventName`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Init Records
--- ---------------------------- \ No newline at end of file
diff --git a/server/pom.xml b/server/pom.xml
index 64449467..a9859580 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -192,7 +192,7 @@
<dependency>
<groupId>org.openecomp.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.1.3</version>
+ <version>1.1.1</version>
</dependency>
<dependency>
diff --git a/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java b/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java
index a99a6c5c..7b9a0b53 100644
--- a/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java
+++ b/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java
@@ -31,10 +31,9 @@ public class UsecaseuiServerApplication {
return new RestTemplate();
}
- public static void main(String[] args) {
- SpringApplication.run(UsecaseuiServerApplication.class, args);
+ public static void main(String[] args) {
+ SpringApplication.run(UsecaseuiServerApplication.class, args);
DmaapSubscriber dmaapSubscriber = new DmaapSubscriber();
dmaapSubscriber.run();
- }
-
+ }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java
index fd896c52..2edaa155 100644
--- a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java
@@ -111,10 +111,12 @@ public class AlarmsHeader implements Serializable{
public AlarmsHeader() {
}
- public AlarmsHeader(String eventId) {
- this.eventId = eventId;
+ public AlarmsHeader(String sourceId) {
+ this.sourceId = sourceId;
}
+
+
public AlarmsHeader(String version, String eventName, String domain, String eventId, String eventType, String nfcNamingCode, String nfNamingCode, String sourceId, String sourceName, String reportingEntityId, String reportingEntityName, String priority, String startEpochMicrosec, String lastEpochMicroSec, String sequence, String faultFieldsVersion, String eventServrity, String eventSourceType, String eventCategory, String alarmCondition, String specificProblem, String vfStatus, String alarmInterfaceA, String status, Date createTime, Date updateTime) {
this.version = version;
this.eventName = eventName;
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java
index ef3ae55f..4d298e02 100644
--- a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java
@@ -51,6 +51,18 @@ public class AlarmsInformation implements Serializable {
@Column(name = "updateTime")
private Date updateTime;
+ @Override
+ public String toString() {
+ return "AlarmsInformation{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", value='" + value + '\'' +
+ ", eventId='" + eventId + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ '}';
+ }
+
public AlarmsInformation() {
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
index c42fcf8e..1d4bd8fa 100755
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
@@ -90,7 +90,9 @@ public class PerformanceHeader implements Serializable {
public PerformanceHeader() {
}
-
+ public PerformanceHeader(String sourceId) {
+ this.sourceId = sourceId;
+ }
public PerformanceHeader(String version, String eventName, String domain, String eventId, String eventType, String nfcNamingCode, String nfNamingCode, String sourceId, String sourceName, String reportingEntityId, String reportingEntityName, String priority, String startEpochMicrosec, String lastEpochMicroSec, String sequence, String measurementsForVfScalingVersion, String measurementInterval, Date createTime, Date updateTime) {
this.version = version;
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 7b3bd7d4..ab7534c6 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
@@ -79,43 +79,50 @@ public class AlarmController
@RequestMapping(value = {"/alarm/{currentPage}/{pageSize}",
- "/alarm/{currentPage}/{pageSize}/{eventId}/{eventName}/{name}/{value}/{createTime}/{status}/{vfStatus}"},
+ "/alarm/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}/{vfStatus}"},
method = RequestMethod.GET , produces = "application/json")
- public String getAlarmData(@PathVariable(required = false) String eventId,@PathVariable(required = false) String eventName,
- @PathVariable(required = false) String name,@PathVariable(required = false) String value,
- @PathVariable(required = false) String createTime,@PathVariable(required = false) String status,
- @PathVariable(required = false) String vfStatus,
+ public String getAlarmData(@PathVariable(required = false) String sourceId,@PathVariable(required = false) String sourceName,
+ @PathVariable(required = false) String priority,@PathVariable(required = false) String startTime,
+ @PathVariable(required = false) String endTime,@PathVariable(required = false) String vfStatus,
@PathVariable int currentPage, @PathVariable int pageSize) throws JsonProcessingException {
logger.info("transfer getAlarmData Apis, " +
- "Parameter all follows : [currentPage : {} , pageSize : {} , eventId : {} , " +
- "eventName : {} , name : {} , value :{} , createTime : {} , status : {} , vfStatus : {}]"
- ,currentPage,pageSize,eventId,eventName,name,value,createTime,status,vfStatus);
+ "Parameter all follows : [currentPage : {} , pageSize : {} , sourceId : {} , " +
+ "sourceName : {} , priority : {} , startTime :{} , endTime : {} , vfStatus : {}]"
+ ,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime,vfStatus);
List<AlarmsHeader> alarmsHeaders = null;
List<AlarmBo> list = new ArrayList<>();
Page pa = null;
- if (null != eventId || null != eventName || null != name || null != value || null != createTime
- || null != status || null != vfStatus ){
+ if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime
+ || null != vfStatus ){
AlarmsHeader alarm = new AlarmsHeader();
- alarm.setEventId(!"null".equals(eventId)?eventId:null);
- alarm.setEventName(!"null".equals(eventName)?eventName:null);
- alarm.setStatus(!"null".equals(status)?status:null);
- alarm.setVfStatus(!"null".equals(vfStatus)?vfStatus:null);
+ alarm.setSourceId(!"null".equals(sourceId)?sourceId:null);
+ alarm.setSourceName(!"null".equals(sourceName)?sourceName:null);
+ alarm.setStatus(!"null".equals(vfStatus)?vfStatus:null);
try {
- alarm.setCreateTime(!"null".equals(createTime)?DateUtils.stringToDate(createTime):null);
+ alarm.setCreateTime(!"null".equals(startTime)?new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(startTime):null);
+ alarm.setUpdateTime(!"null".equals(endTime)?new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime):null);
} catch (ParseException e) {
logger.error("Parse date error :"+e.getMessage());
}
pa = alarmsHeaderService.queryAlarmsHeader(alarm,currentPage,pageSize);
+
alarmsHeaders = pa.getList();
if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
alarmsHeaders.forEach(a ->{
AlarmBo abo = new AlarmBo();
abo.setAlarmsHeader(a);
AlarmsInformation information = new AlarmsInformation();
- information.setName(!"null".equals(name)?name:null);
- information.setValue(!"null".equals(value)?value:null);
- information.setEventId(a.getEventId());
- abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(information,1,100).getList());
+ information.setEventId(a.getSourceId());
+ List<AlarmsInformation> informationList = alarmsInformationService.queryAlarmsInformation(information,1,100).getList();
+ informationList.forEach( il -> {
+ if (il.getValue().equals("")){
+ StringBuffer value1 = new StringBuffer();
+ alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(il.getName()),1,100).getList()
+ .forEach( val -> value1.append(val.getValue()) );
+ il.setValue(value1.toString());
+ }
+ } );
+ abo.setAlarmsInformation(informationList);
list.add(abo);
});
}
@@ -184,4 +191,28 @@ public class AlarmController
}
}
+ @RequestMapping(value = {"/alarm/sourceId"},method = RequestMethod.GET)
+ public String getSourceId(){
+ List<String> sourceIds = new ArrayList<>();
+ alarmsHeaderService.queryAlarmsHeader(null,1,Integer.MAX_VALUE).getList().forEach( al ->{
+ sourceIds.add(al.getSourceId());
+ } );
+ try {
+ return omAlarm.writeValueAsString(sourceIds);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+ @RequestMapping(value = {"/alarm/diagram"},method = RequestMethod.POST)
+ public String genDiagram(@RequestParam String sourceId,@RequestParam String startTime,@RequestParam String endTime){
+ try {
+ return omAlarm.writeValueAsString(alarmsInformationService.queryDateBetween(sourceId,startTime,endTime));
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
}
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 19a69b93..2f0b9722 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
@@ -36,10 +36,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -67,27 +64,28 @@ public class PerformanceController {
private ObjectMapper omPerformance = new ObjectMapper();
- @RequestMapping(value = {"/performance/{currentPage}/{pageSize}","/performance/{currentPage}/{pageSize}/{eventId}/{eventName}/{name}/{value}/{createTime}"},method = RequestMethod.GET, produces = "application/json")
+ @RequestMapping(value = {"/performance/{currentPage}/{pageSize}","/performance/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}"},method = RequestMethod.GET, produces = "application/json")
public String getPerformanceData(HttpServletResponse response,@PathVariable int currentPage,
- @PathVariable int pageSize,@PathVariable(required = false) String eventId,
- @PathVariable(required = false) String eventName,@PathVariable(required = false) String name,
- @PathVariable(required = false) String value,@PathVariable(required = false) String createTime) throws JsonProcessingException {
+ @PathVariable int pageSize,@PathVariable(required = false) String sourceId,
+ @PathVariable(required = false) String sourceName,@PathVariable(required = false) String priority,
+ @PathVariable(required = false) String startTime,@PathVariable(required = false) String endTime) throws JsonProcessingException {
logger.info("transfer getAlarmData Apis, " +
- "Parameter all follows : [currentPage : {} , pageSize : {} , eventId : {} , " +
- "eventName : {} , name : {} , value :{} , createTime : {} ]"
- ,currentPage,pageSize,eventId,eventName,name,value,createTime);
+ "Parameter all follows : [currentPage : {} , pageSize : {} , sourceId : {} , " +
+ "sourceName : {} , priority : {} , startTime :{} , endTime : {} ]"
+ ,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime);
List<Object> list = new ArrayList<>();
Page pa = null;
- if (null != eventId || null != eventName || null != name || null != value || null != createTime){
+ if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime){
PerformanceHeader performanceHeader = new PerformanceHeader();
- performanceHeader.setEventId(!"null".equals(eventId)?eventId:null);
- performanceHeader.setEventName(!"null".equals(eventName)?eventName:null);
+ performanceHeader.setSourceId(!"null".equals(sourceId)?sourceId:null);
+ performanceHeader.setSourceName(!"null".equals(sourceName)?sourceName:null);
try {
- performanceHeader.setCreateTime(!"null".equals(createTime)?DateUtils.stringToDate(createTime):null);
+ performanceHeader.setCreateTime(!"null".equals(startTime)?new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(startTime):null);
+ performanceHeader.setUpdateTime(!"null".equals(endTime)?new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime):null);
} catch (ParseException e) {
if (null != response)
response.setStatus(400);
- logger.error("ParseException["+createTime+"]:"+e.getMessage());
+ logger.error("ParseException["+startTime+"]:"+e.getMessage());
return "{'result':'error'}";
}
pa = performanceHeaderService.queryPerformanceHeader(performanceHeader,currentPage,pageSize);
@@ -95,11 +93,17 @@ public class PerformanceController {
performanceHeaders.forEach( per ->{
PerformanceBo pbo = new PerformanceBo();
PerformanceInformation pe = new PerformanceInformation();
- pe.setEventId(per.getEventId());
- pe.setName(!"null".equals(name)?name:null);
- pe.setValue(!"null".equals(value)?value:null);
+ pe.setEventId(per.getSourceId());
List<PerformanceInformation> performanceInformations = performanceInformationService.queryPerformanceInformation(pe,1,100).getList();
pbo.setPerformanceHeader(per);
+ performanceInformations.forEach( pi ->{
+ if (pi.getValue().equals("")){
+ StringBuffer value1 = new StringBuffer();
+ performanceInformationService.queryPerformanceInformation(new PerformanceInformation(pi.getName()),1,100).getList()
+ .forEach( val -> value1.append(val.getValue()));
+ pi.setValue(value1.toString());
+ }
+ } );
pbo.setPerformanceInformation(performanceInformations);
list.add(pbo);
});
@@ -258,4 +262,56 @@ public class PerformanceController {
return omPerformance.writeValueAsString(diagramSource);
}
+ @RequestMapping(value = {"/performance/diagram"}, method = RequestMethod.POST, produces = "application/json")
+ public String generateDiagram(@RequestParam String sourceId,@RequestParam String startTime,@RequestParam String endTime,@RequestParam String nameParent,@RequestParam(required = false) String nameChild) {
+ List<Integer> diagramSource = new ArrayList<>();
+ try {
+ logger.info(sourceId+":"+startTime+":"+endTime+":"+nameParent+":"+nameChild);
+ if (performanceHeaderService.queryPerformanceHeader(new PerformanceHeader(sourceId),1,10).getList() != null){
+ if (nameChild != null && !"".equals(nameChild)){
+ sourceId = nameParent;
+ nameParent = nameChild;
+ }
+ performanceInformationService.queryDateBetween(sourceId,nameParent,startTime,endTime)
+ .forEach( per -> {
+ diagramSource.add(Integer.parseInt(per.getValue()));
+ });
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ try {
+ return omPerformance.writeValueAsString(diagramSource);
+ } catch (JsonProcessingException e) {
+ logger.error("JsonProcessingException:"+e.getMessage());
+ return "";
+ }
+ }
+
+ @RequestMapping(value = {"/performance/resourceIds"},method = RequestMethod.GET)
+ public String getSourceIds(){
+ try {
+ return omPerformance.writeValueAsString(performanceHeaderService.queryAllSourceId());
+ } catch (JsonProcessingException e) {
+ logger.error(e.getMessage());
+ return "";
+ }
+ }
+
+ @RequestMapping(value = {"/performance/names"},method = RequestMethod.POST)
+ public String getNames(@RequestParam Object sourceId){
+ try {
+ List<String> names = new ArrayList<>();
+ performanceInformationService.queryDateBetween(sourceId.toString(),null,null,null).forEach( per ->{
+ if (!names.contains(per.getName()))
+ names.add(per.getName());
+ } );
+ return omPerformance.writeValueAsString(names);
+ } catch (JsonProcessingException e) {
+ logger.error(e.getMessage());
+ return "";
+ }
+ }
+
+
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java
index ab0780f3..0de43e1d 100644
--- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java
@@ -66,16 +66,4 @@ public class PackageDistributionController {
public JobStatus getJobStatus(@PathVariable(value="jobId") String jobId){
return packageDistributionService.getJobStatus(jobId);
}
-
- @ResponseBody
- @RequestMapping(value = {"/uui-lcm/ns-packages/{casrId}"}, method = RequestMethod.GET , produces = "application/json")
- public DistributionResult deleteNsPackage(@PathVariable("casrId") String casrId){
- return packageDistributionService.deleteNsPackage(casrId);
- }
-
- @ResponseBody
- @RequestMapping(value = {"/uui-lcm/vf-packages/{casrId}"}, method = RequestMethod.GET , produces = "application/json")
- public DistributionResult deleteVfPackage(@PathVariable("casrId") String casrId){
- return packageDistributionService.deleteVfPackage(casrId);
- }
}
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 58b9b6d0..70c37e31 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
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server.service;
import java.util.List;
+import java.util.Map;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
@@ -33,4 +34,6 @@ public interface AlarmsInformationService {
Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation, int currentPage, int pageSize);
List<AlarmsInformation> queryId(String[] id);
+
+ List<Map<String,String>> queryDateBetween(String sourceId, String startTime, String endTime);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java
index 683903d3..4e346efe 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java
@@ -33,4 +33,6 @@ public interface PerformanceHeaderService {
Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage, int pageSize);
List<PerformanceHeader> queryId(String[] id);
+
+ List<String> queryAllSourceId();
}
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 d3060d8e..58932f15 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
@@ -38,4 +38,7 @@ public interface PerformanceInformationService {
List<PerformanceInformation> queryDateBetween(String eventId, Date startDate, Date endDate);
int queryDataBetweenSum(String eventId, String name, Date startDate, Date endDate);
+
+ List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime);
+
}
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 91c090af..a627f1f3 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
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server.service.impl;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -28,6 +29,7 @@ import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
+import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -187,16 +189,16 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
String ver =alarmsHeader.getStatus();
count.append(" and a.status = '"+ver+"'");
}
- if(null!=alarmsHeader.getCreateTime()) {
- Date ver =alarmsHeader.getCreateTime();
- count.append(" and a.createTime > '%"+ver+"%'");
- }
- if(null!=alarmsHeader.getUpdateTime()) {
- Date ver =alarmsHeader.getUpdateTime();
- count.append(" and a.updateTime like '%"+ver+"%'");
- }
- }
- long q=(long)session.createQuery(count.toString()).uniqueResult();
+ if(null!=alarmsHeader.getCreateTime() || alarmsHeader.getUpdateTime()!= null) {
+ count.append(" and a.createTime between :startTime and :endTime");
+ }
+ }
+ Query query = session.createQuery(count.toString());
+ if(null!=alarmsHeader.getCreateTime() || alarmsHeader.getUpdateTime()!= null) {
+ query.setDate("startTime",alarmsHeader.getCreateTime());
+ query.setDate("endTime",alarmsHeader.getUpdateTime());
+ }
+ long q=(long)query.uniqueResult();
session.flush();
return (int)q;
} catch (Exception e) {
@@ -223,7 +225,7 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
if(null!=alarmsHeader.getEventName()) {
String ver=alarmsHeader.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
+ hql.append(" and a.eventName = '"+ver+"'");
}
if(null!=alarmsHeader.getAlarmCondition()) {
String ver=alarmsHeader.getAlarmCondition();
@@ -313,17 +315,16 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
String ver =alarmsHeader.getStatus();
hql.append(" and a.status = '"+ver+"'");
}
- if(null!=alarmsHeader.getCreateTime()) {
- Date ver =alarmsHeader.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }
- if(null!=alarmsHeader.getUpdateTime()) {
- Date ver =alarmsHeader.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
+ if(null!=alarmsHeader.getCreateTime() || alarmsHeader.getUpdateTime()!= null) {
+ hql.append(" and a.createTime between :startTime and :endTime");
}
}
logger.info("AlarmsHeaderServiceImpl queryAlarmsHeader: alarmsHeader={}", alarmsHeader);
Query query = session.createQuery(hql.toString());
+ if(null!=alarmsHeader.getCreateTime() || alarmsHeader.getUpdateTime()!= null) {
+ query.setDate("startTime",alarmsHeader.getCreateTime());
+ query.setDate("endTime",alarmsHeader.getUpdateTime());
+ }
query.setFirstResult(offset);
query.setMaxResults(pageSize);
List<AlarmsHeader> list= query.list();
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 6da264fa..32eec76e 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
@@ -16,9 +16,8 @@
package org.onap.usecaseui.server.service.impl;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.sql.Timestamp;
+import java.util.*;
import javax.transaction.Transactional;
@@ -190,7 +189,39 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
}
}
-
-
-
+
+ @Override
+ public List<Map<String,String>> queryDateBetween(String sourceId, String startTime, String endTime) {
+ try(Session session = sessionFactory.openSession();) {
+ List<Map<String,String>> mapList = new ArrayList<>();
+ String hql = "select a.createTime,count(*) from AlarmsInformation a where 1=1 ";
+ if (sourceId != null && !"".equals(sourceId)){
+ hql += " and a.eventId = :sourceId";
+ }
+ if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
+ hql += " and a.createTime between :startTime and :endTime ";
+ }
+ hql += " group by a.createTime";
+ Query query = session.createQuery(hql);
+ if (sourceId != null && !"".equals(sourceId)){
+ query.setString("sourceId",sourceId);
+ }
+ if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
+ query.setString("startTime", startTime).setString("endTime", endTime);
+ }
+ Iterator it= query.list().iterator();
+ while(it.hasNext()){
+ Object[] res=(Object[]) it.next();
+ Map<String,String> map = new HashMap<>();
+ map.put("Time",res[0].toString());
+ map.put("Count",res[1].toString());
+ mapList.add(map);
+ }
+ logger.info("AlarmsInformationServiceImpl queryDateBetween: list={}", mapList);
+ return mapList;
+ } catch (Exception e) {
+ logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. Details:" + e.getMessage());
+ return null;
+ }
+ }
}
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 3a4ddf54..39828fab 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
@@ -161,16 +161,15 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
String ver =performanceHeder.getEventType();
hql.append(" and a.eventType like '%"+ver+"%'");
}
- if(null!=performanceHeder.getCreateTime()) {
- Date ver =performanceHeder.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
+ if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
+ hql.append(" and a.createTime between :startTime and :endTime ");
}
- if(null!=performanceHeder.getUpdateTime()) {
- Date ver =performanceHeder.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- }
- long q=(long)session.createQuery(hql.toString()).uniqueResult();
+ }
+ Query query = session.createQuery(hql.toString());
+ if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
+ query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());
+ }
+ long q=(long)query.uniqueResult();
session.flush();
return (int)q;
} catch (Exception e) {
@@ -218,7 +217,7 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
if(null!=performanceHeder.getSourceId()) {
String ver =performanceHeder.getSourceId();
- hql.append(" and a.sourceId like '%"+ver+"%'");
+ hql.append(" and a.sourceId = '"+ver+"'");
}
if(null!=performanceHeder.getSourceName()) {
String ver =performanceHeder.getSourceName();
@@ -260,17 +259,15 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
String ver =performanceHeder.getEventType();
hql.append(" and a.eventType like '%"+ver+"%'");
}
- if(null!=performanceHeder.getCreateTime()) {
- Date ver =performanceHeder.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }
- if(null!=performanceHeder.getUpdateTime()) {
- Date ver =performanceHeder.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
+ if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
+ hql.append(" and a.createTime between :startTime and :endTime ");
+ }
}
logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHeder);
Query query = session.createQuery(hql.toString());
+ if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
+ query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());
+ }
query.setFirstResult(offset);
query.setMaxResults(pageSize);
List<PerformanceHeader> list= query.list();
@@ -305,6 +302,14 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
-
-
+ @Override
+ public List<String> queryAllSourceId() {
+ try(Session session = sessionFactory.openSession();) {
+ Query query = session.createQuery("select a.sourceId from PerformanceHeader a");
+ return query.list();
+ } catch (Exception e) {
+ logger.error("exception occurred while performing PerformanceHeaderServiceImpl queryAllSourceId. Details:" + e.getMessage());
+ return null;
+ }
+ }
}
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 0b4371ea..9ab975a6 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
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server.service.impl;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -26,6 +27,7 @@ import javax.transaction.Transactional;
import org.hibernate.*;
import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.service.PerformanceInformationService;
+import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -199,6 +201,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
List<PerformanceInformation> list = new ArrayList<>();
Query query = session.createQuery("from PerformanceInformation a where a.eventId = :eventId and a.createTime BETWEEN :startDate and :endDate");
list = query.setParameter("eventId",eventId).setParameter("startDate", startDate).setParameter("endDate",endDate).list();
+ logger.info("PerformanceInformationServiceImpl queryDateBetween: list={}", list);
return list;
} catch (Exception e) {
logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. Details:" + e.getMessage());
@@ -215,6 +218,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
int sum = 0;
Query query = session.createQuery("select sum(a.value) from PerformanceInformation a where a.eventId = :eventId and a.name = :name and a.createTime BETWEEN :startDate and :endDate");
sum = Integer.parseInt(query.setParameter("eventId",eventId).setParameter("name",name).setParameter("startDate", startDate).setParameter("endDate",endDate).uniqueResult().toString());
+ logger.info("PerformanceInformationServiceImpl queryDataBetweenSum: sum={}", sum);
return sum;
} catch (Exception e) {
logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDataBetweenSum. Details:" + e.getMessage());
@@ -222,4 +226,35 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
}
}
+ @Override
+ public List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime) {
+ try(Session session = sessionFactory.openSession();) {
+ String hql = "from PerformanceInformation a where 1=1 ";
+ if (resourceId != null && !"".equals(resourceId)){
+ hql += " and a.eventId = :resourceId";
+ }
+ if (name != null && !"".equals(name)){
+ hql += " and a.name = :name ";
+ }
+ if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
+ hql += " and a.createTime between :startTime and :endTime ";
+ }
+ Query query = session.createQuery(hql);
+ if (resourceId != null && !"".equals(resourceId)){
+ query.setString("resourceId",resourceId);
+ }
+ if (name != null && !"".equals(name)){
+ query.setString("name",name);
+ }
+ if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
+ query.setString("startTime", startTime).setString("endTime", endTime);
+ }
+ logger.info("PerformanceInformationServiceImpl queryDateBetween: list={}", query.list());
+ return query.list();
+ } catch (Exception e) {
+ logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java
index 76f6eef4..2778613e 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java
@@ -30,8 +30,4 @@ public interface PackageDistributionService {
Job postVfPackage(Csar csar);
JobStatus getJobStatus(String jobId);
-
- DistributionResult deleteNsPackage(String csarId);
-
- DistributionResult deleteVfPackage(String csarId);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java
index c9d5bf6e..3ceb3e72 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java
@@ -23,12 +23,12 @@ public class SDNCControllerRsp {
private List<SDNCController> esrThirdpartySdncList;
- @JsonProperty("esr-thirdparty-sdnc")
+ @JsonProperty("esr-thirdparty-sdnc-list")
public List<SDNCController> getEsrThirdpartySdncList() {
return esrThirdpartySdncList;
}
- @JsonProperty("esr-thirdparty-sdnc")
+ @JsonProperty("esr-thirdparty-sdnc-list")
public void setEsrThirdpartySdncList(List<SDNCController> esrThirdpartySdncList) {
this.esrThirdpartySdncList = esrThirdpartySdncList;
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java
index 6e401cef..ca3b9c11 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java
@@ -30,8 +30,6 @@ public class Vnf {
private String name;
- private String version;
-
public String getUuid() {
return uuid;
}
@@ -56,14 +54,6 @@ public class Vnf {
this.name = name;
}
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -71,12 +61,11 @@ public class Vnf {
Vnf vnf = (Vnf) o;
return Objects.equals(uuid, vnf.uuid) &&
Objects.equals(invariantUUID, vnf.invariantUUID) &&
- Objects.equals(name, vnf.name) &&
- Objects.equals(version, vnf.version);
+ Objects.equals(name, vnf.name);
}
@Override
public int hashCode() {
- return Objects.hash(uuid, invariantUUID, name, version);
+ return Objects.hash(uuid, invariantUUID, name);
}
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgressInformation.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgressInformation.java
index 90d2835a..2cf20ad0 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgressInformation.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgressInformation.java
@@ -20,13 +20,13 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown=true)
public class OperationProgressInformation {
- private OperationProgress operationStatus;
+ private OperationProgress operation;
- public OperationProgress getOperationStatus() {
- return operationStatus;
+ public OperationProgress getOperation() {
+ return operation;
}
- public void setOperationStatus(OperationProgress operationStatus) {
- this.operationStatus = operationStatus;
+ public void setOperation(OperationProgress operation) {
+ this.operation = operation;
}
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java
index 6f81b5c6..f7620742 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/vfc/VfcService.java
@@ -20,7 +20,10 @@ import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.DistributionResult
import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Job;
import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.JobStatus;
import retrofit2.Call;
-import retrofit2.http.*;
+import retrofit2.http.Body;
+import retrofit2.http.GET;
+import retrofit2.http.POST;
+import retrofit2.http.Path;
public interface VfcService {
@@ -32,10 +35,4 @@ public interface VfcService {
@GET("/api/nslcm/v1/jobs/{jobId}")
Call<JobStatus> getJobStatus(@Path("jobId") String jobId);
-
- @DELETE("/api/catalog/v1/nspackages/{csarId}")
- Call<DistributionResult> deleteNsPackage(@Path("csarId") String csarId);
-
- @DELETE("/api/catalog/v1/vnfpackages/{csarId}")
- Call<DistributionResult> deleteVnfPackage(@Path("csarId") String csarId);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java
index a0e07948..da8fd699 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java
@@ -135,34 +135,4 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
throw new VfcException("VFC service is not available!", e);
}
}
-
- @Override
- public DistributionResult deleteNsPackage(String csarId) {
- try {
- Response<DistributionResult> response = vfcService.deleteNsPackage(csarId).execute();
- if (response.isSuccessful()) {
- return response.body();
- } else {
- logger.info(String.format("Can not delete NS packages[code=%s, message=%s]", response.code(), response.message()));
- throw new VfcException("VFC service is not available!");
- }
- } catch (IOException e) {
- throw new VfcException("VFC service is not available!", e);
- }
- }
-
- @Override
- public DistributionResult deleteVfPackage(String csarId) {
- try {
- Response<DistributionResult> response = vfcService.deleteVnfPackage(csarId).execute();
- if (response.isSuccessful()) {
- return response.body();
- } else {
- logger.info(String.format("Can not delete VF packages[code=%s, message=%s]", response.code(), response.message()));
- throw new VfcException("VFC service is not available!");
- }
- } catch (IOException e) {
- throw new VfcException("VFC service is not available!", e);
- }
- }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
index 7d50a170..0419ec9b 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
@@ -53,310 +53,29 @@ import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.
@EnableAspectJAutoProxy
public class DefaultServiceTemplateService implements ServiceTemplateService {
- private static final Logger logger = LoggerFactory.getLogger(DefaultServiceTemplateService.class);
-
- private SDCCatalogService sdcCatalog;
-
- private AAIService aaiService;
-
public DefaultServiceTemplateService() {
- this(RestfulServices.create(SDCCatalogService.class), RestfulServices.create(AAIService.class));
}
public DefaultServiceTemplateService(SDCCatalogService sdcCatalog, AAIService aaiService) {
- this.sdcCatalog = sdcCatalog;
- this.aaiService = aaiService;
}
@Override
public List<SDCServiceTemplate> listDistributedServiceTemplate() {
- try {
- Response<List<SDCServiceTemplate>> response = this.sdcCatalog.listServices(CATEGORY_E2E_SERVICE, DISTRIBUTION_STATUS_DISTRIBUTED).execute();
- if (response.isSuccessful()) {
- return response.body();
- } else {
- logger.info(String.format("Can not get distributed e2e service templates[code=%s, message=%s]", response.code(), response.message()));
- return Collections.emptyList();
- }
- } catch (IOException e) {
- logger.error("Visit SDC Catalog occur exception");
- throw new SDCCatalogException("SDC Catalog is not available.", e);
- }
+ return null;
}
@Override
public ServiceTemplateInput fetchServiceTemplateInput(String uuid, String toscaModelPath) {
- return fetchServiceTemplate(uuid, toscaModelPath, false);
- }
-
- private ServiceTemplateInput fetchServiceTemplate(String uuid, String toscaModelPath, boolean isVF) {
- String toPath = String.format("/home/uui/%s.csar", uuid);
-// String toPath = String.format("D:\\volte/%s.csar", uuid);
- try {
- downloadFile(toscaModelPath, toPath);
- return extractTemplate(toPath, isVF);
- } catch (IOException e) {
- throw new SDCCatalogException("download csar file failed!", e);
- } catch (JToscaException e) {
- throw new SDCCatalogException("parse csar file failed!", e);
- }
- }
-
- protected void downloadFile(String toscaModelPath, String toPath) throws IOException {
- try {
- String msbUrl = RestfulServices.getMsbAddress();
- String templateUrl = String.format("http://%s%s", msbUrl, toscaModelPath);
- ResponseBody body = sdcCatalog.downloadCsar(templateUrl).execute().body();
- Files.write(body.bytes(),new File(toPath));
- } catch (IOException e) {
- logger.error(String.format("Download %s failed!", toscaModelPath));
- throw e;
- }
- }
-
- public ServiceTemplateInput extractTemplate(String toPath, boolean isVF) throws JToscaException, IOException {
- ToscaTemplate tosca = translateToToscaTemplate(toPath);
- ServiceTemplateInput serviceTemplateInput = newServiceTemplateInput(tosca);
- Map<String, Input> inputsMap = getInputsMap(tosca);
- for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) {
- String nodeType = nodeTemplate.getMetaData().getValue("type");
- if ("VF".equals(nodeType)) {
- ServiceTemplateInput nodeService = fetchVFNodeTemplateInput(nodeTemplate);
- if (nodeService == null) {
- continue;
- }
- serviceTemplateInput.addNestedTemplate(nodeService);
- } else {
- ServiceTemplateInput nodeService = fetchVLServiceTemplateInput(nodeTemplate, inputsMap);
- serviceTemplateInput.addNestedTemplate(nodeService);
- }
- }
- List<TemplateInput> serviceInputs = getServiceInputs(inputsMap.values());
- serviceTemplateInput.addInputs(serviceInputs);
- if (isVF) {
- serviceTemplateInput.setType("VF");
- appendLocationParameters(serviceTemplateInput, tosca);
- appendSdnControllerParameter(serviceTemplateInput);
- }
- return serviceTemplateInput;
- }
-
- private void appendLocationParameters(ServiceTemplateInput serviceTemplateInput, ToscaTemplate tosca) {
- for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) {
- String type = nodeTemplate.getMetaData().getValue("type");
- String uuid = nodeTemplate.getMetaData().getValue("UUID");
- if ("VF".equals(type)) {
- serviceTemplateInput.addInput(
- new TemplateInput(
- uuid,
- "vf_location",
- "location for the service " + uuid,
- "true",
- ""
- )
- );
- }
- }
- }
-
- private void appendSdnControllerParameter(ServiceTemplateInput serviceTemplateInput) {
- serviceTemplateInput.addInput(
- new TemplateInput(
- "sdncontroller",
- "sdn_controller",
- "location for the service",
- "true",
- ""
- )
- );
- }
-
- private ServiceTemplateInput fetchVLServiceTemplateInput(NodeTemplate nodeTemplate, Map<String, Input> inputsMap) {
- ServiceTemplateInput nodeService = newServiceTemplateInput(nodeTemplate);
- String prefix = getPrefix(nodeTemplate.getName());
- List<TemplateInput> templateInputs = collectInputs(prefix, inputsMap);
- nodeService.addInputs(templateInputs);
- return nodeService;
- }
-
- private ServiceTemplateInput fetchVFNodeTemplateInput(NodeTemplate nodeTemplate) throws IOException {
- String nodeUUID = fetchNodeUUID(nodeTemplate);
- if (nodeUUID == null) {
- // not found nested node
- return null;
- }
- String toscaModelURL = getToscaUrl(nodeUUID);
- if (toscaModelURL == null) {
- return null;
- }
- return fetchServiceTemplate(nodeUUID, toscaModelURL, true);
- }
-
- private List<TemplateInput> getServiceInputs(Collection<Input> inputs) {
- List<TemplateInput> result = new ArrayList<>();
- for (Input input : inputs) {
- result.add(
- new TemplateInput(
- input.getName(),
- input.getType(),
- input.getDescription(),
- String.valueOf(input.isRequired()),
- String.valueOf(input.getDefault())
- )
- );
- }
- return result;
- }
-
- private String fetchNodeUUID(NodeTemplate nodeTemplate) {
- LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
- for (Map.Entry<String, Property> entry : properties.entrySet()) {
- String key = entry.getKey();
- if (key.endsWith("providing_service_uuid")) {
- return String.valueOf(entry.getValue().getValue());
- }
- }
- // not found
return null;
}
- private List<TemplateInput> collectInputs(String prefix, Map<String, Input> inputsMap) {
- List<TemplateInput> result = new ArrayList<>();
- List<String> removeItems = new ArrayList<>();
- for (Map.Entry<String, Input> entry : inputsMap.entrySet()) {
- String name = entry.getKey();
- if (name.startsWith(prefix)) {
- //remove resource name prefix which sdc added.
- name = name.substring(prefix.length() + 1);
- Input in = entry.getValue();
- result.add(
- new TemplateInput(
- name,
- in.getType(),
- in.getDescription(),
- String.valueOf(in.isRequired()),
- String.valueOf(in.getDefault())
- )
- );
- removeItems.add(entry.getKey());
- }
- }
- for (String key : removeItems) {
- inputsMap.remove(key);
- }
- return result;
- }
-
- private Map<String, Input> getInputsMap(ToscaTemplate tosca) {
- Map<String, Input> result = new HashMap<>();
- for (Input input : tosca.getInputs()) {
- result.put(input.getName(), input);
- }
- return result;
- }
-
- private String getPrefix(String name) {
- return name.replaceAll(" +", "").toLowerCase();
- }
-
- protected String getToscaUrl(String nodeUUID) throws IOException {
- Response<SDCServiceTemplate> response = sdcCatalog.getService(nodeUUID).execute();
- if (response.isSuccessful()) {
- SDCServiceTemplate template = response.body();
- return template.getToscaModelURL();
- } else {
- logger.info(String.format("Cannot get tosca model for node template[%s]", nodeUUID));
- return null;
- }
- }
-
- protected ToscaTemplate translateToToscaTemplate(String toPath) throws JToscaException {
- return new ToscaTemplate(toPath,null,true,null,true);
- }
-
- private static ServiceTemplateInput newServiceTemplateInput(ToscaTemplate tosca) {
- String invariantUUID = tosca.getMetaData().getValue("invariantUUID");
- String uuid = tosca.getMetaData().getValue("UUID");
- String name = tosca.getMetaData().getValue("name");
- String type = tosca.getMetaData().getValue("type");
- String version = tosca.getMetaData().getValue("version");
- if (version == null) {
- version = "";
- }
- String description = tosca.getMetaData().getValue("description");
- String category = tosca.getMetaData().getValue("category");
- String subcategory = tosca.getMetaData().getValue("subcategory");
- if(subcategory == null) {
- subcategory = "";
- }
- return new ServiceTemplateInput(
- invariantUUID,
- uuid,
- name,
- type,
- version,
- description,
- category,
- subcategory,
- new ArrayList<>());
- }
-
- private static ServiceTemplateInput newServiceTemplateInput(NodeTemplate nodeTemplate) {
- String invariantUUID = nodeTemplate.getMetaData().getValue("invariantUUID");
- String uuid = nodeTemplate.getMetaData().getValue("UUID");
- String name = nodeTemplate.getMetaData().getValue("name");
- String type = nodeTemplate.getMetaData().getValue("type");
- String version = nodeTemplate.getMetaData().getValue("version");
- if (version == null) {
- version = "";
- }
- String description = nodeTemplate.getMetaData().getValue("description");
- String category = nodeTemplate.getMetaData().getValue("category");
- String subcategory = nodeTemplate.getMetaData().getValue("subcategory");
- if(subcategory == null) {
- subcategory = "";
- }
- return new ServiceTemplateInput(
- invariantUUID,
- uuid,
- name,
- type,
- version,
- description,
- category,
- subcategory,
- new ArrayList<>());
- }
-
@Override
public List<VimInfo> listVim() {
- try {
- Response<VimInfoRsp> response = aaiService.listVimInfo().execute();
- if (response.isSuccessful()) {
- return response.body().getCloudRegion();
- } else {
- logger.info(String.format("Can not get vim info[code=%s, message=%s]", response.code(), response.message()));
- return Collections.emptyList();
- }
- } catch (IOException e) {
- logger.error("Visit AAI occur exception");
- throw new AAIException("AAI is not available.", e);
- }
+ return null;
}
@Override
public List<SDNCController> listSDNCControllers() {
- try {
- Response<SDNCControllerRsp> response = aaiService.listSdncControllers().execute();
- if (response.isSuccessful()) {
- return response.body().getEsrThirdpartySdncList();
- } else {
- logger.info(String.format("Can not get sdnc controllers[code=%s, message=%s]", response.code(), response.message()));
- return Collections.emptyList();
- }
- } catch (IOException e) {
- logger.error("Visit AAI occur exception");
- throw new AAIException("AAI is not available.", e);
- }
+ return null;
}
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java b/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java
index 6d6116ae..931b0e57 100644
--- a/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java
+++ b/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java
@@ -15,26 +15,20 @@
*/
package org.onap.usecaseui.server.util;
-import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.Getter;
-import lombok.Setter;
import org.glassfish.jersey.client.ClientConfig;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.bean.PerformanceHeader;
import org.onap.usecaseui.server.bean.PerformanceInformation;
+import org.onap.usecaseui.server.constant.Constant;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
import org.onap.usecaseui.server.service.AlarmsInformationService;
import org.onap.usecaseui.server.service.PerformanceHeaderService;
import org.onap.usecaseui.server.service.PerformanceInformationService;
-import org.onap.usecaseui.server.service.impl.AlarmsHeaderServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import javax.ws.rs.client.Client;
@@ -42,6 +36,8 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import java.io.*;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.*;
@org.springframework.context.annotation.Configuration
@@ -51,10 +47,11 @@ public class DmaapSubscriber implements Runnable {
private Logger logger = LoggerFactory.getLogger(DmaapSubscriber.class);
private String url;
- private String topic;
+ private String alarmTopic;
+ private String performanceTopic;
private String consumerGroup;
private String consumer;
- private int timeout ;
+ private int timeout;
private boolean isActive = true;
@@ -70,223 +67,328 @@ public class DmaapSubscriber implements Runnable {
@Resource(name = "PerformanceInformationService")
private PerformanceInformationService performanceInformationService;
- private void subscribe(){
- String response = "";
- try{
- response = getDMaaPData();
+ public void subscribe(String topic) {
+ String response;
+ try {
+ response = getDMaaPData(topic);
logger.info(response);
- try{
+ if (response == null && "".equals(response)) {
+ logger.info("response is null");
+ return;
+ } else {
ObjectMapper objMapper = new ObjectMapper();
- Map<String,Map<String,Map<String,Object>>> maps = objMapper.readValue(response,Map.class);
- AlarmsHeader alarm_header = new AlarmsHeader();
- List<AlarmsInformation> alarm_informations = new ArrayList<>();
- PerformanceHeader performance_header = new PerformanceHeader();
- List<PerformanceInformation> performance_infomations = new ArrayList<>();
- maps.forEach( (k,v) -> {
- maps.get(k).forEach( (k1,v1) ->{
- if (maps.get(k).get(k1).containsValue("fault") || maps.get(k).containsKey("faultFields")){
- if (k1.equals("commonEventHeader")){
- maps.get(k).get(k1).forEach( (k2,v2 ) ->{
- if (k2.equals("version"))
- alarm_header.setVersion(v2.toString());
- if (k2.equals("eventName"))
- alarm_header.setEventName(v2.toString());
- if (k2.equals("domain"))
- alarm_header.setDomain(v2.toString());
- if (k2.equals("eventId"))
- alarm_header.setEventId(v2.toString());
- if (k2.equals("eventType"))
- alarm_header.setEventType(v2.toString());
- if (k2.equals("nfcNamingCode"))
- alarm_header.setNfcNamingCode(v2.toString());
- if (k2.equals("nfNamingCode"))
- alarm_header.setNfNamingCode(v2.toString());
- if (k2.equals("sourceId"))
- alarm_header.setSourceId(v2.toString());
- if (k2.equals("sourceName"))
- alarm_header.setSourceName(v2.toString());
- if (k2.equals("reportingEntityId"))
- alarm_header.setReportingEntityId(v2.toString());
- if (k2.equals("reportingEntityName"))
- alarm_header.setReportingEntityName(v2.toString());
- if (k2.equals("priority"))
- alarm_header.setPriority(v2.toString());
- if (k2.equals("startEpochMicrosec"))
- alarm_header.setStartEpochMicrosec(v2.toString());
- if (k2.equals("lastEpochMicrosec"))
- alarm_header.setLastEpochMicroSec(v2.toString());
- if (k2.equals("sequence"))
- alarm_header.setSequence(v2.toString());
- } );
- }
- else if (k1.equals("faultFields")) {
- maps.get(k).get(k1).forEach((k3, v3) -> {
- if (k3.equals("faultFieldsVersion"))
- alarm_header.setFaultFieldsVersion(v3.toString());
- if (k3.equals("eventSeverity"))
- alarm_header.setEventServrity(v3.toString());
- if (k3.equals("eventSourceType"))
- alarm_header.setEventSourceType(v3.toString());
- if (k3.equals("eventCategory"))
- alarm_header.setEventCategory(v3.toString());
- if (k3.equals("alarmCondition"))
- alarm_header.setAlarmCondition(v3.toString());
- if (k3.equals("specificProblem"))
- alarm_header.setSpecificProblem(v3.toString());
- if (k3.equals("vfStatus"))
- alarm_header.setVfStatus(v3.toString());
- if (k3.equals("alarmInterfaceA"))
- alarm_header.setAlarmInterfaceA(v3.toString());
- if (k3.equals("alarmAdditionalInformation")) {
- try {
- List<Map<String,Object>> m = (List<Map<String, Object>>) v3;
- m.forEach( i -> {
- i.forEach( (k4,v4) -> {
- alarm_informations.add(new AlarmsInformation(k4,v4.toString(),alarm_header.getEventName(),new Date(),new Date()));
- });
- } );
- alarm_header.setCreateTime(new Date());
- if (alarm_header.getEventName().contains("Cleared")){
- alarm_header.setStatus("3");
- alarmsHeaderService.saveAlarmsHeader(alarm_header);
- alarm_informations.forEach( information ->
- alarmsInformationService.saveAlarmsInformation(information));
- AlarmsHeader header1 = new AlarmsHeader();
- header1.setEventName(alarm_header.getEventName().substring(0,alarm_header.getEventName().indexOf("Cleared")));
- List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(header1,1,10).getList();
- alarmsHeaders.forEach( alarms -> {
- alarms.setStatus("2");
- alarmsHeaderService.updateAlarmsHeader(alarms);
- } );
- }else{
- alarm_header.setStatus("1");
- logger.info(alarm_header.toString() +"");
- alarmsHeaderService.saveAlarmsHeader(alarm_header);
- alarm_informations.forEach( information ->
- alarmsInformationService.saveAlarmsInformation(information));
- }
- } catch (Exception e) {
- logger.error("convert alarmAdditionalInformation error:"+e.getMessage());
- }
- }
- });
+ objMapper.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
+ if (response.contains("}}\""))
+ response = response.replaceAll("}}\"","}}");
+ if (response.contains("\"{\"VESversion\""))
+ response = response.replaceAll("\"\\{\"VESversion\"","{\"VESversion\"");
+ if (response.contains("]\""))
+ response = response.replaceAll("]\"","]");
+ if (response.contains("\"["))
+ response = response.replaceAll("\"\\[","[");
+ if (response.contains("Remark:\""))
+ response = response.replaceAll("Remark:\"",":");
+ if (response.contains("\";"))
+ response = response.replaceAll("\";",";");
- }
- }else if(maps.get(k).get(k1).containsValue("measurementsForVfScaling") || maps.get(k).containsKey("measurementsForVfScalingFields")){
- if (k1.equals("commonEventHeader"))
- maps.get(k).get(k1).forEach( (k2,v2) ->{
- if (k2.equals("version"))
- performance_header.setVersion(v2.toString());
- if (k2.equals("eventName"))
- performance_header.setEventName(v2.toString());
- if (k2.equals("domain"))
- performance_header.setDomain(v2.toString());
- if (k2.equals("eventId"))
- performance_header.setEventId(v2.toString());
- if (k2.equals("eventType"))
- performance_header.setEventType(v2.toString());
- if (k2.equals("nfcNamingCode"))
- performance_header.setNfcNamingCode(v2.toString());
- if (k2.equals("nfNamingCode"))
- performance_header.setNfNamingCode(v2.toString());
- if (k2.equals("sourceId"))
- performance_header.setSourceId(v2.toString());
- if (k2.equals("sourceName"))
- performance_header.setSourceName(v2.toString());
- if (k2.equals("reportingEntityId"))
- performance_header.setReportingEntityId(v2.toString());
- if (k2.equals("reportingEntityName"))
- performance_header.setReportingEntityName(v2.toString());
- if (k2.equals("priority"))
- performance_header.setPriority(v2.toString());
- if (k2.equals("startEpochMicrosec"))
- performance_header.setStartEpochMicrosec(v2.toString());
- if (k2.equals("lastEpochMicrosec"))
- performance_header.setLastEpochMicroSec(v2.toString());
- if (k2.equals("sequence"))
- performance_header.setSequence(v2.toString());
- } );
- else if(k1.equals("measurementsForVfScalingFields")) {
- maps.get(k).get(k1).forEach((k3, v3) -> {
- if (k3.equals("measurementsForVfScalingVersion"))
- performance_header.setMeasurementsForVfScalingVersion(v3.toString());
- if (k3.equals("measurementInterval"))
- performance_header.setMeasurementInterval(v3.toString());
- if (k3.equals("additionalMeasurements")){
- try {
- List<Map<String,Object>> m = (List<Map<String, Object>>) v3;
- m.forEach( i -> {
- i.forEach( (k4,v4) -> {
- performance_infomations.add(new PerformanceInformation(k4,v4.toString(),performance_header.getEventName(),new Date(),new Date()));
- });
- } );
- } catch (Exception e) {
- logger.error("convert additionalMeasurements error:"+e.getMessage());
- }
+ if (response.indexOf("[") == 0) {
+ List<Object> eventList = objMapper.readValue(response, List.class);
- }
- });
- performance_header.setCreateTime(new Date());
- performance_header.setUpdateTime(new Date());
- performanceHeaderService.savePerformanceHeader(performance_header);
- performance_infomations.forEach( information ->
- performanceInformationService.savePerformanceInformation(information));
- }
+ eventList.forEach(el -> {
+ Map<String, Object> eventMaps = (Map<String, Object>) ((Map<String, Object>) el).get("event");
+ if (eventMaps.containsKey("measurementsForVfScalingFields")) {
+ performanceProcess(eventMaps);
+ } else if (eventMaps.containsKey("faultFields")) {
+ alarmProcess(eventMaps);
}
-
});
- });
- }catch (Exception e){
- e.printStackTrace();
- logger.error("dispose of Data failed:"+e.getMessage());
+ } else if (response.indexOf("{") == 0) {
+ Map<String, Object> eventMaps = (Map<String, Object>) objMapper.readValue(response, Map.class).get("event");
+
+ if (eventMaps.containsKey("measurementsForVfScalingFields")) {
+ performanceProcess(eventMaps);
+ } else if (eventMaps.containsKey("faultFields")) {
+ alarmProcess(eventMaps);
+ }
+ } else {
+ logger.error("unknown json type!");
+ }
}
- }catch (Exception e){
- logger.error("getDMaaP Information failed :"+e.getMessage());
+ } catch (Exception e) {
+ logger.error("getDMaaP Information failed :" + e.getMessage());
}
}
- private String getDMaaPData(){
+ private String getDMaaPData(String topic) {
Client client = ClientBuilder.newClient(new ClientConfig());
- WebTarget webTarget = client.target(url +"/" + topic +"/"+ consumerGroup +"/"+ consumer);
- Response response = webTarget.queryParam("timeout",timeout).request().get();
+ WebTarget webTarget = client.target(url + "/" + topic + "/" + consumerGroup + "/" + consumer);
+ Response response = webTarget.queryParam("timeout", timeout).request().get();
return response.readEntity(String.class);
}
- private void initConfig(){
+ private void initConfig() {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("dmaap.properties");
Properties p = new Properties();
try {
p.load(inputStream);
- this.url = p.getProperty("dmaap.url");
- this.topic = p.getProperty("dmaap.topic");
+ this.url = p.getProperty("http://") + System.getenv("MS_ADDR");
+ this.alarmTopic = p.getProperty("dmaap.alarmTopic");
+ this.performanceTopic = p.getProperty("dmaap.performanceTopic");
this.consumerGroup = p.getProperty("dmaap.consumerGroup");
this.consumer = p.getProperty("dmaap.consumer");
this.timeout = Integer.parseInt(p.getProperty("dmaap.timeout"));
} catch (IOException e1) {
- logger.error("get configuration file arise error :"+e1.getMessage());
+ logger.error("get configuration file arise error :" + e1.getMessage());
}
-
}
public void run() {
- try{
+ try {
initConfig();
- while(isActive){
- subscribe();
+ while (isActive) {
+ subscribe(alarmTopic);
+ subscribe(performanceTopic);
}
- }catch (Exception e){
+ } catch (Exception e) {
try {
Thread.sleep(10000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
- logger.error("subscribe raise error :"+e.getCause());
+ logger.error("subscribe raise error :" + e.getCause());
}
}
- public void stopTask(){
- if (isActive)
- isActive = false;
+ private void alarmProcess(Map<String, Object> eventMap) {
+ AlarmsHeader alarm_header = new AlarmsHeader();
+ List<AlarmsInformation> alarm_informations = new ArrayList<>();
+ eventMap.forEach((ek1, ev1) -> {
+ if (ek1.equals("commonEventHeader")) {
+ ((Map<String, Object>) ev1).forEach((k2, v2) -> {
+ if (k2.equals("version"))
+ alarm_header.setVersion(v2.toString());
+ if (k2.equals("eventName"))
+ alarm_header.setEventName(v2.toString());
+ if (k2.equals("domain"))
+ alarm_header.setDomain(v2.toString());
+ if (k2.equals("eventId"))
+ alarm_header.setEventId(v2.toString());
+ if (k2.equals("eventType"))
+ alarm_header.setEventType(v2.toString());
+ if (k2.equals("nfcNamingCode"))
+ alarm_header.setNfcNamingCode(v2.toString());
+ if (k2.equals("nfNamingCode"))
+ alarm_header.setNfNamingCode(v2.toString());
+ if (k2.equals("sourceId"))
+ alarm_header.setSourceId(v2.toString());
+ if (k2.equals("sourceName"))
+ alarm_header.setSourceName(v2.toString());
+ if (k2.equals("reportingEntityId"))
+ alarm_header.setReportingEntityId(v2.toString());
+ if (k2.equals("reportingEntityName"))
+ alarm_header.setReportingEntityName(v2.toString());
+ if (k2.equals("priority"))
+ alarm_header.setPriority(v2.toString());
+ if (k2.equals("startEpochMicrosec"))
+ alarm_header.setStartEpochMicrosec(v2.toString());
+ if (k2.equals("lastEpochMicrosec"))
+ alarm_header.setLastEpochMicroSec(v2.toString());
+ if (k2.equals("sequence"))
+ alarm_header.setSequence(v2.toString());
+ });
+ } else if (ek1.equals("faultFields")) {
+ ((Map<String, Object>) ev1).forEach((k3, v3) -> {
+ if (k3.equals("faultFieldsVersion"))
+ alarm_header.setFaultFieldsVersion(v3.toString());
+ if (k3.equals("eventSeverity"))
+ alarm_header.setEventServrity(v3.toString());
+ if (k3.equals("eventSourceType"))
+ alarm_header.setEventSourceType(v3.toString());
+ if (k3.equals("eventCategory"))
+ alarm_header.setEventCategory(v3.toString());
+ if (k3.equals("alarmCondition"))
+ alarm_header.setAlarmCondition(v3.toString());
+ if (k3.equals("specificProblem"))
+ alarm_header.setSpecificProblem(v3.toString());
+ if (k3.equals("vfStatus"))
+ alarm_header.setVfStatus(v3.toString());
+ if (k3.equals("alarmInterfaceA"))
+ alarm_header.setAlarmInterfaceA(v3.toString());
+ if (k3.equals("alarmAdditionalInformation")) {
+ try {
+ List<Map<String, Object>> m = (List<Map<String, Object>>) v3;
+ m.forEach(i -> {
+ if (i.get("name").toString().equals("eventTime"))
+ try {
+ alarm_header.setCreateTime(DateUtils.stringToDate(i.get("value").toString()));
+ alarm_header.setUpdateTime(DateUtils.stringToDate(i.get("value").toString()));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ if (i.get("value").toString().contains(";")) {
+ alarm_informations.add(new AlarmsInformation(i.get("name").toString(), "", alarm_header.getSourceId(), null, null));
+ char[] valStr = i.get("value").toString().toCharArray();
+ String name = "";
+ String value = "";
+ boolean nameFlag = true;
+ boolean valueFlag = false;
+ for (int j = 0; j < valStr.length; j++) {
+ if (valStr[j] == ':') {
+ nameFlag = false;
+ valueFlag = true;
+ continue;
+ }
+ if (valStr[j] == ';') {
+ nameFlag = true;
+ valueFlag = false;
+ alarm_informations.add(new AlarmsInformation(name, value, i.get("name").toString(), null, null));
+ continue;
+ }
+ if (nameFlag)
+ name += valStr[j];
+ if (valueFlag)
+ value += valStr[j];
+ }
+ } else {
+ alarm_informations.add(new AlarmsInformation(i.get("name").toString(), i.get("value").toString(), alarm_header.getSourceId(), null, null));
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.error("convert alarmAdditionalInformation error:" + e.getMessage());
+ }
+ }
+ });
+ alarm_informations.forEach(ai -> {
+ ai.setCreateTime(alarm_header.getCreateTime());
+ ai.setUpdateTime(new Date());
+ });
+ if (alarm_header.getEventName().contains("Cleared")) {
+ alarm_header.setStatus("3");
+ alarmsHeaderService.saveAlarmsHeader(alarm_header);
+ alarm_informations.forEach(information ->
+ alarmsInformationService.saveAlarmsInformation(information));
+ AlarmsHeader header1 = new AlarmsHeader();
+ header1.setEventName(alarm_header.getEventName().substring(0, alarm_header.getEventName().indexOf("Cleared")));
+ List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(header1, 1, 10).getList();
+ alarmsHeaders.forEach(alarms -> {
+ alarms.setStatus("2");
+ alarms.setUpdateTime(new Date());
+ alarmsHeaderService.updateAlarmsHeader(alarms);
+ });
+ } else {
+ alarm_header.setUpdateTime(new Date());
+ alarm_header.setStatus("1");
+ alarmsHeaderService.saveAlarmsHeader(alarm_header);
+ alarm_informations.forEach(information ->
+ alarmsInformationService.saveAlarmsInformation(information));
+ }
+ }
+ });
}
-}
+ private void performanceProcess(Map<String, Object> maps) {
+ PerformanceHeader performance_header = new PerformanceHeader();
+ List<PerformanceInformation> performance_informations = new ArrayList<>();
+ maps.forEach((k, v) -> {
+ if (k.equals("event")) {
+ Map<String, Object> eventMap = (Map<String, Object>) v;
+ eventMap.forEach((ek1, ev1) -> {
+ if (ek1.equals("commonEventHeader")) {
+ ((Map<String, Object>) ev1).forEach((k2, v2) -> {
+ if (k2.equals("version"))
+ performance_header.setVersion(v2.toString());
+ if (k2.equals("eventName"))
+ performance_header.setEventName(v2.toString());
+ if (k2.equals("domain"))
+ performance_header.setDomain(v2.toString());
+ if (k2.equals("eventId"))
+ performance_header.setEventId(v2.toString());
+ if (k2.equals("eventType"))
+ performance_header.setEventType(v2.toString());
+ if (k2.equals("nfcNamingCode"))
+ performance_header.setNfcNamingCode(v2.toString());
+ if (k2.equals("nfNamingCode"))
+ performance_header.setNfNamingCode(v2.toString());
+ if (k2.equals("sourceId"))
+ performance_header.setSourceId(v2.toString());
+ if (k2.equals("sourceName"))
+ performance_header.setSourceName(v2.toString());
+ if (k2.equals("reportingEntityId"))
+ performance_header.setReportingEntityId(v2.toString());
+ if (k2.equals("reportingEntityName"))
+ performance_header.setReportingEntityName(v2.toString());
+ if (k2.equals("priority"))
+ performance_header.setPriority(v2.toString());
+ if (k2.equals("startEpochMicrosec"))
+ performance_header.setStartEpochMicrosec(v2.toString());
+ if (k2.equals("lastEpochMicrosec"))
+ performance_header.setLastEpochMicroSec(v2.toString());
+ if (k2.equals("sequence"))
+ performance_header.setSequence(v2.toString());
+ });
+ } else if (ek1.equals("measurementsForVfScalingFields")) {
+ ((Map<String, Object>) ev1).forEach((k3, v3) -> {
+ if (k3.equals("measurementsForVfScalingVersion"))
+ performance_header.setMeasurementsForVfScalingVersion(v3.toString());
+ if (k3.equals("measurementInterval"))
+ performance_header.setMeasurementInterval(v3.toString());
+ if (k3.equals("additionalMeasurements")) {
+ try {
+ List<Map<String, Object>> m = (List<Map<String, Object>>) v3;
+ m.forEach(i -> {
+ if (i.get("name").toString().equals("eventTime"))
+ try {
+ performance_header.setCreateTime(DateUtils.stringToDate(i.get("value").toString()));
+ performance_header.setUpdateTime(DateUtils.stringToDate(i.get("value").toString()));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ if (i.get("value").toString().contains(";")) {
+ performance_informations.add(new PerformanceInformation(i.get("name").toString(), "", performance_header.getSourceId(), null, null));
+
+ char[] valStr = i.get("value").toString().replace("=", ":").toCharArray();
+ String name = "";
+ String value = "";
+ boolean nameFlag = true;
+ boolean valueFlag = false;
+ for (int j = 0; j < valStr.length; j++) {
+ if (valStr[j] == ':') {
+ nameFlag = false;
+ valueFlag = true;
+ continue;
+ }
+ if (valStr[j] == ';') {
+ nameFlag = true;
+ valueFlag = false;
+ performance_informations.add(new PerformanceInformation(name, value, i.get("name").toString(), null, null));
+ continue;
+ }
+ if (nameFlag)
+ name += valStr[j];
+ if (valueFlag)
+ value += valStr[j];
+ }
+ } else {
+ performance_informations.add(new PerformanceInformation(i.get("name").toString(), i.get("value").toString(), performance_header.getSourceId(), null, null));
+ }
+ });
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.error("convert performanceAdditionalInformation error:" + e.getMessage());
+ }
+ }
+ });
+ performanceHeaderService.savePerformanceHeader(performance_header);
+ performance_informations.forEach(ai -> {
+ ai.setCreateTime(performance_header.getCreateTime());
+ ai.setUpdateTime(new Date());
+ performanceInformationService.savePerformanceInformation(ai);
+ });
+ }
+ });
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/server/src/main/resources/dmaap.properties b/server/src/main/resources/dmaap.properties
index cd34dc65..793fabf2 100644
--- a/server/src/main/resources/dmaap.properties
+++ b/server/src/main/resources/dmaap.properties
@@ -13,8 +13,9 @@
## See the License for the specific language governing permissions and
## limitations under the License.
##
-dmaap.url = http://172.30.3.42:3904
-dmaap.topic = events/unauthenticated.SEC_FAULT_OUTPUT
+dmaap.url = http://
+dmaap.alarmTopic = events/unauthenticated.SEC_FAULT_OUTPUT
+dmaap.performanceTopic = events/unauthenticated.SEC_MEASUREMENT_OUTPUT
dmaap.consumerGroup = uuiGroup
dmaap.conusmer = uuiUser
dmaap.timeout = 10000 \ No newline at end of file
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
index 2fbfaadd..ead47ef3 100755
--- a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
@@ -43,12 +43,12 @@ public class AlarmControllerTest {
@Test
public void getDataNotParam() throws JsonProcessingException {
- System.out.println(alarmController.getAlarmData(null,null,null,null,null,null,null,1,100));
+ System.out.println(alarmController.getAlarmData(null,null,null,null,null,null,1,100));
}
@Test
public void getDataCarryParam() throws JsonProcessingException {
- System.out.println(alarmController.getAlarmData("110","a","drop","down","1506331166000","1","2",1,100));
+ System.out.println(alarmController.getAlarmData("110","a","drop","down","1506331166000","2",1,100));
}
@Test
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
index ca6ba451..4fb9a387 100755
--- a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
@@ -24,6 +24,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.text.ParseException;
+import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest
@@ -36,7 +37,7 @@ public class AlarmsInformationServiceTest {
@Test
public void save() throws ParseException {
AlarmsInformation a = new AlarmsInformation();
- a.setEventId("111");
+ a.setEventId("1119");
a.setName("efw");
a.setValue("fre");
a.setCreateTime(DateUtils.now());
@@ -105,6 +106,12 @@ public class AlarmsInformationServiceTest {
.getList().forEach( al -> System.out.println(al.getEventId()));
}
+ @Test
+ public void queryData() throws ParseException {
+ alarmsInformationService.queryDateBetween("MME40","","").forEach( in -> {
+ System.out.println(in);
+ });
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
index 9705c6b6..bd4283d2 100755
--- a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
@@ -232,5 +232,10 @@ public class PerformanceHeaderServiceTest {
.getList().forEach(per -> System.out.println(per));
}
+ @Test
+ public void queryAllSourceId(){
+ performanceHeaderService.queryAllSourceId().forEach( a-> System.out.println(a) );
+ }
+
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
index 80f8743e..1a8522ad 100755
--- a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
@@ -38,22 +38,13 @@ public class PerformanceInformationServiceTest {
@Test
public void save() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
- for (int y = 1 ; y < 13 ; y++){
- for (int m = 1 ;m < 31 ; m++){
- for (int j = 0 ; j < 24 ;j++){
- for (int i = 14 ; i <= 59;i += 15){
- a.setEventId("2202");
- a.setName("memory");
- a.setValue((i+j+new Random().nextInt(60))+"");
- a.setCreateTime(DateUtils.stringToDate("2016-"+y+"-"+m+" "+j+":"+i+":00"));
- a.setUpdateTime(DateUtils.now());
- System.out.println(performanceInformationService.savePerformanceInformation(a));
- }
- }
- }
-
- }
+ a.setEventId("123");
+ a.setName("SGS.UeUnreachable");
+ a.setValue("40");
+ a.setCreateTime(DateUtils.now());
+ a.setUpdateTime(DateUtils.now());
+ System.out.println(performanceInformationService.savePerformanceInformation(a));
}
@@ -72,9 +63,9 @@ public class PerformanceInformationServiceTest {
@Test
public void update1() throws ParseException {
List<PerformanceInformation> as = performanceInformationService.queryId(new String[]{"2202"});
- as.forEach( a ->{
+ as.forEach(a -> {
try {
- a.setCreateTime(DateUtils.stringToDate(DateUtils.addDate(a.getCreateTime(),"day",1)));
+ a.setCreateTime(DateUtils.stringToDate(DateUtils.addDate(a.getCreateTime(), "day", 1)));
} catch (ParseException e) {
e.printStackTrace();
}
@@ -91,46 +82,50 @@ public class PerformanceInformationServiceTest {
@Test
public void queryEventId() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
- // a.setEventId("2202");
- performanceInformationService.queryPerformanceInformation(a,1,100)
- .getList().forEach( al -> System.out.println(al.getValue()));
+ // a.setEventId("2202");
+ performanceInformationService.queryPerformanceInformation(a, 1, 100)
+ .getList().forEach(al -> System.out.println(al.getValue()));
}
+
@Test
public void queryName() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
a.setName("kl");
- performanceInformationService.queryPerformanceInformation(a,1,100)
- .getList().forEach( al -> System.out.println(al));
+ performanceInformationService.queryPerformanceInformation(a, 1, 100)
+ .getList().forEach(al -> System.out.println(al));
}
+
@Test
public void queryValue() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
a.setValue("yue");
- performanceInformationService.queryPerformanceInformation(a,1,100)
- .getList().forEach( al -> System.out.println(al));
+ performanceInformationService.queryPerformanceInformation(a, 1, 100)
+ .getList().forEach(al -> System.out.println(al));
}
+
@Test
public void queryUpdateTime() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
a.setUpdateTime(DateUtils.now());
- performanceInformationService.queryPerformanceInformation(a,1,100)
- .getList().forEach( al -> System.out.println(al));
+ performanceInformationService.queryPerformanceInformation(a, 1, 100)
+ .getList().forEach(al -> System.out.println(al));
}
+
@Test
public void queryCreateTime() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
a.setCreateTime(DateUtils.now());
- performanceInformationService.queryPerformanceInformation(a,1,100)
- .getList().forEach( al -> System.out.println(al));
+ performanceInformationService.queryPerformanceInformation(a, 1, 100)
+ .getList().forEach(al -> System.out.println(al));
}
@Test
public void between() throws ParseException {
- performanceInformationService.queryDateBetween("2202",DateUtils.stringToDate("2017-10-15 01:00:00"),DateUtils.stringToDate("2017-10-15 02:00:00")).forEach( p -> System.out.println(p));
+ performanceInformationService.queryDateBetween("2202", DateUtils.stringToDate("2017-10-15 01:00:00"), DateUtils.stringToDate("2017-10-15 02:00:00")).forEach(p -> System.out.println(p));
}
@Test
public void sum() throws ParseException {
- System.out.println(performanceInformationService.queryDataBetweenSum("2202","cpu",DateUtils.stringToDate("2017-10-18 09:00:00"),DateUtils.stringToDate("2017-10-18 10:00:00")));
+ System.out.println(performanceInformationService.queryDataBetweenSum("2202", "cpu", DateUtils.stringToDate("2017-10-18 09:00:00"), DateUtils.stringToDate("2017-10-18 10:00:00")));
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
index 943d3806..b9bc532b 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
@@ -46,162 +46,4 @@ import static org.onap.usecaseui.server.util.CallStub.successfulCall;
public class DefaultServiceTemplateServiceTest {
- @Test
- public void itCanListDistributedServiceTemplate() {
- List<SDCServiceTemplate> templates = Collections.singletonList(new SDCServiceTemplate("uuid", "uuid", "name", "V1","url", "category"));
- SDCCatalogService sdcService = mock(SDCCatalogService.class);
- when(sdcService.listServices(CATEGORY_E2E_SERVICE, DISTRIBUTION_STATUS_DISTRIBUTED)).thenReturn(successfulCall(templates));
-
- ServiceTemplateService service = new DefaultServiceTemplateService(sdcService,null);
-
- Assert.assertSame(templates, service.listDistributedServiceTemplate());
- }
-
- @Test(expected = SDCCatalogException.class)
- public void retrieveServiceWillThrowExceptionWhenSDCIsNotAvailable() {
- SDCCatalogService sdcService = mock(SDCCatalogService.class);
- when(sdcService.listServices(CATEGORY_E2E_SERVICE, DISTRIBUTION_STATUS_DISTRIBUTED)).thenReturn(failedCall("SDC is not available!"));
-
- ServiceTemplateService service = new DefaultServiceTemplateService(sdcService,null);
- service.listDistributedServiceTemplate();
- }
-
- @Test
- public void itCanRetrieveInputsFromServiceTemplate() throws IOException {
- final String uuid = "1";
- String modelPath = "model_path";
- String nodeUUID = "2";
-
- SDCCatalogService sdcService = newSdcCatalogService(nodeUUID);
-
- List<VimInfo> vim = Collections.singletonList(new VimInfo("owner", "regionId"));
- AAIService aaiService = newAAIService(vim);
-
- ServiceTemplateService service = newServiceTemplateService(uuid, nodeUUID, sdcService, aaiService);
-
- Assert.assertThat(service.fetchServiceTemplateInput(uuid, modelPath), equalTo(expectedServiceInputs(uuid, nodeUUID)));
- }
-
- private DefaultServiceTemplateService newServiceTemplateService(String uuid, String nodeUUID, SDCCatalogService sdcService, AAIService aaiService) {
- return new DefaultServiceTemplateService(sdcService, aaiService) {
-
- @Override
- protected void downloadFile(String templateUrl, String toPath) throws IOException {
- // download successfully...
- }
-
- @Override
- protected ToscaTemplate translateToToscaTemplate(String toPath) throws JToscaException {
- if (toPath.contains(uuid)) {
- return e2eToscaTemplate(nodeUUID);
- }
- return nodeToscaTemplate(nodeUUID);
- }
- };
- }
-
- private SDCCatalogService newSdcCatalogService(String nodeUUID) throws IOException {
- SDCCatalogService sdcService = mock(SDCCatalogService.class);
- when(sdcService.getService(nodeUUID)).thenReturn(successfulCall(new SDCServiceTemplate(nodeUUID, nodeUUID, "node", "V1", "nodeModelUrl", "service")));
- return sdcService;
- }
-
- private ServiceTemplateInput expectedServiceInputs(String uuid, String nodeUUID) {
- ServiceTemplateInput e2eServiceTemplateInput = new ServiceTemplateInput(
- uuid, uuid, "VoLTE", "service","", "VoLTE", "service", "", Collections.EMPTY_LIST);
- TemplateInput templateInput = new TemplateInput("field_name","field_type", "field_description", "true", "field_default");
- ServiceTemplateInput nodeTemplateInput = new ServiceTemplateInput(
- nodeUUID, nodeUUID, "", "", "","", "service", "", Collections.singletonList(templateInput));
-// e2eServiceTemplateInput.addNestedTemplate(nodeTemplateInput);
- return e2eServiceTemplateInput;
- }
-
- private ToscaTemplate e2eToscaTemplate(String nodeUUID) {
- ToscaTemplate toscaTemplate = mock(ToscaTemplate.class);
- Map<String, Object> e2eAttributes = new HashMap<>();
- e2eAttributes.put("invariantUUID", "1");
- e2eAttributes.put("UUID", "1");
- e2eAttributes.put("name", "VoLTE");
- e2eAttributes.put("type", "service");
- e2eAttributes.put("description", "VoLTE");
- e2eAttributes.put("category", "service");
- e2eAttributes.put("subcategory", "");
- when(toscaTemplate.getMetaData()).thenReturn(new Metadata(e2eAttributes));
- when(toscaTemplate.getInputs()).thenReturn(new ArrayList<>());
- NodeTemplate nodeTemplate = mock(NodeTemplate.class);
-
- Map<String, Object> nodeUUIDAttr = new HashMap<>();
-
- nodeUUIDAttr.put("UUID", nodeUUID);
- when(nodeTemplate.getMetaData()).thenReturn(new Metadata(nodeUUIDAttr));
-
- ArrayList<NodeTemplate> nodeTemplates = new ArrayList<>();
-// nodeTemplates.add(nodeTemplate);
- when(toscaTemplate.getNodeTemplates()).thenReturn(nodeTemplates);
-
- return toscaTemplate;
- }
-
- private ToscaTemplate nodeToscaTemplate(String nodeUUID) {
- ToscaTemplate toscaTemplate = mock(ToscaTemplate.class);
- Map<String, Object> Attributes = new HashMap<>();
- Attributes.put("invariantUUID", nodeUUID);
- Attributes.put("UUID", nodeUUID);
- Attributes.put("name", "");
- Attributes.put("type", "");
- Attributes.put("description", "");
- Attributes.put("category", "service");
- Attributes.put("subcategory", "");
- when(toscaTemplate.getMetaData()).thenReturn(new Metadata(Attributes));
-
- Input input = mock(Input.class);
- when(input.getName()).thenReturn("field_name");
- when(input.getDescription()).thenReturn("field_description");
- when(input.getType()).thenReturn("field_type");
- when(input.getDefault()).thenReturn("field_default");
- when(input.isRequired()).thenReturn(true);
-
- ArrayList<Input> inputs = new ArrayList<>();
- inputs.add(input);
- when(toscaTemplate.getInputs()).thenReturn(inputs);
- when(toscaTemplate.getNodeTemplates()).thenReturn(new ArrayList<>());
-
- return toscaTemplate;
- }
-
- private AAIService newAAIService(List<VimInfo> vim) {
- AAIService aaiService = mock(AAIService.class);
- VimInfoRsp rsp = new VimInfoRsp();
- rsp.setCloudRegion(vim);
- Call<VimInfoRsp> vimCall = successfulCall(rsp);
- when(aaiService.listVimInfo()).thenReturn(vimCall);
- return aaiService;
- }
-
- @Test(expected = SDCCatalogException.class)
- public void retrieveInputsWillThrowExceptionWhenDownloadFailed() {
- ServiceTemplateService service = new DefaultServiceTemplateService(null, null) {
- @Override
- protected void downloadFile(String templateUrl, String toPath) throws IOException {
- throw new IOException("download failed!");
- }
- };
- service.fetchServiceTemplateInput("1", "url");
- }
-
- @Test(expected = SDCCatalogException.class)
- public void retrieveInputsWillThrowExceptionWhenParsingToscaTemplateFailed() {
- ServiceTemplateService service = new DefaultServiceTemplateService(null, null) {
- @Override
- protected void downloadFile(String templateUrl, String toPath) throws IOException {
- // download successfully...
- }
-
- @Override
- protected ToscaTemplate translateToToscaTemplate(String toPath) throws JToscaException {
- throw new JToscaException("parse tosca template failed!", "123");
- }
- };
- service.fetchServiceTemplateInput("1", "url");
- }
} \ No newline at end of file
diff --git a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql b/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql
index 7a55c72b..82c71424 100644
--- a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql
+++ b/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql
@@ -27,7 +27,8 @@ CREATE TABLE `alarms_additionalinformation` (
`eventId` varchar(30) NOT NULL,
`createTime` datetime NOT NULL,
`updateTime` datetime NOT NULL,
- PRIMARY KEY (`name`,`eventId`)
+ `id` int(10) NOT NULL,
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
@@ -61,7 +62,7 @@ CREATE TABLE `alarms_commoneventheader` (
`status` varchar(11) NOT NULL,
`createTime` datetime NOT NULL,
`updateTime` datetime NOT NULL,
- PRIMARY KEY (`eventId`)
+ PRIMARY KEY (`eventName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
@@ -74,7 +75,8 @@ CREATE TABLE `performance_additionalinformation` (
`eventId` varchar(30) NOT NULL,
`createTime` datetime NOT NULL,
`updateTime` datetime NOT NULL,
- PRIMARY KEY (`name`,`eventId`)
+ `id` int(10) NOT NULL,
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
@@ -101,11 +103,5 @@ CREATE TABLE `performance_commoneventheader` (
`measurementInterval` varchar(10) NOT NULL,
`createTime` datetime NOT NULL,
`updateTime` datetime NOT NULL,
- PRIMARY KEY (`eventId`)
+ PRIMARY KEY (`eventName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Init Records
--- ----------------------------
-INSERT INTO `alarms_additionalinformation` VALUES ('name', 'value', 'eventId', '2017-09-19 11:12:34', '2017-09-19 11:12:34');
-INSERT INTO `alarms_commoneventheader` VALUES ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '2017-09-04 15:25:11', '2017-09-11 15:25:19');