aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhangab <zhanganbing@chinamobile.com>2018-05-22 13:50:52 +0800
committerzhangab <zhanganbing@chinamobile.com>2018-05-22 13:51:00 +0800
commit6f2e84fe6337e457e7503fc8d7fc80528a11b416 (patch)
tree75f823a0f6f8f6cde27168560f43d789248fd28a
parentdb90a90c89a55b78a244205ef2928e371ff9df1e (diff)
fix alarm display bug
Change-Id: Iff221fe4dcb8089bcb5e75bdd6a7d52e2754a804 Issue-ID: USECASEUI-119 Signed-off-by: zhangab <zhanganbing@chinamobile.com>
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java9
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java48
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java38
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java20
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java35
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java29
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java53
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java29
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java13
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java3
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java4
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java64
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java32
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java18
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java52
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java243
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java2
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java6
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java6
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java4
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java4
21 files changed, 466 insertions, 246 deletions
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 7b9a0b53..61aa70f2 100644
--- a/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java
+++ b/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server;
import org.onap.usecaseui.server.util.DmaapSubscriber;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@@ -25,7 +26,14 @@ import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@ComponentScan(basePackages = "org.onap.usecaseui.server")
public class UsecaseuiServerApplication {
+
+ public static DmaapSubscriber dmaapSubscriber;
+ @Autowired
+ public void setDatastore(DmaapSubscriber dmaapSubscriber) {
+ UsecaseuiServerApplication.dmaapSubscriber = dmaapSubscriber;
+ }
+
@Bean
public RestTemplate getRestTemplate(){
return new RestTemplate();
@@ -33,7 +41,6 @@ public class UsecaseuiServerApplication {
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 2edaa155..188507de 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
@@ -1,4 +1,4 @@
-/*
+/**
* Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,11 +27,14 @@ import javax.persistence.Table;
@Entity
@Table(name="alarms_commoneventheader")
public class AlarmsHeader implements Serializable{
-
+
+ @Id
+ @Column(name = "id")
+ private String id;
+
@Column(name = "version")
private String version;
- @Id
@Column(name = "eventName")
private String eventName;
@@ -71,6 +74,13 @@ public class AlarmsHeader implements Serializable{
@Column(name = "lastEpochMicroSec")
private String lastEpochMicroSec;
+
+ @Column(name = "startEpochMicrosecCleared")
+ private String startEpochMicrosecCleared;
+
+ @Column(name = "lastEpochMicroSecCleared")
+ private String lastEpochMicroSecCleared;
+
@Column(name = "sequence")
private String sequence;
@@ -108,6 +118,8 @@ public class AlarmsHeader implements Serializable{
@Column(name = "updateTime")
private Date updateTime;
+
+
public AlarmsHeader() {
}
@@ -117,7 +129,7 @@ public class AlarmsHeader implements Serializable{
- 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) {
+ 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 startEpochMicrosecCleared, String lastEpochMicroSecCleared, 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;
this.domain = domain;
@@ -132,6 +144,8 @@ public class AlarmsHeader implements Serializable{
this.priority = priority;
this.startEpochMicrosec = startEpochMicrosec;
this.lastEpochMicroSec = lastEpochMicroSec;
+ this.startEpochMicrosecCleared = startEpochMicrosecCleared;
+ this.lastEpochMicroSecCleared = lastEpochMicroSecCleared;
this.sequence = sequence;
this.faultFieldsVersion = faultFieldsVersion;
this.eventServrity = eventServrity;
@@ -250,6 +264,22 @@ public class AlarmsHeader implements Serializable{
this.startEpochMicrosec = startEpochMicrosec;
}
+ public String getStartEpochMicrosecCleared() {
+ return startEpochMicrosecCleared;
+ }
+
+ public void setStartEpochMicrosecCleared(String startEpochMicrosecCleared) {
+ this.startEpochMicrosecCleared = startEpochMicrosecCleared;
+ }
+
+ public String getLastEpochMicroSecCleared() {
+ return lastEpochMicroSecCleared;
+ }
+
+ public void setLastEpochMicroSecCleared(String lastEpochMicroSecCleared) {
+ this.lastEpochMicroSecCleared = lastEpochMicroSecCleared;
+ }
+
public String getLastEpochMicroSec() {
return lastEpochMicroSec;
}
@@ -353,6 +383,12 @@ public class AlarmsHeader implements Serializable{
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
-
-
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
}
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 4d298e02..db02827f 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
@@ -42,40 +42,45 @@ public class AlarmsInformation implements Serializable {
@Column(name = "value")
private String value;
- @Column(name = "eventId")
- private String eventId;
+ @Column(name = "sourceId")
+ private String sourceId;
@Column(name = "createTime")
private Date createTime;
@Column(name = "updateTime")
private Date updateTime;
-
+
+ @Column(name = "headerId")
+ private String headerId;
+
@Override
public String toString() {
return "AlarmsInformation{" +
"id=" + id +
", name='" + name + '\'' +
", value='" + value + '\'' +
- ", eventId='" + eventId + '\'' +
+ ", sourceId='" + sourceId + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
+ ", headerId=" + headerId +
'}';
}
public AlarmsInformation() {
}
- public AlarmsInformation(String eventId) {
- this.eventId = eventId;
+ public AlarmsInformation(String sourceId) {
+ this.sourceId = sourceId;
}
- public AlarmsInformation(String name, String value, String eventId, Date createTime, Date updateTime) {
+ public AlarmsInformation(String name, String value, String sourceId, Date createTime, Date updateTime,String headerId) {
this.name = name;
this.value = value;
- this.eventId = eventId;
+ this.sourceId = sourceId;
this.createTime = createTime;
this.updateTime = updateTime;
+ this.headerId = headerId;
}
public String getName() {
@@ -94,12 +99,12 @@ public class AlarmsInformation implements Serializable {
this.value = value;
}
- public String getEventId() {
- return eventId;
+ public String getSourceId() {
+ return sourceId;
}
- public void setEventId(String eventId) {
- this.eventId = eventId;
+ public void setSourceId(String sourceId) {
+ this.sourceId = sourceId;
}
public Date getCreateTime() {
@@ -125,6 +130,13 @@ public class AlarmsInformation implements Serializable {
public void setId(int id) {
this.id = id;
}
-
+
+ public String getHeaderId() {
+ return headerId;
+ }
+
+ public void setHeaderId(String headerId) {
+ this.headerId = headerId;
+ }
}
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 1d4bd8fa..05bc3998 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
@@ -1,4 +1,4 @@
-/*
+/**
* Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,11 +27,14 @@ import javax.persistence.Table;
@Entity
@Table(name="performance_commoneventheader")
public class PerformanceHeader implements Serializable {
-
+
+ @Id
+ @Column(name = "id")
+ private String id;
+
@Column(name = "version")
private String version;
- @Id
@Column(name = "eventName")
private String eventName;
@@ -86,7 +89,7 @@ public class PerformanceHeader implements Serializable {
@Column(name = "updateTime")
private Date updateTime;
-
+
public PerformanceHeader() {
}
@@ -268,7 +271,12 @@ public class PerformanceHeader implements Serializable {
this.updateTime = updateTime;
}
-
-
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
index c0da3ab5..7de4cb9f 100755
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
@@ -38,28 +38,32 @@ public class PerformanceInformation implements Serializable {
@Column(name = "value")
private String value;
- @Column(name = "eventId")
- private String eventId;
+ @Column(name = "sourceId")
+ private String sourceId;
@Column(name = "createTime")
private Date createTime;
@Column(name = "updateTime")
private Date updateTime;
-
+
+ @Column(name="headerId")
+ private String headerId;
+
public PerformanceInformation() {
}
- public PerformanceInformation(String eventId) {
- this.eventId = eventId;
+ public PerformanceInformation(String sourceId) {
+ this.sourceId = sourceId;
}
- public PerformanceInformation(String name, String value, String eventId, Date createTime, Date updateTime) {
+ public PerformanceInformation(String name, String value, String sourceId, Date createTime, Date updateTime,String headerId) {
this.name = name;
this.value = value;
- this.eventId = eventId;
+ this.sourceId = sourceId;
this.createTime = createTime;
this.updateTime = updateTime;
+ this.headerId = headerId;
}
public String getName() {
@@ -78,12 +82,12 @@ public class PerformanceInformation implements Serializable {
this.value = value;
}
- public String getEventId() {
- return eventId;
+ public String getSourceId() {
+ return sourceId;
}
- public void setEventId(String eventId) {
- this.eventId = eventId;
+ public void setSourceId(String sourceId) {
+ this.sourceId = sourceId;
}
public Date getCreateTime() {
@@ -109,6 +113,13 @@ public class PerformanceInformation implements Serializable {
public void setId(int id) {
this.id = id;
}
-
+
+ public String getHeaderId() {
+ return headerId;
+ }
+
+ public void setHeaderId(String headerId) {
+ this.headerId = headerId;
+ }
}
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 f89585bf..c16fe82c 100755
--- a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
@@ -29,6 +29,7 @@ import org.onap.usecaseui.server.service.AlarmsInformationService;
import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
import org.onap.usecaseui.server.util.ResponseUtil;
+import org.onap.usecaseui.server.util.UuiCommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@@ -111,7 +112,7 @@ public class AlarmController
AlarmBo abo = new AlarmBo();
abo.setAlarmsHeader(a);
AlarmsInformation information = new AlarmsInformation();
- information.setEventId(a.getSourceId());
+ information.setSourceId(a.getSourceId());
List<AlarmsInformation> informationList = alarmsInformationService.queryAlarmsInformation(information,1,100).getList();
informationList.forEach( il -> {
if (il.getValue().equals("")){
@@ -172,5 +173,31 @@ public class AlarmController
return "";
}
}
+
+ @RequestMapping(value = "/alarm/statusCount", method = RequestMethod.GET, produces = "application/json")
+ public String getStatusCount() throws JsonProcessingException {
+ List<String> statusCount = new ArrayList<>();
+
+ statusCount.add(alarmsHeaderService.queryStatusCount("0"));
+ statusCount.add(alarmsHeaderService.queryStatusCount("active"));
+ statusCount.add(alarmsHeaderService.queryStatusCount("close"));
+ return omAlarm.writeValueAsString(statusCount);
+ }
+
+ @RequestMapping("/alarm/getAlarmsHeaderDetail/{id}")
+ public String getAlarmsHeaderDetail(@PathVariable String id) throws JsonProcessingException {
+ AlarmsHeader alarmsHeader= alarmsHeaderService.getAlarmsHeaderById(id);
+ List<AlarmsInformation> list =new ArrayList<>();
+ if(UuiCommonUtil.isNotNullOrEmpty(alarmsHeader)){
+ String headerId = alarmsHeader.getId();
+ list = alarmsInformationService.getAllAlarmsInformationByHeaderId(headerId);
+ }
+ Map map = new HashMap();
+ map.put("alarmsHeader",alarmsHeader);
+ map.put("list",list);
+
+ String string =omAlarm.writeValueAsString(map);
+ return string;
+ }
}
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 ec97252a..fdb71b6d 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
@@ -16,8 +16,17 @@
package org.onap.usecaseui.server.controller;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
import org.onap.usecaseui.server.bean.PerformanceHeader;
import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.bo.PerformanceBo;
@@ -26,19 +35,20 @@ import org.onap.usecaseui.server.service.PerformanceHeaderService;
import org.onap.usecaseui.server.service.PerformanceInformationService;
import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
-import org.onap.usecaseui.server.util.ResponseUtil;
+import org.onap.usecaseui.server.util.UuiCommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
@RestController
@@ -89,7 +99,7 @@ public class PerformanceController {
performanceHeaders.forEach( per ->{
PerformanceBo pbo = new PerformanceBo();
PerformanceInformation pe = new PerformanceInformation();
- pe.setEventId(per.getSourceId());
+ pe.setSourceId(per.getSourceId());
List<PerformanceInformation> performanceInformations = performanceInformationService.queryPerformanceInformation(pe,1,100).getList();
pbo.setPerformanceHeader(per);
performanceInformations.forEach( pi ->{
@@ -197,7 +207,7 @@ public class PerformanceController {
@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<>();
+ List<String> diagramSource = new ArrayList<>();
try {
logger.info(sourceId+":"+startTime+":"+endTime+":"+nameParent+":"+nameChild);
if (performanceHeaderService.queryPerformanceHeader(new PerformanceHeader(sourceId),1,10).getList() != null){
@@ -207,7 +217,7 @@ public class PerformanceController {
}
performanceInformationService.queryDateBetween(sourceId,nameParent,startTime,endTime)
.forEach( per -> {
- diagramSource.add(Integer.parseInt(per.getValue()));
+ diagramSource.add(per.getValue());
});
}
} catch (Exception e) {
@@ -245,6 +255,23 @@ public class PerformanceController {
return "";
}
}
+
+ @RequestMapping("/performance/getPerformanceHeaderDetail/{id}")
+ public String getPerformanceHeaderDetail(@PathVariable String id) throws JsonProcessingException {
+ PerformanceHeader performanceHeader= performanceHeaderService.getPerformanceHeaderById(id);
+ List<PerformanceInformation> list =new ArrayList<>();
+ if(UuiCommonUtil.isNotNullOrEmpty(performanceHeader)){
+ String headerId = performanceHeader.getId();
+ list = performanceInformationService.getAllPerformanceInformationByHeaderId(headerId);
+ }
+
+ Map map = new HashMap();
+ map.put("performanceHeader",performanceHeader);
+ map.put("list",list);
+
+ String string =omPerformance.writeValueAsString(map);
+ return string;
+ }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
index 6bb8e6f7..570a563f 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server.service;
+import java.sql.Timestamp;
import java.util.List;
import org.onap.usecaseui.server.bean.AlarmsHeader;
@@ -32,4 +33,32 @@ public interface AlarmsHeaderService {
Page<AlarmsHeader> queryAlarmsHeader(AlarmsHeader alarmsHeader, int currentPage, int pageSize);
List<AlarmsHeader> queryId(String[] id);
+
+ public String updateAlarmsHeader2018(String status, Timestamp date, String startEpochMicrosecCleared, String lastEpochMicroSecCleared, String eventName, String reportingEntityName, String specificProblem);
+
+ /**
+ *
+ * queryStatusCount
+ *
+ * @Auther YYY
+ * @Date 2018/5/17 15:59:23
+ * @Title: queryStatusCount
+ * @Description:
+ * @param status
+ * @return
+ */
+ String queryStatusCount(String status);
+
+ /**
+ *
+ * getAlarmsHeaderById
+ *
+ * @Auther YYY
+ * @Date 2018/5/17 16:05:59
+ * @Title: getAlarmsHeaderById
+ * @Description:
+ * @param id
+ * @return
+ */
+ AlarmsHeader getAlarmsHeaderById(String id);
}
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 70c37e31..33126bb0 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
@@ -36,4 +36,17 @@ public interface AlarmsInformationService {
List<AlarmsInformation> queryId(String[] id);
List<Map<String,String>> queryDateBetween(String sourceId, String startTime, String endTime);
+
+ /**
+ *
+ * getAllAlarmsInformationByHeaderId
+ *
+ * @Auther YYY
+ * @Date 2018/5/17 16:10:26
+ * @Title: getAllAlarmsInformationByHeaderId
+ * @Description:
+ * @param id
+ * @return
+ */
+ List<AlarmsInformation> getAllAlarmsInformationByHeaderId(String id);
}
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 4e346efe..6e86ac33 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
@@ -17,7 +17,6 @@ package org.onap.usecaseui.server.service;
import java.util.List;
-import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.PerformanceHeader;
import org.onap.usecaseui.server.util.Page;
@@ -35,4 +34,6 @@ public interface PerformanceHeaderService {
List<PerformanceHeader> queryId(String[] id);
List<String> queryAllSourceId();
+
+ PerformanceHeader getPerformanceHeaderById(String id);
}
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 58932f15..70fbf7f1 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
@@ -18,7 +18,6 @@ package org.onap.usecaseui.server.service;
import java.util.Date;
import java.util.List;
-import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.util.Page;
@@ -40,5 +39,6 @@ public interface PerformanceInformationService {
int queryDataBetweenSum(String eventId, String name, Date startDate, Date endDate);
List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime);
-
+
+ List<PerformanceInformation> getAllPerformanceInformationByHeaderId(String headerId);
}
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 7d6b0afc..ebbd8fc7 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.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -362,4 +363,67 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
return null;
}
}
+
+ @Override
+ public String updateAlarmsHeader2018(String status, Timestamp date, String startEpochMicrosecCleared, String lastEpochMicroSecCleared, String eventName, String reportingEntityName, String specificProblem) {
+
+ try(Session session = getSession()){
+ //try(Session session = sessionFactory.getCurrentSession();){
+ session.beginTransaction();
+
+ //Query q=session.createQuery("update AlarmsHeader set status='"+status+"', updateTime='"+date+"' , startEpochMicrosecCleared='"+startEpochMicrosecCleared+"' ,lastEpochMicroSecCleared='"+lastEpochMicroSecCleared+"' where eventName='"+eventName+"' and reportingEntityName='"+reportingEntityName+"' and specificProblem ='"+specificProblem+"'");
+ Query q=session.createQuery("update AlarmsHeader set status=:status, updateTime=:date, startEpochMicrosecCleared=:startEpochMicrosecCleared ,lastEpochMicroSecCleared=:lastEpochMicroSecCleared where eventName=:eventName and reportingEntityName=:reportingEntityName and specificProblem =:specificProblem");
+
+ q.setString("status",status);
+ q.setDate("date",date);
+
+ q.setString("startEpochMicrosecCleared",startEpochMicrosecCleared);
+ q.setString("lastEpochMicroSecCleared",lastEpochMicroSecCleared);
+ q.setString("eventName",eventName);
+ q.setString("reportingEntityName",reportingEntityName);
+ q.setString("specificProblem",specificProblem);
+
+
+ q.executeUpdate();
+ session.getTransaction().commit();
+ session.flush();
+ return "1";
+ } catch (Exception e) {
+ logger.error("exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());
+ return "0";
+ }
+ }
+
+ @Override
+ public String queryStatusCount(String status) {
+ try(Session session = sessionFactory.openSession()){
+ String hql = "select count(status) from AlarmsHeader a";
+ if (!status.equals("0"))
+ hql+=" where a.status = :status";
+ Query query = session.createQuery(hql);
+ if (!status.equals("0"))
+ query.setString("status",status);
+ return query.uniqueResult().toString();
+ } catch (Exception e) {
+ logger.error("exception occurred while performing AlarmsHeaderServiceImpl queryStatusCount. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public AlarmsHeader getAlarmsHeaderById(String id) {
+ try(Session session = sessionFactory.openSession()) {
+
+ String string = "from AlarmsHeader a where 1=1 and a.id=:id";
+ Query q = session.createQuery(string);
+ q.setString("id",id);
+ AlarmsHeader alarmsHeader =(AlarmsHeader)q.uniqueResult();
+ session.flush();
+ return alarmsHeader;
+
+ }catch (Exception e){
+ logger.error("exception occurred while performing AlarmsHeaderServiceImpl getAlarmsHeaderDetail."+e.getMessage());
+ return null;
+ }
+ }
}
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 c12576dc..a33f9c00 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
@@ -101,9 +101,9 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
String ver=alarmsInformation.getValue();
hql.append(" and a.value like '%"+ver+"%'");
}
- if(null!=alarmsInformation.getEventId()) {
- String ver=alarmsInformation.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
+ if(null!=alarmsInformation.getSourceId()) {
+ String ver=alarmsInformation.getSourceId();
+ hql.append(" and a.sourceId = '"+ver+"'");
}
if(null!=alarmsInformation.getCreateTime()) {
Date ver =alarmsInformation.getCreateTime();
@@ -144,9 +144,9 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
String ver=alarmsInformation.getValue();
hql.append(" and a.value like '%"+ver+"%'");
}
- if(null!=alarmsInformation.getEventId()) {
- String ver=alarmsInformation.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
+ if(null!=alarmsInformation.getSourceId()) {
+ String ver=alarmsInformation.getSourceId();
+ hql.append(" and a.sourceId = '"+ver+"'");
}
if(null!=alarmsInformation.getCreateTime()) {
Date ver =alarmsInformation.getCreateTime();
@@ -183,7 +183,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
}
List<AlarmsInformation> list = new ArrayList<AlarmsInformation>();
Session session = getSession();
- Query query = session.createQuery("from AlarmsInformation a where a.eventId IN (:alist)");
+ Query query = session.createQuery("from AlarmsInformation a where a.sourceId IN (:alist)");
list = query.setParameterList("alist", id).list();
session.close();
return list;
@@ -200,7 +200,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
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";
+ hql += " and a.sourceId = :sourceId";
}
if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
hql += " and a.createTime between :startTime and :endTime ";
@@ -228,4 +228,20 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
return null;
}
}
+
+ @Override
+ public List<AlarmsInformation> getAllAlarmsInformationByHeaderId(String headerId) {
+ try (Session session = getSession()){
+ String string = "from AlarmsInformation a where 1=1 and a.headerId=:headerId";
+ Query query = session.createQuery(string);
+ query.setString("headerId",headerId);
+ List<AlarmsInformation> list = query.list();
+ session.flush();
+ return list;
+ }catch (Exception e){
+ logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. LIST:" + 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 fccee3d7..191eab2e 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
@@ -17,7 +17,6 @@ package org.onap.usecaseui.server.service.impl;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import javax.transaction.Transactional;
@@ -314,4 +313,21 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
return null;
}
}
+
+ @Override
+ public PerformanceHeader getPerformanceHeaderById(String id) {
+ try(Session session = sessionFactory.openSession()) {
+
+ String string = "from PerformanceHeader a where 1=1 and a.id=:id";
+ Query q = session.createQuery(string);
+ q.setString("id",id);
+ PerformanceHeader performanceHeader =(PerformanceHeader)q.uniqueResult();
+ session.flush();
+ return performanceHeader;
+
+ }catch (Exception e){
+ logger.error("exception occurred while performing PerformanceHeaderServiceImpl getPerformanceHeaderById."+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 ae8e0480..c11f1608 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,18 +16,18 @@
package org.onap.usecaseui.server.service.impl;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import javax.persistence.Id;
import javax.transaction.Transactional;
-import org.hibernate.*;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
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;
@@ -101,9 +101,9 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
String ver=performanceInformation.getValue();
hql.append(" and a.value like '%"+ver+"%'");
}
- if(null!=performanceInformation.getEventId()) {
- String ver=performanceInformation.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
+ if(null!=performanceInformation.getSourceId()) {
+ String ver=performanceInformation.getSourceId();
+ hql.append(" and a.sourceId = '"+ver+"'");
}
if(null!=performanceInformation.getCreateTime()) {
Date ver =performanceInformation.getCreateTime();
@@ -144,9 +144,9 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
String ver=performanceInformation.getValue();
hql.append(" and a.value like '%"+ver+"%'");
}
- if(null!=performanceInformation.getEventId()) {
- String ver=performanceInformation.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
+ if(null!=performanceInformation.getSourceId()) {
+ String ver=performanceInformation.getSourceId();
+ hql.append(" and a.sourceId = '"+ver+"'");
}
if(null!=performanceInformation.getCreateTime()) {
Date ver =performanceInformation.getCreateTime();
@@ -183,7 +183,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
logger.error("PerformanceInformationServiceImpl queryId is null!");
}
List<PerformanceInformation> list = new ArrayList<>();
- Query query = session.createQuery("from PerformanceInformation a where a.eventId IN (:alist)");
+ Query query = session.createQuery("from PerformanceInformation a where a.sourceId IN (:alist)");
list = query.setParameterList("alist", id).list();
return list;
} catch (Exception e) {
@@ -195,11 +195,11 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@SuppressWarnings("unchecked")
@Override
- public List<PerformanceInformation> queryDateBetween(String eventId, Date startDate, Date endDate) {
+ public List<PerformanceInformation> queryDateBetween(String sourceId, Date startDate, Date endDate) {
try(Session session = getSession()) {
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();
+ Query query = session.createQuery("from PerformanceInformation a where a.sourceId = :sourceId and a.createTime BETWEEN :startDate and :endDate");
+ list = query.setParameter("sourceId",sourceId).setParameter("startDate", startDate).setParameter("endDate",endDate).list();
logger.info("PerformanceInformationServiceImpl queryDateBetween: list={}", list);
return list;
} catch (Exception e) {
@@ -210,11 +210,11 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@SuppressWarnings("unchecked")
@Override
- public int queryDataBetweenSum(String eventId, String name, Date startDate, Date endDate){
+ public int queryDataBetweenSum(String sourceId, String name, Date startDate, Date endDate){
try(Session session = getSession()) {
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());
+ Query query = session.createQuery("select sum(a.value) from PerformanceInformation a where a.sourceId = :sourceId and a.name = :name and a.createTime BETWEEN :startDate and :endDate");
+ sum = Integer.parseInt(query.setParameter("sourceId",sourceId).setParameter("name",name).setParameter("startDate", startDate).setParameter("endDate",endDate).uniqueResult().toString());
logger.info("PerformanceInformationServiceImpl queryDataBetweenSum: sum={}", sum);
return sum;
} catch (Exception e) {
@@ -228,7 +228,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
try(Session session = getSession()) {
String hql = "from PerformanceInformation a where 1=1 ";
if (resourceId != null && !"".equals(resourceId)){
- hql += " and a.eventId = :resourceId";
+ hql += " and a.sourceId = :resourceId";
}
if (name != null && !"".equals(name)){
hql += " and a.name = :name ";
@@ -253,4 +253,20 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
return null;
}
}
+
+ @Override
+ public List<PerformanceInformation> getAllPerformanceInformationByHeaderId(String headerId) {
+ try (Session session = getSession()){
+ String string = "from PerformanceInformation a where 1=1 and a.headerId=:headerId";
+ Query query = session.createQuery(string);
+ query.setString("headerId",headerId);
+ List<PerformanceInformation> list = query.list();
+ session.flush();
+ return list;
+ }catch (Exception e){
+ logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. LIST:" + e.getMessage());
+
+ 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 df96bd6c..0870053b 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,7 +15,23 @@
*/
package org.onap.usecaseui.server.util;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.annotation.Resource;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
import org.glassfish.jersey.client.ClientConfig;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
@@ -28,20 +44,11 @@ import org.onap.usecaseui.server.service.PerformanceHeaderService;
import org.onap.usecaseui.server.service.PerformanceInformationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Component;
-import javax.annotation.Resource;
-import javax.ws.rs.client.Client;
-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.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
+@Component
public class DmaapSubscriber implements Runnable {
private Logger logger = LoggerFactory.getLogger(DmaapSubscriber.class);
@@ -67,63 +74,42 @@ public class DmaapSubscriber implements Runnable {
@Resource(name = "PerformanceInformationService")
private PerformanceInformationService performanceInformationService;
- public void subscribe(String topic) {
- String response;
+ public void subscribe(String topic) {
try {
- response = getDMaaPData(topic);
- logger.info(response);
- if (response == null && "".equals(response)) {
- logger.info("response is null");
+ List<String> respList = getDMaaPData(topic);
+ if (respList.size() <= 0 || respList == null) {
+ logger.info("response content is :"+respList);
return;
- } else {
- ObjectMapper objMapper = new ObjectMapper();
- 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("\";",";");
-
- if (response.indexOf("[") == 0) {
- List<Object> eventList = objMapper.readValue(response, List.class);
-
- 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);
- }
- });
- } else if (response.indexOf("{") == 0) {
- Map<String, Object> eventMaps = (Map<String, Object>) objMapper.readValue(response, Map.class).get("event");
-
+ }
+ ObjectMapper objMapper = new ObjectMapper();
+ objMapper.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
+ respList.forEach(rl -> {
+ try {
+ Map<String, Object> eventMaps = (Map<String, Object>) objMapper.readValue(rl, Map.class).get("event");
if (eventMaps.containsKey("measurementsForVfScalingFields")) {
performanceProcess(eventMaps);
} else if (eventMaps.containsKey("faultFields")) {
alarmProcess(eventMaps);
}
- } else {
- logger.error("unknown json type!");
+ } catch (IOException e) {
+ e.printStackTrace();
+ logger.error(rl);
+ logger.error("exception occurred while performing DmaapSubcriber performanceProcess or alarmProcess. Details:"+ e.getMessage());
+
}
- }
+ });
+
} catch (Exception e) {
+ e.printStackTrace();
logger.error("getDMaaP Information failed :" + e.getMessage());
}
}
- private String getDMaaPData(String topic) {
+ private List<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();
- return response.readEntity(String.class);
+ return response.readEntity(List.class);
}
private void initConfig() {
@@ -156,6 +142,7 @@ public class DmaapSubscriber implements Runnable {
private void alarmProcess(Map<String, Object> eventMap) {
AlarmsHeader alarm_header = new AlarmsHeader();
+ alarm_header.setId(UuiCommonUtil.getUUID());
List<AlarmsInformation> alarm_informations = new ArrayList<>();
eventMap.forEach((ek1, ev1) -> {
if (ek1.equals("commonEventHeader")) {
@@ -213,40 +200,7 @@ public class DmaapSubscriber implements Runnable {
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));
- }
+ alarm_informations.add(new AlarmsInformation(i.get("name").toString(), i.get("value").toString(), alarm_header.getSourceId(), new Date(), null,alarm_header.getId()));
});
} catch (Exception e) {
e.printStackTrace();
@@ -254,41 +208,39 @@ public class DmaapSubscriber implements Runnable {
}
}
});
- 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));
- }
}
});
+ if (alarm_header.getEventName() != null){
+ alarm_informations.forEach(ai -> {
+ ai.setCreateTime(alarm_header.getCreateTime());
+ ai.setUpdateTime(new Date());
+ });
+ Long l = System.currentTimeMillis();
+
+ Timestamp date_get = new Timestamp(l);
+ if (alarm_header.getEventName().contains("Cleared")) {
+ alarm_header.setStatus("close");
+ alarmsHeaderService.updateAlarmsHeader2018("close", date_get, alarm_header.getStartEpochMicrosec(), alarm_header.getLastEpochMicroSec(), alarm_header.getEventName().replace("Cleared", ""), alarm_header.getReportingEntityName(), alarm_header.getSpecificProblem());
+ alarm_informations.forEach(information ->
+ alarmsInformationService.saveAlarmsInformation(information));
+
+ } else {
+ alarm_header.setCreateTime(new Date());
+ alarm_header.setStatus("active");
+ alarmsHeaderService.saveAlarmsHeader(alarm_header);
+ if(alarm_informations.size() > 0) {
+ alarm_informations.forEach(information ->
+ alarmsInformationService.saveAlarmsInformation(information));
+ }
+ }
+ }
}
private void performanceProcess(Map<String, Object> maps) {
PerformanceHeader performance_header = new PerformanceHeader();
+ performance_header.setId(UuiCommonUtil.getUUID());
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) -> {
+ maps.forEach((ek1, ev1) -> {
if (ek1.equals("commonEventHeader")) {
((Map<String, Object>) ev1).forEach((k2, v2) -> {
if (k2.equals("version"))
@@ -332,43 +284,31 @@ public class DmaapSubscriber implements Runnable {
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));
+ i.forEach( (k,v) -> {
+ if (k.equals("arrayOfFields")){
+ List<Map<String,String>> arrayOfFields = (List<Map<String, String>>) v;
+ arrayOfFields.forEach( fields -> {
+ if (fields.get("name").equals("StartTime")){
- 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];
+ try {
+ String type = performance_header.getEventType();
+ performance_informations.add(new PerformanceInformation(fields.get("name"), fields.get("value"), performance_header.getSourceId(), null, DateUtils.now(),performance_header.getId()));
+ performance_header.setCreateTime(DateUtils.stringToDate(fields.get("value").replaceAll(Constant.RegEX_DATE_FORMAT, " ")));
+ performance_header.setUpdateTime(DateUtils.now());
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }else{
+ try {
+ performance_informations.add(new PerformanceInformation(fields.get("name"), fields.get("value"), performance_header.getSourceId(), null, DateUtils.now(), performance_header.getId()));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+ } );
}
- } 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());
@@ -378,12 +318,9 @@ public class DmaapSubscriber implements Runnable {
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/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java
index 1f774b75..4f7571be 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java
@@ -54,7 +54,7 @@ public class AlarmsHeaderTest {
public void testGetAlarmsHeader() throws Exception {
AlarmsHeader ah = new AlarmsHeader("version", "eventName", "domain", "eventId", "eventType", "nfcNamingCode",
"nfNamingCode", "sourceId", "sourceName", "reportingEntityId", "reportingEntityName",
- "priority", "startEpochMicrosec", "lastEpochMicroSec", "sequence", "faultFieldsVersion",
+ "priority", "startEpochMicrosec", "lastEpochMicroSec","startEpochMicrosecCleared", "lastEpochMicroSecCleared", "sequence", "faultFieldsVersion",
"eventServrity", "eventSourceType", "eventCategory", "alarmCondition", "specificProblem",
"vfStatus", "alarmInterfaceA", "status", DateUtils.now(), DateUtils.now());
ah.getVersion();
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java
index 0a66e1e0..469b4778 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java
@@ -52,10 +52,10 @@ public class AlarmsInformationTest implements Serializable {
@Test
public void testGetAlarmsInformation() throws Exception {
- AlarmsInformation ai = new AlarmsInformation("name", "value", "eventId", DateUtils.now(), DateUtils.now());
+ AlarmsInformation ai = new AlarmsInformation("name", "value", "eventId", DateUtils.now(), DateUtils.now(),"headerId");
ai.getName();
ai.getValue();
- ai.getEventId();
+ ai.getSourceId();
ai.getCreateTime();
ai.getUpdateTime();
ai.getId();
@@ -67,7 +67,7 @@ public class AlarmsInformationTest implements Serializable {
AlarmsInformation ai = new AlarmsInformation("eventId");
ai.setName("");
ai.setValue("");
- ai.setEventId("");
+ ai.setSourceId("");
ai.setCreateTime(DateUtils.now());
ai.setUpdateTime(DateUtils.now());
ai.setId(1);
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java
index 1d59b156..64315854 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java
@@ -52,10 +52,10 @@ public class PerformanceInformationTest implements Serializable {
@Test
public void testGetPerformanceInformation() throws Exception {
- PerformanceInformation pi = new PerformanceInformation("name", "value", "eventId", DateUtils.now(), DateUtils.now());
+ PerformanceInformation pi = new PerformanceInformation("name", "value", "eventId", DateUtils.now(), DateUtils.now(),"headerId");
pi.getName();
pi.getValue();
- pi.getEventId();
+ pi.getSourceId();
pi.getCreateTime();
pi.getUpdateTime();
pi.getId();
@@ -66,7 +66,7 @@ public class PerformanceInformationTest implements Serializable {
PerformanceInformation pi = new PerformanceInformation("eventId");
pi.setName("");
pi.setValue("");
- pi.setEventId("");
+ pi.setSourceId("");
pi.setCreateTime(DateUtils.now());
pi.setUpdateTime(DateUtils.now());
pi.setId(1);
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
index 0676c4f3..0743a863 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
@@ -167,7 +167,7 @@ public class AlarmsInformationServiceImplTest {
AlarmsInformation ai = new AlarmsInformation();
ai.setName("");
ai.setValue("");
- ai.setEventId("");
+ ai.setSourceId("");
ai.setCreateTime(DateUtils.now());
ai.setUpdateTime(DateUtils.now());
alarmsInformationServiceImpl.getAllCount(ai, 1, 1);
@@ -182,7 +182,7 @@ public class AlarmsInformationServiceImplTest {
AlarmsInformation ai = new AlarmsInformation();
ai.setName("");
ai.setValue("");
- ai.setEventId("");
+ ai.setSourceId("");
ai.setCreateTime(DateUtils.now());
ai.setUpdateTime(DateUtils.now());
alarmsInformationServiceImpl.queryAlarmsInformation(ai, 1, 1);
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
index b628ebdf..ebbc38e0 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
@@ -167,7 +167,7 @@ public class PerformanceInformationServiceImplTest {
PerformanceInformation pi = new PerformanceInformation();
pi.setName("");
pi.setValue("");
- pi.setEventId("");
+ pi.setSourceId("");
pi.setCreateTime(DateUtils.now());
pi.setUpdateTime(DateUtils.now());
performanceInformationServiceImpl.getAllCount(pi, 1, 1);
@@ -182,7 +182,7 @@ public class PerformanceInformationServiceImplTest {
PerformanceInformation pi = new PerformanceInformation();
pi.setName("");
pi.setValue("");
- pi.setEventId("");
+ pi.setSourceId("");
pi.setCreateTime(DateUtils.now());
pi.setUpdateTime(DateUtils.now());
performanceInformationServiceImpl.queryPerformanceInformation(pi, 1, 1);