summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhangab <zhanganbing@chinamobile.com>2018-04-14 12:02:13 +0800
committerzhangab <zhanganbing@chinamobile.com>2018-04-14 12:02:18 +0800
commit53aac91804a550effcfa1e1bc9b7520efcdea184 (patch)
treef704afa8d96f01bc2ca621f829b7a0c9d8318bb2
parent2d85274e10a6a95dd8b0e2604638c87d90a3958f (diff)
revoke monitor function of vims
Change-Id: Icd6b12931e20e9de3108f4bfbe45a0d9135b37da Issue-ID: USECASEUI-103 Signed-off-by: zhangab <zhanganbing@chinamobile.com>
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java12
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java48
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java17
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderPm.java281
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderVm.java281
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationPm.java114
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationVm.java114
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java12
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java51
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/constant/Constant.java1
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java379
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java478
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/controller/PerformancePmController.java557
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/controller/PerformanceVmController.java569
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java2
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java20
-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/PerformanceHeaderPmService.java47
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java15
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderVmService.java49
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationPmService.java45
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java9
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationVmService.java45
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java271
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java56
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderPmServiceImpl.java479
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java159
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderVmServiceImpl.java467
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationPmServiceImpl.java301
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java129
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationVmServiceImpl.java302
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/util/DateUtils.java180
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java460
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/Page.java8
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java63
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java60
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java469
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java437
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java290
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java117
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java241
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java131
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java459
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java306
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/InitializationServiceImplTest.java67
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java374
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java241
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java3
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java72
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/util/ResponseUtilTest.java54
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/util/RestfulServicesTest.java86
-rw-r--r--standalone/src/main/assembly/resources/topologyD_data.json21
52 files changed, 1802 insertions, 7650 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 e57bd5e4..7b9a0b53 100644
--- a/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java
+++ b/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java
@@ -16,27 +16,16 @@
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;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;
-import javax.annotation.Resource;
-
@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();
@@ -44,6 +33,7 @@ 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 c9ebcf78..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
@@ -27,14 +27,11 @@ import javax.persistence.Table;
@Entity
@Table(name="alarms_commoneventheader")
public class AlarmsHeader implements Serializable{
-
- @Id
- @Column(name = "id")
- private int id;
-
+
@Column(name = "version")
private String version;
+ @Id
@Column(name = "eventName")
private String eventName;
@@ -74,15 +71,6 @@ 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;
@@ -120,8 +108,6 @@ public class AlarmsHeader implements Serializable{
@Column(name = "updateTime")
private Date updateTime;
-
-
public AlarmsHeader() {
}
@@ -131,7 +117,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 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) {
+ 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;
this.domain = domain;
@@ -146,8 +132,6 @@ 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;
@@ -266,22 +250,6 @@ 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;
}
@@ -385,12 +353,6 @@ public class AlarmsHeader implements Serializable{
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
+
+
}
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 8fe725a0..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
@@ -27,14 +27,11 @@ import javax.persistence.Table;
@Entity
@Table(name="performance_commoneventheader")
public class PerformanceHeader implements Serializable {
-
- @Id
- @Column(name = "id")
- private int id;
-
+
@Column(name = "version")
private String version;
+ @Id
@Column(name = "eventName")
private String eventName;
@@ -271,11 +268,7 @@ public class PerformanceHeader implements Serializable {
this.updateTime = updateTime;
}
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
+
+
+
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderPm.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderPm.java
deleted file mode 100644
index f48ee9b9..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderPm.java
+++ /dev/null
@@ -1,281 +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.
- */
-package org.onap.usecaseui.server.bean;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-
-@Entity
-@Table(name="performance_commoneventheader_pm")
-public class PerformanceHeaderPm implements Serializable {
-
- @Id
- @Column(name = "id")
- private int id;
-
- @Column(name = "version")
- private String version;
-
- @Column(name = "eventName")
- private String eventName;
-
- @Column(name = "domain")
- private String domain;
-
-
- @Column(name = "eventId")
- private String eventId;
-
- @Column(name = "eventType")
- private String eventType;
-
- @Column(name = "nfcNamingCode", nullable=false)
- private String nfcNamingCode;
-
- @Column(name = "nfNamingCode", nullable=false)
- private String nfNamingCode;
-
- @Column(name = "sourceId")
- private String sourceId;
-
- @Column(name = "sourceName")
- private String sourceName;
-
- @Column(name = "reportingEntityId")
- private String reportingEntityId;
-
- @Column(name = "reportingEntityName")
- private String reportingEntityName;
-
- @Column(name = "priority")
- private String priority;
-
- @Column(name = "startEpochMicrosec")
- private String startEpochMicrosec;
-
- @Column(name = "lastEpochMicroSec")
- private String lastEpochMicroSec;
-
- @Column(name = "sequence")
- private String sequence;
-
- @Column(name = "measurementsForVfScalingVersion")
- private String measurementsForVfScalingVersion;
-
- @Column(name = "measurementInterval")
- private String measurementInterval;
-
- @Column(name = "createTime")
- private Date createTime;
-
- @Column(name = "updateTime")
- private Date updateTime;
-
- public PerformanceHeaderPm() {
- }
-
- public PerformanceHeaderPm(String sourceId) {
- this.sourceId = sourceId;
- }
-
- public PerformanceHeaderPm(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;
- this.eventName = eventName;
- this.domain = domain;
- this.eventId = eventId;
- this.eventType = eventType;
- this.nfcNamingCode = nfcNamingCode;
- this.nfNamingCode = nfNamingCode;
- this.sourceId = sourceId;
- this.sourceName = sourceName;
- this.reportingEntityId = reportingEntityId;
- this.reportingEntityName = reportingEntityName;
- this.priority = priority;
- this.startEpochMicrosec = startEpochMicrosec;
- this.lastEpochMicroSec = lastEpochMicroSec;
- this.sequence = sequence;
- this.measurementsForVfScalingVersion = measurementsForVfScalingVersion;
- this.measurementInterval = measurementInterval;
- this.createTime = createTime;
- this.updateTime = updateTime;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getEventName() {
- return eventName;
- }
-
- public void setEventName(String eventName) {
- this.eventName = eventName;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public String getEventId() {
- return eventId;
- }
-
- public void setEventId(String eventId) {
- this.eventId = eventId;
- }
-
- public String getEventType() {
- return eventType;
- }
-
- public void setEventType(String eventType) {
- this.eventType = eventType;
- }
-
- public String getNfcNamingCode() {
- return nfcNamingCode;
- }
-
- public void setNfcNamingCode(String nfcNamingCode) {
- this.nfcNamingCode = nfcNamingCode;
- }
-
- public String getNfNamingCode() {
- return nfNamingCode;
- }
-
- public void setNfNamingCode(String nfNamingCode) {
- this.nfNamingCode = nfNamingCode;
- }
-
- public String getSourceId() {
- return sourceId;
- }
-
- public void setSourceId(String sourceId) {
- this.sourceId = sourceId;
- }
-
- public String getSourceName() {
- return sourceName;
- }
-
- public void setSourceName(String sourceName) {
- this.sourceName = sourceName;
- }
-
- public String getReportingEntityId() {
- return reportingEntityId;
- }
-
- public void setReportingEntityId(String reportingEntityId) {
- this.reportingEntityId = reportingEntityId;
- }
-
- public String getReportingEntityName() {
- return reportingEntityName;
- }
-
- public void setReportingEntityName(String reportingEntityName) {
- this.reportingEntityName = reportingEntityName;
- }
-
- public String getPriority() {
- return priority;
- }
-
- public void setPriority(String priority) {
- this.priority = priority;
- }
-
- public String getStartEpochMicrosec() {
- return startEpochMicrosec;
- }
-
- public void setStartEpochMicrosec(String startEpochMicrosec) {
- this.startEpochMicrosec = startEpochMicrosec;
- }
-
- public String getLastEpochMicroSec() {
- return lastEpochMicroSec;
- }
-
- public void setLastEpochMicroSec(String lastEpochMicroSec) {
- this.lastEpochMicroSec = lastEpochMicroSec;
- }
-
- public String getSequence() {
- return sequence;
- }
-
- public void setSequence(String sequence) {
- this.sequence = sequence;
- }
-
- public String getMeasurementsForVfScalingVersion() {
- return measurementsForVfScalingVersion;
- }
-
- public void setMeasurementsForVfScalingVersion(String measurementsForVfScalingVersion) {
- this.measurementsForVfScalingVersion = measurementsForVfScalingVersion;
- }
-
- public String getMeasurementInterval() {
- return measurementInterval;
- }
-
- public void setMeasurementInterval(String measurementInterval) {
- this.measurementInterval = measurementInterval;
- }
-
- public Date getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderVm.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderVm.java
deleted file mode 100644
index 1aaa28e7..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderVm.java
+++ /dev/null
@@ -1,281 +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.
- */
-package org.onap.usecaseui.server.bean;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-
-@Entity
-@Table(name="performance_commoneventheader_vm")
-public class PerformanceHeaderVm implements Serializable {
-
- @Id
- @Column(name = "id")
- private int id;
-
- @Column(name = "version")
- private String version;
-
- @Column(name = "eventName")
- private String eventName;
-
- @Column(name = "domain")
- private String domain;
-
-
- @Column(name = "eventId")
- private String eventId;
-
- @Column(name = "eventType")
- private String eventType;
-
- @Column(name = "nfcNamingCode", nullable=false)
- private String nfcNamingCode;
-
- @Column(name = "nfNamingCode", nullable=false)
- private String nfNamingCode;
-
- @Column(name = "sourceId")
- private String sourceId;
-
- @Column(name = "sourceName")
- private String sourceName;
-
- @Column(name = "reportingEntityId")
- private String reportingEntityId;
-
- @Column(name = "reportingEntityName")
- private String reportingEntityName;
-
- @Column(name = "priority")
- private String priority;
-
- @Column(name = "startEpochMicrosec")
- private String startEpochMicrosec;
-
- @Column(name = "lastEpochMicroSec")
- private String lastEpochMicroSec;
-
- @Column(name = "sequence")
- private String sequence;
-
- @Column(name = "measurementsForVfScalingVersion")
- private String measurementsForVfScalingVersion;
-
- @Column(name = "measurementInterval")
- private String measurementInterval;
-
- @Column(name = "createTime")
- private Date createTime;
-
- @Column(name = "updateTime")
- private Date updateTime;
-
- public PerformanceHeaderVm() {
- }
-
- public PerformanceHeaderVm(String sourceId) {
- this.sourceId = sourceId;
- }
-
- public PerformanceHeaderVm(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;
- this.eventName = eventName;
- this.domain = domain;
- this.eventId = eventId;
- this.eventType = eventType;
- this.nfcNamingCode = nfcNamingCode;
- this.nfNamingCode = nfNamingCode;
- this.sourceId = sourceId;
- this.sourceName = sourceName;
- this.reportingEntityId = reportingEntityId;
- this.reportingEntityName = reportingEntityName;
- this.priority = priority;
- this.startEpochMicrosec = startEpochMicrosec;
- this.lastEpochMicroSec = lastEpochMicroSec;
- this.sequence = sequence;
- this.measurementsForVfScalingVersion = measurementsForVfScalingVersion;
- this.measurementInterval = measurementInterval;
- this.createTime = createTime;
- this.updateTime = updateTime;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getEventName() {
- return eventName;
- }
-
- public void setEventName(String eventName) {
- this.eventName = eventName;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public String getEventId() {
- return eventId;
- }
-
- public void setEventId(String eventId) {
- this.eventId = eventId;
- }
-
- public String getEventType() {
- return eventType;
- }
-
- public void setEventType(String eventType) {
- this.eventType = eventType;
- }
-
- public String getNfcNamingCode() {
- return nfcNamingCode;
- }
-
- public void setNfcNamingCode(String nfcNamingCode) {
- this.nfcNamingCode = nfcNamingCode;
- }
-
- public String getNfNamingCode() {
- return nfNamingCode;
- }
-
- public void setNfNamingCode(String nfNamingCode) {
- this.nfNamingCode = nfNamingCode;
- }
-
- public String getSourceId() {
- return sourceId;
- }
-
- public void setSourceId(String sourceId) {
- this.sourceId = sourceId;
- }
-
- public String getSourceName() {
- return sourceName;
- }
-
- public void setSourceName(String sourceName) {
- this.sourceName = sourceName;
- }
-
- public String getReportingEntityId() {
- return reportingEntityId;
- }
-
- public void setReportingEntityId(String reportingEntityId) {
- this.reportingEntityId = reportingEntityId;
- }
-
- public String getReportingEntityName() {
- return reportingEntityName;
- }
-
- public void setReportingEntityName(String reportingEntityName) {
- this.reportingEntityName = reportingEntityName;
- }
-
- public String getPriority() {
- return priority;
- }
-
- public void setPriority(String priority) {
- this.priority = priority;
- }
-
- public String getStartEpochMicrosec() {
- return startEpochMicrosec;
- }
-
- public void setStartEpochMicrosec(String startEpochMicrosec) {
- this.startEpochMicrosec = startEpochMicrosec;
- }
-
- public String getLastEpochMicroSec() {
- return lastEpochMicroSec;
- }
-
- public void setLastEpochMicroSec(String lastEpochMicroSec) {
- this.lastEpochMicroSec = lastEpochMicroSec;
- }
-
- public String getSequence() {
- return sequence;
- }
-
- public void setSequence(String sequence) {
- this.sequence = sequence;
- }
-
- public String getMeasurementsForVfScalingVersion() {
- return measurementsForVfScalingVersion;
- }
-
- public void setMeasurementsForVfScalingVersion(String measurementsForVfScalingVersion) {
- this.measurementsForVfScalingVersion = measurementsForVfScalingVersion;
- }
-
- public String getMeasurementInterval() {
- return measurementInterval;
- }
-
- public void setMeasurementInterval(String measurementInterval) {
- this.measurementInterval = measurementInterval;
- }
-
- public Date getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationPm.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationPm.java
deleted file mode 100644
index 881c5a6f..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationPm.java
+++ /dev/null
@@ -1,114 +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.
- */
-package org.onap.usecaseui.server.bean;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-
-@Entity
-@Table(name="performance_additionalinformation_pm")
-public class PerformanceInformationPm implements Serializable {
-
- @Id
- @Column(name = "id")
- private int id;
-
- @Column(name = "name")
- private String name;
-
- @Column(name = "value")
- private String value;
-
- @Column(name = "eventId")
- private String eventId;
-
- @Column(name = "createTime")
- private Date createTime;
-
- @Column(name = "updateTime")
- private Date updateTime;
-
- public PerformanceInformationPm() {
- }
-
- public PerformanceInformationPm(String eventId) {
- this.eventId = eventId;
- }
-
- public PerformanceInformationPm(String name, String value, String eventId, Date createTime, Date updateTime) {
- this.name = name;
- this.value = value;
- this.eventId = eventId;
- this.createTime = createTime;
- this.updateTime = updateTime;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getEventId() {
- return eventId;
- }
-
- public void setEventId(String eventId) {
- this.eventId = eventId;
- }
-
- public Date getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
-
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationVm.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationVm.java
deleted file mode 100644
index aa53fdc9..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationVm.java
+++ /dev/null
@@ -1,114 +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.
- */
-package org.onap.usecaseui.server.bean;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-
-@Entity
-@Table(name="performance_additionalinformation_vm")
-public class PerformanceInformationVm implements Serializable {
-
- @Id
- @Column(name = "id")
- private int id;
-
- @Column(name = "name")
- private String name;
-
- @Column(name = "value")
- private String value;
-
- @Column(name = "eventId")
- private String eventId;
-
- @Column(name = "createTime")
- private Date createTime;
-
- @Column(name = "updateTime")
- private Date updateTime;
-
- public PerformanceInformationVm() {
- }
-
- public PerformanceInformationVm(String eventId) {
- this.eventId = eventId;
- }
-
- public PerformanceInformationVm(String name, String value, String eventId, Date createTime, Date updateTime) {
- this.name = name;
- this.value = value;
- this.eventId = eventId;
- this.createTime = createTime;
- this.updateTime = updateTime;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getEventId() {
- return eventId;
- }
-
- public void setEventId(String eventId) {
- this.eventId = eventId;
- }
-
- public Date getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
-
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java b/server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java
index 990f5bd7..8904db55 100644
--- a/server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java
@@ -15,7 +15,8 @@
*/
package org.onap.usecaseui.server.bo;
-import org.onap.usecaseui.server.bean.*;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.util.Page;
import java.io.Serializable;
@@ -26,17 +27,16 @@ public class AlarmBo implements Serializable {
private AlarmsHeader alarmsHeader;
-
-
private List<AlarmsInformation> alarmsInformation;
-
-
public AlarmBo() {
}
-
+ public AlarmBo(AlarmsHeader alarmsHeader, List<AlarmsInformation> alarmsInformation) {
+ this.alarmsHeader = alarmsHeader;
+ this.alarmsInformation = alarmsInformation;
+ }
public AlarmsHeader getAlarmsHeader() {
return alarmsHeader;
diff --git a/server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java b/server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java
index 3031b06d..b3bd5965 100755
--- a/server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java
@@ -15,7 +15,8 @@
*/
package org.onap.usecaseui.server.bo;
-import org.onap.usecaseui.server.bean.*;
+import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.util.Page;
import java.io.Serializable;
@@ -27,18 +28,14 @@ public class PerformanceBo implements Serializable {
private List<PerformanceInformation> performanceInformation;
- private PerformanceHeaderPm performanceHeaderPm;
-
- private List<PerformanceInformationPm> performanceInformationPm;
-
- private PerformanceHeaderVm performanceHeaderVm;
-
- private List<PerformanceInformationVm> performanceInformationVm;
-
public PerformanceBo() {
}
+ public PerformanceBo(PerformanceHeader performanceHeader, List<PerformanceInformation> performanceInformation) {
+ this.performanceHeader = performanceHeader;
+ this.performanceInformation = performanceInformation;
+ }
public PerformanceHeader getPerformanceHeader() {
return performanceHeader;
@@ -55,40 +52,4 @@ public class PerformanceBo implements Serializable {
public void setPerformanceInformation(List<PerformanceInformation> performanceInformation) {
this.performanceInformation = performanceInformation;
}
-
-
- public PerformanceHeaderPm getPerformanceHeaderPm() {
- return performanceHeaderPm;
- }
-
- public void setPerformanceHeaderPm(PerformanceHeaderPm performanceHeaderPm) {
- this.performanceHeaderPm = performanceHeaderPm;
- }
-
- public List<PerformanceInformationPm> getPerformanceInformationPm() {
- return performanceInformationPm;
- }
-
- public void setPerformanceInformationPm(List<PerformanceInformationPm> performanceInformationPm) {
- this.performanceInformationPm = performanceInformationPm;
- }
-
-
-
-
- public PerformanceHeaderVm getPerformanceHeaderVm() {
- return performanceHeaderVm;
- }
-
- public void setPerformanceHeaderVm(PerformanceHeaderVm performanceHeaderVm) {
- this.performanceHeaderVm = performanceHeaderVm;
- }
-
- public List<PerformanceInformationVm> getPerformanceInformationVm() {
- return performanceInformationVm;
- }
-
- public void setPerformanceInformationVm(List<PerformanceInformationVm> performanceInformationVm) {
- this.performanceInformationVm = performanceInformationVm;
- }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
index 013eaab4..9a818e4e 100755
--- a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
+++ b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
@@ -21,6 +21,5 @@ public final class Constant
public static final String DATE_FORMAT= "yyyy-MM-dd HH:mm:ss";
- public static final String RegEX_DATE_FORMAT = "[^0-9-:]";
}
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 0040a072..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
@@ -16,6 +16,8 @@
package org.onap.usecaseui.server.controller;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.usecaseui.server.bean.AlarmsHeader;
@@ -24,25 +26,30 @@ import org.onap.usecaseui.server.bo.AlarmBo;
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.util.*;
+import org.onap.usecaseui.server.util.CSVUtils;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.onap.usecaseui.server.util.Page;
+import org.onap.usecaseui.server.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
-
-import java.io.*;
-
+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.*;
@RestController
@org.springframework.context.annotation.Configuration
@EnableAspectJAutoProxy
-public class AlarmController {
+public class AlarmController
+{
private final Logger logger = LoggerFactory.getLogger(AlarmController.class);
@@ -50,270 +57,162 @@ public class AlarmController {
@Resource(name = "AlarmsHeaderService")
private AlarmsHeaderService alarmsHeaderService;
-
- public void setAlarmsHeaderService(AlarmsHeaderService alarmsHeaderService) {
- this.alarmsHeaderService = alarmsHeaderService;
- }
-
-
- public void setAlarmsInformationService(AlarmsInformationService alarmsInformationService) {
- this.alarmsInformationService = alarmsInformationService;
- }
-
@Resource(name = "AlarmsInformationService")
private AlarmsInformationService alarmsInformationService;
+ private String[] AlarmCSVHeaders = new String[]{"version",
+ "eventName","domain","eventId","eventType","nfcNamingCode",
+ "nfNamingCode","sourceId","sourceName","reportingEntityId",
+ "reportingEntityName","priority","startEpochMicrosec","lastEpochMicroSec",
+ "sequence","faultFieldsVersion","eventServrity","eventSourceType",
+ "eventCategory","alarmCondition","specificProblem","vfStatus",
+ "alarmInterfaceA","status",
+ "createTime","updateTime","name","value"};
+
private ObjectMapper omAlarm = new ObjectMapper();
- private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+ @RequestMapping(value = {"/usecase-ui"}, method = RequestMethod.GET)
+ public ModelAndView index(){
+ return new ModelAndView("index");
+ }
+
@RequestMapping(value = {"/alarm/{currentPage}/{pageSize}",
"/alarm/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}/{vfStatus}"},
- method = RequestMethod.GET, produces = "application/json")
- public String getAlarmData(@PathVariable int currentPage, @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, @PathVariable(required = false) String vfStatus
- ) throws JsonProcessingException, ParseException {
+ method = RequestMethod.GET , produces = "application/json")
+ 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 : {} , sourceId : {} , " +
- "sourceName : {} , priority : {} , startTime :{} , endTime : {} , vfStatus : {}]"
- , currentPage, pageSize, sourceId, sourceName, priority, startTime, endTime, vfStatus);
- List<AlarmsHeader> alarmsHeaders = new ArrayList<AlarmsHeader>();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ "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;
+ Page pa = null;
if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime
- || null != vfStatus) {
+ || null != vfStatus ){
AlarmsHeader alarm = new AlarmsHeader();
- alarm.setSourceId(!"null".equals(sourceId) ? sourceId : null);
- alarm.setSourceName(!"null".equals(sourceName) ? sourceName : null);
- alarm.setStatus(!"null".equals(vfStatus) ? vfStatus : null);
- alarm.setPriority(!"null".equals(priority) ? 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(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);
+ 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);
-
- if (null == pa) {
- AlarmsHeader alarm_s = new AlarmsHeader();
- //SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String startTime_s="2017-10-31 09:52:15";
- String endTime_s="2017-11-15 15:27:16";
- alarm_s.setSourceId("11694_113");
- alarm_s.setSourceName("11694_113");
- alarm_s.setPriority("High");
- alarm_s.setVfStatus("Medium");
- alarm_s.setCreateTime(formatter.parse(startTime_s));
- alarm_s.setUpdateTime(formatter.parse(endTime_s));
- alarm_s.setEventId("ab305d54-85b4-a31b-7db2-fb6b9e546015");
- alarm_s.setEventName("Fault_MultiCloud_VMFailureCleared");
- alarm_s.setId(5);
- alarm_s.setStatus("close");
- alarmsHeaders.add(alarm_s);
- }else {
- alarmsHeaders = pa.getList();
+ logger.error("Parse date error :"+e.getMessage());
}
-
-
- if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
-
- //if (null != pa) {
- //alarmsHeaders = pa.getList();
- //alarmsHeaders.forEach(a -> {
- AlarmsHeader a;
- for(int c=0;c<alarmsHeaders.size();c++){
- a = alarmsHeaders.get(c);
-
- logger.info(a.toString());
- AlarmBo abo = new AlarmBo();
- if (!a.getStatus().equals("active")) {
- abo.setAlarmsHeader(a);
- AlarmsInformation information = new AlarmsInformation();
- information.setEventId(a.getSourceId());
- List<AlarmsInformation> informationList=new ArrayList<AlarmsInformation>();
- if("11694_113".equals(a.getSourceId())){
- AlarmsInformation al = new AlarmsInformation();
- al.setName("neType");
- al.setValue("IMSSBC");
- al.setEventId("11694_113");
- al.setCreateTime(formatter.parse("2017-10-31 09:51:15"));
- al.setUpdateTime(formatter.parse("2017-11-15 15:27:15"));
- informationList.add(al);
- }else {
- informationList = alarmsInformationService.queryAlarmsInformation(information, 1, 100).getList();
-
- }
- abo.setAlarmsInformation(informationList);
- list.add(abo);
+ 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.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());
}
- }
- // });
- }
-
- } else {
+ } );
+ abo.setAlarmsInformation(informationList);
+ list.add(abo);
+ });
+ }
+ }else {
pa = alarmsHeaderService.queryAlarmsHeader(null, currentPage, pageSize);
- if (null == pa) {
- AlarmsHeader alarm_s = new AlarmsHeader();
- //SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String startTime_s="2017-10-31 09:52:15";
- String endTime_s="2017-11-15 15:27:16";
- alarm_s.setSourceId("11694_113");
- alarm_s.setSourceName("11694_113");
- alarm_s.setPriority("High");
- alarm_s.setVfStatus("Medium");
- alarm_s.setCreateTime(formatter.parse(startTime_s));
- alarm_s.setUpdateTime(formatter.parse(endTime_s));
- alarm_s.setEventId("ab305d54-85b4-a31b-7db2-fb6b9e546015");
- alarm_s.setEventName("Fault_MultiCloud_VMFailureCleared");
- alarm_s.setId(5);
- alarm_s.setStatus("close");
- alarmsHeaders.add(alarm_s);
- }else{
- alarmsHeaders = pa.getList();
+ alarmsHeaders = pa.getList();
+ if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
+ alarmsHeaders.forEach(a -> {
+ AlarmBo abo = new AlarmBo();
+ abo.setAlarmsHeader(a);
+ abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(a.getEventId()),currentPage,pageSize).getList());
+ list.add(abo);
+ });
}
-
- if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
- alarmsHeaders.forEach(a -> {
- AlarmBo abo = new AlarmBo();
- if (!a.getStatus().equals("active")) {
- abo.setAlarmsHeader(a);
- abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(a.getEventId()), currentPage, pageSize).getList());
- list.add(abo);
- }
-
- });
- }
-
- }
- Map<String, Object> map = new HashMap<>();
- map.put("alarms", list);
- map.put("totalRecords", pa==null?0:pa.getTotalRecords());
- omAlarm.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
- return omAlarm.writeValueAsString(map);
- }
-
-
- @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(value = {"/alarm/sourceId"}, method = RequestMethod.GET)
- public String getSourceId() throws JsonProcessingException {
- List<String> sourceIds = new ArrayList<>();
- Page page = alarmsHeaderService.queryAlarmsHeader(new AlarmsHeader(), 1, Integer.MAX_VALUE);
- AlarmsHeader alarmsHeader;
-
- if(page==null){
- page = new Page();
- List list = new ArrayList();
- alarmsHeader = new AlarmsHeader();
- alarmsHeader.setId(1);
- alarmsHeader.setSourceId("aaaa");
- list.add(alarmsHeader);
- page.setPageNo(1);
- page.setPageSize(12);
- page.setTotalRecords(1);
- page.setList(list);
-
}
- for(int a=0;a<page.getList().size();a++){
-
- alarmsHeader = (AlarmsHeader)page.getList().get(a);
- String sourceid = alarmsHeader.getSourceId();
- if (!sourceIds.contains(sourceid)) {
- sourceIds.add(sourceid);
- }
+ try {
+ Map<String,Object> map = new HashMap<>();
+ map.put("alarms",list);
+ map.put("totalRecords",pa.getTotalRecords());
+ omAlarm.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
+ return omAlarm.writeValueAsString(map);
+ } catch (JsonProcessingException e) {
+ logger.debug("JsonProcessingException :"+e.getMessage());
+ return omAlarm.writeValueAsString("failed");
}
- return omAlarm.writeValueAsString(sourceIds);
- }
-
- @RequestMapping(value = {"/alarm/diagram"}, method = RequestMethod.POST)
- public String genDiagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String showMode) throws JsonProcessingException {
-
- return omAlarm.writeValueAsString(diagramDate(sourceId, startTime, endTime, showMode));
-
}
- private List<List<Long>> dateProcess(String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit) throws ParseException {
- List<List<Long>> dataList = new ArrayList<>();
- long tmpEndTimeL = startTimeL + timeIteraPlusVal;
- while (endTimeL >= tmpEndTimeL) {
- List<Map<String, String>> maps = alarmsInformationService.queryDateBetween(sourceId, sdf.format(new Date(startTimeL)), sdf.format(new Date(tmpEndTimeL)));
- maps.forEach(map -> {
- try {
- List<Long> longList = new ArrayList<>();
- if (map.get("Time") != null && !"".equals(map.get("Time")) && !"NULL".equals(map.get("Time"))) {
- longList.add(sdf.parse(map.get("Time")).getTime());
- if (map.get("Count") != null && !"".equals(map.get("Count")))
- longList.add(Long.parseLong(map.get("Count")));
- else
- longList.add(0L);
+ @RequestMapping(value = { "/alarm/genCsv/{eventId}" } , method = RequestMethod.GET , produces = "application/json")
+ public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId) throws JsonProcessingException {
+ logger.info("transfer generateCsvFile Apis, " +
+ "Parameter all follows : [eventId : {}]",eventId);
+ String csvFile = "csvFiles/vnf_alarm_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
+ List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryId(eventId);
+ List<String[]> csvData = new ArrayList<>();
+ try{
+ alarmsHeaders.forEach(ala ->{
+ List<AlarmsInformation> information = alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(ala.getEventId()),1,100).getList();
+ String names = "";
+ String values = "";
+ if (0 < information.size() && null != information){
+ for (AlarmsInformation a : information){
+ names += a.getName()+",";
+ values += a.getValue()+",";
}
- if (longList.size() > 0)
- dataList.add(longList);
- } catch (ParseException e) {
- e.printStackTrace();
+ names = names.substring(0,names.lastIndexOf(','));
+ values = values.substring(0,values.lastIndexOf(','));
}
+ csvData.add(new String[]{
+ ala.getVersion(),ala.getEventName(),ala.getDomain(),ala.getEventId(),ala.getEventType(),
+ ala.getNfcNamingCode(),ala.getNfNamingCode(),ala.getSourceId(),ala.getSourceName(),
+ ala.getReportingEntityId(),ala.getReportingEntityName(),ala.getPriority(),ala.getStartEpochMicrosec(),
+ ala.getLastEpochMicroSec(),ala.getSequence(),ala.getFaultFieldsVersion(),ala.getEventServrity(),
+ ala.getEventSourceType(),ala.getEventCategory(),ala.getAlarmCondition(),ala.getSpecificProblem(),
+ ala.getVfStatus(),ala.getAlarmInterfaceA(),ala.getStatus(),DateUtils.dateToString(ala.getCreateTime()),
+ DateUtils.dateToString(ala.getUpdateTime()),names,values
+ });
});
- startTimeL += timeIteraPlusVal;
- tmpEndTimeL += timeIteraPlusVal;
- keyVal += keyValIteraVal;
+ CSVUtils.writeCsv(AlarmCSVHeaders,csvData,csvFile);
+ }catch (Exception e){
+ logger.error(e.getMessage());
+ }
+ if (ResponseUtil.responseDownload(csvFile,response)){
+ return omAlarm.writeValueAsString("success");
+ }else{
+ return omAlarm.writeValueAsString("failed");
}
- return dataList;
}
- private List<List<Long>> diagramDate(String sourceId, String startTime, String endTime, String format) {
+ @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 {
- long startTimel = sdf.parse(startTime).getTime();
- long endTimel = sdf.parse(endTime).getTime();
- if (format != null && !format.equals("auto")) {
- switch (format) {
- case "minute":
- return dateProcess(sourceId, startTimel, endTimel, 900000, 15, 15, "minute");
- case "hour":
- return dateProcess(sourceId, startTimel, endTimel, 3600000, 1, 1, "hour");
- case "day":
- return dateProcess(sourceId, startTimel, endTimel, 86400000, 1, 1, "day");
- case "month":
- return dateProcess(sourceId, startTimel, endTimel, 2592000000L, 1, 1, "month");
- case "year":
- return dateProcess(sourceId, startTimel, endTimel, 31536000000L, 1, 1, "year");
- }
- } else if (format != null && format.equals("auto")) {
- long minutes = (endTimel - startTimel) / (1000 * 60);
- long hours = minutes / 60;
- if (hours > 12) {
- long days = hours / 24;
- if (days > 3) {
- long months = days / 31;
- if (months > 2) {
- return dateProcess(sourceId, startTimel, endTimel, 86400000, 1, 1, "day");
- } else {
- return dateProcess(sourceId, startTimel, endTimel, 2592000000L, 1, 1, "month");
- }
- } else {
- return dateProcess(sourceId, startTimel, endTimel, 3600000, 1, 1, "hour");
- }
- } else {
- return dateProcess(sourceId, startTimel, endTimel, 900000, 15, 15, "minute");
- }
- }
- } catch (ParseException e) {
- logger.error(e.getMessage());
+ 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 "";
}
- return null;
}
+
}
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 fee843bc..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
@@ -22,8 +22,12 @@ import org.onap.usecaseui.server.bean.PerformanceHeader;
import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.bo.PerformanceBo;
import org.onap.usecaseui.server.constant.Constant;
-import org.onap.usecaseui.server.service.*;
+import org.onap.usecaseui.server.service.PerformanceHeaderService;
+import org.onap.usecaseui.server.service.PerformanceInformationService;
+import org.onap.usecaseui.server.util.CSVUtils;
+import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
+import org.onap.usecaseui.server.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
@@ -49,305 +53,265 @@ public class PerformanceController {
@Resource(name = "PerformanceInformationService")
private PerformanceInformationService performanceInformationService;
- public void setPerformanceHeaderService(PerformanceHeaderService performanceHeaderService) {
- this.performanceHeaderService = performanceHeaderService;
- }
-
-
- public void setPerformanceInformationService(PerformanceInformationService performanceInformationService) {
- this.performanceInformationService = performanceInformationService;
- }
-
private Logger logger = LoggerFactory.getLogger(PerformanceController.class);
private final String[] PerformanceCSVHeaders = {"version",
- "eventName", "domain", "eventId", "eventType", "nfcNamingCode",
- "nfNamingCode", "sourceId", "sourceName", "reportingEntityId",
- "reportingEntityName", "priority", "startEpochMicrosec", "lastEpochMicroSec",
- "sequence", "measurementsForVfScalingVersion", "measurementInterval",
- "createTime", "updateTime", "value", "name"};
+ "eventName","domain","eventId","eventType","nfcNamingCode",
+ "nfNamingCode","sourceId","sourceName","reportingEntityId",
+ "reportingEntityName","priority","startEpochMicrosec","lastEpochMicroSec",
+ "sequence","measurementsForVfScalingVersion","measurementInterval",
+ "createTime","updateTime","value","name"};
private ObjectMapper omPerformance = new ObjectMapper();
- private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-
- @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 sourceId,
- @PathVariable(required = false) String sourceName, @PathVariable(required = false) String priority,
- @PathVariable(required = false) String startTime, @PathVariable(required = false) String endTime) throws JsonProcessingException, ParseException {
- logger.info("transfer getPerformanceData Apis, " +
+ @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 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 : {} , sourceId : {} , " +
"sourceName : {} , priority : {} , startTime :{} , endTime : {} ]"
- , currentPage, pageSize, sourceId, sourceName, priority, startTime, endTime);
- List<PerformanceBo> list = new ArrayList<>();
- List<PerformanceHeader> performanceHeaderList = new ArrayList<>();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ ,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime);
+ List<Object> list = new ArrayList<>();
Page pa = null;
- if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime) {
+ if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime){
PerformanceHeader performanceHeader = new PerformanceHeader();
- performanceHeader.setSourceId(!"null".equals(sourceId) ? sourceId : null);
- performanceHeader.setSourceName(!"null".equals(sourceName) ? sourceName : null);
+ performanceHeader.setSourceId(!"null".equals(sourceId)?sourceId:null);
+ performanceHeader.setSourceName(!"null".equals(sourceName)?sourceName:null);
try {
- 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);
+ 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)
+ if (null != response)
response.setStatus(400);
- logger.error("ParseException[" + startTime + "]:" + e.getMessage());
+ logger.error("ParseException["+startTime+"]:"+e.getMessage());
return "{'result':'error'}";
}
- pa = performanceHeaderService.queryPerformanceHeader(performanceHeader, currentPage, pageSize);
- if(pa==null) {
-
- PerformanceHeader performanceHeader_s = new PerformanceHeader();
- //SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String createtime="2017-11-15 06:30:00";
- String upatetime="2017-11-15 14:46:09";
- performanceHeader_s.setSourceName("101ZTHX1EPO1NK7E0Z2");
- performanceHeader_s.setSourceId("1101ZTHX1EPO1NK7E0Z21");
- performanceHeader_s.setEventName("Mfvs_MMEEthernetPort");
- performanceHeader_s.setEventId("2017-11-15T06:30:00EthernetPort1101ZTHX1EPO1NK7E0Z2");
- performanceHeader_s.setPriority("Normal");
- performanceHeader_s.setCreateTime(formatter.parse(createtime));
- performanceHeader_s.setUpdateTime(formatter.parse(upatetime));
- performanceHeader_s.setId(5);
- performanceHeaderList.add(performanceHeader_s);
-
- }else{
- performanceHeaderList = pa.getList();
- }
-
-
- if (null != performanceHeaderList && performanceHeaderList.size() > 0) {
- PerformanceHeader per;
- for(int c=0;c<performanceHeaderList.size();c++){
- per = performanceHeaderList.get(c);
-
- //performanceHeaderList.forEach(per -> {
- PerformanceBo pbo = new PerformanceBo();
- PerformanceInformation pe = new PerformanceInformation();
- pe.setEventId(per.getSourceId());
- List<PerformanceInformation> performanceInformations =new ArrayList<>();
- if("1101ZTHX1EPO1NK7E0Z21".equals(per.getSourceId())){
- PerformanceInformation pera = new PerformanceInformation();
- pera.setValue("0");
- pera.setId(6);
- pera.setName("HO.AttOutInterMme");
- pera.setEventId("1101ZTHX1MMEGJM1W1");
- String createtime="2017-11-15 06:30:00";
- String updatetime="2017-11-15 14:45:10";
- pera.setCreateTime(formatter.parse(createtime));
- pera.setUpdateTime(formatter.parse(updatetime));
- performanceInformations.add(pera);
-
-
-
- }else{
- performanceInformations = performanceInformationService.queryPerformanceInformation(pe, 1, 100).getList();
-
+ pa = performanceHeaderService.queryPerformanceHeader(performanceHeader,currentPage,pageSize);
+ List<PerformanceHeader> performanceHeaders = pa.getList();
+ performanceHeaders.forEach( per ->{
+ PerformanceBo pbo = new PerformanceBo();
+ PerformanceInformation pe = new PerformanceInformation();
+ 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);
+ });
+ }else{
+ pa = performanceHeaderService.queryPerformanceHeader(null,currentPage,pageSize);
+ List<PerformanceHeader> p = pa!=null?pa.getList():null;
+ if (null != p && p.size() > 0)
+ p.forEach( per ->{
+ PerformanceBo pbo = new PerformanceBo();
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);
+ pbo.setPerformanceInformation(performanceInformationService.queryPerformanceInformation(new PerformanceInformation(per.getEventId()),1,100).getList());
list.add(pbo);
+ });
+ }
+ try {
+ Map<String,Object> map = new HashMap<>();
+ map.put("performances",list);
+ map.put("totalRecords",pa.getTotalRecords());
+ omPerformance.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
+ return omPerformance.writeValueAsString(map);
+ } catch (JsonProcessingException e) {
+ logger.error("JsonProcessingException"+e.getMessage());
+ return omPerformance.writeValueAsString("failed");
+ }
+ }
+ @RequestMapping(value = {"/performance/genCsv/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
+ public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId) throws JsonProcessingException {
+ String csvFile = "csvFiles/vnf_performance_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
+ List<PerformanceHeader> performanceHeaders = performanceHeaderService.queryId(eventId);
+ if (null == performanceHeaders || performanceHeaders.size() <= 0)
+ return new ObjectMapper().writeValueAsString("selected eventId don't exist");
+ List<String[]> csvData = new ArrayList<>();
+ performanceHeaders.forEach(s ->{
+ List<PerformanceInformation> information = performanceInformationService.queryPerformanceInformation(new PerformanceInformation(s.getEventId()),1,100).getList();
+ String names = "";
+ String values = "";
+ if (0 < information.size() && null != information){
+ for (PerformanceInformation a : information){
+ names += a.getName()+",";
+ values += a.getValue()+",";
}
+ names = names.substring(0,names.lastIndexOf(','));
+ values = values.substring(0,values.lastIndexOf(','));
}
+ csvData.add(new String[]{
+ s.getVersion(),s.getEventName(),s.getDomain(),s.getEventId(),s.getEventType(),s.getNfcNamingCode(),s.getNfNamingCode(),
+ s.getSourceId(),s.getSourceName(),s.getReportingEntityId(),s.getReportingEntityName(),s.getPriority(),
+ s.getStartEpochMicrosec(),s.getLastEpochMicroSec(),s.getSequence(),s.getMeasurementsForVfScalingVersion(),
+ s.getMeasurementInterval(),DateUtils.dateToString(s.getCreateTime()),DateUtils.dateToString(s.getUpdateTime()),
+ names,values
+ });
+ });
+ CSVUtils.writeCsv(PerformanceCSVHeaders,csvData,csvFile);
+ if (ResponseUtil.responseDownload(csvFile,response)){
+ return omPerformance.writeValueAsString("success");
+ }else{
+ return omPerformance.writeValueAsString("failed");
+ }
+ }
- } else {
- pa = performanceHeaderService.queryPerformanceHeader(null, currentPage, pageSize);
- if (pa == null) {
- PerformanceHeader performanceHeader = new PerformanceHeader();
- //SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String createtime="2017-11-15 06:30:00";
- String upatetime="2017-11-15 14:46:09";
- performanceHeader.setSourceName("101ZTHX1EPO1NK7E0Z2");
- performanceHeader.setSourceId("1101ZTHX1EPO1NK7E0Z2");
- performanceHeader.setEventName("Mfvs_MMEEthernetPort");
- performanceHeader.setEventId("2017-11-15T06:30:00EthernetPort1101ZTHX1EPO1NK7E0Z2");
- performanceHeader.setPriority("Normal");
- performanceHeader.setCreateTime(formatter.parse(createtime));
- performanceHeader.setUpdateTime(formatter.parse(upatetime));
- performanceHeader.setId(5);
- performanceHeaderList.add(performanceHeader);
- pa = new Page();
- pa.setPageNo(1);
- pa.setPageSize(12);
- pa.setTotalRecords(1);
- pa.setList(performanceHeaderList);
- }
-
- //performanceHeaders = pa.getList();
- //if (null != performanceHeaders && performanceHeaders.size() > 0) {
- //list = pa.getList();
-
- List<PerformanceHeader> p = pa != null ? pa.getList() : null;
- if (null != p && p.size() > 0)
- p.forEach(per -> {
- PerformanceBo pbo = new PerformanceBo();
- pbo.setPerformanceHeader(per);
- pbo.setPerformanceInformation(performanceInformationService.queryPerformanceInformation(new PerformanceInformation(per.getEventId()), 1, 100).getList());
- list.add(pbo);
+ @RequestMapping(value = {"/performance/genDiaCsv/{dataJson}"}, method = RequestMethod.GET, produces = "application/json")
+ public String generateDiaCsvFile(HttpServletResponse response,@PathVariable String dataJson) throws IOException {
+ List<Map<String,Object>> dataList = omPerformance.readValue(dataJson,List.class);
+ String csvFileName = "csvFiles/"+dataList.get(0).get("name")+"_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
+ try{
+ String[] headers = new String[]{"eventId","name","dateUnit","value"};
+ List<String[]> csvDatas = new ArrayList<>();
+ if (null != dataList){
+ dataList.forEach((l)->{
+ StringBuffer fileData = new StringBuffer();
+ l.forEach((k,v)->{
+ logger.info(v.toString());
+ fileData.append(v.toString()+",");
});
+ csvDatas.add(fileData.toString().split(","));
+ });
+ }
+ CSVUtils.writeCsv(headers,csvDatas,csvFileName);
+ }catch (Exception pe){
+ logger.error(pe.getMessage());
+ }
+ if (ResponseUtil.responseDownload(csvFileName,response)){
+ return omPerformance.writeValueAsString("success");
+ }else{
+ return omPerformance.writeValueAsString("failed");
+ }
+ }
+ @ResponseBody
+ @RequestMapping(value = {"/performance/diagram/{unit}/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
+ public String generateDiagram(@PathVariable String unit,@PathVariable String eventId) throws ParseException, JsonProcessingException {
+ Map<String,List<Integer>> diagramSource = new HashMap<>();
+ String[] names = {"cpu","network","disk","memory"};
+ switch (unit){
+ case "hour":
+ for(int i = 0 ; i < 4 ; i++){
+ Date startDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,1,-1,0,0));
+ Date endDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,1,-1,0,0));
+ endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour,"minute",15));
+ List<Integer> values = new ArrayList<>();
+ for (int j = 0 ; j < 4 ; j++){
+ logger.info(DateUtils.dateToString(startDateHour));
+ logger.info(DateUtils.dateToString(endDateHour));
+ values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateHour,endDateHour));
+ startDateHour = DateUtils.stringToDate(DateUtils.addDate(startDateHour,"minute",15));
+ endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour,"minute",15));
+ }
+ diagramSource.put(names[i],values);
+ }
+ break;
+ case "day":
+ for(int i = 0 ; i < 4 ; i++){
+ Date startDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,-1,0,0,0));
+ Date endDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,-1,0,0,0));
+ endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay,"hour",1));
+ List<Integer> values = new ArrayList<>();
+ for (int j = 0 ; j < 24 ; j++){
+ values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateDay,endDateDay));
+ startDateDay = DateUtils.stringToDate(DateUtils.addDate(startDateDay,"hour",1));
+ endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay,"hour",1));
+ }
+ diagramSource.put(names[i],values);
+ }
+ break;
+ case "month":
+ for(int i = 0 ; i < 4 ; i++){
+ Date startDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,-1,0,0,0,0));
+ Date endDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,-1,0,0,0,0));
+ endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth,"day",1));
+ List<Integer> values = new ArrayList<>();
+ for (int j = 0 ; j < 31 ; j++){
+ values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateMonth,endDateMonth));
+ startDateMonth = DateUtils.stringToDate(DateUtils.addDate(startDateMonth,"day",1));
+ endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth,"day",1));
+ }
+ diagramSource.put(names[i],values);
+ }
+ break;
+ case "year":
+ for(int i = 0 ; i < 4 ; i++){
+ Date startDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(),-1,0,0,0,0,0));
+ Date endDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(),-1,0,0,0,0,0));
+ endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear,"month",1));
+ List<Integer> values = new ArrayList<>();
+ for (int j = 0 ; j < 12 ; j++){
+ values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateYear,endDateYear));
+ startDateYear = DateUtils.stringToDate(DateUtils.addDate(startDateYear,"month",1));
+ endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear,"month",1));
+ }
+ diagramSource.put(names[i],values);
+ }
+ break;
}
- Map<String, Object> map = new HashMap<>();
- map.put("performances", list);
- map.put("totalRecords", pa==null?0:pa.getTotalRecords());
omPerformance.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
- return omPerformance.writeValueAsString(map);
+ 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 String format) throws JsonProcessingException {
- List<List<Long>> list =null;
- list = diagramDate(sourceId, nameParent, startTime, endTime, format);
- return omPerformance.writeValueAsString(list);
- }
-
- @RequestMapping(value = {"/performance/resourceIds"}, method = RequestMethod.GET)
- public String getSourceIds() throws JsonProcessingException {
- List<String> sourceIds = new ArrayList<>();
- List list= performanceHeaderService.queryAllSourceId();
- PerformanceHeader performanceHeader;
- if(list.size()==0){
- performanceHeader = new PerformanceHeader();
- performanceHeader.setId(1);
- performanceHeader.setSourceId("aaaa");
- list.add(performanceHeader);
-
- }
- for(int a=0;a<list.size();a++){
-
- performanceHeader = (PerformanceHeader)list.get(a);
- String sourceid = performanceHeader.getSourceId();
- if (!sourceIds.contains(sourceid)) {
- sourceIds.add(sourceid);
- }
- }
-
- return omPerformance.writeValueAsString(sourceIds);
-
- }
-
- @RequestMapping(value = {"/performance/names"}, method = RequestMethod.POST)
- public String getNames(@RequestParam Object sourceId) {
+ 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 {
- List<String> names = new ArrayList<>();
- List<PerformanceInformation> list =performanceInformationService.queryDateBetween(sourceId.toString(), null, null, null);
- PerformanceInformation per;
- if(list.size()==0){
- PerformanceInformation perf= new PerformanceInformation();
- perf.setEventId("1101ZTHX1MMEGJM1W1");
- perf.setValue("0");
- perf.setName("DNS.AttDnsQuery");
- perf.setId(1);
- list.add(perf);
-
- }
- for(int a=0;a<list.size();a++) {
- per = (PerformanceInformation)list.get(a);
- if (null == per) {
- per.setName("MM.AttEpsAttach");
- per.setValue("0");
+ 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;
}
- if (!names.contains(per.getName()) && per.getValue().matches("[0-9]*"))
- if (Double.parseDouble(per.getValue()) > 0 && !per.getName().equals("Period"))
- names.add(per.getName());
-
+ performanceInformationService.queryDateBetween(sourceId,nameParent,startTime,endTime)
+ .forEach( per -> {
+ diagramSource.add(Integer.parseInt(per.getValue()));
+ });
}
- return omPerformance.writeValueAsString(names);
} catch (Exception e) {
- logger.error(e.getMessage());
+ e.printStackTrace();
+ }
+ try {
+ return omPerformance.writeValueAsString(diagramSource);
+ } catch (JsonProcessingException e) {
+ logger.error("JsonProcessingException:"+e.getMessage());
return "";
}
}
- private List<List<Long>> dateProcess(String sourceId, String name, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit) throws ParseException {
- List<List<Long>> dataList = new ArrayList<>();
- long tmpEndTimeL = startTimeL + timeIteraPlusVal;
- Date datea_a = new Date(startTimeL);
- Date dateb_a = new Date(tmpEndTimeL);
- String datea = sdf.format(datea_a);
- String dateb = sdf.format(dateb_a);
- while (endTimeL >= tmpEndTimeL) {
- List<Map<String, String>> maps = performanceInformationService.queryMaxValueByBetweenDate(sourceId, name, datea, dateb);
-
- maps.forEach(map -> {
- try {
- List<Long> longList = new ArrayList<>();
- if (map.get("Time") != null && !"".equals(map.get("Time")) && !"NULL".equals(map.get("Time"))) {
- longList.add(sdf.parse(map.get("Time")).getTime());
- if (map.get("Max") != null && !"".equals(map.get("Max")))
- longList.add(Long.parseLong(map.get("Max")));
- else
- longList.add(0L);
- }
- if (longList.size() > 0)
- dataList.add(longList);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- });
- startTimeL += timeIteraPlusVal;
- tmpEndTimeL += timeIteraPlusVal;
- keyVal += keyValIteraVal;
+ @RequestMapping(value = {"/performance/resourceIds"},method = RequestMethod.GET)
+ public String getSourceIds(){
+ try {
+ return omPerformance.writeValueAsString(performanceHeaderService.queryAllSourceId());
+ } catch (JsonProcessingException e) {
+ logger.error(e.getMessage());
+ return "";
}
- return dataList;
}
- private List<List<Long>> diagramDate(String sourceId, String name, String startTime, String endTime, String format) {
+ @RequestMapping(value = {"/performance/names"},method = RequestMethod.POST)
+ public String getNames(@RequestParam Object sourceId){
try {
- long startTimel = sdf.parse(startTime).getTime();
- long endTimel = sdf.parse(endTime).getTime();
- if (format != null && !format.equals("auto")) {
- switch (format) {
- case "minute":
- return dateProcess(sourceId, name, startTimel, endTimel, 900000, 15, 15, "minute");
- case "hour":
- return dateProcess(sourceId, name, startTimel, endTimel, 3600000, 1, 1, "hour");
- case "day":
- return dateProcess(sourceId, name, startTimel, endTimel, 86400000, 1, 1, "day");
- case "month":
- return dateProcess(sourceId, name, startTimel, endTimel, 2592000000L, 1, 1, "month");
- case "year":
- return dateProcess(sourceId, name, startTimel, endTimel, 31536000000L, 1, 1, "year");
- }
- } else if (format != null && format.equals("auto")) {
- long minutes = (endTimel - startTimel) / (1000 * 60);
- long hours = minutes / 60;
- if (hours > 12) {
- long days = hours / 24;
- if (days > 3) {
- long months = days / 31;
- if (months > 2) {
- return dateProcess(sourceId, name, startTimel, endTimel, 86400000, 1, 1, "day");
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 2592000000L, 1, 1, "month");
- }
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 3600000, 1, 1, "hour");
- }
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 900000, 15, 15, "minute");
- }
- }
- } catch (ParseException e) {
+ 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());
- e.printStackTrace();
+ return "";
}
- return null;
}
+
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/PerformancePmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/PerformancePmController.java
deleted file mode 100644
index 99eb1bc4..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/controller/PerformancePmController.java
+++ /dev/null
@@ -1,557 +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.
- */
-package org.onap.usecaseui.server.controller;
-
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.usecaseui.server.bean.PerformanceHeaderPm;
-import org.onap.usecaseui.server.bean.PerformanceInformationPm;
-import org.onap.usecaseui.server.bo.PerformanceBo;
-import org.onap.usecaseui.server.constant.Constant;
-import org.onap.usecaseui.server.service.*;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-
-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 javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-
-@RestController
-@Configuration
-@EnableAspectJAutoProxy
-public class PerformancePmController {
-
- @Resource(name = "PerformanceHeaderPmService")
- private PerformanceHeaderPmService performanceHeaderPmService;
-
- @Resource(name = "PerformanceInformationPmService")
- private PerformanceInformationPmService performanceInformationPmService;
-
-
-
- @Resource(name = "PerformanceHeaderService")
- private PerformanceHeaderService performanceHeaderService;
-
- @Resource(name = "PerformanceInformationService")
- private PerformanceInformationService performanceInformationService;
-
-
-
- @Resource(name = "PerformanceHeaderVmService")
- private PerformanceHeaderVmService performanceHeaderVmService;
-
- @Resource(name = "PerformanceInformationVmService")
- private PerformanceInformationVmService performanceInformationVmService;
-
-
- public void setPerformanceHeaderPmService(PerformanceHeaderPmService performanceHeaderPmService) {
- this.performanceHeaderPmService = performanceHeaderPmService;
- }
-
- public void setPerformanceInformationPmService(PerformanceInformationPmService performanceInformationPmService) {
- this.performanceInformationPmService = performanceInformationPmService;
- }
-
- public void setPerformanceHeaderVmService(PerformanceHeaderVmService performanceHeaderVmService) {
- this.performanceHeaderVmService = performanceHeaderVmService;
- }
-
- public void setPerformanceInformationVmService(PerformanceInformationVmService performanceInformationVmService) {
- this.performanceInformationVmService = performanceInformationVmService;
- }
-
- public void setPerformanceHeaderService(PerformanceHeaderService performanceHeaderService) {
- this.performanceHeaderService = performanceHeaderService;
- }
-
-
- public void setPerformanceInformationService(PerformanceInformationService performanceInformationService) {
- this.performanceInformationService = performanceInformationService;
- }
-
-
-
-
-
-
-
- private Logger logger = LoggerFactory.getLogger(PerformanceController.class);
-
- private final String[] PerformanceCSVHeaders = {"version",
- "eventName", "domain", "eventId", "eventType", "nfcNamingCode",
- "nfNamingCode", "sourceId", "sourceName", "reportingEntityId",
- "reportingEntityName", "priority", "startEpochMicrosec", "lastEpochMicroSec",
- "sequence", "measurementsForVfScalingVersion", "measurementInterval",
- "createTime", "updateTime", "value", "name"};
-
- private ObjectMapper omPerformance = new ObjectMapper();
-
- private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-
-
- @RequestMapping("/performance/getAllByDatetimePm/{eventId}/{startTime}/{endTime}")
- public String getAllByDatetime(@PathVariable(required = false) String eventId,@PathVariable(required = false) String startTime, @PathVariable(required = false) String endTime) throws ParseException, JsonProcessingException {
- String startime_s = "2017-10-29";
- String endtime_s = "2017-12-24";
- eventId = "2017-11-15T06:30:00MmeFunction1101ZTHX1MMEGJM1W1";
- //String startime_s = startTime;
- //String endtime_s = endTime;
- String string ="";
- if(startime_s!=null && endtime_s!=null && !"".equals(startime_s) && !"".equals(endtime_s) ) {
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- Date startime = formatter.parse(startime_s);
- Date endtime = formatter.parse(endtime_s);
- DateUtils dateUtils = new DateUtils();
- List<Date> datelist = dateUtils.getBetweenDates(startime, endtime);
- StringBuffer dateB = new StringBuffer();
- StringBuffer allB = new StringBuffer();
- //StringBuffer activeB = new StringBuffer();
- //StringBuffer closeB = new StringBuffer();
-
- for (Date dates : datelist) {
- String date_s = formatter.format(dates);
- dateB.append(date_s).append(",");
- //int aa = performanceHeaderService.getAllByDatetime("active", eventId, date_s);
- //activeB.append(aa + "").append(",");
- //int bb = performanceHeaderService.getAllByDatetime("close", eventId, date_s);
- //closeB.append(bb + "").append(",");
- int cc = performanceHeaderPmService.getAllByDatetime(eventId, date_s);
- allB.append(cc + "").append(",");
-
- }
- String dateBa = dateB.toString();
- String allBa = allB.toString();
- //String activeBa = activeB.toString();
- //String closeBa = closeB.toString();
-
- String[] dateArr = dateBa.substring(0, dateBa.length() - 1).split(",");
- //String[] activeArr = activeBa.substring(0, activeBa.length() - 1).split(",");
- //String[] closeArr = closeBa.substring(0, closeBa.length() - 1).split(",");
- String[] allArr = allBa.substring(0, allBa.length() - 1).split(",");
-
- Map map = new HashMap();
- map.put("dateArr", dateArr);
- //map.put("activeArr", activeArr);
- //map.put("closeArr", closeArr);
- map.put("allArr", allArr);
- string = omPerformance.writeValueAsString(map);
- }
-
- return string;
- }
-
-
- @RequestMapping("/performance/getPerformanceHeaderPmDetail/{id}")
- public String getPerformanceHeaderDetail(@PathVariable Integer id) throws JsonProcessingException {
- PerformanceHeaderPm performanceHeaderPm= performanceHeaderPmService.getPerformanceHeaderDetail(id);
- String eventId ="ab305d54-85b4-a31b-7db2-fb6b9e546015_s";
- if(null!=performanceHeaderPm){
- eventId = performanceHeaderPm.getSourceId();
- }
- //List<PerformanceInformation> list =getAllPerformanceInformationByeventId(eventId);
- List<PerformanceInformationPm> list =new ArrayList<>();
- if(!"ab305d54-85b4-a31b-7db2-fb6b9e546015_s".equals(eventId)){
- list = performanceInformationPmService.getAllPerformanceInformationByeventId(eventId);
- }else{
- PerformanceInformationPm performanceInformation_s = new PerformanceInformationPm();
- performanceInformation_s.setId(4);
- }
-
- Map map = new HashMap();
- map.put("performanceHeaderPm",performanceHeaderPm);
- map.put("list",list);
-
- String string =omPerformance.writeValueAsString(map);
- return string;
- }
-
-
-
-
-
-
-
-
- @RequestMapping(value = {"/performance/getPerformanceDataByPm/{eventName}/{sourceName}/{reportingEntityName}/{createTime}/{endTime}"},method =RequestMethod.GET,produces = "application/json")
- public String getPerformanceDataByPm( @PathVariable(required = false) String eventName,@PathVariable(required = false) String sourceName,@PathVariable(required = false) String reportingEntityName,@PathVariable(required = false) String createTime,@PathVariable(required = false) String endTime) throws JsonProcessingException {
- Map map = new HashMap();
- Date createTime_s=null;
- Date endTime_s=null;
-
- /* Date currentTime = new Date();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String dateString = formatter.format(currentTime);*/
-
-
- eventName="Mfvs_MMEEthernetPort";
- sourceName="1101ZTHX1EPO1NK7E0Z2";
- reportingEntityName="ZTE-CMBJ-BJ,SubNetwork=100001,ManagedElement=100040_40,EthernetPort=40_65535_1_2";
- createTime="2017-11-15 06:30:00";
- endTime="2017-12-15 06:30:00";
-
- try {
- createTime_s =(!"null".equals(createTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(createTime) : null);
- endTime_s =(!"null".equals(endTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime) : null);
- } catch (ParseException e) {
- logger.error("Parse date error :" + e.getMessage());
- }
- /* int countPm = performanceHeaderPmService.getAllCountByEventType();
- int countVm = performanceHeaderVmService.getAllCountByEventType();
- int countBn = performanceHeaderService.getAllCountByEventType();*/
-
- Set<String> eventNameList = new HashSet();
- Set<String> sourceNameList = new HashSet<>();
- Set<String> reportingEntityNameList = new HashSet<>();
- Set<String> sourceIdList = new HashSet<>();
- List<PerformanceHeaderPm> list = performanceHeaderPmService.getAllByEventType(eventName,sourceName,reportingEntityName,createTime_s,endTime_s);
- PerformanceHeaderPm performanceHeaderPm;
- for(int a=0;a<list.size();a++){
- performanceHeaderPm = list.get(a);
- eventNameList.add(performanceHeaderPm.getEventName());
- sourceNameList.add(performanceHeaderPm.getSourceName());
- reportingEntityNameList.add(performanceHeaderPm.getReportingEntityName());
-
- sourceIdList.add(performanceHeaderPm.getSourceId());
-
- }
-
- /*map.put("countPm",countPm);
- map.put("countVm",countVm);
- map.put("countBn",countBn);*/
- //map.put("list",list);
- map.put("eventNameList",eventNameList);
- map.put("sourceNameList",sourceNameList);
- map.put("reportingEntityNameList",reportingEntityNameList);
-
- map.put("sourceIdList",sourceIdList);
-
-
- String string =omPerformance.writeValueAsString(map);
-
- return string;
- }
-
- @RequestMapping(value = {"/performance/getPerformanceListByPm/{eventName}/{sourceName}/{reportingEntityName}/{createTime}/{endTime}"},method =RequestMethod.GET,produces = "application/json")
- public String getPerformanceListByPm( @PathVariable(required = false) String eventName,@PathVariable(required = false) String sourceName,@PathVariable(required = false) String reportingEntityName,@PathVariable(required = false) String createTime,@PathVariable(required = false) String endTime) throws JsonProcessingException {
- Map map = new HashMap();
- Date createTime_s=null;
- Date endTime_s=null;
-
- /* Date currentTime = new Date();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String dateString = formatter.format(currentTime);*/
-
-
- eventName="Mfvs_MMEEthernetPort";
- sourceName="1101ZTHX1EPO1NK7E0Z2";
- reportingEntityName="ZTE-CMBJ-BJ,SubNetwork=100001,ManagedElement=100040_40,EthernetPort=40_65535_1_2";
- createTime="2017-11-15 06:30:00";
- endTime="2017-12-15 06:30:00";
-
-
-
- try {
- createTime_s =(!"null".equals(createTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(createTime) : null);
- endTime_s =(!"null".equals(endTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime) : null);
- } catch (ParseException e) {
- logger.error("Parse date error :" + e.getMessage());
- }
- //int countClose = performanceHeaderService.getAllCountByStatus("close");
- //int countActive = performanceHeaderService.getAllCountByStatus("active");
- //int countAll =countActive + countClose;
- //Set<String> eventNameList = new HashSet();
- //Set<String> sourceNameList = new HashSet<>();
- //Set<String> reportingEntityNameList = new HashSet<>();
-
- //Set<String> sourceIdList = new HashSet<>();
-
-
- List<PerformanceHeaderPm> list = performanceHeaderPmService.getAllByEventType(eventName,sourceName,reportingEntityName,createTime_s,endTime_s);
- /* PerformanceHeader performanceHeader;
- for(int a=0;a<list.size();a++){
- performanceHeader = list.get(a);
- eventNameList.add(performanceHeader.getEventName());
- sourceNameList.add(performanceHeader.getSourceName());
- reportingEntityNameList.add(performanceHeader.getReportingEntityName());
-
- sourceIdList.add(performanceHeader.getSourceId());
-
- }*/
-
- map.put("list",list);
-
- String string =omPerformance.writeValueAsString(map);
-
- return string;
- }
-
-
-
-
-
-
-
-
- @RequestMapping(value = {"/performancePm/{currentPage}/{pageSize}", "/performancePm/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}"}, method = RequestMethod.GET, produces = "application/json")
- public String getPerformancePmData(HttpServletResponse response, @PathVariable int currentPage,
- @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 : {} , sourceId : {} , " +
- "sourceName : {} , priority : {} , startTime :{} , endTime : {} ]"
- , currentPage, pageSize, sourceId, sourceName, priority, startTime, endTime);
- List<Object> list = new ArrayList<>();
- Page pa = null;
- if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime) {
- PerformanceHeaderPm performanceHeaderPm = new PerformanceHeaderPm();
- performanceHeaderPm.setSourceId(!"null".equals(sourceId) ? sourceId : null);
- performanceHeaderPm.setSourceName(!"null".equals(sourceName) ? sourceName : null);
- try {
- performanceHeaderPm.setCreateTime(!"null".equals(startTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(startTime) : null);
- performanceHeaderPm.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[" + startTime + "]:" + e.getMessage());
- return "{'result':'error'}";
- }
- pa = performanceHeaderPmService.queryPerformanceHeaderPm(performanceHeaderPm, currentPage, pageSize);
- List<PerformanceHeaderPm> performanceHeaderPms = pa.getList();
- performanceHeaderPms.forEach(per -> {
- PerformanceBo pbo = new PerformanceBo();
- PerformanceInformationPm pe = new PerformanceInformationPm();
- pe.setEventId(per.getSourceId());
- List<PerformanceInformationPm> performanceInformationPms = performanceInformationPmService.queryPerformanceInformationPm(pe, 1, 100).getList();
- pbo.setPerformanceHeaderPm(per);
- performanceInformationPms.forEach(pi -> {
- if (pi.getValue().equals("")) {
- StringBuffer value1 = new StringBuffer();
- performanceInformationPmService.queryPerformanceInformationPm(new PerformanceInformationPm(pi.getName()), 1, 100).getList()
- .forEach(val -> value1.append(val.getValue()));
- pi.setValue(value1.toString());
- }
- });
- pbo.setPerformanceInformationPm(performanceInformationPms);
- list.add(pbo);
- });
- } else {
- pa = performanceHeaderPmService.queryPerformanceHeaderPm(null, currentPage, pageSize);
- List<PerformanceHeaderPm> p = pa != null ? pa.getList() : null;
- if (null != p && p.size() > 0)
- p.forEach(per -> {
- PerformanceBo pbo = new PerformanceBo();
- pbo.setPerformanceHeaderPm(per);
- pbo.setPerformanceInformationPm(performanceInformationPmService.queryPerformanceInformationPm(new PerformanceInformationPm(per.getEventId()), 1, 100).getList());
- list.add(pbo);
- });
- }
- Map<String, Object> map = new HashMap<>();
- map.put("performances", list);
- map.put("totalRecords", pa.getTotalRecords());
- omPerformance.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
- return omPerformance.writeValueAsString(map);
- }
-
- /*@RequestMapping(value = {"/performance/genCsv/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
- public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId) throws JsonProcessingException {
- String csvFile = "csvFiles/vnf_performance_" + new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date()) + ".csv";
- List<PerformanceHeaderPm> performanceHeaderPms = performanceHeaderPmService.queryId(eventId);
- if (null == performanceHeaderPms || performanceHeaderPms.size() <= 0)
- return new ObjectMapper().writeValueAsString("selected eventId don't exist");
- List<String[]> csvData = new ArrayList<>();
- performanceHeaderPms.forEach(s -> {
- List<PerformanceInformationPm> information = performanceInformationPmService.queryPerformanceInformationPm(new PerformanceInformationPm(s.getEventId()), 1, 100).getList();
- String names = "";
- String values = "";
- if (0 < information.size() && null != information) {
- for (PerformanceInformationPm a : information) {
- names += a.getName() + ",";
- values += a.getValue() + ",";
- }
- names = names.substring(0, names.lastIndexOf(','));
- values = values.substring(0, values.lastIndexOf(','));
- }
- csvData.add(new String[]{
- s.getVersion(), s.getEventName(), s.getDomain(), s.getEventId(), s.getEventType(), s.getNfcNamingCode(), s.getNfNamingCode(),
- s.getSourceId(), s.getSourceName(), s.getReportingEntityId(), s.getReportingEntityName(), s.getPriority(),
- s.getStartEpochMicrosec(), s.getLastEpochMicroSec(), s.getSequence(), s.getMeasurementsForVfScalingVersion(),
- s.getMeasurementInterval(), DateUtils.dateToString(s.getCreateTime()), DateUtils.dateToString(s.getUpdateTime()),
- names, values
- });
- });
- CSVUtils.writeCsv(PerformanceCSVHeaders, csvData, csvFile);
- if (ResponseUtil.responseDownload(csvFile, response)) {
- return omPerformance.writeValueAsString("success");
- } else {
- return omPerformance.writeValueAsString("failed");
- }
- }*/
-
- /*@RequestMapping(value = {"/performance/genDiaCsv/{dataJson}"}, method = RequestMethod.GET, produces = "application/json")
- public String generateDiaCsvFile(HttpServletResponse response, @PathVariable String dataJson) throws IOException {
- List<Map<String, Object>> dataList = omPerformance.readValue(dataJson, List.class);
- String csvFileName = "csvFiles/" + dataList.get(0).get("name") + "_" + new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date()) + ".csv";
- try {
- String[] headers = new String[]{"eventId", "name", "dateUnit", "value"};
- List<String[]> csvDatas = new ArrayList<>();
- if (null != dataList) {
- dataList.forEach((l) -> {
- StringBuffer fileData = new StringBuffer();
- l.forEach((k, v) -> {
- logger.info(v.toString());
- fileData.append(v.toString() + ",");
- });
- csvDatas.add(fileData.toString().split(","));
- });
- }
- CSVUtils.writeCsv(headers, csvDatas, csvFileName);
- } catch (Exception pe) {
- logger.error(pe.getMessage());
- }
- if (ResponseUtil.responseDownload(csvFileName, response)) {
- return omPerformance.writeValueAsString("success");
- } else {
- return omPerformance.writeValueAsString("failed");
- }
- }*/
-
- @RequestMapping(value = {"/performancePm/diagram"}, method = RequestMethod.POST, produces = "application/json")
- public String generateDiagramPm(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String nameParent, @RequestParam String format) {
- try {
- return omPerformance.writeValueAsString(diagramDate(sourceId, nameParent, startTime, endTime, format));
- } catch (Exception e) {
- logger.error(e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- @RequestMapping(value = {"/performancePm/resourceIds"}, method = RequestMethod.GET)
- public String getSourceIdsPm() {
- List<String> sourceIds = new ArrayList<>();
- try {
- performanceHeaderPmService.queryAllSourceId().forEach(ph -> {
- if (!sourceIds.contains(ph))
- sourceIds.add(ph);
- });
- return omPerformance.writeValueAsString(sourceIds);
- } catch (Exception e) {
- logger.error(e.getMessage());
- return null;
- }
- }
-
- @RequestMapping(value = {"/performancePm/names"}, method = RequestMethod.POST)
- public String getNamesPm(@RequestParam Object sourceId) {
- try {
- List<String> names = new ArrayList<>();
- performanceInformationPmService.queryDateBetween(sourceId.toString(), null, null, null).forEach(per -> {
- if (!names.contains(per.getName()) && per.getValue().matches("[0-9]*"))
- if (Double.parseDouble(per.getValue()) > 0 && !per.getName().equals("Period"))
- names.add(per.getName());
-
- });
- return omPerformance.writeValueAsString(names);
- } catch (Exception e) {
- logger.error(e.getMessage());
- return "";
- }
- }
-
- private List<List<Long>> dateProcess(String sourceId, String name, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit) throws ParseException {
- List<List<Long>> dataList = new ArrayList<>();
- long tmpEndTimeL = startTimeL + timeIteraPlusVal;
- while (endTimeL >= tmpEndTimeL) {
- List<Map<String, String>> maps = performanceInformationPmService.queryMaxValueByBetweenDate(sourceId, name, sdf.format(new Date(startTimeL)), sdf.format(new Date(tmpEndTimeL)));
- maps.forEach(map -> {
- try {
- List<Long> longList = new ArrayList<>();
- if (map.get("Time") != null && !"".equals(map.get("Time")) && !"NULL".equals(map.get("Time"))) {
- longList.add(sdf.parse(map.get("Time")).getTime());
- if (map.get("Max") != null && !"".equals(map.get("Max")))
- longList.add(Long.parseLong(map.get("Max")));
- else
- longList.add(0L);
- }
- if (longList.size() > 0)
- dataList.add(longList);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- });
- startTimeL += timeIteraPlusVal;
- tmpEndTimeL += timeIteraPlusVal;
- keyVal += keyValIteraVal;
- }
- return dataList;
- }
-
- private List<List<Long>> diagramDate(String sourceId, String name, String startTime, String endTime, String format) {
- try {
- long startTimel = sdf.parse(startTime).getTime();
- long endTimel = sdf.parse(endTime).getTime();
- if (format != null && !format.equals("auto")) {
- switch (format) {
- case "minute":
- return dateProcess(sourceId, name, startTimel, endTimel, 900000, 15, 15, "minute");
- case "hour":
- return dateProcess(sourceId, name, startTimel, endTimel, 3600000, 1, 1, "hour");
- case "day":
- return dateProcess(sourceId, name, startTimel, endTimel, 86400000, 1, 1, "day");
- case "month":
- return dateProcess(sourceId, name, startTimel, endTimel, 2592000000L, 1, 1, "month");
- case "year":
- return dateProcess(sourceId, name, startTimel, endTimel, 31536000000L, 1, 1, "year");
- }
- } else if (format != null && format.equals("auto")) {
- long minutes = (endTimel - startTimel) / (1000 * 60);
- long hours = minutes / 60;
- if (hours > 12) {
- long days = hours / 24;
- if (days > 3) {
- long months = days / 31;
- if (months > 2) {
- return dateProcess(sourceId, name, startTimel, endTimel, 86400000, 1, 1, "day");
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 2592000000L, 1, 1, "month");
- }
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 3600000, 1, 1, "hour");
- }
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 900000, 15, 15, "minute");
- }
- }
- } catch (ParseException e) {
- logger.error(e.getMessage());
- e.printStackTrace();
- }
- return null;
- }
-
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceVmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceVmController.java
deleted file mode 100644
index 8cd0a519..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceVmController.java
+++ /dev/null
@@ -1,569 +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.
- */
-package org.onap.usecaseui.server.controller;
-
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.usecaseui.server.bean.PerformanceHeaderVm;
-import org.onap.usecaseui.server.bean.PerformanceInformationVm;
-import org.onap.usecaseui.server.bo.PerformanceBo;
-import org.onap.usecaseui.server.constant.Constant;
-import org.onap.usecaseui.server.service.*;
-import org.onap.usecaseui.server.util.CSVUtils;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-import org.onap.usecaseui.server.util.ResponseUtil;
-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 javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-
-@RestController
-@Configuration
-@EnableAspectJAutoProxy
-public class PerformanceVmController {
-
- @Resource(name = "PerformanceHeaderVmService")
- private PerformanceHeaderVmService performanceHeaderVmService;
-
- @Resource(name = "PerformanceInformationVmService")
- private PerformanceInformationVmService performanceInformationVmService;
-
-
-
- @Resource(name = "PerformanceHeaderService")
- private PerformanceHeaderService performanceHeaderService;
-
- @Resource(name = "PerformanceInformationService")
- private PerformanceInformationService performanceInformationService;
-
-
- @Resource(name = "PerformanceHeaderPmService")
- private PerformanceHeaderPmService performanceHeaderPmService;
-
- @Resource(name = "PerformanceInformationPmService")
- private PerformanceInformationPmService performanceInformationPmService;
-
-
-
- public void setPerformanceHeaderPmService(PerformanceHeaderPmService performanceHeaderPmService) {
- this.performanceHeaderPmService = performanceHeaderPmService;
- }
-
- public void setPerformanceInformationPmService(PerformanceInformationPmService performanceInformationPmService) {
- this.performanceInformationPmService = performanceInformationPmService;
- }
-
- public void setPerformanceHeaderVmService(PerformanceHeaderVmService performanceHeaderVmService) {
- this.performanceHeaderVmService = performanceHeaderVmService;
- }
-
- public void setPerformanceInformationVmService(PerformanceInformationVmService performanceInformationVmService) {
- this.performanceInformationVmService = performanceInformationVmService;
- }
-
- public void setPerformanceHeaderService(PerformanceHeaderService performanceHeaderService) {
- this.performanceHeaderService = performanceHeaderService;
- }
-
-
- public void setPerformanceInformationService(PerformanceInformationService performanceInformationService) {
- this.performanceInformationService = performanceInformationService;
- }
-
-
-
-
-
-
-
-
-
-
- private Logger logger = LoggerFactory.getLogger(PerformanceController.class);
-
- private final String[] PerformanceCSVHeaders = {"version",
- "eventName", "domain", "eventId", "eventType", "nfcNamingCode",
- "nfNamingCode", "sourceId", "sourceName", "reportingEntityId",
- "reportingEntityName", "priority", "startEpochMicrosec", "lastEpochMicroSec",
- "sequence", "measurementsForVfScalingVersion", "measurementInterval",
- "createTime", "updateTime", "value", "name"};
-
- private ObjectMapper omPerformance = new ObjectMapper();
-
- private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-
-
-
- @RequestMapping("/performance/getAllByDatetimeVm/{eventId}/{startTime}/{endTime}")
- public String getAllByDatetime(@PathVariable(required = false) String eventId,@PathVariable(required = false) String startTime, @PathVariable(required = false) String endTime) throws ParseException, JsonProcessingException {
- String startime_s = "2017-10-29";
- String endtime_s = "2017-12-24";
- eventId = "2017-11-15T06:30:00MmeFunction1101ZTHX1MMEGJM1W1";
- //String startime_s = startTime;
- //String endtime_s = endTime;
- String string ="";
- if(startime_s!=null && endtime_s!=null && !"".equals(startime_s) && !"".equals(endtime_s) ) {
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- Date startime = formatter.parse(startime_s);
- Date endtime = formatter.parse(endtime_s);
- DateUtils dateUtils = new DateUtils();
- List<Date> datelist = dateUtils.getBetweenDates(startime, endtime);
- StringBuffer dateB = new StringBuffer();
- StringBuffer allB = new StringBuffer();
- //StringBuffer activeB = new StringBuffer();
- //StringBuffer closeB = new StringBuffer();
-
- for (Date dates : datelist) {
- String date_s = formatter.format(dates);
- dateB.append(date_s).append(",");
- //int aa = performanceHeaderService.getAllByDatetime("active", eventId, date_s);
- // activeB.append(aa + "").append(",");
- // int bb = performanceHeaderService.getAllByDatetime("close", eventId, date_s);
- // closeB.append(bb + "").append(",");
- int cc = performanceHeaderVmService.getAllByDatetime( eventId, date_s);
- allB.append(cc + "").append(",");
-
- }
- String dateBa = dateB.toString();
- String allBa = allB.toString();
- //String activeBa = activeB.toString();
- //String closeBa = closeB.toString();
-
- String[] dateArr = dateBa.substring(0, dateBa.length() - 1).split(",");
- //String[] activeArr = activeBa.substring(0, activeBa.length() - 1).split(",");
- //String[] closeArr = closeBa.substring(0, closeBa.length() - 1).split(",");
- String[] allArr = allBa.substring(0, allBa.length() - 1).split(",");
-
- Map map = new HashMap();
- map.put("dateArr", dateArr);
- //map.put("activeArr", activeArr);
- // map.put("closeArr", closeArr);
- map.put("allArr", allArr);
- string = omPerformance.writeValueAsString(map);
- }
-
- return string;
- }
-
-
- @RequestMapping("/performance/getPerformanceHeaderVmDetail/{id}")
- public String getPerformanceHeaderDetail(@PathVariable Integer id) throws JsonProcessingException {
- PerformanceHeaderVm performanceHeaderVm= performanceHeaderVmService.getPerformanceHeaderDetail(id);
- String eventId ="ab305d54-85b4-a31b-7db2-fb6b9e546015_s";
- if(null!=performanceHeaderVm){
- eventId = performanceHeaderVm.getSourceId();
- }
- //List<PerformanceInformation> list =getAllPerformanceInformationByeventId(eventId);
- List<PerformanceInformationVm> list =new ArrayList<>();
- if(!"ab305d54-85b4-a31b-7db2-fb6b9e546015_s".equals(eventId)){
- list = performanceInformationVmService.getAllPerformanceInformationByeventId(eventId);
- }else{
- PerformanceInformationVm performanceInformation_sVm = new PerformanceInformationVm();
- performanceInformation_sVm.setId(4);
- }
-
- Map map = new HashMap();
- map.put("performanceHeaderVm",performanceHeaderVm);
- map.put("list",list);
-
- String string =omPerformance.writeValueAsString(map);
- return string;
- }
-
-
-
-
-
-
- @RequestMapping(value = {"/performance/getPerformanceDataByVm/{eventName}/{sourceName}/{reportingEntityName}/{createTime}/{endTime}"},method =RequestMethod.GET,produces = "application/json")
- public String getPerformanceDataByVm( @PathVariable(required = false) String eventName,@PathVariable(required = false) String sourceName,@PathVariable(required = false) String reportingEntityName,@PathVariable(required = false) String createTime,@PathVariable(required = false) String endTime) throws JsonProcessingException {
- Map map = new HashMap();
- Date createTime_s=null;
- Date endTime_s=null;
-
- /* Date currentTime = new Date();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String dateString = formatter.format(currentTime);*/
-
-
- eventName="Mfvs_MMEEthernetPort";
- sourceName="1101ZTHX1EPO1NK7E0Z2";
- reportingEntityName="ZTE-CMBJ-BJ,SubNetwork=100001,ManagedElement=100040_40,EthernetPort=40_65535_1_2";
- createTime="2017-11-15 06:30:00";
- endTime="2017-12-15 06:30:00";
-
- try {
- createTime_s =(!"null".equals(createTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(createTime) : null);
- endTime_s =(!"null".equals(endTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime) : null);
- } catch (ParseException e) {
- logger.error("Parse date error :" + e.getMessage());
- }
- /*int countPm = performanceHeaderPmService.getAllCountByEventType();
- int countVm = performanceHeaderVmService.getAllCountByEventType();
- int countBn = performanceHeaderService.getAllCountByEventType();*/
- //int countAll =countActive + countClose;
- Set<String> eventNameList = new HashSet();
- Set<String> sourceNameList = new HashSet<>();
- Set<String> reportingEntityNameList = new HashSet<>();
- Set<String> sourceIdList = new HashSet<>();
- List<PerformanceHeaderVm> list = performanceHeaderVmService.getAllByEventType(eventName,sourceName,reportingEntityName,createTime_s,endTime_s);
- PerformanceHeaderVm performanceHeaderVm;
- for(int a=0;a<list.size();a++){
- performanceHeaderVm = list.get(a);
- eventNameList.add(performanceHeaderVm.getEventName());
- sourceNameList.add(performanceHeaderVm.getSourceName());
- reportingEntityNameList.add(performanceHeaderVm.getReportingEntityName());
-
- sourceIdList.add(performanceHeaderVm.getSourceId());
-
- }
-
- /*map.put("countPm",countPm);
- map.put("countVm",countVm);
- map.put("countBn",countBn);*/
- //map.put("list",list);
- map.put("eventNameList",eventNameList);
- map.put("sourceNameList",sourceNameList);
- map.put("reportingEntityNameList",reportingEntityNameList);
-
- map.put("sourceIdList",sourceIdList);
-
-
- String string =omPerformance.writeValueAsString(map);
-
- return string;
- }
-
- @RequestMapping(value = {"/performance/getPerformanceListByVm/{eventName}/{sourceName}/{reportingEntityName}/{createTime}/{endTime}"},method =RequestMethod.GET,produces = "application/json")
- public String getPerformanceListByVm( @PathVariable(required = false) String eventName,@PathVariable(required = false) String sourceName,@PathVariable(required = false) String reportingEntityName,@PathVariable(required = false) String createTime,@PathVariable(required = false) String endTime) throws JsonProcessingException {
- Map map = new HashMap();
- Date createTime_s=null;
- Date endTime_s=null;
-
- /* Date currentTime = new Date();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String dateString = formatter.format(currentTime);*/
-
-
- eventName="Mfvs_MMEEthernetPort";
- sourceName="1101ZTHX1EPO1NK7E0Z2";
- reportingEntityName="ZTE-CMBJ-BJ,SubNetwork=100001,ManagedElement=100040_40,EthernetPort=40_65535_1_2";
- createTime="2017-11-15 06:30:00";
- endTime="2017-12-15 06:30:00";
-
-
-
- try {
- createTime_s =(!"null".equals(createTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(createTime) : null);
- endTime_s =(!"null".equals(endTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime) : null);
- } catch (ParseException e) {
- logger.error("Parse date error :" + e.getMessage());
- }
- //int countClose = performanceHeaderService.getAllCountByStatus("close");
- //int countActive = performanceHeaderService.getAllCountByStatus("active");
- //int countAll =countActive + countClose;
- // Set<String> eventNameList = new HashSet();
- // Set<String> sourceNameList = new HashSet<>();
- //Set<String> reportingEntityNameList = new HashSet<>();
-
- //Set<String> sourceIdList = new HashSet<>();
-
-
- List<PerformanceHeaderVm> list = performanceHeaderVmService.getAllByEventType(eventName,sourceName,reportingEntityName,createTime_s,endTime_s);
- /* PerformanceHeader performanceHeader;
- for(int a=0;a<list.size();a++){
- performanceHeader = list.get(a);
- eventNameList.add(performanceHeader.getEventName());
- sourceNameList.add(performanceHeader.getSourceName());
- reportingEntityNameList.add(performanceHeader.getReportingEntityName());
-
- sourceIdList.add(performanceHeader.getSourceId());
-
- }*/
-
- map.put("list",list);
-
- String string =omPerformance.writeValueAsString(map);
-
- return string;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @RequestMapping(value = {"/performanceVm/{currentPage}/{pageSize}", "/performanceVm/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}"}, method = RequestMethod.GET, produces = "application/json")
- public String getPerformanceVmData(HttpServletResponse response, @PathVariable int currentPage,
- @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 : {} , sourceId : {} , " +
- "sourceName : {} , priority : {} , startTime :{} , endTime : {} ]"
- , currentPage, pageSize, sourceId, sourceName, priority, startTime, endTime);
- List<Object> list = new ArrayList<>();
- Page pa = null;
- if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime) {
- PerformanceHeaderVm performanceHeaderVm = new PerformanceHeaderVm();
- performanceHeaderVm.setSourceId(!"null".equals(sourceId) ? sourceId : null);
- performanceHeaderVm.setSourceName(!"null".equals(sourceName) ? sourceName : null);
- try {
- performanceHeaderVm.setCreateTime(!"null".equals(startTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(startTime) : null);
- performanceHeaderVm.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[" + startTime + "]:" + e.getMessage());
- return "{'result':'error'}";
- }
- pa = performanceHeaderVmService.queryPerformanceHeaderVm(performanceHeaderVm, currentPage, pageSize);
- List<PerformanceHeaderVm> performanceHeaderVms = pa.getList();
- performanceHeaderVms.forEach(per -> {
- PerformanceBo pbo = new PerformanceBo();
- PerformanceInformationVm pe = new PerformanceInformationVm();
- pe.setEventId(per.getSourceId());
- List<PerformanceInformationVm> performanceInformationVms = performanceInformationVmService.queryPerformanceInformationVm(pe, 1, 100).getList();
- pbo.setPerformanceHeaderVm(per);
- performanceInformationVms.forEach(pi -> {
- if (pi.getValue().equals("")) {
- StringBuffer value1 = new StringBuffer();
- performanceInformationVmService.queryPerformanceInformationVm(new PerformanceInformationVm(pi.getName()), 1, 100).getList()
- .forEach(val -> value1.append(val.getValue()));
- pi.setValue(value1.toString());
- }
- });
- pbo.setPerformanceInformationVm(performanceInformationVms);
- list.add(pbo);
- });
- } else {
- pa = performanceHeaderVmService.queryPerformanceHeaderVm(null, currentPage, pageSize);
- List<PerformanceHeaderVm> p = pa != null ? pa.getList() : null;
- if (null != p && p.size() > 0)
- p.forEach(per -> {
- PerformanceBo pbo = new PerformanceBo();
- pbo.setPerformanceHeaderVm(per);
- pbo.setPerformanceInformationVm(performanceInformationVmService.queryPerformanceInformationVm(new PerformanceInformationVm(per.getEventId()), 1, 100).getList());
- list.add(pbo);
- });
- }
- Map<String, Object> map = new HashMap<>();
- map.put("performances", list);
- map.put("totalRecords", pa.getTotalRecords());
- omPerformance.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
- return omPerformance.writeValueAsString(map);
- }
-
- /*@RequestMapping(value = {"/performance/genCsv/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
- public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId) throws JsonProcessingException {
- String csvFile = "csvFiles/vnf_performance_" + new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date()) + ".csv";
- List<PerformanceHeaderVm> performanceHeaderVms = performanceHeaderVmService.queryId(eventId);
- if (null == performanceHeaderVms || performanceHeaderVms.size() <= 0)
- return new ObjectMapper().writeValueAsString("selected eventId don't exist");
- List<String[]> csvData = new ArrayList<>();
- performanceHeaderVms.forEach(s -> {
- List<PerformanceInformationVm> information = performanceInformationVmService.queryPerformanceInformationVm(new PerformanceInformationVm(s.getEventId()), 1, 100).getList();
- String names = "";
- String values = "";
- if (0 < information.size() && null != information) {
- for (PerformanceInformationVm a : information) {
- names += a.getName() + ",";
- values += a.getValue() + ",";
- }
- names = names.substring(0, names.lastIndexOf(','));
- values = values.substring(0, values.lastIndexOf(','));
- }
- csvData.add(new String[]{
- s.getVersion(), s.getEventName(), s.getDomain(), s.getEventId(), s.getEventType(), s.getNfcNamingCode(), s.getNfNamingCode(),
- s.getSourceId(), s.getSourceName(), s.getReportingEntityId(), s.getReportingEntityName(), s.getPriority(),
- s.getStartEpochMicrosec(), s.getLastEpochMicroSec(), s.getSequence(), s.getMeasurementsForVfScalingVersion(),
- s.getMeasurementInterval(), DateUtils.dateToString(s.getCreateTime()), DateUtils.dateToString(s.getUpdateTime()),
- names, values
- });
- });
- CSVUtils.writeCsv(PerformanceCSVHeaders, csvData, csvFile);
- if (ResponseUtil.responseDownload(csvFile, response)) {
- return omPerformance.writeValueAsString("success");
- } else {
- return omPerformance.writeValueAsString("failed");
- }
- }*/
-
- /*@RequestMapping(value = {"/performance/genDiaCsv/{dataJson}"}, method = RequestMethod.GET, produces = "application/json")
- public String generateDiaCsvFile(HttpServletResponse response, @PathVariable String dataJson) throws IOException {
- List<Map<String, Object>> dataList = omPerformance.readValue(dataJson, List.class);
- String csvFileName = "csvFiles/" + dataList.get(0).get("name") + "_" + new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date()) + ".csv";
- try {
- String[] headers = new String[]{"eventId", "name", "dateUnit", "value"};
- List<String[]> csvDatas = new ArrayList<>();
- if (null != dataList) {
- dataList.forEach((l) -> {
- StringBuffer fileData = new StringBuffer();
- l.forEach((k, v) -> {
- logger.info(v.toString());
- fileData.append(v.toString() + ",");
- });
- csvDatas.add(fileData.toString().split(","));
- });
- }
- CSVUtils.writeCsv(headers, csvDatas, csvFileName);
- } catch (Exception pe) {
- logger.error(pe.getMessage());
- }
- if (ResponseUtil.responseDownload(csvFileName, response)) {
- return omPerformance.writeValueAsString("success");
- } else {
- return omPerformance.writeValueAsString("failed");
- }
- }*/
-
- @RequestMapping(value = {"/performanceVm/diagram"}, method = RequestMethod.POST, produces = "application/json")
- public String generateDiagramVm(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String nameParent, @RequestParam String format) {
- try {
- return omPerformance.writeValueAsString(diagramDate(sourceId, nameParent, startTime, endTime, format));
- } catch (Exception e) {
- logger.error(e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- @RequestMapping(value = {"/performanceVm/resourceIds"}, method = RequestMethod.GET)
- public String getSourceIdsVm() {
- List<String> sourceIds = new ArrayList<>();
- try {
- performanceHeaderVmService.queryAllSourceId().forEach(ph -> {
- if (!sourceIds.contains(ph))
- sourceIds.add(ph);
- });
- return omPerformance.writeValueAsString(sourceIds);
- } catch (Exception e) {
- logger.error(e.getMessage());
- return null;
- }
- }
-
- @RequestMapping(value = {"/performanceVm/names"}, method = RequestMethod.POST)
- public String getNamesVm(@RequestParam Object sourceId) {
- try {
- List<String> names = new ArrayList<>();
- performanceInformationVmService.queryDateBetween(sourceId.toString(), null, null, null).forEach(per -> {
- if (!names.contains(per.getName()) && per.getValue().matches("[0-9]*"))
- if (Double.parseDouble(per.getValue()) > 0 && !per.getName().equals("Period"))
- names.add(per.getName());
-
- });
- return omPerformance.writeValueAsString(names);
- } catch (Exception e) {
- logger.error(e.getMessage());
- return "";
- }
- }
-
- private List<List<Long>> dateProcess(String sourceId, String name, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit) throws ParseException {
- List<List<Long>> dataList = new ArrayList<>();
- long tmpEndTimeL = startTimeL + timeIteraPlusVal;
- while (endTimeL >= tmpEndTimeL) {
- List<Map<String, String>> maps = performanceInformationVmService.queryMaxValueByBetweenDate(sourceId, name, sdf.format(new Date(startTimeL)), sdf.format(new Date(tmpEndTimeL)));
- maps.forEach(map -> {
- try {
- List<Long> longList = new ArrayList<>();
- if (map.get("Time") != null && !"".equals(map.get("Time")) && !"NULL".equals(map.get("Time"))) {
- longList.add(sdf.parse(map.get("Time")).getTime());
- if (map.get("Max") != null && !"".equals(map.get("Max")))
- longList.add(Long.parseLong(map.get("Max")));
- else
- longList.add(0L);
- }
- if (longList.size() > 0)
- dataList.add(longList);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- });
- startTimeL += timeIteraPlusVal;
- tmpEndTimeL += timeIteraPlusVal;
- keyVal += keyValIteraVal;
- }
- return dataList;
- }
-
- private List<List<Long>> diagramDate(String sourceId, String name, String startTime, String endTime, String format) {
- try {
- long startTimel = sdf.parse(startTime).getTime();
- long endTimel = sdf.parse(endTime).getTime();
- if (format != null && !format.equals("auto")) {
- switch (format) {
- case "minute":
- return dateProcess(sourceId, name, startTimel, endTimel, 900000, 15, 15, "minute");
- case "hour":
- return dateProcess(sourceId, name, startTimel, endTimel, 3600000, 1, 1, "hour");
- case "day":
- return dateProcess(sourceId, name, startTimel, endTimel, 86400000, 1, 1, "day");
- case "month":
- return dateProcess(sourceId, name, startTimel, endTimel, 2592000000L, 1, 1, "month");
- case "year":
- return dateProcess(sourceId, name, startTimel, endTimel, 31536000000L, 1, 1, "year");
- }
- } else if (format != null && format.equals("auto")) {
- long minutes = (endTimel - startTimel) / (1000 * 60);
- long hours = minutes / 60;
- if (hours > 12) {
- long days = hours / 24;
- if (days > 3) {
- long months = days / 31;
- if (months > 2) {
- return dateProcess(sourceId, name, startTimel, endTimel, 86400000, 1, 1, "day");
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 2592000000L, 1, 1, "month");
- }
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 3600000, 1, 1, "hour");
- }
- } else {
- return dateProcess(sourceId, name, startTimel, endTimel, 900000, 15, 15, "minute");
- }
- }
- } catch (ParseException e) {
- logger.error(e.getMessage());
- e.printStackTrace();
- }
- return null;
- }
-
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java b/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java
index 591f08c1..b47b2dfd 100755
--- a/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java
+++ b/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java
@@ -45,7 +45,7 @@ public class HibernateConfiguration
private Properties hibernateProperties() {
Properties properties = new Properties();
properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
- properties.put("hibernate.show_sql", "false");
+ properties.put("hibernate.show_sql", "true");
return properties;
}
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 2e5ed4a1..6bb8e6f7 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,8 +16,6 @@
package org.onap.usecaseui.server.service;
-import java.sql.Timestamp;
-import java.util.Date;
import java.util.List;
import org.onap.usecaseui.server.bean.AlarmsHeader;
@@ -28,26 +26,10 @@ public interface AlarmsHeaderService {
String saveAlarmsHeader(AlarmsHeader alarmsHeader);
String updateAlarmsHeader(AlarmsHeader alarmsHeader);
-
- //public String updateAlarmsHeader2018(String status, String date, String eventNameCleared,String eventName, String reportingEntityName,String specificProblem);
- public String updateAlarmsHeader2018(String status, Timestamp date, String startEpochMicrosecCleared, String lastEpochMicroSecCleared, String eventName, String reportingEntityName, String specificProblem);
- public Boolean getStatusBySourceName(String sourceName);
- public AlarmsHeader getIdByStatusSourceName(String sourceName);
-
-
+
int getAllCount(AlarmsHeader alarmsHeader, int currentPage, int pageSize);
Page<AlarmsHeader> queryAlarmsHeader(AlarmsHeader alarmsHeader, int currentPage, int pageSize);
List<AlarmsHeader> queryId(String[] id);
-
- String queryStatusCount(String status);
-
- public int getAllCountByStatus(String status);
- public List<AlarmsHeader> getAllByStatus(String status,String eventName,String sourceName,String eventServerity,String reportingEntityName ,Date createTime, Date endTime);
-
- public AlarmsHeader getAlarmsHeaderDetail(Integer id);
-
- public int getAllByDatetime(String status,String eventId,String eventServerity,String createTime);
-
}
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 83f6fb19..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
@@ -36,7 +36,4 @@ public interface AlarmsInformationService {
List<AlarmsInformation> queryId(String[] id);
List<Map<String,String>> queryDateBetween(String sourceId, String startTime, String endTime);
-
-
- List<AlarmsInformation> getAllAlarmsInformationByeventId(String eventId);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderPmService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderPmService.java
deleted file mode 100644
index c546dc72..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderPmService.java
+++ /dev/null
@@ -1,47 +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.
- */
-package org.onap.usecaseui.server.service;
-
-import java.util.Date;
-import java.util.List;
-
-import org.onap.usecaseui.server.bean.PerformanceHeader;
-import org.onap.usecaseui.server.bean.PerformanceHeaderPm;
-import org.onap.usecaseui.server.util.Page;
-
-
-public interface PerformanceHeaderPmService {
-
- String savePerformanceHeaderPm(PerformanceHeaderPm performanceHederPm);
-
- String updatePerformanceHeaderPm(PerformanceHeaderPm performanceHederPm);
-
- int getAllCount(PerformanceHeaderPm performanceHederPm, int currentPage, int pageSize);
-
- Page<PerformanceHeaderPm> queryPerformanceHeaderPm(PerformanceHeaderPm performanceHederPm, int currentPage, int pageSize);
-
- List<PerformanceHeaderPm> queryId(String[] id);
-
- List<String> queryAllSourceId();
-
-
- public int getAllCountByEventType();
- public List<PerformanceHeaderPm> getAllByEventType(String eventName, String sourceName, String reportingEntityName, Date createTime, Date endTime);
-
- public PerformanceHeaderPm getPerformanceHeaderDetail(Integer id);
-
- public int getAllByDatetime(String eventId,String createTime);
-}
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 9caf834e..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
@@ -15,7 +15,6 @@
*/
package org.onap.usecaseui.server.service;
-import java.util.Date;
import java.util.List;
import org.onap.usecaseui.server.bean.AlarmsHeader;
@@ -36,18 +35,4 @@ public interface PerformanceHeaderService {
List<PerformanceHeader> queryId(String[] id);
List<String> queryAllSourceId();
-
-
- public int getAllCountByEventType();
- public List<PerformanceHeader> getAllByEventType( String eventName, String sourceName, String reportingEntityName, Date createTime, Date endTime);
-
- public PerformanceHeader getPerformanceHeaderDetail(Integer id);
-
- public int getAllByDatetime(String eventId,String createTime);
-
-
-
-
-
-
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderVmService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderVmService.java
deleted file mode 100644
index da8e7968..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderVmService.java
+++ /dev/null
@@ -1,49 +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.
- */
-package org.onap.usecaseui.server.service;
-
-import java.util.Date;
-import java.util.List;
-
-import org.onap.usecaseui.server.bean.PerformanceHeader;
-import org.onap.usecaseui.server.bean.PerformanceHeaderVm;
-import org.onap.usecaseui.server.util.Page;
-
-
-public interface PerformanceHeaderVmService {
-
- String savePerformanceHeaderVm(PerformanceHeaderVm performanceHederVm);
-
- String updatePerformanceHeaderVm(PerformanceHeaderVm performanceHederVm);
-
- int getAllCount(PerformanceHeaderVm performanceHederVm, int currentPage, int pageSize);
-
- Page<PerformanceHeaderVm> queryPerformanceHeaderVm(PerformanceHeaderVm performanceHederVm, int currentPage, int pageSize);
-
- List<PerformanceHeaderVm> queryId(String[] id);
-
- List<String> queryAllSourceId();
-
-
-
- public int getAllCountByEventType();
- public List<PerformanceHeaderVm> getAllByEventType(String eventName, String sourceName, String reportingEntityName, Date createTime, Date endTime);
-
-
- public PerformanceHeaderVm getPerformanceHeaderDetail(Integer id);
-
- public int getAllByDatetime(String eventId,String createTime);
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationPmService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationPmService.java
deleted file mode 100644
index 2dc6c7d3..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationPmService.java
+++ /dev/null
@@ -1,45 +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.
- */
-package org.onap.usecaseui.server.service;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.usecaseui.server.bean.PerformanceInformationPm;
-import org.onap.usecaseui.server.util.Page;
-
-
-public interface PerformanceInformationPmService {
-
- String savePerformanceInformationPm(PerformanceInformationPm performanceInformationPm);
-
- String updatePerformanceInformationPm(PerformanceInformationPm performanceInformationPm);
-
- int getAllCount(PerformanceInformationPm performanceInformationPm, int currentPage, int pageSize);
-
- Page<PerformanceInformationPm> queryPerformanceInformationPm(PerformanceInformationPm performanceInformationPm, int currentPage, int pageSize);
-
- List<PerformanceInformationPm> queryId(String[] id);
-
- List<PerformanceInformationPm> queryDateBetween(String eventId, Date startDate, Date endDate);
-
- List<PerformanceInformationPm> queryDateBetween(String resourceId, String name, String startTime, String endTime);
-
- List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime);
-
- List<PerformanceInformationPm> getAllPerformanceInformationByeventId(String eventId);
-}
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 2d2cad49..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
@@ -17,8 +17,8 @@ package org.onap.usecaseui.server.service;
import java.util.Date;
import java.util.List;
-import java.util.Map;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.util.Page;
@@ -37,11 +37,8 @@ public interface PerformanceInformationService {
List<PerformanceInformation> queryDateBetween(String eventId, Date startDate, Date endDate);
- List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime);
-
- List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime);
+ int queryDataBetweenSum(String eventId, String name, Date startDate, Date endDate);
+ List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime);
- List<PerformanceInformation> getAllPerformanceInformationByeventId(String eventId);
- public List<PerformanceInformation> getAllEventId();
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationVmService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationVmService.java
deleted file mode 100644
index ab8e94d7..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationVmService.java
+++ /dev/null
@@ -1,45 +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.
- */
-package org.onap.usecaseui.server.service;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.usecaseui.server.bean.PerformanceInformationVm;
-import org.onap.usecaseui.server.util.Page;
-
-
-public interface PerformanceInformationVmService {
-
- String savePerformanceInformationVm(PerformanceInformationVm performanceInformationVm);
-
- String updatePerformanceInformationVm(PerformanceInformationVm performanceInformationVm);
-
- int getAllCount(PerformanceInformationVm performanceInformationVm, int currentPage, int pageSize);
-
- Page<PerformanceInformationVm> queryPerformanceInformationVm(PerformanceInformationVm performanceInformationVm, int currentPage, int pageSize);
-
- List<PerformanceInformationVm> queryId(String[] id);
-
- List<PerformanceInformationVm> queryDateBetween(String eventId, Date startDate, Date endDate);
-
- List<PerformanceInformationVm> queryDateBetween(String resourceId, String name, String startTime, String endTime);
-
- List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime);
-
- List<PerformanceInformationVm> getAllPerformanceInformationByeventId(String eventId);
-}
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 4812589e..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
@@ -15,17 +15,21 @@
*/
package org.onap.usecaseui.server.service.impl;
-import java.util.Date;
-import java.sql.Timestamp;
+
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+
import javax.transaction.Transactional;
+
import org.hibernate.Query;
import org.hibernate.Session;
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;
@@ -44,13 +48,10 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
@Autowired
private SessionFactory sessionFactory;
-
- private Session getSession() {
- return sessionFactory.openSession();
- }
+
public String saveAlarmsHeader(AlarmsHeader alarmsHeader) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
if (null == alarmsHeader) {
logger.error("AlarmsHeaderServiceImpl saveAlarmsHeader alarmsHeader is null!");
}
@@ -66,74 +67,11 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
}
-
- @Override
- public String updateAlarmsHeader2018(String status, Timestamp date, String startEpochMicrosecCleared, String lastEpochMicroSecCleared, String eventName, String reportingEntityName, String specificProblem) {
-
- try(Session session = getSession()){
- logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}");
- Transaction tx = 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");
- 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();
- tx = session.getTransaction();
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());
- return "0";
- }
- }
-
- @Override
- public Boolean getStatusBySourceName(String sourceName) {
- try(Session session = getSession()){
- logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}");
- Query q=session.createQuery("select status from AlarmsHeader where sourceName='"+sourceName+"' and status='active'");
- q.setMaxResults(1);
- String s=(String)q.uniqueResult();
- Boolean status=false;
- if(s!=null && "active".equals(s)){
- status = true;
- }else{
- status = false;
- }
- session.flush();
- return status;
- } catch (Exception e) {
- logger.error("exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());
- return false;
- }
- }
-
-
- @Override
- public AlarmsHeader getIdByStatusSourceName(String sourceName) {
- AlarmsHeader s = new AlarmsHeader();
- try(Session session = getSession()){
- logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}");
- Query q=session.createQuery("from AlarmsHeader where sourceName='"+sourceName+"' and status='active' order by createTime desc");
- q.setMaxResults(1);
- s = (AlarmsHeader)q.uniqueResult();
- session.flush();
- return s;
- } catch (Exception e) {
- logger.error("exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());
- return s;
- }
- }
+
@Override
public String updateAlarmsHeader(AlarmsHeader alarmsHeader) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
if (null == alarmsHeader){
logger.error("AlarmsHeaderServiceImpl updateAlarmsHeader alarmsHeader is null!");
}
@@ -149,129 +87,8 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
}
- @Override
- public int getAllCountByStatus(String status){
- try (Session session = getSession()){
- StringBuffer count = new StringBuffer("select count(*) from AlarmsHeader a where 1=1");
- if(!"0".equals(status)){
- count.append(" and a.status=:status");
- }
- Query query = session.createQuery(count.toString());
- query.setString("status",status);
- Object obj = query.uniqueResult();
- session.flush();
- return Integer.parseInt(obj.toString());
- }catch (Exception e){
- logger.error("exception occurred while performing AlarmsHeaderServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
- }
-
- @Override
- public List<AlarmsHeader> getAllByStatus(String status,String eventName,String sourceName,String eventServrity,String reportingEntityName, Date createTime, Date endTime){
- try (Session session = getSession()){
- StringBuffer string = new StringBuffer("from AlarmsHeader a where 1=1");
- if(!"0".equals(status)){
- string.append(" and a.status=:status");
- }
- if(!"0".equals(eventName) && eventName!=null){
- string.append(" and a.eventName=:eventName");
- }
- if(!"0".equals(sourceName) && sourceName!=null){
- string.append(" and a.sourceName=:sourceName");
- }
- if(!"0".equals(eventServrity) && eventServrity!=null){
- string.append(" and a.eventServrity=:eventServrity");
- }
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null){
- string.append(" and a.reportingEntityName=:reportingEntityName");
- }
- if( null!=createTime && endTime!= null) {
- string.append(" and a.createTime between :startTime and :endTime");
- }
- Query query = session.createQuery(string.toString());
- if(!"0".equals(status)) {
- query.setString("status", status);
- }
- if(!"0".equals(eventName) && eventName!=null) {
- query.setString("eventName", eventName);
- }
- if(!"0".equals(sourceName) && sourceName!=null) {
- query.setString("sourceName", sourceName);
- }
- if(!"0".equals(eventServrity) && eventServrity!=null) {
- query.setString("eventServrity", eventServrity);
- }
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null) {
- query.setString("reportingEntityName", reportingEntityName);
- }
- if( null!=createTime && endTime!= null) {
- query.setDate("startTime",createTime);
- query.setDate("endTime",endTime);
- }
- List<AlarmsHeader> list =query.list();
- return list;
- }catch (Exception e){
- logger.error("exception occurred while performing AlarmsHeaderServiceImpl getAllCount."+e.getMessage());
- return null;
- }
- }
-
- @Override
- public AlarmsHeader getAlarmsHeaderDetail(Integer id) {
- try(Session session = getSession()) {
- String string = "from AlarmsHeader a where 1=1 and a.id=:id";
- Query q = session.createQuery(string);
- q.setInteger("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;
- }
- }
-
- @Override
- public int getAllByDatetime(String status,String eventId, String eventServrity, String createTime) {
- try (Session session = getSession()){
- StringBuffer string = new StringBuffer("select count(*) as count from AlarmsHeader a where 1=1");
-
- if(!"0".equals(status) && status!=null){
- string.append(" and a.status=:status");
- }
- if(!"0".equals(eventId) && eventId!=null){
- string.append(" and a.eventId=:eventId");
- }
- if(!"0".equals(eventServrity) && eventServrity!=null){
- string.append(" and a.eventServrity=:eventServrity");
- }
- if( null!=createTime) {
- string.append(" and to_days(a.createTime) = to_days('"+createTime+"')");
- }
-
- Query query = session.createQuery(string.toString());
- if(!"0".equals(status) && status!=null) {
- query.setString("status", status);
- }
- if(!"0".equals(eventId) && eventId!=null) {
- query.setString("eventId", eventId);
- }
- if(!"0".equals(eventServrity) && eventServrity!=null) {
- query.setString("eventServrity", eventServrity);
- }
-
- Object obj = query.uniqueResult();
- session.flush();
- return Integer.parseInt(obj.toString());
- }catch (Exception e){
- logger.error("exception occurred while performing AlarmsHeaderServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
- }
-
public int getAllCount(AlarmsHeader alarmsHeader,int currentPage,int pageSize) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
StringBuffer count=new StringBuffer("select count(*) from AlarmsHeader a where 1=1");
if (null == alarmsHeader) {
//logger.error("AlarmsHeaderServiceImpl getAllCount alarmsHeader is null!");
@@ -360,6 +177,10 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
String ver =alarmsHeader.getSpecificProblem();
count.append(" and a.specificProblem like '%"+ver+"%'");
}
+ if(null!=alarmsHeader.getVfStatus()) {
+ String ver =alarmsHeader.getVfStatus();
+ count.append(" and a.vfStatus = '"+ver+"'");
+ }
if(null!=alarmsHeader.getAlarmInterfaceA()) {
String ver =alarmsHeader.getAlarmInterfaceA();
count.append(" and a.alarmInterfaceA like '%"+ver+"%'");
@@ -373,15 +194,13 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
}
Query query = session.createQuery(count.toString());
- if (null != alarmsHeader)
- if(null!=alarmsHeader.getCreateTime() || alarmsHeader.getUpdateTime()!= null) {
- query.setDate("startTime",alarmsHeader.getCreateTime());
- query.setDate("endTime",alarmsHeader.getUpdateTime());
- }
-
- Object obj = query.uniqueResult();
+ 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 Integer.parseInt(obj.toString());
+ return (int)q;
} catch (Exception e) {
logger.error("exception occurred while performing AlarmsHeaderServiceImpl getAllCount. Details:" + e.getMessage());
return -1;
@@ -394,10 +213,12 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
Page<AlarmsHeader> page = new Page<AlarmsHeader>();
int allRow =this.getAllCount(alarmsHeader,currentPage,pageSize);
int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = getSession()){
+
+ try(Session session = sessionFactory.openSession();){
StringBuffer hql =new StringBuffer("from AlarmsHeader a where 1=1");
- if (null != alarmsHeader) {
+ if (null == alarmsHeader) {
+ //logger.error("AlarmsHeaderServiceImpl queryAlarmsHeader alarmsHeader is null!");
+ }else {
if(null!=alarmsHeader.getVersion()) {
String ver=alarmsHeader.getVersion();
hql.append(" and a.version like '%"+ver+"%'");
@@ -482,10 +303,10 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
String ver =alarmsHeader.getSpecificProblem();
hql.append(" and a.specificProblem like '%"+ver+"%'");
}
- /*if(null!=alarmsHeader.getVfStatus()) {
+ if(null!=alarmsHeader.getVfStatus()) {
String ver =alarmsHeader.getVfStatus();
hql.append(" and a.vfStatus = '"+ver+"'");
- }*/
+ }
if(null!=alarmsHeader.getAlarmInterfaceA()) {
String ver =alarmsHeader.getAlarmInterfaceA();
hql.append(" and a.alarmInterfaceA like '%"+ver+"%'");
@@ -500,11 +321,10 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
logger.info("AlarmsHeaderServiceImpl queryAlarmsHeader: alarmsHeader={}", alarmsHeader);
Query query = session.createQuery(hql.toString());
- if (null != alarmsHeader)
- if(null!=alarmsHeader.getCreateTime() || alarmsHeader.getUpdateTime()!= null) {
- query.setDate("startTime",alarmsHeader.getCreateTime());
- query.setDate("endTime",alarmsHeader.getUpdateTime());
- }
+ 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();
@@ -524,14 +344,13 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
@SuppressWarnings("unchecked")
@Override
public List<AlarmsHeader> queryId(String[] id) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
if(id.length==0) {
logger.error("AlarmsHeaderServiceImpl queryId is null!");
}
List<AlarmsHeader> list = new ArrayList<AlarmsHeader>();
Query query = session.createQuery("from AlarmsHeader a where a.eventName IN (:alist)");
- query = query.setParameterList("alist", id);
- list = query.list();
+ list = query.setParameterList("alist", id).list();
return list;
} catch (Exception e) {
logger.error("exception occurred while performing AlarmsHeaderServiceImpl queryId. Details:" + e.getMessage());
@@ -539,22 +358,8 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
}
- @Override
- public String queryStatusCount(String status) {
- try(Session session = getSession()){
- 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);
- }
- Object obj = query.uniqueResult();
- return obj.toString();
- } catch (Exception e) {
- logger.error("exception occurred while performing AlarmsHeaderServiceImpl queryStatusCount. Details:" + 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 980a3a61..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
@@ -45,14 +45,9 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
@Autowired
private SessionFactory sessionFactory;
- private Session getSession() {
- return sessionFactory.openSession();
- }
-
-
@Override
public String saveAlarmsInformation(AlarmsInformation alarmsInformation) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
if (null == alarmsInformation) {
logger.error("alarmsInformation saveAlarmsInformation alarmsInformation is null!");
}
@@ -71,7 +66,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
@Override
public String updateAlarmsInformation(AlarmsInformation alarmsInformation) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
if (null == alarmsInformation) {
logger.error("alarmsInformation updateAlarmsInformation alarmsInformation is null!");
}
@@ -89,7 +84,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
public int getAllCount(AlarmsInformation alarmsInformation, int currentPage, int pageSize) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
StringBuffer hql = new StringBuffer("select count(*) from AlarmsInformation a where 1=1");
if (null == alarmsInformation) {
//logger.error("AlarmsInformationServiceImpl getAllCount alarmsInformation is null!");
@@ -114,13 +109,11 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
Date ver =alarmsInformation.getUpdateTime();
hql.append(" and a.updateTime like '%"+ver+"%'");
}
- }
-
- Query query = session.createQuery(hql.toString());
- Object obj = query.uniqueResult();
- session.flush();
- return Integer.parseInt(obj.toString());
- } catch (Exception e) {
+ }
+ long q=(long)session.createQuery(hql.toString()).uniqueResult();
+ session.flush();
+ return (int)q;
+ } catch (Exception e) {
logger.error("exception occurred while performing AlarmsInformationServiceImpl getAllCount. Details:" + e.getMessage());
return 0;
}
@@ -134,7 +127,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
int allRow =this.getAllCount(alarmsInformation,currentPage,pageSize);
int offset = page.countOffset(currentPage, pageSize);
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
StringBuffer hql =new StringBuffer("from AlarmsInformation a where 1=1");
if (null == alarmsInformation) {
//logger.error("AlarmsInformationServiceImpl queryAlarmsInformation alarmsInformation is null!");
@@ -185,10 +178,9 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
logger.error("AlarmsInformationServiceImpl queryId is null!");
}
List<AlarmsInformation> list = new ArrayList<AlarmsInformation>();
- Session session = getSession();
+ Session session = sessionFactory.openSession();
Query query = session.createQuery("from AlarmsInformation a where a.eventId IN (:alist)");
- query = query.setParameterList("alist", id);
- list = query.list();
+ list = query.setParameterList("alist", id).list();
session.close();
return list;
} catch (Exception e) {
@@ -198,15 +190,13 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
}
-
-
@Override
public List<Map<String,String>> queryDateBetween(String sourceId, String startTime, String endTime) {
- try(Session session = getSession()) {
+ try(Session session = sessionFactory.openSession();) {
List<Map<String,String>> mapList = new ArrayList<>();
- String hql = "select a.createTime,count(*) from AlarmsHeader a where 1=1 ";
+ String hql = "select a.createTime,count(*) from AlarmsInformation a where 1=1 ";
if (sourceId != null && !"".equals(sourceId)){
- hql += " and a.sourceId = :sourceId";
+ hql += " and a.eventId = :sourceId";
}
if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
hql += " and a.createTime between :startTime and :endTime ";
@@ -219,8 +209,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
query.setString("startTime", startTime).setString("endTime", endTime);
}
- List<Object[]> queryResult = query.list();
- Iterator it= queryResult.iterator();
+ Iterator it= query.list().iterator();
while(it.hasNext()){
Object[] res=(Object[]) it.next();
Map<String,String> map = new HashMap<>();
@@ -235,19 +224,4 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
return null;
}
}
-
- @Override
- public List<AlarmsInformation> getAllAlarmsInformationByeventId(String eventId) {
- try (Session session = getSession()){
- String string = "from AlarmsInformation a where 1=1 and a.eventId=:eventId";
- Query query = session.createQuery(string);
- query.setString("eventId",eventId);
- 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/PerformanceHeaderPmServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderPmServiceImpl.java
deleted file mode 100644
index bef75986..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderPmServiceImpl.java
+++ /dev/null
@@ -1,479 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.transaction.Transactional;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.onap.usecaseui.server.bean.PerformanceHeaderPm;
-import org.onap.usecaseui.server.service.PerformanceHeaderPmService;
-import org.onap.usecaseui.server.util.Page;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.stereotype.Service;
-
-
-@Service("PerformanceHeaderPmService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class PerformanceHeaderPmServiceImpl implements PerformanceHeaderPmService {
-
- private static final Logger logger = LoggerFactory.getLogger(PerformanceHeaderPmServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
-
-
- @Override
- public PerformanceHeaderPm getPerformanceHeaderDetail(Integer id) {
- try(Session session = sessionFactory.openSession()) {
-
- String string = "from PerformanceHeaderPm a where 1=1 and a.id=:id";
- Query q = session.createQuery(string);
- q.setInteger("id",id);
- PerformanceHeaderPm performanceHeaderPm =(PerformanceHeaderPm)q.uniqueResult();
- session.flush();
- return performanceHeaderPm;
-
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderPmServiceImpl getPerformanceHeaderPmDetail."+e.getMessage());
- return null;
- }
- }
-
- @Override
- public int getAllByDatetime(String eventId, String createTime) {
- try (Session session = sessionFactory.openSession();){
- StringBuffer string = new StringBuffer("select count(*) as count from PerformanceHeaderPm a where 1=1");
-
- /*if(!"0".equals(status) && status!=null){
- string.append(" and a.status=:status");
- }*/
- if(!"0".equals(eventId) && eventId!=null){
- string.append(" and a.eventId=:eventId");
- }
-
-
-
- /*if( null!=createTime && endTime!= null) {
- string.append(" and a.createTime between :startTime and :endTime");
- }*/
- if( null!=createTime) {
- string.append(" and to_days(a.createTime) = to_days('"+createTime+"')");
- }
-
- /*string.append(" group by DATE_FORMAT(a.createTime,'%y-%m-%d')");*/
- Query query = session.createQuery(string.toString());
- /*if(!"0".equals(status) && status!=null) {
- query.setString("status", status);
- }*/
- if(!"0".equals(eventId) && eventId!=null) {
- query.setString("eventId", eventId);
- }
-
- //query.setDate("createTime",createTime);
-
- /*if( null!=createTime && endTime!= null) {
- query.setDate("startTime",createTime);
- query.setDate("endTime",endTime);
-
- }*/
- long l = (long)query.uniqueResult();
- int a = (int) l;
- //List<PerformanceHeaderPm> list =query.list();
- session.flush();
- return a;
-
- }catch (Exception e){
-
- logger.error("exception occurred while performing PerformanceHeaderPmServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
-
- }
-
- @Override
- public int getAllCountByEventType(){
- try (Session session = sessionFactory.openSession()){
- StringBuffer count = new StringBuffer("select count(*) from PerformanceHeaderPm a where 1=1");
- /*if(!"0".equals(status)){
- count.append(" and a.status=:status");
- }*/
- Query query =session.createQuery(count.toString());
- /*query.setString("status",status);*/
- //int q = (int)query.uniqueResult();
- long q=(long)query.uniqueResult();
- session.flush();
- return (int)q;
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderPmServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
- }
-
-
-
-
-
- @Override
- public List<PerformanceHeaderPm> getAllByEventType(String eventName, String sourceName, String reportingEntityName, Date createTime, Date endTime){
- try (Session session = sessionFactory.openSession()){
- StringBuffer string = new StringBuffer("from PerformanceHeaderPm a where 1=1");
- /*if(!"0".equals(status)){
- string.append(" and a.status=:status");
- }*/
- if(!"0".equals(eventName) && eventName!=null){
- string.append(" and a.eventName=:eventName");
- }
- if(!"0".equals(sourceName) && sourceName!=null){
- string.append(" and a.sourceName=:sourceName");
- }
-
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null){
- string.append(" and a.reportingEntityName=:reportingEntityName");
- }
- if( null!=createTime && endTime!= null) {
- string.append(" and a.createTime between :startTime and :endTime");
- }
- Query query = session.createQuery(string.toString());
- /*if(!"0".equals(status)) {
- query.setString("status", status);
- }*/
- if(!"0".equals(eventName) && eventName!=null) {
- query.setString("eventName", eventName);
- }
- if(!"0".equals(sourceName) && sourceName!=null) {
- query.setString("sourceName", sourceName);
- }
-
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null) {
- query.setString("reportingEntityName", reportingEntityName);
- }
- if( null!=createTime && endTime!= null) {
- query.setDate("startTime",createTime);
- query.setDate("endTime",endTime);
-
- }
-
- List<PerformanceHeaderPm> list =query.list();
-
- return list;
-
- }catch (Exception e){
-
- logger.error("exception occurred while performing PerformanceHeaderPmServiceImpl getAllCount."+e.getMessage());
- return null;
- }
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @Override
- public String savePerformanceHeaderPm(PerformanceHeaderPm performanceHederPm) {
- try(Session session = sessionFactory.openSession();){
- if (null == performanceHederPm){
- logger.error("PerformanceHeaderServiceImpl savePerformanceHeaderPm performanceHeder is null!");
- }
- logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHederPm);
- Transaction tx = session.beginTransaction();
- session.save(performanceHederPm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
-
- @Override
- public String updatePerformanceHeaderPm(PerformanceHeaderPm performanceHederPm) {
- try(Session session = sessionFactory.openSession();){
- if (null == performanceHederPm){
- logger.error("PerformanceHeaderServiceImpl updatePerformanceHeaderPm performanceHeder is null!");
- }
- logger.info("PerformanceHeaderServiceImpl updatePerformanceHeader: performanceHeder={}", performanceHederPm);
- Transaction tx = session.beginTransaction();
- session.update(performanceHederPm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl updatePerformanceHeader. Details:" + e.getMessage());
- return "0";
- }
- }
-
-
- public int getAllCount(PerformanceHeaderPm performanceHederPm, int currentPage, int pageSize) {
- try(Session session = sessionFactory.openSession();){
- StringBuffer hql = new StringBuffer("select count(*) from PerformanceHeaderPm a where 1=1");
- if (null == performanceHederPm) {
- //logger.error("PerformanceHeaderServiceImpl getAllCount performanceHeder is null!");
- }else {
- if(null!=performanceHederPm.getVersion()) {
- String ver=performanceHederPm.getVersion();
- hql.append(" and a.version like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getEventName()) {
- String ver=performanceHederPm.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getDomain()) {
- String ver=performanceHederPm.getDomain();
- hql.append(" and a.domain like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getEventId()) {
- String ver=performanceHederPm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceHederPm.getNfcNamingCode()) {
- String ver=performanceHederPm.getNfcNamingCode();
- hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getNfNamingCode()) {
- String ver=performanceHederPm.getNfNamingCode();
- hql.append(" and a.nfNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getSourceId()) {
- String ver =performanceHederPm.getSourceId();
- hql.append(" and a.sourceId like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getSourceName()) {
- String ver =performanceHederPm.getSourceName();
- hql.append(" and a.sourceName like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getReportingEntityId()) {
- String ver =performanceHederPm.getReportingEntityId();
- hql.append(" and a.reportingEntityId like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getReportingEntityName()) {
- String ver =performanceHederPm.getReportingEntityName();
- hql.append(" and a.reportingEntityName like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getPriority()) {
- String ver =performanceHederPm.getPriority();
- hql.append(" and a.priority like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getStartEpochMicrosec()) {
- String ver =performanceHederPm.getStartEpochMicrosec();
- hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getLastEpochMicroSec()) {
- String ver =performanceHederPm.getLastEpochMicroSec();
- hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getSequence()) {
- String ver =performanceHederPm.getSequence();
- hql.append(" and a.sequence like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getMeasurementsForVfScalingVersion()) {
- String ver =performanceHederPm.getMeasurementsForVfScalingVersion();
- hql.append(" and a.measurementsForVfScalingVersion like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getMeasurementInterval()) {
- String ver =performanceHederPm.getMeasurementInterval();
- hql.append(" and a.measurementInterval like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getEventType()) {
- String ver =performanceHederPm.getEventType();
- hql.append(" and a.eventType like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getCreateTime() && null!=performanceHederPm.getUpdateTime()) {
- hql.append(" and a.createTime between :startTime and :endTime ");
- }
- }
- Query query = session.createQuery(hql.toString());
- if (null != performanceHederPm)
- if(null!=performanceHederPm.getCreateTime() && null!=performanceHederPm.getUpdateTime()) {
- query.setDate("startTime",performanceHederPm.getCreateTime()).setDate("endTime",performanceHederPm.getUpdateTime());
- }
- long q=(long)query.uniqueResult();
- session.flush();
- return (int)q;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<PerformanceHeaderPm> queryPerformanceHeaderPm(PerformanceHeaderPm performanceHederPm, int currentPage,
- int pageSize) {
- Page<PerformanceHeaderPm> page = new Page<PerformanceHeaderPm>();
- int allRow =this.getAllCount(performanceHederPm,currentPage,pageSize);
- int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = sessionFactory.openSession();){
- StringBuffer hql =new StringBuffer("from PerformanceHeaderPm a where 1=1");
- if (null == performanceHederPm) {
- //logger.error("PerformanceHeaderServiceImpl queryPerformanceHeaderPm performanceHeder is null!");
- }else {
- if(null!=performanceHederPm.getVersion()) {
- String ver=performanceHederPm.getVersion();
- hql.append(" and a.version like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getEventName()) {
- String ver=performanceHederPm.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getDomain()) {
- String ver=performanceHederPm.getDomain();
- hql.append(" and a.domain like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getEventId()) {
- String ver=performanceHederPm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceHederPm.getNfcNamingCode()) {
- String ver=performanceHederPm.getNfcNamingCode();
- hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getNfNamingCode()) {
- String ver=performanceHederPm.getNfNamingCode();
- hql.append(" and a.nfNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getSourceId()) {
- String ver =performanceHederPm.getSourceId();
- hql.append(" and a.sourceId = '"+ver+"'");
- }
- if(null!=performanceHederPm.getSourceName()) {
- String ver =performanceHederPm.getSourceName();
- hql.append(" and a.sourceName like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getReportingEntityId()) {
- String ver =performanceHederPm.getReportingEntityId();
- hql.append(" and a.reportingEntityId like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getReportingEntityName()) {
- String ver =performanceHederPm.getReportingEntityName();
- hql.append(" and a.reportingEntityName like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getPriority()) {
- String ver =performanceHederPm.getPriority();
- hql.append(" and a.priority like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getStartEpochMicrosec()) {
- String ver =performanceHederPm.getStartEpochMicrosec();
- hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getLastEpochMicroSec()) {
- String ver =performanceHederPm.getLastEpochMicroSec();
- hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getSequence()) {
- String ver =performanceHederPm.getSequence();
- hql.append(" and a.sequence like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getMeasurementsForVfScalingVersion()) {
- String ver =performanceHederPm.getMeasurementsForVfScalingVersion();
- hql.append(" and a.measurementsForVfScalingVersion like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getMeasurementInterval()) {
- String ver =performanceHederPm.getMeasurementInterval();
- hql.append(" and a.measurementInterval like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getEventType()) {
- String ver =performanceHederPm.getEventType();
- hql.append(" and a.eventType like '%"+ver+"%'");
- }
- if(null!=performanceHederPm.getCreateTime() && null!=performanceHederPm.getUpdateTime()) {
- hql.append(" and a.createTime between :startTime and :endTime ");
- }
- }
- logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHederPm);
- Query query = session.createQuery(hql.toString());
- if (null != performanceHederPm)
- if(null!=performanceHederPm.getCreateTime() && null!=performanceHederPm.getUpdateTime()) {
- query.setDate("startTime",performanceHederPm.getCreateTime()).setDate("endTime",performanceHederPm.getUpdateTime());
- }
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<PerformanceHeaderPm> list= query.list();
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- return page;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl queryPerformanceHeader. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public List<PerformanceHeaderPm> queryId(String[] id) {
- try(Session session = sessionFactory.openSession();) {
- if(id.length==0) {
- logger.error("PerformanceHeaderServiceImpl queryId is null!");
- }
- List<PerformanceHeaderPm> list = new ArrayList<PerformanceHeaderPm>();
- Query query = session.createQuery("from PerformanceHeaderPm a where a.eventName IN (:alist)");
- list = query.setParameterList("alist", id).list();
- return list;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @Override
- public List<String> queryAllSourceId() {
- try(Session session = sessionFactory.openSession();) {
- Query query = session.createQuery("select a.sourceId from PerformanceHeaderPm 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/PerformanceHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
index 705112d8..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
@@ -41,37 +41,36 @@ import org.springframework.stereotype.Service;
@org.springframework.context.annotation.Configuration
@EnableAspectJAutoProxy
public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
-
+
private static final Logger logger = LoggerFactory.getLogger(PerformanceHeaderServiceImpl.class);
@Autowired
private SessionFactory sessionFactory;
- private Session getSession(){
- return sessionFactory.openSession();
- }
@Override
public String savePerformanceHeader(PerformanceHeader performanceHeder) {
- try(Session session = getSession()){
- if (null == performanceHeder){
- logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");
- }
- logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);
- Transaction tx = session.beginTransaction();
- session.save(performanceHeder);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());
- return "0";
- }
+ try(Session session = sessionFactory.openSession();){
+ if (null == performanceHeder){
+ logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");
+ }
+ logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);
+ Transaction tx = session.beginTransaction();
+ session.save(performanceHeder);
+ tx.commit();
+ session.flush();
+ return "1";
+ } catch (Exception e) {
+ logger.error("exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());
+ return "0";
+ }
+
}
+
@Override
public String updatePerformanceHeader(PerformanceHeader performanceHeder) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
if (null == performanceHeder){
logger.error("PerformanceHeaderServiceImpl updatePerformanceHeader performanceHeder is null!");
}
@@ -87,98 +86,9 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
}
- @Override
- public int getAllCountByEventType(){
- try (Session session = getSession()){
- StringBuffer count = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");
- Query query =session.createQuery(count.toString());
- Object obj = query.uniqueResult();
- session.flush();
- return Integer.parseInt(obj.toString());
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
- }
-
- @Override
- public List<PerformanceHeader> getAllByEventType(String eventName,String sourceName,String reportingEntityName, Date createTime, Date endTime){
- try (Session session = getSession()){
- StringBuffer string = new StringBuffer("from PerformanceHeader a where 1=1");
- if(!"0".equals(eventName) && eventName!=null){
- string.append(" and a.eventName=:eventName");
- }
- if(!"0".equals(sourceName) && sourceName!=null){
- string.append(" and a.sourceName=:sourceName");
- }
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null){
- string.append(" and a.reportingEntityName=:reportingEntityName");
- }
- if( null!=createTime && endTime!= null) {
- string.append(" and a.createTime between :startTime and :endTime");
- }
- Query query = session.createQuery(string.toString());
- if(!"0".equals(eventName) && eventName!=null) {
- query.setString("eventName", eventName);
- }
- if(!"0".equals(sourceName) && sourceName!=null) {
- query.setString("sourceName", sourceName);
- }
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null) {
- query.setString("reportingEntityName", reportingEntityName);
- }
- if( null!=createTime && endTime!= null) {
- query.setDate("startTime",createTime);
- query.setDate("endTime",endTime);
- }
- List<PerformanceHeader> list =query.list();
- return list;
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount."+e.getMessage());
- return null;
- }
- }
-
- @Override
- public PerformanceHeader getPerformanceHeaderDetail(Integer id) {
- try(Session session = getSession()) {
- String string = "from PerformanceHeader a where 1=1 and a.id=:id";
- Query q = session.createQuery(string);
- q.setInteger("id",id);
- PerformanceHeader performanceHeader =(PerformanceHeader)q.uniqueResult();
- session.flush();
- return performanceHeader;
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getPerformanceHeaderDetail."+e.getMessage());
- return null;
- }
- }
-
- @Override
- public int getAllByDatetime(String eventId, String createTime) {
- try (Session session = getSession()){
- StringBuffer string = new StringBuffer("select count(*) as count from PerformanceHeader a where 1=1");
- if(!"0".equals(eventId) && eventId!=null){
- string.append(" and a.eventId=:eventId");
- }
- if( null!=createTime) {
- string.append(" and to_days(a.createTime) = to_days('"+createTime+"')");
- }
- Query query = session.createQuery(string.toString());
- if(!"0".equals(eventId) && eventId!=null) {
- query.setString("eventId", eventId);
- }
- Object obj = query.uniqueResult();
- session.flush();
- return Integer.parseInt(obj.toString());
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
- }
public int getAllCount(PerformanceHeader performanceHeder, int currentPage, int pageSize) {
- try(Session session = getSession()){
+ try(Session session = sessionFactory.openSession();){
StringBuffer hql = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");
if (null == performanceHeder) {
//logger.error("PerformanceHeaderServiceImpl getAllCount performanceHeder is null!");
@@ -256,14 +166,12 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
}
Query query = session.createQuery(hql.toString());
- if (null != performanceHeder) {
- if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
- query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());
- }
+ if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
+ query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());
}
- Object obj = query.uniqueResult();
- session.flush();
- return Integer.parseInt(obj.toString());
+ long q=(long)query.uniqueResult();
+ session.flush();
+ return (int)q;
} catch (Exception e) {
logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount. Details:" + e.getMessage());
return 0;
@@ -272,12 +180,13 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
@SuppressWarnings("unchecked")
@Override
- public Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage, int pageSize) {
+ public Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage,
+ int pageSize) {
Page<PerformanceHeader> page = new Page<PerformanceHeader>();
int allRow =this.getAllCount(performanceHeder,currentPage,pageSize);
int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = getSession()){
+
+ try(Session session = sessionFactory.openSession();){
StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");
if (null == performanceHeder) {
//logger.error("PerformanceHeaderServiceImpl queryPerformanceHeader performanceHeder is null!");
@@ -356,10 +265,8 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHeder);
Query query = session.createQuery(hql.toString());
- if (null != performanceHeder) {
- if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
- query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());
- }
+ if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {
+ query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());
}
query.setFirstResult(offset);
query.setMaxResults(pageSize);
@@ -376,10 +283,11 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
}
+
@SuppressWarnings("unchecked")
@Override
public List<PerformanceHeader> queryId(String[] id) {
- try(Session session = getSession()) {
+ try(Session session = sessionFactory.openSession();) {
if(id.length==0) {
logger.error("PerformanceHeaderServiceImpl queryId is null!");
}
@@ -393,9 +301,10 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
}
+
@Override
public List<String> queryAllSourceId() {
- try(Session session = getSession()) {
+ try(Session session = sessionFactory.openSession();) {
Query query = session.createQuery("select a.sourceId from PerformanceHeader a");
return query.list();
} catch (Exception e) {
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderVmServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderVmServiceImpl.java
deleted file mode 100644
index fd93d934..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderVmServiceImpl.java
+++ /dev/null
@@ -1,467 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.transaction.Transactional;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.onap.usecaseui.server.bean.PerformanceHeaderVm;
-import org.onap.usecaseui.server.service.PerformanceHeaderVmService;
-import org.onap.usecaseui.server.util.Page;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.stereotype.Service;
-
-
-@Service("PerformanceHeaderVmService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class PerformanceHeaderVmServiceImpl implements PerformanceHeaderVmService {
-
- private static final Logger logger = LoggerFactory.getLogger(PerformanceHeaderVmServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
-
-
-
- @Override
- public PerformanceHeaderVm getPerformanceHeaderDetail(Integer id) {
- try(Session session = sessionFactory.openSession()) {
-
- String string = "from PerformanceHeaderVm a where 1=1 and a.id=:id";
- Query q = session.createQuery(string);
- q.setInteger("id",id);
- PerformanceHeaderVm performanceHeaderVm =(PerformanceHeaderVm)q.uniqueResult();
- session.flush();
- return performanceHeaderVm;
-
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getPerformanceHeaderDetail."+e.getMessage());
- return null;
- }
- }
-
- @Override
- public int getAllByDatetime(String eventId, String createTime) {
- try (Session session = sessionFactory.openSession();){
- StringBuffer string = new StringBuffer("select count(*) as count from PerformanceHeaderVm a where 1=1");
-
- /*if(!"0".equals(status) && status!=null){
- string.append(" and a.status=:status");
- }*/
- if(!"0".equals(eventId) && eventId!=null){
- string.append(" and a.eventId=:eventId");
- }
-
-
-
- /*if( null!=createTime && endTime!= null) {
- string.append(" and a.createTime between :startTime and :endTime");
- }*/
- if( null!=createTime) {
- string.append(" and to_days(a.createTime) = to_days('"+createTime+"')");
- }
-
- /*string.append(" group by DATE_FORMAT(a.createTime,'%y-%m-%d')");*/
- Query query = session.createQuery(string.toString());
- /*if(!"0".equals(status) && status!=null) {
- query.setString("status", status);
- }*/
- if(!"0".equals(eventId) && eventId!=null) {
- query.setString("eventId", eventId);
- }
-
- //query.setDate("createTime",createTime);
-
- /*if( null!=createTime && endTime!= null) {
- query.setDate("startTime",createTime);
- query.setDate("endTime",endTime);
-
- }*/
- long l = (long)query.uniqueResult();
- int a = (int) l;
- //List<PerformanceHeader> list =query.list();
- session.flush();
- return a;
-
- }catch (Exception e){
-
- logger.error("exception occurred while performing PerformanceHeaderVmServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
-
- }
-
-
- @Override
- public int getAllCountByEventType(){
- try (Session session = sessionFactory.openSession()){
- StringBuffer count = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");
- /*if(!"0".equals(status)){
- count.append(" and a.status=:status");
- }*/
- Query query =session.createQuery(count.toString());
- /*query.setString("status",status);*/
- //int q = (int)query.uniqueResult();
- long q=(long)query.uniqueResult();
- session.flush();
- return (int)q;
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount."+e.getMessage());
- return 0;
- }
- }
-
-
-
-
-
- @Override
- public List<PerformanceHeaderVm> getAllByEventType(String eventName,String sourceName,String reportingEntityName, Date createTime, Date endTime){
- try (Session session = sessionFactory.openSession()){
- StringBuffer string = new StringBuffer("from PerformanceHeaderVm a where 1=1");
- /*if(!"0".equals(status)){
- string.append(" and a.status=:status");
- }*/
- if(!"0".equals(eventName) && eventName!=null){
- string.append(" and a.eventName=:eventName");
- }
- if(!"0".equals(sourceName) && sourceName!=null){
- string.append(" and a.sourceName=:sourceName");
- }
-
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null){
- string.append(" and a.reportingEntityName=:reportingEntityName");
- }
- if( null!=createTime && endTime!= null) {
- string.append(" and a.createTime between :startTime and :endTime");
- }
- Query query = session.createQuery(string.toString());
- /*if(!"0".equals(status)) {
- query.setString("status", status);
- }*/
- if(!"0".equals(eventName) && eventName!=null) {
- query.setString("eventName", eventName);
- }
- if(!"0".equals(sourceName) && sourceName!=null) {
- query.setString("sourceName", sourceName);
- }
-
- if(!"0".equals(reportingEntityName) && reportingEntityName!=null) {
- query.setString("reportingEntityName", reportingEntityName);
- }
- if( null!=createTime && endTime!= null) {
- query.setDate("startTime",createTime);
- query.setDate("endTime",endTime);
-
- }
-
- List<PerformanceHeaderVm> list =query.list();
-
- return list;
-
- }catch (Exception e){
-
- logger.error("exception occurred while performing PerformanceHeaderVmServiceImpl getAllCount."+e.getMessage());
- return null;
- }
-
-
-
- }
-
-
-
- @Override
- public String savePerformanceHeaderVm(PerformanceHeaderVm performanceHederVm) {
- try(Session session = sessionFactory.openSession();){
- if (null == performanceHederVm){
- logger.error("PerformanceHeaderServiceImpl savePerformanceHeaderVm performanceHeder is null!");
- }
- logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHederVm);
- Transaction tx = session.beginTransaction();
- session.save(performanceHederVm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
-
- @Override
- public String updatePerformanceHeaderVm(PerformanceHeaderVm performanceHederVm) {
- try(Session session = sessionFactory.openSession();){
- if (null == performanceHederVm){
- logger.error("PerformanceHeaderServiceImpl updatePerformanceHeaderVm performanceHeder is null!");
- }
- logger.info("PerformanceHeaderServiceImpl updatePerformanceHeader: performanceHeder={}", performanceHederVm);
- Transaction tx = session.beginTransaction();
- session.update(performanceHederVm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl updatePerformanceHeader. Details:" + e.getMessage());
- return "0";
- }
- }
-
-
- public int getAllCount(PerformanceHeaderVm performanceHederVm, int currentPage, int pageSize) {
- try(Session session = sessionFactory.openSession();){
- StringBuffer hql = new StringBuffer("select count(*) from PerformanceHeaderVm a where 1=1");
- if (null == performanceHederVm) {
- //logger.error("PerformanceHeaderServiceImpl getAllCount performanceHeder is null!");
- }else {
- if(null!=performanceHederVm.getVersion()) {
- String ver=performanceHederVm.getVersion();
- hql.append(" and a.version like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getEventName()) {
- String ver=performanceHederVm.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getDomain()) {
- String ver=performanceHederVm.getDomain();
- hql.append(" and a.domain like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getEventId()) {
- String ver=performanceHederVm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceHederVm.getNfcNamingCode()) {
- String ver=performanceHederVm.getNfcNamingCode();
- hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getNfNamingCode()) {
- String ver=performanceHederVm.getNfNamingCode();
- hql.append(" and a.nfNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getSourceId()) {
- String ver =performanceHederVm.getSourceId();
- hql.append(" and a.sourceId like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getSourceName()) {
- String ver =performanceHederVm.getSourceName();
- hql.append(" and a.sourceName like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getReportingEntityId()) {
- String ver =performanceHederVm.getReportingEntityId();
- hql.append(" and a.reportingEntityId like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getReportingEntityName()) {
- String ver =performanceHederVm.getReportingEntityName();
- hql.append(" and a.reportingEntityName like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getPriority()) {
- String ver =performanceHederVm.getPriority();
- hql.append(" and a.priority like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getStartEpochMicrosec()) {
- String ver =performanceHederVm.getStartEpochMicrosec();
- hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getLastEpochMicroSec()) {
- String ver =performanceHederVm.getLastEpochMicroSec();
- hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getSequence()) {
- String ver =performanceHederVm.getSequence();
- hql.append(" and a.sequence like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getMeasurementsForVfScalingVersion()) {
- String ver =performanceHederVm.getMeasurementsForVfScalingVersion();
- hql.append(" and a.measurementsForVfScalingVersion like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getMeasurementInterval()) {
- String ver =performanceHederVm.getMeasurementInterval();
- hql.append(" and a.measurementInterval like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getEventType()) {
- String ver =performanceHederVm.getEventType();
- hql.append(" and a.eventType like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getCreateTime() && null!=performanceHederVm.getUpdateTime()) {
- hql.append(" and a.createTime between :startTime and :endTime ");
- }
- }
- Query query = session.createQuery(hql.toString());
- if (null != performanceHederVm)
- if(null!=performanceHederVm.getCreateTime() && null!=performanceHederVm.getUpdateTime()) {
- query.setDate("startTime",performanceHederVm.getCreateTime()).setDate("endTime",performanceHederVm.getUpdateTime());
- }
- long q=(long)query.uniqueResult();
- session.flush();
- return (int)q;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<PerformanceHeaderVm> queryPerformanceHeaderVm(PerformanceHeaderVm performanceHederVm, int currentPage,
- int pageSize) {
- Page<PerformanceHeaderVm> page = new Page<PerformanceHeaderVm>();
- int allRow =this.getAllCount(performanceHederVm,currentPage,pageSize);
- int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = sessionFactory.openSession();){
- StringBuffer hql =new StringBuffer("from PerformanceHeaderVm a where 1=1");
- if (null == performanceHederVm) {
- //logger.error("PerformanceHeaderServiceImpl queryPerformanceHeaderVm performanceHeder is null!");
- }else {
- if(null!=performanceHederVm.getVersion()) {
- String ver=performanceHederVm.getVersion();
- hql.append(" and a.version like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getEventName()) {
- String ver=performanceHederVm.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getDomain()) {
- String ver=performanceHederVm.getDomain();
- hql.append(" and a.domain like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getEventId()) {
- String ver=performanceHederVm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceHederVm.getNfcNamingCode()) {
- String ver=performanceHederVm.getNfcNamingCode();
- hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getNfNamingCode()) {
- String ver=performanceHederVm.getNfNamingCode();
- hql.append(" and a.nfNamingCode like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getSourceId()) {
- String ver =performanceHederVm.getSourceId();
- hql.append(" and a.sourceId = '"+ver+"'");
- }
- if(null!=performanceHederVm.getSourceName()) {
- String ver =performanceHederVm.getSourceName();
- hql.append(" and a.sourceName like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getReportingEntityId()) {
- String ver =performanceHederVm.getReportingEntityId();
- hql.append(" and a.reportingEntityId like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getReportingEntityName()) {
- String ver =performanceHederVm.getReportingEntityName();
- hql.append(" and a.reportingEntityName like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getPriority()) {
- String ver =performanceHederVm.getPriority();
- hql.append(" and a.priority like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getStartEpochMicrosec()) {
- String ver =performanceHederVm.getStartEpochMicrosec();
- hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getLastEpochMicroSec()) {
- String ver =performanceHederVm.getLastEpochMicroSec();
- hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getSequence()) {
- String ver =performanceHederVm.getSequence();
- hql.append(" and a.sequence like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getMeasurementsForVfScalingVersion()) {
- String ver =performanceHederVm.getMeasurementsForVfScalingVersion();
- hql.append(" and a.measurementsForVfScalingVersion like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getMeasurementInterval()) {
- String ver =performanceHederVm.getMeasurementInterval();
- hql.append(" and a.measurementInterval like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getEventType()) {
- String ver =performanceHederVm.getEventType();
- hql.append(" and a.eventType like '%"+ver+"%'");
- }
- if(null!=performanceHederVm.getCreateTime() && null!=performanceHederVm.getUpdateTime()) {
- hql.append(" and a.createTime between :startTime and :endTime ");
- }
- }
- logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHederVm);
- Query query = session.createQuery(hql.toString());
- if (null != performanceHederVm)
- if(null!=performanceHederVm.getCreateTime() && null!=performanceHederVm.getUpdateTime()) {
- query.setDate("startTime",performanceHederVm.getCreateTime()).setDate("endTime",performanceHederVm.getUpdateTime());
- }
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<PerformanceHeaderVm> list= query.list();
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- return page;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl queryPerformanceHeader. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public List<PerformanceHeaderVm> queryId(String[] id) {
- try(Session session = sessionFactory.openSession();) {
- if(id.length==0) {
- logger.error("PerformanceHeaderServiceImpl queryId is null!");
- }
- List<PerformanceHeaderVm> list = new ArrayList<PerformanceHeaderVm>();
- Query query = session.createQuery("from PerformanceHeaderVm a where a.eventName IN (:alist)");
- list = query.setParameterList("alist", id).list();
- return list;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @Override
- public List<String> queryAllSourceId() {
- try(Session session = sessionFactory.openSession();) {
- Query query = session.createQuery("select a.sourceId from PerformanceHeaderVm 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/PerformanceInformationPmServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationPmServiceImpl.java
deleted file mode 100644
index 9c981863..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationPmServiceImpl.java
+++ /dev/null
@@ -1,301 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-import javax.persistence.Id;
-import javax.transaction.Transactional;
-
-import org.hibernate.*;
-import org.onap.usecaseui.server.bean.PerformanceInformationPm;
-import org.onap.usecaseui.server.service.PerformanceInformationPmService;
-
-import org.onap.usecaseui.server.util.Page;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.stereotype.Service;
-
-
-@Service("PerformanceInformationPmService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class PerformanceInformationPmServiceImpl implements PerformanceInformationPmService {
- private static final Logger logger = LoggerFactory.getLogger(PerformanceInformationPmServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
-
- @Override
- public List<PerformanceInformationPm> getAllPerformanceInformationByeventId(String eventId) {
- try (Session session = sessionFactory.openSession()){
- String string = "from PerformanceInformationPm a where 1=1 and a.eventId=:eventId";
- Query query = session.createQuery(string);
- query.setString("eventId",eventId);
- List<PerformanceInformationPm> list = query.list();
- session.flush();
- return list;
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl queryDateBetween. LIST:" + e.getMessage());
-
- return null;
- }
-
-
-
- }
-
-
- @Override
- public String savePerformanceInformationPm(PerformanceInformationPm performanceInformationPm) {
- try(Session session = sessionFactory.openSession();) {
- if (null == performanceInformationPm) {
- logger.error("performanceInformationPm savePerformanceInformationPm performanceInformationPm is null!");
- }
- logger.info("PerformanceInformationPmServiceImpl savePerformanceInformationPm: performanceInformationPm={}", performanceInformationPm);
- Transaction tx = session.beginTransaction();
- session.save(performanceInformationPm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl savePerformanceInformationPm. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
-
- @Override
- public String updatePerformanceInformationPm(PerformanceInformationPm performanceInformationPm) {
- try(Session session = sessionFactory.openSession();) {
- if (null == performanceInformationPm) {
- logger.error("performanceInformationPm updatePerformanceInformationPm performanceInformationPm is null!");
- }
- logger.info("PerformanceInformationPmServiceImpl updatePerformanceInformationPm: performanceInformationPm={}", performanceInformationPm);
- Transaction tx = session.beginTransaction();
- session.update(performanceInformationPm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl updatePerformanceInformationPm. Details:" + e.getMessage());
- return "0";
- }
- }
-
-
- public int getAllCount(PerformanceInformationPm performanceInformationPm, int currentPage, int pageSize) {
- try(Session session = sessionFactory.openSession();){
- StringBuffer hql = new StringBuffer("select count(*) from PerformanceInformationPm a where 1=1");
- if (null == performanceInformationPm) {
- //logger.error("AlarmsInformationServiceImpl getAllCount performanceInformationPm is null!");
- }else {
- if(null!=performanceInformationPm.getName()) {
- String ver=performanceInformationPm.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }
- if(null!=performanceInformationPm.getValue()) {
- String ver=performanceInformationPm.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }
- if(null!=performanceInformationPm.getEventId()) {
- String ver=performanceInformationPm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceInformationPm.getCreateTime()) {
- Date ver =performanceInformationPm.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }
- if(null!=performanceInformationPm.getUpdateTime()) {
- Date ver =performanceInformationPm.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- }
- long q=(long)session.createQuery(hql.toString()).uniqueResult();
- session.flush();
- return (int)q;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<PerformanceInformationPm> queryPerformanceInformationPm(PerformanceInformationPm performanceInformationPm,
- int currentPage, int pageSize) {
- Page<PerformanceInformationPm> page = new Page<PerformanceInformationPm>();
- int allRow =this.getAllCount(performanceInformationPm,currentPage,pageSize);
- int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = sessionFactory.openSession()){
- StringBuffer hql =new StringBuffer("from PerformanceInformationPm a where 1=1 ");
- if (null == performanceInformationPm) {
-
- }else {
- if(null!=performanceInformationPm.getName()) {
- String ver=performanceInformationPm.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }
- if(null!=performanceInformationPm.getValue()) {
- String ver=performanceInformationPm.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }
- if(null!=performanceInformationPm.getEventId()) {
- String ver=performanceInformationPm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceInformationPm.getCreateTime()) {
- Date ver =performanceInformationPm.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }
- if(null!=performanceInformationPm.getUpdateTime()) {
- Date ver =performanceInformationPm.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- }
- logger.info("PerformanceInformationPmServiceImpl queryPerformanceInformationPm: performanceInformationPm={}", performanceInformationPm);
- Query query = session.createQuery(hql.toString());
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<PerformanceInformationPm> list= query.list();
-
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- return page;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl queryPerformanceInformationPm. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public List<PerformanceInformationPm> queryId(String[] id) {
- try(Session session = sessionFactory.openSession();) {
- List<PerformanceInformationPm> list;
- Query query = session.createQuery("from PerformanceInformationPm a where a.eventId IN (:alist)");
- list = query.setParameterList("alist", id).list();
- return list;
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public List<PerformanceInformationPm> queryDateBetween(String eventId,Date startDate, Date endDate) {
- try(Session session = sessionFactory.openSession()) {
- List<PerformanceInformationPm> list ;
- Query query = session.createQuery("from PerformanceInformationPm 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("PerformanceInformationPmServiceImpl queryDateBetween: list={}", list);
- return list;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl queryDateBetween. Details:" + e.getMessage());
- return null;
- }
- }
-
-
-
- @Override
- public List<PerformanceInformationPm> queryDateBetween(String resourceId, String name, String startTime, String endTime) {
- try(Session session = sessionFactory.openSession()) {
- String hql = "from PerformanceInformationPm 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("PerformanceInformationPmServiceImpl queryDateBetween: list={}", query.list());
- return query.list();
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl queryDateBetween. Details:" + e.getMessage());
- return null;
- }
- }
-
- @Override
- public List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime) {
- try(Session session = sessionFactory.openSession()) {
- List<Map<String,String>> mapList = new ArrayList<>();
- String hql = "select a.createTime,max(a.value) from PerformanceInformationPm a where 1=1 ";
- if (sourceId != null && !"".equals(sourceId)){
- 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 ";
- }
- hql += " group by a.createTime";
- Query query = session.createQuery(hql);
- if (sourceId != null && !"".equals(sourceId)){
- query.setString("resourceId",sourceId);
- }
- 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);
- }
- 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("Max",res[1].toString());
- mapList.add(map);
- }
- logger.info("PerformanceInformationPmServiceImpl queryMaxValueByBetweenDate: maxValue={}", mapList.size());
- return mapList;
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("exception occurred while performing PerformanceInformationPmServiceImpl queryMaxValueByBetweenDate. 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 e205375b..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
@@ -17,7 +17,9 @@ package org.onap.usecaseui.server.service.impl;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
import javax.persistence.Id;
import javax.transaction.Transactional;
@@ -45,51 +47,9 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
private SessionFactory sessionFactory;
- private Session getSessionFactory(){
- return sessionFactory.openSession();
- }
- @Override
- public List<PerformanceInformation> getAllEventId() {
- try (Session session = getSessionFactory();){
- String hql = "from PerformanceInformation a where 1=1";
- Query query = session.createQuery(hql);
-
- /*if(eventId!=null && ""!=eventId){
- query.setString("eventId",eventId);
- }*/
- List<PerformanceInformation> list= query.list();
- session.flush();
- return list;
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceHeaderServiceImpl getEventServrity. Details:" + e.getMessage());
-
- return null;
- }
- }
-
- @Override
- public List<PerformanceInformation> getAllPerformanceInformationByeventId(String eventId) {
- try (Session session = getSessionFactory()){
- String string = "from PerformanceInformation a where 1=1 and a.eventId=:eventId";
- Query query = session.createQuery(string);
- query.setString("eventId",eventId);
- 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;
- }
-
-
-
- }
-
-
@Override
public String savePerformanceInformation(PerformanceInformation performanceInformation) {
- try(Session session = getSessionFactory();) {
+ try(Session session = sessionFactory.openSession();) {
if (null == performanceInformation) {
logger.error("performanceInformation savePerformanceInformation performanceInformation is null!");
}
@@ -109,7 +69,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@Override
public String updatePerformanceInformation(PerformanceInformation performanceInformation) {
- try(Session session = getSessionFactory();) {
+ try(Session session = sessionFactory.openSession();) {
if (null == performanceInformation) {
logger.error("performanceInformation updatePerformanceInformation performanceInformation is null!");
}
@@ -127,10 +87,10 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
public int getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize) {
- try(Session session = getSessionFactory();){
+ try(Session session = sessionFactory.openSession();){
StringBuffer hql = new StringBuffer("select count(*) from PerformanceInformation a where 1=1");
if (null == performanceInformation) {
- //logger.error("PerformanceInformationServiceImpl getAllCount performanceInformation is null!");
+ //logger.error("AlarmsInformationServiceImpl getAllCount performanceInformation is null!");
}else {
if(null!=performanceInformation.getName()) {
String ver=performanceInformation.getName();
@@ -170,10 +130,10 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
int allRow =this.getAllCount(performanceInformation,currentPage,pageSize);
int offset = page.countOffset(currentPage, pageSize);
- try(Session session = getSessionFactory()){
+ try(Session session = sessionFactory.openSession();){
StringBuffer hql =new StringBuffer("from PerformanceInformation a where 1=1 ");
if (null == performanceInformation) {
-
+ //logger.error("AlarmsInformationServiceImpl queryPerformanceInformation performanceInformation is null!");
}else {
if(null!=performanceInformation.getName()) {
String ver=performanceInformation.getName();
@@ -218,8 +178,11 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@SuppressWarnings("unchecked")
@Override
public List<PerformanceInformation> queryId(String[] id) {
- try(Session session = getSessionFactory();) {
- List<PerformanceInformation> list;
+ try(Session session = sessionFactory.openSession();) {
+ if(id.length==0) {
+ //logger.error("PerformanceInformationServiceImpl queryId is null!");
+ }
+ List<PerformanceInformation> list = new ArrayList<>();
Query query = session.createQuery("from PerformanceInformation a where a.eventId IN (:alist)");
list = query.setParameterList("alist", id).list();
return list;
@@ -231,11 +194,11 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
}
- /*@SuppressWarnings("unchecked")*/
+ @SuppressWarnings("unchecked")
@Override
public List<PerformanceInformation> queryDateBetween(String eventId,Date startDate, Date endDate) {
- try(Session session = getSessionFactory()) {
- List<PerformanceInformation> list ;
+ try(Session session = sessionFactory.openSession();) {
+ 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);
@@ -247,10 +210,25 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public int queryDataBetweenSum(String eventId, String name, Date startDate, Date endDate){
+
+ try(Session session = sessionFactory.openSession();) {
+ 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());
+ return 0;
+ }
+ }
@Override
public List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime) {
- try(Session session = getSessionFactory()) {
+ try(Session session = sessionFactory.openSession();) {
String hql = "from PerformanceInformation a where 1=1 ";
if (resourceId != null && !"".equals(resourceId)){
hql += " and a.eventId = :resourceId";
@@ -279,45 +257,4 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
}
}
- @Override
- public List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime) {
- try(Session session = getSessionFactory()) {
- List<Map<String,String>> mapList = new ArrayList<>();
- String hql = "select a.createTime,max(a.value) from PerformanceInformation a where 1=1 ";
- if (sourceId != null && !"".equals(sourceId)){
- 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 ";
- }
- hql += " group by a.createTime";
- Query query = session.createQuery(hql);
- if (sourceId != null && !"".equals(sourceId)){
- query.setString("resourceId",sourceId);
- }
- 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);
- }
- 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("Max",res[1].toString());
- mapList.add(map);
- }
- logger.info("PerformanceInformationServiceImpl queryMaxValueByBetweenDate: maxValue={}", mapList.size());
- return mapList;
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("exception occurred while performing PerformanceInformationServiceImpl queryMaxValueByBetweenDate. Details:" + e.getMessage());
- return null;
- }
- }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationVmServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationVmServiceImpl.java
deleted file mode 100644
index fb7b7129..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationVmServiceImpl.java
+++ /dev/null
@@ -1,302 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-import javax.persistence.Id;
-import javax.transaction.Transactional;
-
-import org.hibernate.*;
-import org.onap.usecaseui.server.bean.PerformanceInformationVm;
-import org.onap.usecaseui.server.service.PerformanceInformationVmService;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.stereotype.Service;
-
-
-@Service("PerformanceInformationVmService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class PerformanceInformationVmServiceImpl implements PerformanceInformationVmService {
- private static final Logger logger = LoggerFactory.getLogger(PerformanceInformationVmServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
-
- @Override
- public List<PerformanceInformationVm> getAllPerformanceInformationByeventId(String eventId) {
- try (Session session = sessionFactory.openSession()){
- String string = "from PerformanceInformationVm a where 1=1 and a.eventId=:eventId";
- Query query = session.createQuery(string);
- query.setString("eventId",eventId);
- List<PerformanceInformationVm> list = query.list();
- session.flush();
- return list;
- }catch (Exception e){
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl queryDateBetween. LIST:" + e.getMessage());
-
- return null;
- }
-
-
-
- }
-
-
-
- @Override
- public String savePerformanceInformationVm(PerformanceInformationVm performanceInformationVm) {
- try(Session session = sessionFactory.openSession();) {
- if (null == performanceInformationVm) {
- logger.error("performanceInformationVm savePerformanceInformationVm performanceInformationVm is null!");
- }
- logger.info("PerformanceInformationVmServiceImpl savePerformanceInformationVm: performanceInformationVm={}", performanceInformationVm);
- Transaction tx = session.beginTransaction();
- session.save(performanceInformationVm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl savePerformanceInformationVm. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
-
- @Override
- public String updatePerformanceInformationVm(PerformanceInformationVm performanceInformationVm) {
- try(Session session = sessionFactory.openSession();) {
- if (null == performanceInformationVm) {
- logger.error("performanceInformationVm updatePerformanceInformationVm performanceInformationVm is null!");
- }
- logger.info("PerformanceInformationVmServiceImpl updatePerformanceInformationVm: performanceInformationVm={}", performanceInformationVm);
- Transaction tx = session.beginTransaction();
- session.update(performanceInformationVm);
- tx.commit();
- session.flush();
- return "1";
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl updatePerformanceInformationVm. Details:" + e.getMessage());
- return "0";
- }
- }
-
-
- public int getAllCount(PerformanceInformationVm performanceInformationVm, int currentPage, int pageSize) {
- try(Session session = sessionFactory.openSession();){
- StringBuffer hql = new StringBuffer("select count(*) from PerformanceInformationVm a where 1=1");
- if (null == performanceInformationVm) {
- //logger.error("AlarmsInformationServiceImpl getAllCount performanceInformationVm is null!");
- }else {
- if(null!=performanceInformationVm.getName()) {
- String ver=performanceInformationVm.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }
- if(null!=performanceInformationVm.getValue()) {
- String ver=performanceInformationVm.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }
- if(null!=performanceInformationVm.getEventId()) {
- String ver=performanceInformationVm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceInformationVm.getCreateTime()) {
- Date ver =performanceInformationVm.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }
- if(null!=performanceInformationVm.getUpdateTime()) {
- Date ver =performanceInformationVm.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- }
- long q=(long)session.createQuery(hql.toString()).uniqueResult();
- session.flush();
- return (int)q;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<PerformanceInformationVm> queryPerformanceInformationVm(PerformanceInformationVm performanceInformationVm,
- int currentPage, int pageSize) {
- Page<PerformanceInformationVm> page = new Page<PerformanceInformationVm>();
- int allRow =this.getAllCount(performanceInformationVm,currentPage,pageSize);
- int offset = page.countOffset(currentPage, pageSize);
-
- try(Session session = sessionFactory.openSession()){
- StringBuffer hql =new StringBuffer("from PerformanceInformationVm a where 1=1 ");
- if (null == performanceInformationVm) {
-
- }else {
- if(null!=performanceInformationVm.getName()) {
- String ver=performanceInformationVm.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }
- if(null!=performanceInformationVm.getValue()) {
- String ver=performanceInformationVm.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }
- if(null!=performanceInformationVm.getEventId()) {
- String ver=performanceInformationVm.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }
- if(null!=performanceInformationVm.getCreateTime()) {
- Date ver =performanceInformationVm.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }
- if(null!=performanceInformationVm.getUpdateTime()) {
- Date ver =performanceInformationVm.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- }
- logger.info("PerformanceInformationVmServiceImpl queryPerformanceInformationVm: performanceInformationVm={}", performanceInformationVm);
- Query query = session.createQuery(hql.toString());
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<PerformanceInformationVm> list= query.list();
-
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- return page;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl queryPerformanceInformationVm. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public List<PerformanceInformationVm> queryId(String[] id) {
- try(Session session = sessionFactory.openSession();) {
- List<PerformanceInformationVm> list;
- Query query = session.createQuery("from PerformanceInformationVm a where a.eventId IN (:alist)");
- list = query.setParameterList("alist", id).list();
- return list;
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public List<PerformanceInformationVm> queryDateBetween(String eventId,Date startDate, Date endDate) {
- try(Session session = sessionFactory.openSession()) {
- List<PerformanceInformationVm> list ;
- Query query = session.createQuery("from PerformanceInformationVm 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("PerformanceInformationVmServiceImpl queryDateBetween: list={}", list);
- return list;
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl queryDateBetween. Details:" + e.getMessage());
- return null;
- }
- }
-
-
-
- @Override
- public List<PerformanceInformationVm> queryDateBetween(String resourceId, String name, String startTime, String endTime) {
- try(Session session = sessionFactory.openSession()) {
- String hql = "from PerformanceInformationVm 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("PerformanceInformationVmServiceImpl queryDateBetween: list={}", query.list());
- return query.list();
- } catch (Exception e) {
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl queryDateBetween. Details:" + e.getMessage());
- return null;
- }
- }
-
- @Override
- public List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime) {
- try(Session session = sessionFactory.openSession()) {
- List<Map<String,String>> mapList = new ArrayList<>();
- String hql = "select a.createTime,max(a.value) from PerformanceInformationVm a where 1=1 ";
- if (sourceId != null && !"".equals(sourceId)){
- 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 ";
- }
- hql += " group by a.createTime";
- Query query = session.createQuery(hql);
- if (sourceId != null && !"".equals(sourceId)){
- query.setString("resourceId",sourceId);
- }
- 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);
- }
- 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("Max",res[1].toString());
- mapList.add(map);
- }
- logger.info("PerformanceInformationVmServiceImpl queryMaxValueByBetweenDate: maxValue={}", mapList.size());
- return mapList;
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("exception occurred while performing PerformanceInformationVmServiceImpl queryMaxValueByBetweenDate. Details:" + e.getMessage());
- return null;
- }
- }
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java b/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java
index 17e590f5..0d294d1a 100755
--- a/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java
+++ b/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java
@@ -23,33 +23,103 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Date;
public class DateUtils {
- /**
- * 获取两个日期之间的日期
- * @param start 开始日期
- * @param end 结束日期
- * @return 日期集合
- */
- public static List<Date> getBetweenDates(Date start, Date end) {
- List<Date> result = new ArrayList<Date>();
- Calendar tempStart = Calendar.getInstance();
- tempStart.setTime(start);
- tempStart.add(Calendar.DAY_OF_YEAR, 1);
-
- Calendar tempEnd = Calendar.getInstance();
- tempEnd.setTime(end);
- while (tempStart.before(tempEnd)) {
- result.add(tempStart.getTime());
- tempStart.add(Calendar.DAY_OF_YEAR, 1);
- }
- return result;
+
+
+ public static String initDate(Date d,int year,int month,int day,int hour,int minute,int second) throws ParseException {
+ Instant instant = d.toInstant();
+ ZoneId zone = ZoneId.systemDefault();
+ LocalDateTime ldt = LocalDateTime.ofInstant(instant,zone);
+ if(year >= 0){
+ if(year == 0)
+ ldt = ldt.withYear(1);
+ } else
+ ldt = ldt.withYear(ldt.getYear()-1);
+ if(month >= 0){
+ if(month == 0)
+ ldt = ldt.withMonth(1);
+ } else
+ ldt = ldt.withMonth(ldt.getMonthValue()-1);
+ if(day >= 0){
+ if(day == 0)
+ ldt = ldt.withDayOfMonth(1);
+ } else
+ ldt = ldt.withDayOfMonth(ldt.getDayOfMonth()-1<1?ldt.getDayOfMonth():ldt.getDayOfMonth()+-1);
+ if(hour >= 0){
+ if(hour == 0)
+ ldt = ldt.withHour(0);
+ } else
+ ldt = ldt.withHour(ldt.getHour()-1);
+ if(minute >= 0){
+ if(minute == 0)
+ ldt = ldt.withMinute(0);
+ } else
+ ldt = ldt.withMinute(ldt.getMinute()-1);
+ if(second >= 0){
+ if(second == 0)
+ ldt = ldt.withSecond(0);
+ } else
+ ldt = ldt.withMinute(ldt.getSecond()-1);
+ return ldt.format(DateTimeFormatter.ofPattern(Constant.DATE_FORMAT));
}
+
+
+ /**
+ * param except data ,if int equal 0 then cleared zero,
+ * if equal -1 then minus 1 ,else unchanging
+ * @param d
+ * @param year
+ * @param month
+ * @param hour
+ * @param minute
+ * @param second
+ * @return
+ * @throws ParseException
+ */
+ public static Date initProcessDate(Date d,int year,int month,int day,int hour,int minute,int second) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat(Constant.DATE_FORMAT);
+ Calendar c = Calendar.getInstance();
+ c.setTime(d);
+ if(year >= 0){
+ if(year == 0)
+ c.set(Calendar.YEAR,0);
+ } else
+ c.set(Calendar.YEAR,c.get(Calendar.YEAR)-1);
+ if(month >= 0){
+ if(month == 0)
+ c.set(Calendar.MONTH,0);
+ } else
+ c.set(Calendar.MONTH,c.get(Calendar.MONTH)-1);
+ if(day >= 0){
+ if(day == 0)
+ c.set(Calendar.DAY_OF_MONTH,0);
+ } else
+ c.set(Calendar.DAY_OF_MONTH,c.get(Calendar.DAY_OF_MONTH)-1);
+ if(hour >= 0){
+ if(hour == 0)
+ c.set(Calendar.HOUR_OF_DAY,0);
+ } else
+ c.set(Calendar.HOUR_OF_DAY,c.get(Calendar.HOUR_OF_DAY)-1);
+ if(minute >= 0){
+ if(minute == 0)
+ c.set(Calendar.MINUTE,0);
+ } else
+ c.set(Calendar.MINUTE,c.get(Calendar.MINUTE)-1);
+ if(second >= 0){
+ if(second == 0)
+ c.set(Calendar.SECOND,0);
+ } else
+ c.set(Calendar.SECOND,c.get(Calendar.SECOND)-1);
+ return sdf.parse(sdf.format(c.getTime()));
+ }
+
/**
*
* @param d
@@ -110,74 +180,4 @@ public class DateUtils {
return new SimpleDateFormat(Constant.DATE_FORMAT).parse(dateToString(new Date()));
}
- public String getYearMonthDayHourMinuteSecond(long timeMillis) {
- Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
- calendar.setTimeInMillis(timeMillis);
- int year=calendar.get(Calendar.YEAR);
-
- int month=calendar.get(Calendar.MONTH) + 1;
- String mToMonth=null;
- if (String.valueOf(month).length()==1) {
- mToMonth="0"+month;
- } else {
- mToMonth=String.valueOf(month);
- }
-
- int day=calendar.get(Calendar.DAY_OF_MONTH);
- String dToDay=null;
- if (String.valueOf(day).length()==1) {
- dToDay="0"+day;
- } else {
- dToDay=String.valueOf(day);
- }
-
- int hour=calendar.get(Calendar.HOUR_OF_DAY);
- String hToHour=null;
- if (String.valueOf(hour).length()==1) {
- hToHour="0"+hour;
- } else {
- hToHour=String.valueOf(hour);
- }
-
- int minute=calendar.get(Calendar.MINUTE);
- String mToMinute=null;
- if (String.valueOf(minute).length()==1) {
- mToMinute="0"+minute;
- } else {
- mToMinute=String.valueOf(minute);
- }
-
- int second=calendar.get(Calendar.SECOND);
- String sToSecond=null;
- if (String.valueOf(second).length()==1) {
- sToSecond="0"+second;
- } else {
- sToSecond=String.valueOf(second);
- }
- return year+ "-" +mToMonth+ "-" +dToDay+ " "+hToHour+ ":" +mToMinute+ ":" +sToSecond;
- }
-
-
-
- public static void main(String[] args) {
- // System.out.println(new DateUtils().getYearMonthDayHourMinuteSecond(System.currentTimeMillis()));
- String startime_s = "2017-10-31";
- String endtime_s = "2017-12-24";
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- Date startime = null;
- Date endtime =null;
- try {
- startime = formatter.parse(startime_s);
- endtime = formatter.parse(endtime_s);
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
-
- List<Date> result =getBetweenDates(startime,endtime);
-
- System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaa===="+result);
-
- }
-
}
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 05e40c5e..199bc7e4 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
@@ -17,28 +17,31 @@ package org.onap.usecaseui.server.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.glassfish.jersey.client.ClientConfig;
-import org.onap.usecaseui.server.bean.*;
+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.*;
+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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
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.IOException;
-import java.io.InputStream;
-import java.sql.Timestamp;
+import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.*;
-@Component
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
public class DmaapSubscriber implements Runnable {
private Logger logger = LoggerFactory.getLogger(DmaapSubscriber.class);
@@ -55,7 +58,6 @@ public class DmaapSubscriber implements Runnable {
@Resource(name = "AlarmsHeaderService")
private AlarmsHeaderService alarmsHeaderService;
-
@Resource(name = "AlarmsInformationService")
private AlarmsInformationService alarmsInformationService;
@@ -65,53 +67,63 @@ public class DmaapSubscriber implements Runnable {
@Resource(name = "PerformanceInformationService")
private PerformanceInformationService performanceInformationService;
- @Resource(name = "PerformanceHeaderPmService")
- private PerformanceHeaderPmService performanceHeaderPmService;
-
- @Resource(name = "PerformanceInformationPmService")
- private PerformanceInformationPmService performanceInformationPmService;
-
- @Resource(name = "PerformanceHeaderVmService")
- private PerformanceHeaderVmService performanceHeaderVmService;
-
- @Resource(name = "PerformanceInformationVmService")
- private PerformanceInformationVmService performanceInformationVmService;
-
public void subscribe(String topic) {
+ String response;
try {
- List<String> respList = getDMaaPData(topic);
- if (respList.size() <= 0 || respList == null) {
+ response = getDMaaPData(topic);
+ logger.info(response);
+ if (response == null && "".equals(response)) {
logger.info("response is null");
return;
- }
- ObjectMapper objMapper = new ObjectMapper();
- objMapper.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
- respList.forEach(rl -> {
- logger.info(rl);
- try {
- Map<String, Object> eventMaps = (Map<String, Object>) objMapper.readValue(rl, Map.class).get("event");
+ } 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");
+
if (eventMaps.containsKey("measurementsForVfScalingFields")) {
performanceProcess(eventMaps);
} else if (eventMaps.containsKey("faultFields")) {
alarmProcess(eventMaps);
}
- } catch (IOException e) {
- e.printStackTrace();
+ } else {
+ logger.error("unknown json type!");
}
- });
-
+ }
} catch (Exception e) {
- e.printStackTrace();
logger.error("getDMaaP Information failed :" + e.getMessage());
}
}
- private List<String> getDMaaPData(String topic) {
+ private String getDMaaPData(String topic) {
Client client = ClientBuilder.newClient(new ClientConfig());
WebTarget webTarget = client.target(url + "/" + topic + "/" + consumerGroup + "/" + consumer);
- logger.info("target:" + url + "/" + topic + "/" + consumerGroup + "/" + consumer);
Response response = webTarget.queryParam("timeout", timeout).request().get();
- return response.readEntity(List.class);
+ return response.readEntity(String.class);
}
private void initConfig() {
@@ -134,12 +146,8 @@ public class DmaapSubscriber implements Runnable {
try {
initConfig();
while (isActive) {
- logger.info("alarm data subscription is starting......");
subscribe(alarmTopic);
- logger.info("alarm data subscription has finished.");
- logger.info("performance data subscription is starting......");
subscribe(performanceTopic);
- logger.info("performance data subscription has finished.");
}
} catch (Exception e) {
try {
@@ -147,9 +155,7 @@ public class DmaapSubscriber implements Runnable {
} catch (InterruptedException e1) {
e1.printStackTrace();
}
- e.printStackTrace();
logger.error("subscribe raise error :" + e.getCause());
- run();
}
}
@@ -212,7 +218,40 @@ public class DmaapSubscriber implements Runnable {
try {
List<Map<String, Object>> m = (List<Map<String, Object>>) v3;
m.forEach(i -> {
- alarm_informations.add(new AlarmsInformation(i.get("name").toString(), i.get("value").toString(), alarm_header.getSourceId(), new Date(), null));
+ 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();
@@ -220,235 +259,136 @@ public class DmaapSubscriber implements Runnable {
}
}
});
-
- }
- });
- if (alarm_header.getEventName() != null){
- alarm_informations.forEach(ai -> {
- ai.setCreateTime(alarm_header.getCreateTime());
- ai.setUpdateTime(new Date());
- });
-
- // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Long l = System.currentTimeMillis();
-
- Timestamp date_get = new Timestamp(l); //2013-01-14 22:45:36.484
- if (alarm_header.getEventName().contains("Cleared")) {
- alarm_header.setStatus("close");
- logger.info("alarmCleared data header insert is starting......");
-
- alarmsHeaderService.updateAlarmsHeader2018("close", date_get, alarm_header.getStartEpochMicrosec(), alarm_header.getLastEpochMicroSec(), alarm_header.getEventName().replace("Cleared", ""), alarm_header.getReportingEntityName(), alarm_header.getSpecificProblem());
-
- logger.info("alarmCleared data header insert has finished.");
- logger.info("alarmCleared data detail insert is starting......");
- alarm_informations.forEach(information ->
- alarmsInformationService.saveAlarmsInformation(information));
-
- logger.info("alarmCleared data detail insert has finished. " + alarm_informations.size() + " records have been inserted.");
- } else {
- alarm_header.setCreateTime(new Date());
- alarm_header.setStatus("active");
-
-
- logger.info("alarm data header insert is starting......");
-
+ 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);
-
- logger.info("alarm data header insert has finished.");
- logger.info("alarm data detail insert is starting......");
- if(alarm_informations.size() > 0) {
alarm_informations.forEach(information ->
alarmsInformationService.saveAlarmsInformation(information));
- logger.info("alarm data detail insert has finished. " + alarm_informations.size() + " records have been inserted.");
}
}
- }
+ });
}
- private void performanceProcess(Map<String, Object> eventMap) {
+ private void performanceProcess(Map<String, Object> maps) {
PerformanceHeader performance_header = new PerformanceHeader();
List<PerformanceInformation> performance_informations = new ArrayList<>();
-
- PerformanceHeaderPm performance_headerPm = new PerformanceHeaderPm();
- List<PerformanceInformationPm> performance_informationsPm = new ArrayList<>();
-
-
- PerformanceHeaderVm performance_headerVm = new PerformanceHeaderVm();
- List<PerformanceInformationVm> performance_informationsVm = new ArrayList<>();
-
- 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 -> {
- 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")){
-
- 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.setCreateTime(DateUtils.stringToDate(fields.get("value").replaceAll(Constant.RegEX_DATE_FORMAT, " ")));
- performance_header.setUpdateTime(DateUtils.now());
-
- } catch (ParseException e) {
- e.printStackTrace();
+ 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;
}
- }else{
- try {
- performance_informations.add(new PerformanceInformation(fields.get("name"), fields.get("value"), performance_header.getSourceId(), null, DateUtils.now()));
- } catch (ParseException e) {
- e.printStackTrace();
+ 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];
}
- } );
- }
- });
- });
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("convert performanceAdditionalInformation error:" + e.getMessage());
- }
+ } 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);
+ });
}
});
}
});
- if (performance_header.getSourceId() !=null && performance_informations.size() > 0 ){
-
- String version = performance_header.getVersion();
- String eventName = performance_header.getEventName();
- String domain = performance_header.getDomain();
- String eventId = performance_header.getEventId();
- String eventType = performance_header.getEventType();
- String nfcNamingCode = performance_header.getNfcNamingCode();
- String nfNamingCode = performance_header.getNfNamingCode();
- String sourceId = performance_header.getSourceId();
- String sourceName = performance_header.getSourceName();
- String reportingEntityId = performance_header.getReportingEntityId();
- String reportingEntityName = performance_header.getReportingEntityName();
- String priority = performance_header.getPriority();
- String startEpochMicrosec = performance_header.getStartEpochMicrosec();
- String lastEpochMicroSec = performance_header.getLastEpochMicroSec();
- String sequence = performance_header.getSequence();
- String measurementsForVfScalingVersion = performance_header.getMeasurementsForVfScalingVersion();
- String measurementInterval = performance_header.getMeasurementInterval();
- Date createTime = performance_header.getCreateTime();
- Date updateTime = performance_header.getUpdateTime();
-
-
-
-
-
-
-
-
- if("guestOS".equals(performance_header.getEventType())){
- performance_headerVm = new PerformanceHeaderVm(
- version, eventName, domain, eventId, eventType, nfcNamingCode,
- nfNamingCode, sourceId, sourceName, reportingEntityId, reportingEntityName,
- priority, startEpochMicrosec, lastEpochMicroSec, sequence, measurementsForVfScalingVersion,
- measurementInterval, createTime, updateTime
-
- );
- logger.info("performance data header insert is starting......");
- performanceHeaderVmService.savePerformanceHeaderVm(performance_headerVm);
- logger.info("performance data header insert has finished.");
- logger.info("performance data detail insert is starting......");
- performance_informationsVm.forEach(aiVm -> {
- aiVm.setCreateTime(performance_header.getCreateTime());
- performanceInformationVmService.savePerformanceInformationVm(aiVm);
- });
- logger.info("performance data detail insert has finished. " + performance_informationsVm.size() + " records have been inserted.");
-
-
-
-
- }else if("hostOS".equals(performance_header.getEventType())){
-
- performance_headerPm = new PerformanceHeaderPm(
- version, eventName, domain, eventId, eventType, nfcNamingCode,
- nfNamingCode, sourceId, sourceName, reportingEntityId, reportingEntityName,
- priority, startEpochMicrosec, lastEpochMicroSec, sequence, measurementsForVfScalingVersion,
- measurementInterval, createTime, updateTime
-
- );
-
-
-
- logger.info("performance data header insert is starting......");
- performanceHeaderPmService.savePerformanceHeaderPm(performance_headerPm);
- logger.info("performance data header insert has finished.");
- logger.info("performance data detail insert is starting......");
- performance_informationsPm.forEach(aiPm -> {
- aiPm.setCreateTime(performance_header.getCreateTime());
- performanceInformationPmService.savePerformanceInformationPm(aiPm);
- });
- logger.info("performance data detail insert has finished. " + performance_informationsPm.size() + " records have been inserted.");
-
-
-
- }else{
-
-
-
-
- logger.info("performance data header insert is starting......");
- performanceHeaderService.savePerformanceHeader(performance_header);
- logger.info("performance data header insert has finished.");
- logger.info("performance data detail insert is starting......");
- performance_informations.forEach(ai -> {
- ai.setCreateTime(performance_header.getCreateTime());
- performanceInformationService.savePerformanceInformation(ai);
- });
- logger.info("performance data detail insert has finished. " + performance_informations.size() + " records have been inserted.");
-
- }
- }
-
-
-
-
-
}
} \ No newline at end of file
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/Page.java b/server/src/main/java/org/onap/usecaseui/server/util/Page.java
index 6bd830ea..fd7665f5 100644
--- a/server/src/main/java/org/onap/usecaseui/server/util/Page.java
+++ b/server/src/main/java/org/onap/usecaseui/server/util/Page.java
@@ -19,13 +19,13 @@ import java.util.List;
public class Page<E> {
- public List<E> list;
+ private List<E> list;
- public int totalRecords;
+ private int totalRecords;
- public int pageSize;
+ private int pageSize;
- public int pageNo;
+ private int pageNo;
diff --git a/server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java b/server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java
new file mode 100644
index 00000000..17997116
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+package org.onap.usecaseui.server.wrapper;
+
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+
+public class AlarmWrapper {
+
+ private AlarmsHeader alarmsHeader;
+
+ private AlarmsInformation alarmsInformation;
+
+ private int currentPage = 1;
+
+ private int pageSize = 100;
+
+
+ public AlarmsHeader getAlarmsHeader() {
+ return alarmsHeader;
+ }
+
+ public void setAlarmsHeader(AlarmsHeader alarmsHeader) {
+ this.alarmsHeader = alarmsHeader;
+ }
+
+ public AlarmsInformation getAlarmsInformation() {
+ return alarmsInformation;
+ }
+
+ public void setAlarmsInformation(AlarmsInformation alarmsInformation) {
+ this.alarmsInformation = alarmsInformation;
+ }
+
+ public int getCurrentPage() {
+ return currentPage;
+ }
+
+ public void setCurrentPage(int currentPage) {
+ this.currentPage = currentPage;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java b/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java
index f130ef98..ae1e2990 100644
--- a/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java
+++ b/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java
@@ -16,55 +16,37 @@
package org.onap.usecaseui.server;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
import java.text.ParseException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest
public class UsecaseuiServerApplicationTests {
- @Test
- public void contextLoads() {
- String data = "";
- try {
- BufferedReader br = new BufferedReader(new FileReader("src/main/resources/topologyD_data.json"));
- String tmpStr = "";
- while ((tmpStr=br.readLine()) != null){
- data += tmpStr;
- }
- br.close();
- //System.out.println(data);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- ObjectMapper om = new ObjectMapper();
- try {
- Map<String,Object> map = om.readValue(data, Map.class);
- List<Map<String,Object>> list = (List<Map<String, Object>>) map.get("services");
- list.forEach( i -> {
- i.forEach( (k,v) ->{
- System.out.println(k+"_"+v);
- } );
- });
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+
+
+ @Test
+ public void contextLoads() throws JsonProcessingException, ParseException {
+ /*ObjectMapper objectMapper = new ObjectMapper();
+ AlarmsHeader alarmsHeader = new AlarmsHeader();
+ alarmsHeader.setAlarmCondition("send to my phone");
+ alarmsHeader.setAlarmInterfaceA("Baby have no fear");
+ alarmsHeader.setCreateTime(new Date());
+ alarmsHeader.setDomain("Hope they ready");
+ List<AlarmsHeader> alarmsHeaders = new ArrayList<>();
+ alarmsHeaders.add(alarmsHeader);
+ alarmsHeaders.add(alarmsHeader);
+ alarmsHeaders.add(alarmsHeader);
+ Map<String,Object> map = new HashMap<>();
+ map.put("alarms",alarmsHeaders);
+ map.put("asd",alarmsHeader);
+ String jsonStr = objectMapper.writeValueAsString(map);
+ System.out.println(jsonStr);*/
+ //System.out.println(alarmsInformationService.saveAlarmsInformation(new AlarmsInformation("11","22","123",new Date(),new Date())));
+ }
}
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 bd3c0a9a..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
@@ -13,469 +13,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.usecaseui.server.controller;
+package org.onap.usecaseui.server.controller;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
import org.onap.usecaseui.server.service.AlarmsInformationService;
+import org.onap.usecaseui.server.util.CSVUtils;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import javax.annotation.Resource;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
-import static org.mockito.Mockito.*;
-
-/**
-* AlarmController Tester.
-*
-* @author <Authors name>
-* @since <pre>���� 6, 2018</pre>
-* @version 1.0
-*/
+@RunWith(SpringRunner.class)
+@SpringBootTest
public class AlarmControllerTest {
- AlarmController controller = new AlarmController();
- AlarmsHeaderService service;
- AlarmsInformationService alService;
-@Before
-public void before() throws Exception {
- service = mock(AlarmsHeaderService.class);
- alService = mock(AlarmsInformationService.class);
- controller.setAlarmsHeaderService(service);
- controller.setAlarmsInformationService(alService);
-}
-
-@After
-public void after() throws Exception {
-}
-
-/**
-*
-* Method: setAlarmsHeaderService(AlarmsHeaderService alarmsHeaderService)
-*
-*/
-@Test
-public void testSetAlarmsHeaderService() throws Exception {
-//TODO: Test goes here...
-}
-
-/**
-*
-* Method: setAlarmsInformationService(AlarmsInformationService alarmsInformationService)
-*
-*/
-@Test
-public void testSetAlarmsInformationService() throws Exception {
-//TODO: Test goes here...
-}
-
-/**
-*
-* Method: getAlarmData(@PathVariable int currentPage, @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, @PathVariable(required = false) String vfStatus)
-*
-*/
-@Test
-public void testGetAlarmData() throws Exception {
-//TODO: Test goes here...
- AlarmController controller = new AlarmController();
- AlarmsHeaderService service = mock(AlarmsHeaderService.class);
- controller.setAlarmsHeaderService(service);
- AlarmsHeader header = new AlarmsHeader();
- int currentPage=1;
- int pageSize=10;
- //String sourceId="shentao-test-1003";
- //String sourceName="shentao-test-1003";
- //String priority="High";
- //String startTime="2017-10-31 09:51";
- //String endTime="2018-03-15 00:00";
- //String vfStatus="Active";
- String sourceId="11694_113";
- String sourceName="11694_113";
- String priority="High";
- String startTime="2017-10-31 09:52:15";
- String endTime="2017-11-15 15:27:16";
- String vfStatus="Medium";
- /*String sourceId=null;
- String sourceName=null;
- String priority=null;
- String startTime=null;
- String endTime=null;
- String vfStatus=null;*/
-
- header.setPriority(priority);
- header.setStatus(vfStatus);
- header.setSourceId(sourceId);
- header.setSourceName(sourceName);
-
-
-
- controller.getAlarmData(currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime,vfStatus);
- verify(service,times(1)).queryAlarmsHeader(header,currentPage,pageSize);
-}
-
- @Test
- public void testGetAlarmData_a() throws Exception {
-//TODO: Test goes here...
-
- AlarmController controller = new AlarmController();
- AlarmsHeaderService service = mock(AlarmsHeaderService.class);
- controller.setAlarmsHeaderService(service);
- AlarmsHeader header = new AlarmsHeader();
- int currentPage=1;
- int pageSize=10;
-
- String sourceId=null;
- String sourceName=null;
- String priority=null;
- String startTime=null;
- String endTime=null;
- String vfStatus=null;
-
-
- header.setPriority(priority);
- header.setStatus(vfStatus);
- header.setSourceId(sourceId);
- header.setSourceName(sourceName);
-
-
-
- controller.getAlarmData(currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime,vfStatus);
- verify(service,times(1)).queryAlarmsHeader(header,currentPage,pageSize);
- }
-
-
-/**
-*
-* Method: getStatusCount()
-*
-*/
-@Test
-public void testGetStatusCount() throws Exception {
-//TODO: Test goes here...
- AlarmController controller = new AlarmController();
- AlarmsHeaderService service = mock(AlarmsHeaderService.class);
- controller.setAlarmsHeaderService(service);
-
- controller.getStatusCount();
- verify(service,times(1)).queryStatusCount("0");
- verify(service,times(1)).queryStatusCount("active");
- verify(service,times(1)).queryStatusCount("close");
-
-}
-
-/**
-*
-* Method: getSourceId()
-*
-*/
-@Test
-public void testGetSourceId() throws Exception {
-//TODO: Test goes here...
- controller.getSourceId();
- AlarmsHeader alarmsHeader = new AlarmsHeader();
- verify(service,times(1)).queryAlarmsHeader(alarmsHeader,1,12);
-}
-
-/**
-*
-* Method: genDiagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String showMode)
-*
-*/
-@Test
-public void testGenDiagram() throws Exception {
-//TODO: Test goes here...
- String sourceId="";
- String startTime="";
- String endTime="";
- String nameParent="";
- String format="";
- controller.genDiagram(sourceId,startTime,endTime,format);
-}
-
-
- @Test
- public void testGenDiagram_a() throws Exception {
-//TODO: Test goes here...
- String sourceId="";
- String startTime="2017-10-15";
- String endTime="2017-11-15";
- String nameParent="";
- String format="";
- controller.genDiagram(sourceId,startTime,endTime,"0000");
- }
-
-
- /**
-*
-* Method: dateProcess(String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit)
-*
-*/
-@Test
-public void testDateProcess() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="HO.SuccOutInterMme";
- String time_star="2017-11-15 06:30:00";
- //String time_itera="2017-11-15 06:31:00";
- String time_end="2017-12-15 06:30:00";
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date_star = format.parse(time_star);
- //Date date_itera = format.parse(time_itera);
- Date date_end = format.parse(time_end);
-
- //System.out.println(date.getTime()); //将时间转化为毫秒数例如: 1473297300000
-
- long startTimeL =date_star.getTime();
- long endTimeL = date_end.getTime();
- //long timeIteraPlusVal =date_itera.getTime();
- long timeIteraPlusVal =2592000000L;
- long keyVal=1l;
- long keyValIteraVal=1l;
- String keyUnit="month";
-try {
- Method method = alarmController.getClass().getDeclaredMethod("dateProcess", String.class, long.class, long.class, long.class, long.class, long.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController,sourceId,name, startTimeL,endTimeL,timeIteraPlusVal,keyVal,keyValIteraVal,keyUnit);
-} catch(NoSuchMethodException e) {
-} catch(IllegalAccessException e) {
-} catch(InvocationTargetException e) {
-}
-
-}
-
-/**
-*
-* Method: diagramDate(String sourceId, String startTime, String endTime, String format)
-*
-*/
-@Test
-public void testDiagramDate_year() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="DNS.AttDnsQuery";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-11-16 06:30:00";
- String format="year";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
-try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
-} catch(NoSuchMethodException e) {
-} catch(IllegalAccessException e) {
-} catch(InvocationTargetException e) {
-}
-
-}
-
-
-
-
- @Test
- public void testDiagramDate_month() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="DNS.AttDnsQuery";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-11-16 06:30:00";
- String format="month";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
+ @Autowired
+ AlarmController alarmController;
@Test
- public void testDiagramDate_day() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1E6M2QI4FZVTOXU";
- String name="Dn";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-09-16 06:30:00";
- String format="day";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
+ public void getDataNotParam() throws JsonProcessingException {
+ System.out.println(alarmController.getAlarmData(null,null,null,null,null,null,1,100));
}
-
-
-
@Test
- public void testDiagramDate_hour() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1E6M2QI4FZVTOXU";
- String name="rmUID";
- String startTime="2017-11-15 06:10:00";
- String endTime="2017-11-17 07:40:20";
- String format="hour";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
+ public void getDataCarryParam() throws JsonProcessingException {
+ System.out.println(alarmController.getAlarmData("110","a","drop","down","1506331166000","2",1,100));
}
-
-
-
-
@Test
- public void testDiagramDate_minute() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="HO.AttOutInterMme";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-11-16 08:20:15";
- String format="minute";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
-
- @Test
- public void testDiagramDate_auto_hours() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="IRATHO.AttIncFromGeran";
- String startTime="2017-11-19 06:10:00";
- String endTime="2017-11-19 09:59:59";
- String format="auto";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
+ public void csvFile() throws JsonProcessingException {
+ System.out.println(alarmController.generateCsvFile(null,new String[]{"110"}));
}
-
-
- @Test
- public void testDiagramDate_auto_month2() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="IRATHO.SuccOutToUtran";
- String startTime="2017-02-15 06:10:00";
- String endTime="2017-11-28 09:59:59";
- String format="auto";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
-
- @Test
- public void testDiagramDate_auto_month1() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="MM.AttEpsAttach";
- String startTime="2017-09-10 06:10:00";
- String endTime="2017-11-19 07:59:59";
- String format="auto";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
- @Test
- public void testDiagramDate_auto_day1() throws Exception {
-//TODO: Test goes here...
- AlarmController alarmController = new AlarmController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="IRATHO.SuccIncFromUtran";
- String startTime="2017-10-17 06:10:00";
- String endTime="2017-10-19 07:59:59";
- String format="auto";
-
- // String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit
- try {
- Method method = alarmController.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(alarmController, sourceId,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-}
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
index 0d8432ca..65ef8708 100755
--- a/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
@@ -15,417 +15,78 @@
*/
package org.onap.usecaseui.server.controller;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.usecaseui.server.bean.PerformanceHeader;
import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.service.PerformanceHeaderService;
import org.onap.usecaseui.server.service.PerformanceInformationService;
-
-import javax.servlet.http.HttpServletResponse;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import org.onap.usecaseui.server.util.CSVUtils;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+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.Date;
+import java.util.*;
-import static org.mockito.Mockito.*;
-
-/**
-* PerformanceController Tester.
-*
-* @author <Authors name>
-* @since <pre>���� 28, 2018</pre>
-* @version 1.0
-*/
+@RunWith(SpringRunner.class)
+@SpringBootTest
public class PerformanceControllerTest {
- PerformanceController controller_s;
- PerformanceController controller = new PerformanceController();
- PerformanceHeaderService service;
- PerformanceInformationService perservece;
-
-
- @Before
-public void before() throws Exception {
- service = mock(PerformanceHeaderService.class);
- perservece = mock(PerformanceInformationService.class);
- controller.setPerformanceHeaderService(service);
- controller.setPerformanceInformationService(perservece);
- controller_s = new PerformanceController();
-}
-
-@After
-public void after() throws Exception {
-}
-
-/**
-*
-* Method: getPerformanceData(HttpServletResponse response, @PathVariable int currentPage, @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)
-*
-*/
-@Test
-public void testGetPerformanceData() throws Exception {
-//TODO: Test goes here...
- HttpServletResponse response = mock(HttpServletResponse.class);
- int currentPage = 1;
- int pageSize=12;
- String sourceId="1101ZTHX1MNE1NK7E0";
- String sourceName="1101ZTHX1MNE1NK7E0";
- String priority="Normal";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-11-15 14:45:26";
- PerformanceHeader header = new PerformanceHeader();
-
-
- controller.getPerformanceData(response,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime);
- verify(service,times(1)).queryPerformanceHeader(header,currentPage,pageSize);
-
-}
-
+ @Autowired
+ private PerformanceController performanceController;
@Test
- public void testGetPerformanceData_2() throws Exception {
-//TODO: Test goes here...
- HttpServletResponse response = mock(HttpServletResponse.class);
- int currentPage = 1;
- int pageSize=12;
- String sourceId=null;
- String sourceName=null;
- String priority=null;
- String startTime=null;
- String endTime=null;
- PerformanceHeader header = new PerformanceHeader();
-
-
- controller.getPerformanceData(response,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime);
- verify(service,times(1)).queryPerformanceHeader(header,currentPage,pageSize);
-
+ public void getPerformanceData() throws JsonProcessingException {
+ System.out.println(performanceController.getPerformanceData(null,1,100,null,null,null,null,null));
}
-
-
@Test
- public void testGetPerformanceData_3() throws Exception {
-//TODO: Test goes here...
- HttpServletResponse response = mock(HttpServletResponse.class);
- int currentPage = 1;
- int pageSize=12;
- String sourceId="1101ZTHX1MNE1NK7E0";
- String sourceName="1101ZTHX1MNE1NK7E0";
- String priority="Normal";
- String startTime="2017-11-15";
- String endTime="2017-11-15";
- PerformanceHeader header = new PerformanceHeader();
+ public void generateCsvFile() throws JsonProcessingException {
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","fre","2017-09-28 10:00:00"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","fre","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","null","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","null","null","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"null","null","null","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","null","asdasdasda"));
- controller.getPerformanceData(response,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime);
- verify(service,times(1)).queryPerformanceHeader(header,currentPage,pageSize);
-
}
- /**
-*
-* Method: generateDiagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String nameParent, @RequestParam String format)
-*
-*/
-@Test
-public void testGenerateDiagram() throws Exception {
-//TODO: Test goes here...
-
- String sourceId="";
- String startTime="";
- String endTime="";
- String nameParent="";
- String format="";
- controller.generateDiagram(sourceId,startTime,endTime,nameParent,format);
-}
-
-
@Test
- public void testGenerateDiagram_a() throws Exception {
-//TODO: Test goes here...
-
- String sourceId="";
- String startTime="2017-10-15";
- String endTime="2017-11-15";
- String nameParent="";
- String format="";
- controller.generateDiagram(sourceId,startTime,endTime,nameParent,"0000");
+ public void generateDiaCsvFile() throws JsonProcessingException {
+ Map<String,String> p = new HashMap<>();
+ p.put("eventId","110");
+ p.put("name","110");
+ p.put("value","110");
+ p.put("createTime","110");
+ p.put("updateTime","110");
+ //System.out.println(performanceController.generateDiaCsvFile(null,p));
}
- /**
-*
-* Method: getSourceIds()
-*
-*/
-@Test
-public void testGetSourceIds() throws Exception {
-//TODO: Test goes here...
- controller.getSourceIds();
- verify(service,times(1)).queryAllSourceId();
-}
-
-/**
-*
-* Method: getNames(@RequestParam Object sourceId)
-*
-*/
-@Test
-public void testGetNames() throws Exception {
-//TODO: Test goes here...
-Object sourceId="1101ZTHX1MMEGJM1W1";
- controller.getNames(sourceId);
- verify(perservece,times(1)).queryDateBetween(sourceId.toString(),null,null,null);
-}
-
-
-/**
-*
-* Method: dateProcess(String sourceId, String name, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit)
-*
-*/
-@Test
-public void testDateProcess() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="HO.SuccOutInterMme";
- String time_star="2017-11-15 06:30:00";
- //String time_itera="2017-11-15 06:31:00";
- String time_end="2017-12-15 06:30:00";
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date_star = format.parse(time_star);
- //Date date_itera = format.parse(time_itera);
- Date date_end = format.parse(time_end);
-
- //System.out.println(date.getTime()); //将时间转化为毫秒数例如: 1473297300000
-
- long startTimeL =date_star.getTime();
- long endTimeL = date_end.getTime();
- //long timeIteraPlusVal =date_itera.getTime();
- long timeIteraPlusVal =2592000000L;
- long keyVal=1l;
- long keyValIteraVal=1l;
- String keyUnit="month";
-try {
- Method method = per.getClass().getDeclaredMethod("dateProcess", String.class, String.class, long.class, long.class, long.class, long.class, long.class, String.class);
- method.setAccessible(true);
- method.invoke(per,sourceId,name, startTimeL,endTimeL,timeIteraPlusVal,keyVal,keyValIteraVal,keyUnit);
-} catch(NoSuchMethodException e) {
-} catch(IllegalAccessException e) {
-} catch(InvocationTargetException e) {
-}
-
-}
-
-/**
-*
-* Method: diagramDate(String sourceId, String name, String startTime, String endTime, String format)
-*
-*/
-@Test
-public void testDiagramDate_year() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="DNS.AttDnsQuery";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-11-16 06:30:00";
- String format="year";
-try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
-} catch(NoSuchMethodException e) {
-} catch(IllegalAccessException e) {
-} catch(InvocationTargetException e) {
-}
-
-}
-
-
-
-
@Test
- public void testDiagramDate_month() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="DNS.AttDnsQuery";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-11-16 06:30:00";
- String format="month";
+ public void generateDiagram(){
try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
+ System.out.println(performanceController.generateDiagram("hour","110"));
+ System.out.println(performanceController.generateDiagram("day","110"));
+ System.out.println(performanceController.generateDiagram("month","110"));
+ System.out.println(performanceController.generateDiagram("year","110"));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
}
-
}
-
-
- @Test
- public void testDiagramDate_day() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1E6M2QI4FZVTOXU";
- String name="Dn";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-09-16 06:30:00";
- String format="day";
- try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
- @Test
- public void testDiagramDate_hour() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1E6M2QI4FZVTOXU";
- String name="rmUID";
- String startTime="2017-11-15 06:10:00";
- String endTime="2017-11-17 07:40:20";
- String format="hour";
- try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
- @Test
- public void testDiagramDate_minute() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="HO.AttOutInterMme";
- String startTime="2017-11-15 06:30:00";
- String endTime="2017-11-16 08:20:15";
- String format="minute";
- try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
- @Test
- public void testDiagramDate_auto_hours() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="IRATHO.AttIncFromGeran";
- String startTime="2017-11-19 06:10:00";
- String endTime="2017-11-19 09:59:59";
- String format="auto";
- try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
- @Test
- public void testDiagramDate_auto_month2() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="IRATHO.SuccOutToUtran";
- String startTime="2017-02-15 06:10:00";
- String endTime="2017-11-28 09:59:59";
- String format="auto";
- try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
-
- @Test
- public void testDiagramDate_auto_month1() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="MM.AttEpsAttach";
- String startTime="2017-09-10 06:10:00";
- String endTime="2017-11-19 07:59:59";
- String format="auto";
- try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-
-
- @Test
- public void testDiagramDate_auto_day1() throws Exception {
-//TODO: Test goes here...
- PerformanceController per = new PerformanceController();
- String sourceId="1101ZTHX1MMEGJM1W1";
- String name="IRATHO.SuccIncFromUtran";
- String startTime="2017-10-17 06:10:00";
- String endTime="2017-10-19 07:59:59";
- String format="auto";
- try {
- Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
- method.setAccessible(true);
- method.invoke(per, sourceId,name,startTime,endTime,format);
- } catch(NoSuchMethodException e) {
- } catch(IllegalAccessException e) {
- } catch(InvocationTargetException e) {
- }
-
- }
-
-}
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java
new file mode 100644
index 00000000..5616ef23
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java
@@ -0,0 +1,290 @@
+/*
+ * 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.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AlarmsHeaderServiceTest {
+
+ @Resource(name = "AlarmsHeaderService")
+ private AlarmsHeaderService alarmsHeaderService;
+
+ @Test
+ public void save() throws ParseException {
+ AlarmsHeader a = new AlarmsHeader();
+ a.setEventName("a");
+ a.setStatus("1");
+ a.setVfStatus("1");
+ a.setEventId("1119");
+ a.setDomain("asb");
+ a.setEventCategory("s");
+ a.setAlarmCondition("ea");
+ a.setAlarmInterfaceA("cs");
+ a.setCreateTime(DateUtils.now());
+ a.setEventServrity("s");
+ a.setEventSourceType("q");
+ a.setEventType("q");
+ a.setFaultFieldsVersion("v1");
+ a.setLastEpochMicroSec("csa");
+ a.setNfcNamingCode("std");
+ a.setNfNamingCode("cout");
+ a.setPriority("cs");
+ a.setReportingEntityId("112");
+ a.setReportingEntityName("asfs");
+ a.setSequence("cgg");
+ a.setSourceId("123");
+ a.setSourceName("eggs");
+ a.setSpecificProblem("especially");
+ a.setStartEpochMicrosec("wallet");
+ a.setUpdateTime(DateUtils.now());
+ a.setVersion("va2");
+ System.out.println(alarmsHeaderService.saveAlarmsHeader(a));
+
+ }
+
+ @Test
+ public void update() throws ParseException {
+ AlarmsHeader a = new AlarmsHeader();
+ a.setEventName("a1");
+ a.setStatus("2");
+ a.setVfStatus("3");
+ a.setEventId("1101");
+ a.setDomain("asb");
+ a.setEventCategory("s");
+ a.setAlarmCondition("ea");
+ a.setAlarmInterfaceA("cs");
+ a.setCreateTime(DateUtils.now());
+ a.setEventServrity("s");
+ a.setEventSourceType("q");
+ a.setEventType("q");
+ a.setFaultFieldsVersion("v1");
+ a.setLastEpochMicroSec("csa");
+ a.setNfcNamingCode("std");
+ a.setNfNamingCode("cout");
+ a.setPriority("cs");
+ a.setReportingEntityId("112");
+ a.setReportingEntityName("asfs");
+ a.setSequence("cgg");
+ a.setSourceId("123");
+ a.setSourceName("eggs");
+ a.setSpecificProblem("especially");
+ a.setStartEpochMicrosec("wallet");
+ a.setUpdateTime(DateUtils.now());
+ a.setVersion("va2");
+ System.out.println(alarmsHeaderService.updateAlarmsHeader(a));
+ }
+
+
+ @Test
+ public void update1() throws ParseException {
+ AlarmsHeader a = new AlarmsHeader();
+ a.setEventName("a1");
+ a.setStatus("2");
+ a.setVfStatus("3");
+ a.setEventId("1101");
+ a.setDomain("asb");
+ a.setEventCategory("s");
+ a.setAlarmCondition("ea");
+ a.setAlarmInterfaceA("cs");
+ a.setCreateTime(DateUtils.now());
+ a.setEventServrity("s");
+ a.setEventSourceType("q");
+ a.setEventType("q");
+ a.setSpecificProblem("especially");
+ a.setStartEpochMicrosec("wallet");
+ a.setUpdateTime(DateUtils.now());
+ a.setVersion("va2");
+ System.out.println(alarmsHeaderService.updateAlarmsHeader(a));
+ }
+
+ @Test
+ public void get(){
+
+ alarmsHeaderService.queryId(new String[]{"1101"}).forEach( a -> System.out.println(a));
+ }
+
+ @Test
+ public void queryEventName() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventId("110");
+ a.setEventName("asdasds");
+ // a.setVfStatus("2");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().forEach( as->System.out.println(as.toString()));
+ }
+
+ @Test
+ public void queryStatus() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setStatus("1");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventId() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventId("1101");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryDomain() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setDomain("asb");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventCategory() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventCategory("s");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryAlarmCondition() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setAlarmCondition("ea");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryAlarmInterfaceA() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setAlarmInterfaceA("cs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventServrity() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventServrity("s");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventSourceType() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventSourceType("q");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventType() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventType("q");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryFaultFieldsVersion() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setFaultFieldsVersion("v1");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryLastEpochMicroSec() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setLastEpochMicroSec("csa");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryNfcNamingCode() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setNfcNamingCode("std");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryNfNamingCode() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setNfNamingCode("cout");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryPriority() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setPriority("cs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryReportingEntityId() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setReportingEntityId("112");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryReportingEntityName() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setReportingEntityName("asfs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySequence() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSequence("cgg");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySourceId() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSourceId("123");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySourceName() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSourceName("eggs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySpecificProblem() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSpecificProblem("especially");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryStartEpochMicrosec() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setStartEpochMicrosec("wallet");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryVersion() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setVersion("va2");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryVfStatus() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setVfStatus("1");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryCreateTime() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setCreateTime(DateUtils.now());
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryUpdateTime() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setUpdateTime(DateUtils.now());
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+
+}
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
new file mode 100644
index 00000000..4fb9a387
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.util.Map;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AlarmsInformationServiceTest {
+
+
+ @Resource(name = "AlarmsInformationService")
+ AlarmsInformationService alarmsInformationService;
+
+ @Test
+ public void save() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setEventId("1119");
+ a.setName("efw");
+ a.setValue("fre");
+ a.setCreateTime(DateUtils.now());
+ a.setUpdateTime(DateUtils.now());
+ System.out.println(alarmsInformationService.saveAlarmsInformation(a));
+ }
+
+ @Test
+ public void update() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setEventId("110");
+ a.setName("1");
+ a.setValue("fko");
+ a.setUpdateTime(DateUtils.now());
+ a.setCreateTime(DateUtils.now());
+ System.out.println(alarmsInformationService.updateAlarmsInformation(a));
+ }
+
+ @Test
+ public void update1() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setEventId("110");
+ a.setValue("fko");
+ System.out.println(alarmsInformationService.updateAlarmsInformation(a));
+ }
+
+ @Test
+ public void get() throws ParseException {
+ alarmsInformationService.queryId(new String[]{"110"}).forEach(ai -> System.out.println(ai));
+ }
+
+ @Test
+ public void queryEventId() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setEventId("110");
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
+ @Test
+ public void queryName() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setName("efw");
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
+ @Test
+ public void queryValue() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setValue("fko");
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
+
+ @Test
+ public void queryCreateTime() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setCreateTime(DateUtils.now());
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
+ @Test
+ public void queryUpdateTime() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setUpdateTime(DateUtils.now());
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .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
new file mode 100644
index 00000000..bd4283d2
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
@@ -0,0 +1,241 @@
+/*
+ * 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.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class PerformanceHeaderServiceTest {
+
+
+ @Resource(name = "PerformanceHeaderService")
+ PerformanceHeaderService performanceHeaderService;
+
+ @Test
+ public void save() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setCreateTime(DateUtils.now());
+ p.setEventId("2202");
+ p.setEventName("fxc");
+ p.setDomain("asb");
+ p.setCreateTime(DateUtils.now());
+ p.setEventType("q");
+ p.setLastEpochMicroSec("csa");
+ p.setNfcNamingCode("std");
+ p.setNfNamingCode("cout");
+ p.setPriority("cs");
+ p.setReportingEntityId("112");
+ p.setReportingEntityName("asfs");
+ p.setSequence("cgg");
+ p.setSourceId("123");
+ p.setSourceName("eggs");
+ p.setStartEpochMicrosec("wallet");
+ p.setUpdateTime(DateUtils.now());
+ p.setVersion("va2");
+ p.setMeasurementInterval("12");
+ p.setMeasurementsForVfScalingVersion("12");
+
+ System.out.println(performanceHeaderService.savePerformanceHeader(p));
+ }
+
+ @Test
+ public void update() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setCreateTime(DateUtils.now());
+ p.setEventId("110");
+ p.setEventName("fxc");
+ p.setDomain("asb");
+ p.setCreateTime(DateUtils.now());
+ p.setEventType("q");
+ p.setLastEpochMicroSec("csa");
+ p.setNfcNamingCode("std");
+ p.setNfNamingCode("cout");
+ p.setPriority("cs");
+ p.setReportingEntityId("112");
+ p.setReportingEntityName("asfs");
+ p.setSequence("cgg");
+ p.setSourceId("123");
+ p.setSourceName("eggs");
+ p.setStartEpochMicrosec("wallet");
+ p.setUpdateTime(DateUtils.now());
+ p.setVersion("va2");
+ p.setMeasurementInterval("12");
+ p.setMeasurementsForVfScalingVersion("12");
+ System.out.println(performanceHeaderService.updatePerformanceHeader(p));
+ }
+
+ @Test
+ public void update1() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setCreateTime(DateUtils.now());
+ p.setEventId("110");
+ p.setEventName("fxc");
+ p.setDomain("asb");
+ p.setCreateTime(DateUtils.now());
+ p.setEventType("q");
+ p.setLastEpochMicroSec("csa");
+ p.setNfcNamingCode("std");
+ p.setNfNamingCode("cout");
+ p.setPriority("cs");
+ p.setReportingEntityId("112");
+ p.setMeasurementsForVfScalingVersion("12");
+ System.out.println(performanceHeaderService.updatePerformanceHeader(p));
+ }
+
+
+ @Test
+ public void get() throws ParseException {
+ performanceHeaderService.queryId(new String[]{"110"})
+ .forEach(pe -> System.out.println(pe.getCreateTime()));
+ }
+
+ @Test
+ public void queryEventId() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setEventId("110");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryEventName() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setEventName("fxc");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryDomain() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setDomain("asb");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryEventType() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setEventType("q");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryLastEpochMicroSec() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setLastEpochMicroSec("csa");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryNfcNamingCode() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setNfcNamingCode("std");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryNfNamingCode() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setNfNamingCode("cout");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryPriority() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setPriority("cs");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryReportingEntityId() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setReportingEntityId("112");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryReportingEntityName() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setReportingEntityName("asfs");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void querySequence() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setSequence("cgg");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void querySourceId() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setSourceId("123");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void querySourceName() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setSourceName("eggs");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryStartEpochMicrosec() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setStartEpochMicrosec("wallet");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryVersion() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setVersion("va2");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryMeasurementInterval() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setMeasurementInterval("12");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryMeasurementsForVfScalingVersion() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setMeasurementsForVfScalingVersion("12");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .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
new file mode 100644
index 00000000..1a8522ad
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.PerformanceInformation;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.util.List;
+import java.util.Random;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class PerformanceInformationServiceTest {
+
+
+ @Resource(name = "PerformanceInformationService")
+ PerformanceInformationService performanceInformationService;
+
+ @Test
+ public void save() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
+
+ a.setEventId("123");
+ a.setName("SGS.UeUnreachable");
+ a.setValue("40");
+ a.setCreateTime(DateUtils.now());
+ a.setUpdateTime(DateUtils.now());
+ System.out.println(performanceInformationService.savePerformanceInformation(a));
+
+
+ }
+
+ @Test
+ public void update() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
+ a.setEventId("110");
+ a.setName("efw");
+ a.setValue("fko11");
+ a.setUpdateTime(DateUtils.now());
+ a.setCreateTime(DateUtils.now());
+ System.out.println(performanceInformationService.updatePerformanceInformation(a));
+ }
+
+ @Test
+ public void update1() throws ParseException {
+ List<PerformanceInformation> as = performanceInformationService.queryId(new String[]{"2202"});
+ as.forEach(a -> {
+ try {
+ a.setCreateTime(DateUtils.stringToDate(DateUtils.addDate(a.getCreateTime(), "day", 1)));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ System.out.println(performanceInformationService.updatePerformanceInformation(a));
+ });
+ }
+
+ @Test
+ public void get() throws ParseException {
+ performanceInformationService.queryId(new String[]{"2202"})
+ .forEach(ai -> System.out.println(ai.getCreateTime()));
+ }
+
+ @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()));
+ }
+
+ @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));
+ }
+
+ @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));
+ }
+
+ @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));
+ }
+
+ @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));
+ }
+
+ @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));
+ }
+
+ @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")));
+ }
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java
deleted file mode 100644
index bb769e22..00000000
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java
+++ /dev/null
@@ -1,459 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.AlarmsHeader;
-import org.onap.usecaseui.server.service.impl.AlarmsHeaderServiceImpl;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.*;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-/**
-* AlarmsHeaderServiceImpl Tester.
-*
-* @author <Authors name>
-* @since <pre>8, 2018</pre>
-* @version 1.0
-*/
-public class AlarmsHeaderServiceImplTest {
- AlarmsHeaderServiceImpl alarmsHeaderServiceImpl = null;
- private static final long serialVersionUID = 1L;
-
- @Before
- public void before() throws Exception {
- alarmsHeaderServiceImpl = new AlarmsHeaderServiceImpl();
-
- MockUp<Transaction> mockUpTransaction = new MockUp<Transaction>() {
- @Mock
- public void commit() {
- }
- };
- MockUp<Query> mockUpQuery = new MockUp<Query>() {
- };
- new MockUp<Query>() {
- @Mock
- public Query setString(String name, String value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setDate(String name, Date value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setInteger(String name, int value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public int executeUpdate() {
- return 0;
- }
- @Mock
- public Query setMaxResults(int value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setFirstResult(int firstResult) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setParameterList(String name, Object[] values) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public List<AlarmsHeader> list() {
- AlarmsHeader ah = new AlarmsHeader();
- return Arrays.asList(ah);
- }
- @Mock
- public Object uniqueResult() {
- return "0";
- }
- };
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String sql) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Transaction beginTransaction() {
- return mockUpTransaction.getMockInstance();
- }
- @Mock
- public Transaction getTransaction() {
- return mockUpTransaction.getMockInstance();
- }
- @Mock
- public Serializable save(Object object) {
- return (Serializable) serialVersionUID;
- }
- @Mock
- public void flush() {
- }
- @Mock
- public void update(Object object) {
- }
- };
- new MockUp<SessionFactory>() {
- @Mock
- public Session openSession() {
- return mockedSession.getMockInstance();
- }
- };
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- }
-
- @After
- public void after() throws Exception {
- }
-
- @Test
- public void testSaveAlarmsHeader() throws Exception {
- AlarmsHeader ah = null;
- alarmsHeaderServiceImpl.saveAlarmsHeader(ah);
- }
-
- @Test
- public void testUpdateAlarmsHeader2018() throws Exception {
- alarmsHeaderServiceImpl.updateAlarmsHeader2018("status", new Timestamp(System.currentTimeMillis()), "startEpochMicrosecCleared", "lastEpochMicroSecCleared", "eventName", "reportingEntityName", "specificProblem");
- }
-
- @Test
- public void testGetStatusBySourceName() throws Exception {
- new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return "active";
- }
- };
- alarmsHeaderServiceImpl.getStatusBySourceName("sourceName");
- }
-
- @Test
- public void testGetIdByStatusSourceName() throws Exception {
- new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return "AlarmsHeader";
- }
- };
- alarmsHeaderServiceImpl.getIdByStatusSourceName("sourceName");
- }
-
- @Test
- public void testUpdateAlarmsHeader() throws Exception {
- AlarmsHeader ah = null;
- alarmsHeaderServiceImpl.updateAlarmsHeader(ah);
- }
-
- @Test
- public void testGetAllCountByStatus() throws Exception {
- new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return "1";
- }
- };
- alarmsHeaderServiceImpl.getAllCountByStatus("status");
- }
-
- @Test
- public void testGetAllByStatus() throws Exception {
- alarmsHeaderServiceImpl.getAllByStatus("status", "eventName", "sourceName", "eventServrity", "reportingEntityName", new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()));
- }
-
- @Test
- public void testGetAlarmsHeaderDetail() throws Exception {
- new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return "AlarmsHeader";
- }
- };
- alarmsHeaderServiceImpl.getAlarmsHeaderDetail(1);
- }
-
- @Test
- public void testGetAllByDatetime() throws Exception {
- new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return "1";
- }
- };
- alarmsHeaderServiceImpl.getAllCountByStatus("status");
- alarmsHeaderServiceImpl.getAllByDatetime("status", "eventId", "eventServrity", "createTime");
- }
-
- @Test
- public void testGetAllCount() throws Exception {
- new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return "1";
- }
- };
- AlarmsHeader ah = new AlarmsHeader();
- ah.setVersion("va2");
- ah.setEventName("a");
- ah.setAlarmCondition("ea");
- ah.setDomain("asb");
- ah.setEventId("1119");
- ah.setNfcNamingCode("std");
- ah.setNfNamingCode("cout");
- ah.setSourceId("123");
- ah.setSourceName("eggs");
- ah.setReportingEntityId("112");
- ah.setReportingEntityName("asfs");
- ah.setPriority("cs");
- ah.setStartEpochMicrosec("wallet");
- ah.setLastEpochMicroSec("csa");
- ah.setSequence("cgg");
- ah.setFaultFieldsVersion("v1");
- ah.setEventServrity("s");
- ah.setEventType("q");
- ah.setEventCategory("s");
- ah.setSpecificProblem("especially");
- ah.setAlarmInterfaceA("cs");
- ah.setStatus("1");
- ah.setCreateTime(DateUtils.now());
- ah.setUpdateTime(DateUtils.now());
- ah.setVfStatus("1");
- ah.setEventSourceType("q");
- alarmsHeaderServiceImpl.getAllCount(ah, 1, 1);
- }
-
- @Test
- public void testQueryAlarmsHeader() throws Exception {
- AlarmsHeader ah = new AlarmsHeader();
- ah.setVersion("va2");
- ah.setEventName("a");
- ah.setAlarmCondition("ea");
- ah.setDomain("asb");
- ah.setEventId("1119");
- ah.setNfcNamingCode("std");
- ah.setNfNamingCode("cout");
- ah.setSourceId("123");
- ah.setSourceName("eggs");
- ah.setReportingEntityId("112");
- ah.setReportingEntityName("asfs");
- ah.setPriority("cs");
- ah.setStartEpochMicrosec("wallet");
- ah.setLastEpochMicroSec("csa");
- ah.setSequence("cgg");
- ah.setFaultFieldsVersion("v1");
- ah.setEventServrity("s");
- ah.setEventType("q");
- ah.setEventCategory("s");
- ah.setSpecificProblem("especially");
- ah.setAlarmInterfaceA("cs");
- ah.setStatus("1");
- ah.setCreateTime(DateUtils.now());
- ah.setUpdateTime(DateUtils.now());
- ah.setVfStatus("1");
- ah.setEventSourceType("q");
- alarmsHeaderServiceImpl.queryAlarmsHeader(ah, 1, 1);
- }
-
- @Test
- public void testQueryId() throws Exception {
- String[] id = {"1", "2", "3"};
- alarmsHeaderServiceImpl.queryId(id);
- }
-
- @Test
- public void testQueryStatusCount() throws Exception {
- new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return "1";
- }
- };
- alarmsHeaderServiceImpl.queryStatusCount("status");
- }
-
- @Test(expected = Exception.class)
- public void testSaveAlarmsHeaderException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsHeader ah = new AlarmsHeader();
- alarmsHeaderServiceImpl.saveAlarmsHeader(ah);
- }
-
- @Test(expected = Exception.class)
- public void testUpdateAlarmsHeader2018Exception() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.updateAlarmsHeader2018("status", new Timestamp(System.currentTimeMillis()), "startEpochMicrosecCleared", "lastEpochMicroSecCleared", "eventName", "reportingEntityName", "specificProblem");
- }
-
- @Test(expected = Exception.class)
- public void testGetStatusBySourceNameException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.getStatusBySourceName("sourceName");
- }
-
- @Test(expected = Exception.class)
- public void testGetIdByStatusSourceNameException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.getIdByStatusSourceName("sourceName");
- }
-
- @Test(expected = Exception.class)
- public void testUpdateAlarmsHeaderException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsHeader ah = new AlarmsHeader();
- alarmsHeaderServiceImpl.updateAlarmsHeader(ah);
- }
-
- @Test(expected = Exception.class)
- public void testGetAllCountByStatusException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.getAllCountByStatus("status");
- }
-
- @Test(expected = Exception.class)
- public void testGetAllByStatusException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.getAllByStatus("status", "eventName", "sourceName", "eventServrity", "reportingEntityName", new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()));
- }
-
- @Test(expected = Exception.class)
- public void testGetAlarmsHeaderDetailException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.getAlarmsHeaderDetail(1);
- }
-
- @Test(expected = Exception.class)
- public void testGetAllByDatetimeException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.getAllByDatetime("status", "eventId", "eventServrity", "createTime");
- }
-
- @Test(expected = Exception.class)
- public void testGetAllCountException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsHeader ah = new AlarmsHeader();
- alarmsHeaderServiceImpl.getAllCount(ah, 1, 1);
- }
-
- @Test(expected = Exception.class)
- public void testQueryAlarmsHeaderException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsHeader ah = new AlarmsHeader();
- alarmsHeaderServiceImpl.queryAlarmsHeader(ah, 1, 1);
- }
-
- @Test(expected = Exception.class)
- public void testQueryIdException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- String[] id = {"1", "2", "3"};
- alarmsHeaderServiceImpl.queryId(id);
- }
-
- @Test(expected = Exception.class)
- public void testQueryStatusCountException() {
- new MockUp<AlarmsHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsHeaderServiceImpl.queryStatusCount("status");
- }
-}
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
deleted file mode 100644
index 9cc926d0..00000000
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
+++ /dev/null
@@ -1,306 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.AlarmsInformation;
-import org.onap.usecaseui.server.service.impl.AlarmsInformationServiceImpl;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import javax.annotation.Resource;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.*;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-/**
-* AlarmsInformationServiceImpl Tester.
-*
-* @author <Authors name>
-* @since <pre> 8, 2018</pre>
-* @version 1.0
-*/
-public class AlarmsInformationServiceImplTest {
-
- AlarmsInformationServiceImpl alarmsInformationServiceImpl = null;
- private static final long serialVersionUID = 1L;
-
- @Before
- public void before() throws Exception {
- alarmsInformationServiceImpl = new AlarmsInformationServiceImpl();
-
- MockUp<Transaction> mockUpTransaction = new MockUp<Transaction>() {
- @Mock
- public void commit() {
- }
- };
- MockUp<Query> mockUpQuery = new MockUp<Query>() {
- };
- new MockUp<Query>() {
- @Mock
- public Query setString(String name, String value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setDate(String name, Date value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setInteger(String name, int value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public int executeUpdate() {
- return 0;
- }
- @Mock
- public Query setMaxResults(int value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setFirstResult(int firstResult) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setParameterList(String name, Object[] values) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public List<AlarmsInformation> list() {
- AlarmsInformation ai = new AlarmsInformation();
- return Arrays.asList(ai);
- }
- @Mock
- public Object uniqueResult() {
- return "0";
- }
- };
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String sql) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Transaction beginTransaction() {
- return mockUpTransaction.getMockInstance();
- }
- @Mock
- public Transaction getTransaction() {
- return mockUpTransaction.getMockInstance();
- }
- @Mock
- public Serializable save(Object object) {
- return (Serializable) serialVersionUID;
- }
- @Mock
- public void flush() {
- }
- @Mock
- public void update(Object object) {
- }
- };
- new MockUp<SessionFactory>() {
- @Mock
- public Session openSession() {
- return mockedSession.getMockInstance();
- }
- };
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- }
-
- @After
- public void after() throws Exception {
- }
-
- @Test
- public void testSaveAlarmsInformation() throws Exception {
- AlarmsInformation ai = null;
- alarmsInformationServiceImpl.saveAlarmsInformation(ai);
- }
-
- @Test
- public void testUpdateAlarmsInformation() throws Exception {
- AlarmsInformation ai = null;
- alarmsInformationServiceImpl.updateAlarmsInformation(ai);
- }
-
- @Test
- public void testGetAllCount() throws Exception {
- AlarmsInformation ai = new AlarmsInformation();
- ai.setName("name");
- ai.setValue("value");
- ai.setEventId("eventId");
- ai.setCreateTime(DateUtils.now());
- ai.setUpdateTime(DateUtils.now());
- alarmsInformationServiceImpl.getAllCount(ai, 1, 10);
- }
-
- @Test
- public void testQueryAlarmsInformation() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private int getAllCount(AlarmsInformation alarmsInformation, int currentPage, int pageSize) {
- return 10;
- }
- };
- AlarmsInformation ai = new AlarmsInformation();
- ai.setName("name");
- ai.setValue("value");
- ai.setEventId("eventId");
- ai.setCreateTime(DateUtils.now());
- ai.setUpdateTime(DateUtils.now());
- alarmsInformationServiceImpl.queryAlarmsInformation(ai, 1, 10);
- }
-
- @Test
- public void testQueryId() throws Exception {
- String[] id = {};
- alarmsInformationServiceImpl.queryId(id);
- }
-
- @Test
- public void testQueryDateBetween() throws Exception {
- new MockUp<Query>() {
- @Mock
- public List<Object[]> list() {
- List<Object[]> resultlist = new ArrayList<Object[]>();
- Object[] objs = {"name", "value"};
- resultlist.add(objs);
- return resultlist;
- }
- };
- new MockUp<List>() {
- @Mock
- private Iterator iterator() {
- String[] strlist1 = {"time1", "count1"};
- String[] strlist2 = {"time2", "count2"};
- List<String[]> list = new ArrayList<String[]>();
- list.add(strlist1);
- list.add(strlist2);
- return list.iterator();
- }
- };
- alarmsInformationServiceImpl.queryDateBetween("sourceId", "startTime", "endTime");
- }
-
- @Test
- public void testGetAllAlarmsInformationByeventId() throws Exception {
- alarmsInformationServiceImpl.getAllAlarmsInformationByeventId("eventId");
- }
-
- @Test(expected = Exception.class)
- public void testSaveAlarmsInformationException() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsInformation ai = null;
- alarmsInformationServiceImpl.saveAlarmsInformation(ai);
- }
-
- @Test(expected = Exception.class)
- public void testUpdateAlarmsInformationException() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsInformation ai = null;
- alarmsInformationServiceImpl.updateAlarmsInformation(ai);
- }
-
- @Test(expected = Exception.class)
- public void testGetAllCountException() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsInformation ai = null;
- alarmsInformationServiceImpl.getAllCount(ai, 1, 10);
- }
-
- @Test(expected = Exception.class)
- public void testQueryAlarmsInformationException() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- AlarmsInformation ai = null;
- alarmsInformationServiceImpl.queryAlarmsInformation(ai, 1, 10);
- }
-
- @Test(expected = Exception.class)
- public void testQueryIdException() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- String[] id = {};
- alarmsInformationServiceImpl.queryId(id);
- }
-
- @Test(expected = Exception.class)
- public void testQueryDateBetweenException() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsInformationServiceImpl.queryDateBetween("sourceId", "startTime", "endTime");
- }
-
- @Test(expected = Exception.class)
- public void testGetAllAlarmsInformationByeventIdException() throws Exception {
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- alarmsInformationServiceImpl.getAllAlarmsInformationByeventId("eventId");
- }
-
-}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/InitializationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/InitializationServiceImplTest.java
deleted file mode 100644
index 7362ac3f..00000000
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/InitializationServiceImplTest.java
+++ /dev/null
@@ -1,67 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.service.InitializationService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import static org.mockito.Mockito.mock;
-
-/**
-* InitializationServiceImpl Tester.
-*
-* @author <Authors name>
-* @since <pre>���� 15, 2018</pre>
-* @version 1.0
-*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = UsecaseuiServerApplication.class)
-@WebAppConfiguration
-public class InitializationServiceImplTest {
-
- /* @Autowired
- private InitializationService initializationService;*/
-
-@Before
-public void before() throws Exception {
-}
-
-@After
-public void after() throws Exception {
-}
-
-/**
-*
-* Method: initialize()
-*
-*/
-@Test
-public void testInitialize() throws Exception {
-//TODO: Test goes here...
- InitializationServiceImpl service = mock(InitializationServiceImpl.class);
- service.initialize();
-}
-
-
-}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
deleted file mode 100644
index b2fe2b47..00000000
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
+++ /dev/null
@@ -1,374 +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.
- */
-package org.onap.usecaseui.server.service.impl;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.PerformanceHeader;
-import org.onap.usecaseui.server.service.impl.PerformanceHeaderServiceImpl;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import javax.annotation.Resource;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.*;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-
-import mockit.Mock;
-import mockit.MockUp;
-import static org.mockito.Mockito.mock;
-
-/**
-* PerformanceHeaderServiceImpl Tester.
-*
-* @author <Authors name>
-* @since <pre> 8, 2018</pre>
-* @version 1.0
-*/
-public class PerformanceHeaderServiceImplTest {
-
- PerformanceHeaderServiceImpl performanceHeaderServiceImpl = null;
- private static final long serialVersionUID = 1L;
-
- @Before
- public void before() throws Exception {
- performanceHeaderServiceImpl = new PerformanceHeaderServiceImpl();
-
- MockUp<Transaction> mockUpTransaction = new MockUp<Transaction>() {
- @Mock
- public void commit() {
- }
- };
- MockUp<Query> mockUpQuery = new MockUp<Query>() {
- };
- new MockUp<Query>() {
- @Mock
- public Query setString(String name, String value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setDate(String name, Date value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setInteger(String name, int value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public int executeUpdate() {
- return 0;
- }
- @Mock
- public Query setMaxResults(int value) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setFirstResult(int firstResult) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Query setParameterList(String name, Object[] values) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public List<PerformanceHeader> list() {
- PerformanceHeader ph = new PerformanceHeader();
- return Arrays.asList(ph);
- }
- @Mock
- public Object uniqueResult() {
- return "0";
- }
- };
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String sql) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Transaction beginTransaction() {
- return mockUpTransaction.getMockInstance();
- }
- @Mock
- public Transaction getTransaction() {
- return mockUpTransaction.getMockInstance();
- }
- @Mock
- public Serializable save(Object object) {
- return (Serializable) serialVersionUID;
- }
- @Mock
- public void flush() {
- }
- @Mock
- public void update(Object object) {
- }
- };
- new MockUp<SessionFactory>() {
- @Mock
- public Session openSession() {
- return mockedSession.getMockInstance();
- }
- };
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- }
-
- @After
- public void after() throws Exception {
- }
-
- @Test
- public void testSavePerformanceHeader() throws Exception {
- PerformanceHeader ph = null;
- performanceHeaderServiceImpl.savePerformanceHeader(ph);
- }
-
- @Test
- public void testUpdatePerformanceHeader() throws Exception {
- PerformanceHeader ph = null;
- performanceHeaderServiceImpl.updatePerformanceHeader(ph);
- }
-
- @Test
- public void testGetAllCountByEventType() throws Exception {
- performanceHeaderServiceImpl.getAllCountByEventType();
- }
-
- @Test
- public void testGetAllByEventType() throws Exception {
- new MockUp<Query>() {
- @Mock
- public List<PerformanceHeader> list() {
- PerformanceHeader ph = new PerformanceHeader();
- return Arrays.asList(ph);
- }
- };
- performanceHeaderServiceImpl.getAllByEventType("eventName", "sourceName", "reportingEntityName", DateUtils.now(), DateUtils.now());
- }
-
- @Test
- public void testGetPerformanceHeaderDetail() throws Exception {
- performanceHeaderServiceImpl.getPerformanceHeaderDetail(1);
- }
-
- @Test
- public void testGetAllByDatetime() throws Exception {
- performanceHeaderServiceImpl.getAllByDatetime("eventId", "createTime");
- }
-
- @Test
- public void testGetAllCount() throws Exception {
- PerformanceHeader ph = new PerformanceHeader();
- ph.setVersion("version");
- ph.setEventName("eventName");
- ph.setDomain("domain");
- ph.setEventId("eventId");
- ph.setNfcNamingCode("nfcNamingCode");
- ph.setNfNamingCode("nfNamingCode");
- ph.setSourceId("sourceId");
- ph.setSourceName("sourceName");
- ph.setReportingEntityId("reportingEntityId");
- ph.setReportingEntityName("reportingEntityName");
- ph.setPriority("priority");
- ph.setStartEpochMicrosec("startEpochMicrosec");
- ph.setLastEpochMicroSec("lastEpochMicroSec");
- ph.setSequence("sequence");
- ph.setMeasurementsForVfScalingVersion("measurementsForVfScalingVersion");
- ph.setMeasurementInterval("measurementInterval");
- ph.setEventType("eventType");
- ph.setCreateTime(DateUtils.now());
- ph.setUpdateTime(DateUtils.now());
- performanceHeaderServiceImpl.getAllCount(ph, 1, 10);
- }
-
- @Test
- public void testQueryPerformanceHeader() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private int getAllCount(PerformanceHeader performanceHeader, int currentPage, int pageSize) {
- return 10;
- }
- };
- PerformanceHeader ph = new PerformanceHeader();
- ph.setVersion("version");
- ph.setEventName("eventName");
- ph.setDomain("domain");
- ph.setEventId("eventId");
- ph.setNfcNamingCode("nfcNamingCode");
- ph.setNfNamingCode("nfNamingCode");
- ph.setSourceId("sourceId");
- ph.setSourceName("sourceName");
- ph.setReportingEntityId("reportingEntityId");
- ph.setReportingEntityName("reportingEntityName");
- ph.setPriority("priority");
- ph.setStartEpochMicrosec("startEpochMicrosec");
- ph.setLastEpochMicroSec("lastEpochMicroSec");
- ph.setSequence("sequence");
- ph.setMeasurementsForVfScalingVersion("measurementsForVfScalingVersion");
- ph.setMeasurementInterval("measurementInterval");
- ph.setEventType("eventType");
- ph.setCreateTime(DateUtils.now());
- ph.setUpdateTime(DateUtils.now());
- performanceHeaderServiceImpl.queryPerformanceHeader(ph, 1, 10);
- }
-
- @Test
- public void testQueryId() throws Exception {
- String[] id = {};
- performanceHeaderServiceImpl.queryId(id);
- }
-
- @Test
- public void testQueryAllSourceId() throws Exception {
- String[] id = {};
- performanceHeaderServiceImpl.queryAllSourceId();
- }
-
- @Test(expected = Exception.class)
- public void testSavePerformanceHeaderException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- PerformanceHeader ph = null;
- performanceHeaderServiceImpl.savePerformanceHeader(ph);
- }
-
- @Test(expected = Exception.class)
- public void testUpdatePerformanceHeaderException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- PerformanceHeader ph = null;
- performanceHeaderServiceImpl.updatePerformanceHeader(ph);
- }
-
- @Test(expected = Exception.class)
- public void testGetAllCountByEventTypeException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- performanceHeaderServiceImpl.getAllCountByEventType();
- }
-
- @Test(expected = Exception.class)
- public void testGetAllByEventTypeException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- performanceHeaderServiceImpl.getAllByEventType("eventName", "sourceName", "reportingEntityName", DateUtils.now(), DateUtils.now());
- }
-
- @Test(expected = Exception.class)
- public void testGetPerformanceHeaderDetailException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- performanceHeaderServiceImpl.getPerformanceHeaderDetail(1);
- }
-
- @Test(expected = Exception.class)
- public void testGetAllByDatetimeException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- performanceHeaderServiceImpl.getAllByDatetime("eventId", "createTime");
- }
-
- @Test(expected = Exception.class)
- public void testGetAllCountException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- PerformanceHeader ph = new PerformanceHeader();
- performanceHeaderServiceImpl.getAllCount(ph, 1, 10);
- }
-
- @Test(expected = Exception.class)
- public void testQueryPerformanceHeaderException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- PerformanceHeader ph = new PerformanceHeader();
- performanceHeaderServiceImpl.queryPerformanceHeader(ph, 1, 10);
- }
-
- @Test(expected = Exception.class)
- public void testQueryIdException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- String[] id = {};
- performanceHeaderServiceImpl.queryId(id);
- }
-
- @Test(expected = Exception.class)
- public void testQueryAllSourceIdException() throws Exception {
- new MockUp<PerformanceHeaderServiceImpl>() {
- @Mock
- private Session getSession() throws Exception {
- throw new Exception();
- }
- };
- String[] id = {};
- performanceHeaderServiceImpl.queryAllSourceId();
- }
-} \ No newline at end of file
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
deleted file mode 100644
index fb0f29ca..00000000
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
+++ /dev/null
@@ -1,241 +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.
- */
-
-package org.onap.usecaseui.server.service.impl;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.PerformanceInformation;
-import org.onap.usecaseui.server.service.PerformanceInformationService;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import javax.annotation.Resource;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-import static org.mockito.Mockito.mock;
-
-/**
-* PerformanceInformationServiceImpl Tester.
-*
-* @author <Authors name>
-* @since <pre> 8, 2018</pre>
-* @version 1.0
-*/
-public class PerformanceInformationServiceImplTest {
- /*@Resource(name = "PerformanceInformationService")
- PerformanceInformationService performanceInformationService;*/
- PerformanceInformationServiceImpl service;
-@Before
-public void before() throws Exception {
- service = mock(PerformanceInformationServiceImpl.class);
-}
-
-@After
-public void after() throws Exception {
-}
-
-private Session session;
-private Transaction transaction;
-private Query query;
-/**
- * mockupUtil
- */
-public void mockupUtil(){
- MockUp<Query> mockUpQuery = new MockUp<Query>() {
- };
- MockUp<Session> mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String sql) {
- return mockUpQuery.getMockInstance();
- }
- @Mock
- public Transaction beginTransaction() {
- return transaction;
- }
- };
- new MockUp<SessionFactory>() {
- @Mock
- public Session openSession() {
- return mockedSession.getMockInstance();
- }
- };
- new MockUp<Transaction>() {
- @Mock
- public void commit() {
- }
- };
- new MockUp<AlarmsInformationServiceImpl>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-}
-/**
-*
-* Method: savePerformanceInformation(PerformanceInformation performanceInformation)
-*
-*/
-@Test
-public void testSavePerformanceInformation() throws Exception {
-//TODO: Test goes here...
-
- PerformanceInformation a = new PerformanceInformation();
-
- a.setEventId("123");
- a.setName("SGS.UeUnreachable");
- a.setValue("40");
- a.setCreateTime(DateUtils.now());
- a.setUpdateTime(DateUtils.now());
- mockupUtil();
- service.savePerformanceInformation(a);
-
-}
-
-/**
-*
-* Method: updatePerformanceInformation(PerformanceInformation performanceInformation)
-*
-*/
-@Test
-public void testUpdatePerformanceInformation() throws Exception {
-//TODO: Test goes here...
-
- PerformanceInformation a = new PerformanceInformation();
- a.setEventId("110");
- a.setName("efw");
- a.setValue("fko11");
- a.setUpdateTime(DateUtils.now());
- a.setCreateTime(DateUtils.now());
- mockupUtil();
- service.updatePerformanceInformation(a);
-}
-
-/**
-*
-* Method: getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize)
-*
-*/
-@Test
-public void testGetAllCount() throws Exception {
-//TODO: Test goes here...
-
- PerformanceInformation performanceInformation = new PerformanceInformation();
- performanceInformation.setName("vnf_a_3");
-
- mockupUtil();
- service.getAllCount(performanceInformation,0,12);
-
-}
-
-/**
-*
-* Method: queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize)
-*
-*/
-@Test
-public void testQueryPerformanceInformation() throws Exception {
-//TODO: Test goes here...
- PerformanceInformation a = new PerformanceInformation();
- // a.setEventId("2202");
- mockupUtil();
- service.queryPerformanceInformation(a, 1, 100);
- // .getList().forEach(al -> System.out.println(al.getValue()));
-}
-
-/**
-*
-* Method: queryId(String[] id)
-*
-*/
-@Test
-public void testQueryId() throws Exception {
-//TODO: Test goes here...
- mockupUtil();
- service.queryId(new String[]{"2202"});
- // .forEach(ai -> System.out.println(ai.getCreateTime()));
-}
-
-/**
-*
-* Method: queryDateBetween(String eventId, Date startDate, Date endDate)
-*
-*/
-@Test
-public void testQueryDateBetweenForEventIdStartDateEndDate() throws Exception {
-//TODO: Test goes here...
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- String star = "2017-11-15 06:30:00";
- String end="2017-11-15 14:45:10";
- Date stard = sdf.parse(star);
- Date endd = sdf.parse(end);
- // mockupUtil();
- service.queryDateBetween("1101ZTHX1MMEGJM1W1",stard,endd);
-}
-
-/**
-*
-* Method: queryDateBetween(String resourceId, String name, String startTime, String endTime)
-*
-*/
-@Test
-public void testQueryDateBetweenForResourceIdNameStartTimeEndTime() throws Exception {
-//TODO: Test goes here...
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- String star = "2017-11-15 06:30:00";
- String end="2017-11-15 14:45:10";
- Date stard = sdf.parse(star);
- Date endd = sdf.parse(end);
- mockupUtil();
- service.queryDateBetween("1101ZTHX1MMEGJM1W1",stard,endd);
-
-}
-
-/**
-*
-* Method: queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime)
-*
-*/
-@Test
-public void testQueryMaxValueByBetweenDate() throws Exception {
-//TODO: Test goes here...
- mockupUtil();
- service.queryDateBetween("2202", DateUtils.stringToDate("2017-10-15 01:00:00"), DateUtils.stringToDate("2017-10-15 02:00:00")).forEach(p -> System.out.println(p));
-
-}
-
-
-}
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java b/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java
index 46cd1f92..50ee6e48 100755
--- a/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java
@@ -15,7 +15,6 @@
*/
package org.onap.usecaseui.server.util;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
@@ -25,6 +24,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+@RunWith(SpringRunner.class)
+@SpringBootTest
public class CSVUtilsTest {
@Test
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java b/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
index a7aba26f..c4b363df 100755
--- a/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
@@ -15,14 +15,9 @@
*/
package org.onap.usecaseui.server.util;
-import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.constant.Constant;
-
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import java.text.ParseException;
@@ -33,41 +28,66 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
+@RunWith(SpringRunner.class)
+@SpringBootTest
public class DateUtilsTest {
+
@Test
- public void stringToDate() throws ParseException {
- Date result = DateUtils.stringToDate("2017-08-12 13:12:12");
- Assert.assertEquals(result,new SimpleDateFormat(Constant.DATE_FORMAT).parse("2017-08-12 13:12:12"));
+ public void stringToDate(){
+ try {
+ System.out.println(DateUtils.stringToDate("2017-09-28 16:00:00"));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
}
@Test
public void dateToString(){
- Assert.assertEquals(DateUtils.dateToString(new Date()),new SimpleDateFormat(Constant.DATE_FORMAT).format(new Date()));
- }
+ System.out.println(DateUtils.dateToString(new Date()));
+ }
@Test
- public void now() throws ParseException {
- Assert.assertNotNull(DateUtils.now());
+ public void initDate(){
+ try {
+ System.out.println(DateUtils.initDate(new Date(),0,0,0,0,0,0));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
}
@Test
- public void testGetYearMonthDayHourMinuteSecond(){
- DateUtils dateUtils = new DateUtils();
- String str = dateUtils.getYearMonthDayHourMinuteSecond(System.currentTimeMillis());
-
+ public void initProcessDate(){
+ try {
+ System.out.println(DateUtils.initProcessDate(new Date(),0,0,0,0,0,0));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
- }
+ @Test
+ public void now(){
+ try {
+ System.out.println(DateUtils.now());
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
@Test
- public void addDate() throws ParseException {
- Assert.assertNotNull(DateUtils.addDate(new Date(),"year",1));
- Assert.assertNotNull(DateUtils.addDate(new Date(),"month",1));
- Assert.assertNotNull(DateUtils.addDate(new Date(),"month",13));
- Assert.assertNotNull(DateUtils.addDate(new Date(),"day",1));
- Assert.assertNotNull(DateUtils.addDate(new Date(),"day",10));
- Assert.assertNotNull(DateUtils.addDate(new Date(),"hour",1));
- Assert.assertNotNull(DateUtils.addDate(new Date(),"hour",24));
- Assert.assertNotNull(DateUtils.addDate(new Date(),"minute",1));
+ public void addDate(){
+ try {
+ LocalDateTime localDateTime = LocalDateTime.now();
+ System.out.println(localDateTime.withDayOfMonth(0));
+ System.out.println(DateUtils.addDate(new Date(),"day",1));
+ /*System.out.println(DateUtils.addDate(new Date(),"month",1));
+ System.out.println(DateUtils.addDate(new Date(),"year",-1));*/
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
}
+
+
+
+
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/ResponseUtilTest.java b/server/src/test/java/org/onap/usecaseui/server/util/ResponseUtilTest.java
deleted file mode 100644
index 00374903..00000000
--- a/server/src/test/java/org/onap/usecaseui/server/util/ResponseUtilTest.java
+++ /dev/null
@@ -1,54 +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.
- */
-package org.onap.usecaseui.server.util;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-import javax.servlet.http.HttpServletResponse;
-
-/**
-* ResponseUtil Tester.
-*
-* @author <Authors name>
-* @since <pre>���� 14, 2018</pre>
-* @version 1.0
-*/
-public class ResponseUtilTest {
-
-@Before
-public void before() throws Exception {
-}
-
-@After
-public void after() throws Exception {
-}
-
-/**
-*
-* Method: responseDownload(String filePath, HttpServletResponse response)
-*
-*/
-@Test
-public void testResponseDownload() throws Exception {
-//TODO: Test goes here...
- HttpServletResponse httpServletResponse = null;
- ResponseUtil.responseDownload("D:/topology.csv", httpServletResponse);
-}
-
-
-}
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/RestfulServicesTest.java b/server/src/test/java/org/onap/usecaseui/server/util/RestfulServicesTest.java
index 7946d69f..d229c275 100644
--- a/server/src/test/java/org/onap/usecaseui/server/util/RestfulServicesTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/util/RestfulServicesTest.java
@@ -1,5 +1,5 @@
-/*
- * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+/**
+ * Copyright 2016-2017 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,75 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.usecaseui.server.util;
+package org.onap.usecaseui.server.util;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
+public class RestfulServicesTest {
+ @Test
+ public void testCreateServiceImpl() throws Exception {
+ Object aaiService = createService(AAIService.class);
-/**
-* RestfulServices Tester.
-*
-* @author <Authors name>
-* @since <pre>���� 14, 2018</pre>
-* @version 1.0
-*/
-public class RestfulServicesTest {
+ Assert.assertTrue(aaiService instanceof AAIService);
+ }
-@Before
-public void before() throws Exception {
-}
-
-@After
-public void after() throws Exception {
-}
-
-/**
-*
-* Method: create(String baseUrl, Class<T> clazz)
-*
-*/
-@Test
-public void testCreateForBaseUrlClazz() throws Exception {
-//TODO: Test goes here...
-}
-
-/**
-*
-* Method: create(Class<T> clazz)
-*
-*/
-@Test
-public void testCreateClazz() throws Exception {
-//TODO: Test goes here...
- RestfulServices.create(RestfulServicesTest.class);
-}
-
-/**
-*
-* Method: getMsbAddress()
-*
-*/
-@Test
-public void testGetMsbAddress() throws Exception {
-//TODO: Test goes here...
- RestfulServices.getMsbAddress();
-}
-
-/**
-*
-* Method: extractBody(HttpServletRequest request)
-*
-*/
-@Test
-public void testExtractBody() throws Exception {
-//TODO: Test goes here...
- HttpServletRequest request = null;
- RestfulServices.extractBody(request);
-}
-
-
-}
+ private <T> Object createService(Class<T> clazz) {
+ return RestfulServices.create(clazz);
+ }
+} \ No newline at end of file
diff --git a/standalone/src/main/assembly/resources/topologyD_data.json b/standalone/src/main/assembly/resources/topologyD_data.json
deleted file mode 100644
index b945ae3a..00000000
--- a/standalone/src/main/assembly/resources/topologyD_data.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "services":[
- {"ServiceName":"VoLTE"},
- {"ServiceName":"VoLTE_1"}
- ],
- "networkServices":[
- {"nsName":"ns1","parentService":"VoLTE"},
- {"nsName":"ns2","parentService":"VoLTE"},
- {"nsName":"ns3","parentService":"VoLTE"}
- ],
- "VNFS":[
- {"vnfName":"vnf_a_1","parentNS":"ns1"},
- {"vnfName":"vnf_a_2","parentNS":"ns1"},
- {"vnfName":"vnf_a_3","parentNS":"ns1"},
- {"vnfName":"vnf_b_1","parentNS":"ns2"},
- {"vnfName":"vnf_b_2","parentNS":"ns2"},
- {"vnfName":"vnf_b_3","parentNS":"ns2"},
- {"vnfName":"vnf_c_1","parentNS":"ns3"},
- {"vnfName":"vnf_c_1","parentNS":"ns3"}
- ]
-} \ No newline at end of file