aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhangab <zhanganbing@chinamobile.com>2018-04-09 14:30:42 +0800
committerzhangab <zhanganbing@chinamobile.com>2018-04-09 14:30:47 +0800
commit6e7544cee0b2163bf7769175421a1997d54ac0d6 (patch)
treee724295169cc7d465431da05796c69175e42513d
parent72b7f8326affcba2f58d5f0616816ce17f8b7472 (diff)
improve sonar coverage for uui-server
Change-Id: Iba105358a5a372f520d499a6a90d92ec17abea12 Issue-ID: USECASEUI-103 Signed-off-by: zhangab <zhanganbing@chinamobile.com>
-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
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java34
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java135
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java177
-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
-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.java14
-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.java4
-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.java14
-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.java138
-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.java60
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationVmServiceImpl.java302
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java71
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java389
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java304
-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/PerformanceInformationServiceImplTest.java2
27 files changed, 4783 insertions, 277 deletions
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
new file mode 100644
index 00000000..f48ee9b9
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderPm.java
@@ -0,0 +1,281 @@
+/**
+ * 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
new file mode 100644
index 00000000..1aaa28e7
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeaderVm.java
@@ -0,0 +1,281 @@
+/**
+ * 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
new file mode 100644
index 00000000..881c5a6f
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationPm.java
@@ -0,0 +1,114 @@
+/**
+ * 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
new file mode 100644
index 00000000..aa53fdc9
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformationVm.java
@@ -0,0 +1,114 @@
+/**
+ * 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/PerformanceBo.java b/server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java
index e0e716aa..3031b06d 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
@@ -27,7 +27,13 @@ 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() {
@@ -51,10 +57,38 @@ public class PerformanceBo implements Serializable {
}
+ 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/controller/AlarmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
index 55efa84e..0040a072 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,11 +16,6 @@
package org.onap.usecaseui.server.controller;
import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.usecaseui.server.bean.AlarmsHeader;
@@ -55,9 +50,6 @@ public class AlarmController {
@Resource(name = "AlarmsHeaderService")
private AlarmsHeaderService alarmsHeaderService;
- /* public AlarmsHeaderService getAlarmsHeaderService() {
- return alarmsHeaderService;
- }*/
public void setAlarmsHeaderService(AlarmsHeaderService alarmsHeaderService) {
this.alarmsHeaderService = alarmsHeaderService;
@@ -75,17 +67,6 @@ public class AlarmController {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
-
-
-
-
-
-
-
-
-
-
-
@RequestMapping(value = {"/alarm/{currentPage}/{pageSize}",
"/alarm/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}/{vfStatus}"},
method = RequestMethod.GET, produces = "application/json")
@@ -217,32 +198,122 @@ public class AlarmController {
}
-
@RequestMapping(value = "/alarm/statusCount", method = RequestMethod.GET, produces = "application/json")
- public String getStatusCount() {
+ public String getStatusCount() throws JsonProcessingException {
List<String> statusCount = new ArrayList<>();
- try {
+
statusCount.add(alarmsHeaderService.queryStatusCount("0"));
statusCount.add(alarmsHeaderService.queryStatusCount("active"));
statusCount.add(alarmsHeaderService.queryStatusCount("close"));
return omAlarm.writeValueAsString(statusCount);
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- logger.error(e.getMessage());
- }
- return null;
- }
-
-
-
-
+ }
+ @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);
+ }
+ }
+ 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);
+ }
+ 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 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, 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());
+ e.printStackTrace();
+ }
+ 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 73222498..fee843bc 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,12 +22,8 @@ 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.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.service.*;
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;
@@ -50,6 +46,8 @@ public class PerformanceController {
@Resource(name = "PerformanceHeaderService")
private PerformanceHeaderService performanceHeaderService;
+ @Resource(name = "PerformanceInformationService")
+ private PerformanceInformationService performanceInformationService;
public void setPerformanceHeaderService(PerformanceHeaderService performanceHeaderService) {
this.performanceHeaderService = performanceHeaderService;
@@ -60,9 +58,6 @@ public class PerformanceController {
this.performanceInformationService = performanceInformationService;
}
- @Resource(name = "PerformanceInformationService")
- private PerformanceInformationService performanceInformationService;
-
private Logger logger = LoggerFactory.getLogger(PerformanceController.class);
private final String[] PerformanceCSVHeaders = {"version",
@@ -81,7 +76,7 @@ public class PerformanceController {
@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 getAlarmData Apis, " +
+ logger.info("transfer getPerformanceData Apis, " +
"Parameter all follows : [currentPage : {} , pageSize : {} , sourceId : {} , " +
"sourceName : {} , priority : {} , startTime :{} , endTime : {} ]"
, currentPage, pageSize, sourceId, sourceName, priority, startTime, endTime);
@@ -146,6 +141,8 @@ public class PerformanceController {
pera.setUpdateTime(formatter.parse(updatetime));
performanceInformations.add(pera);
+
+
}else{
performanceInformations = performanceInformationService.queryPerformanceInformation(pe, 1, 100).getList();
@@ -153,10 +150,8 @@ public class PerformanceController {
pbo.setPerformanceHeader(per);
performanceInformations.forEach(pi -> {
if (pi.getValue().equals("")) {
- // List<PerformanceInformation> perf = new ArrayList<PerformanceInformation>();
+ StringBuffer value1 = new StringBuffer();
- StringBuffer value1 = new StringBuffer();
- // if()
performanceInformationService.queryPerformanceInformation(new PerformanceInformation(pi.getName()), 1, 100).getList()
.forEach(val -> value1.append(val.getValue()));
pi.setValue(value1.toString());
@@ -164,30 +159,35 @@ public class PerformanceController {
});
pbo.setPerformanceInformation(performanceInformations);
list.add(pbo);
- //});
+
}
}
} else {
pa = performanceHeaderService.queryPerformanceHeader(null, currentPage, pageSize);
if (pa == null) {
- PerformanceHeader performanceHeader_s = new PerformanceHeader();
+ 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_s.setSourceName("101ZTHX1EPO1NK7E0Z2");
- performanceHeader_s.setSourceId("1101ZTHX1EPO1NK7E0Z2");
- 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));
- performanceHeaderList.add(performanceHeader_s);
- performanceHeader_s.setId(5);
+ 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);
}
- //alarmsHeaders = pa.getList();
- //if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
+ //performanceHeaders = pa.getList();
+ //if (null != performanceHeaders && performanceHeaders.size() > 0) {
//list = pa.getList();
List<PerformanceHeader> p = pa != null ? pa.getList() : null;
@@ -207,104 +207,55 @@ public class PerformanceController {
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<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");
- }
- }*/
- /*@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 = {"/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) {
- try {
- return omPerformance.writeValueAsString(diagramDate(sourceId, nameParent, startTime, endTime, format));
- } catch (Exception e) {
- logger.error(e.getMessage());
- e.printStackTrace();
- return null;
- }
+ 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() {
+ public String getSourceIds() throws JsonProcessingException {
List<String> sourceIds = new ArrayList<>();
- try {
- performanceHeaderService.queryAllSourceId().forEach(ph -> {
- if (!sourceIds.contains(ph))
- sourceIds.add(ph);
- });
+ 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);
- } catch (Exception e) {
- logger.error(e.getMessage());
- return null;
- }
+
}
@RequestMapping(value = {"/performance/names"}, method = RequestMethod.POST)
public String getNames(@RequestParam Object sourceId) {
try {
List<String> names = new ArrayList<>();
- //String sourceId_s = sourceId.toString();
-
- //performanceInformationService.queryDateBetween(sourceId.toString(), null, null, null).forEach(per -> {
- List list =performanceInformationService.queryDateBetween(sourceId.toString(), null, null, null);
+ 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) {
@@ -316,7 +267,6 @@ public class PerformanceController {
names.add(per.getName());
}
- // });
return omPerformance.writeValueAsString(names);
} catch (Exception e) {
logger.error(e.getMessage());
@@ -327,9 +277,14 @@ public class PerformanceController {
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, sdf.format(new Date(startTimeL)), sdf.format(new Date(tmpEndTimeL)));
- maps.forEach(map -> {
+ 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"))) {
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
new file mode 100644
index 00000000..99eb1bc4
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/PerformancePmController.java
@@ -0,0 +1,557 @@
+/**
+ * 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
new file mode 100644
index 00000000..8cd0a519
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceVmController.java
@@ -0,0 +1,569 @@
+/**
+ * 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/service/PerformanceHeaderPmService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderPmService.java
new file mode 100644
index 00000000..c546dc72
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderPmService.java
@@ -0,0 +1,47 @@
+/**
+ * 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 ec5172fa..9caf834e 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
@@ -38,6 +38,16 @@ public interface PerformanceHeaderService {
List<String> queryAllSourceId();
- public int getAllCountByStatus(String status);
- public List<PerformanceHeader> getAllByStatus(String status, String eventName, String sourceName, String eventServerity,String reportingEntityName, Date createTime, Date endTime);
+ 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
new file mode 100644
index 00000000..da8e7968
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderVmService.java
@@ -0,0 +1,49 @@
+/*
+ * 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
new file mode 100644
index 00000000..2dc6c7d3
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationPmService.java
@@ -0,0 +1,45 @@
+/*
+ * 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 a29ec2df..2d2cad49 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
@@ -40,4 +40,8 @@ public interface PerformanceInformationService {
List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime);
List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, 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
new file mode 100644
index 00000000..ab8e94d7
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationVmService.java
@@ -0,0 +1,45 @@
+/*
+ * 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 6abaf0f3..6f8904a5 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
@@ -202,7 +202,7 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
if(!"0".equals(eventServrity) && eventServrity!=null) {
query.setString("eventServrity", eventServrity);
}
- if(!"0".equals(reportingEntityName) && eventServrity!=null) {
+ if(!"0".equals(reportingEntityName) && reportingEntityName!=null) {
query.setString("reportingEntityName", reportingEntityName);
}
if( null!=createTime && endTime!= null) {
@@ -251,9 +251,15 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
Query query = session.createQuery(string.toString());
- query.setString("status",status);
- query.setString("eventId",eventId);
- query.setString("eventServrity",eventServrity);
+ 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);
+ }
String num = query.uniqueResult().toString();
session.flush();
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
new file mode 100644
index 00000000..bef75986
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderPmServiceImpl.java
@@ -0,0 +1,479 @@
+/*
+ * 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 d92ff953..77810b9d 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
@@ -47,14 +47,18 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
@Autowired
private SessionFactory sessionFactory;
- private Session getSession() {
+
+
+ private Session getSessionFactory(){
return sessionFactory.openSession();
}
+
+
@Override
public String savePerformanceHeader(PerformanceHeader performanceHeder) {
- try(Session session = getSession();){
+ try(Session session = getSessionFactory();){
if (null == performanceHeder){
logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");
}
@@ -74,7 +78,7 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
@Override
public String updatePerformanceHeader(PerformanceHeader performanceHeder) {
- try(Session session = getSession();){
+ try(Session session = getSessionFactory();){
if (null == performanceHeder){
logger.error("PerformanceHeaderServiceImpl updatePerformanceHeader performanceHeder is null!");
}
@@ -94,15 +98,17 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
+
+
@Override
- public int getAllCountByStatus(String status){
- try (Session session = getSession()){
+ public int getAllCountByEventType(){
+ try (Session session = getSessionFactory()){
StringBuffer count = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");
- if(!"0".equals(status)){
+ /*if(!"0".equals(status)){
count.append(" and a.status=:status");
- }
+ }*/
Query query =session.createQuery(count.toString());
- query.setString("status",status);
+ /*query.setString("status",status);*/
//int q = (int)query.uniqueResult();
long q=(long)query.uniqueResult();
session.flush();
@@ -113,33 +119,44 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
}
+
+
+
+
@Override
- public List<PerformanceHeader> getAllByStatus(String status,String eventName,String sourceName,String eventServerity,String reportingEntityName, Date createTime, Date endTime){
- try (Session session = getSession()){
+ public List<PerformanceHeader> getAllByEventType(String eventName,String sourceName,String reportingEntityName, Date createTime, Date endTime){
+ try (Session session = getSessionFactory()){
StringBuffer string = new StringBuffer("from PerformanceHeader a where 1=1");
- if(!"0".equals(status)){
+ /*if(!"0".equals(status)){
string.append(" and a.status=:status");
- }if(!"".equals(eventName) && eventName!=null){
+ }*/
+ if(!"0".equals(eventName) && eventName!=null){
string.append(" and a.eventName=:eventName");
}
- if(!"".equals(sourceName) && sourceName!=null){
+ if(!"0".equals(sourceName) && sourceName!=null){
string.append(" and a.sourceName=:sourceName");
}
- if(!"".equals(eventServerity) && eventServerity!=null){
- string.append(" and a.eventServerity=:eventServerity");
- }
- if(!"".equals(reportingEntityName) && eventServerity!=null){
+
+ 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());
- query.setString("status",status);
- query.setString("eventName",eventName);
- query.setString("sourceName",sourceName);
- query.setString("eventServerity",eventServerity);
- query.setString("reportingEntityName",reportingEntityName);
+ /*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);
@@ -164,13 +181,82 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
+ @Override
+ public PerformanceHeader getPerformanceHeaderDetail(Integer id) {
+ try(Session session = getSessionFactory()) {
+
+ 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 = getSessionFactory();){
+ StringBuffer string = new StringBuffer("select count(*) as count from PerformanceHeader 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 PerformanceHeaderServiceImpl getAllCount."+e.getMessage());
+ return 0;
+ }
+
+ }
+
+
public int getAllCount(PerformanceHeader performanceHeder, int currentPage, int pageSize) {
- try(Session session = getSession();){
+ try(Session session = getSessionFactory();){
StringBuffer hql = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");
if (null == performanceHeder) {
//logger.error("PerformanceHeaderServiceImpl getAllCount performanceHeder is null!");
@@ -269,7 +355,7 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
int allRow =this.getAllCount(performanceHeder,currentPage,pageSize);
int offset = page.countOffset(currentPage, pageSize);
- try(Session session = getSession();){
+ try(Session session = getSessionFactory();){
StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");
if (null == performanceHeder) {
//logger.error("PerformanceHeaderServiceImpl queryPerformanceHeader performanceHeder is null!");
@@ -371,7 +457,7 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
@SuppressWarnings("unchecked")
@Override
public List<PerformanceHeader> queryId(String[] id) {
- try(Session session = getSession();) {
+ try(Session session = getSessionFactory();) {
if(id.length==0) {
logger.error("PerformanceHeaderServiceImpl queryId is null!");
}
@@ -388,7 +474,7 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
@Override
public List<String> queryAllSourceId() {
- try(Session session = getSession();) {
+ try(Session session = getSessionFactory();) {
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
new file mode 100644
index 00000000..fd93d934
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderVmServiceImpl.java
@@ -0,0 +1,467 @@
+/*
+ * 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
new file mode 100644
index 00000000..9c981863
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationPmServiceImpl.java
@@ -0,0 +1,301 @@
+/*
+ * 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 84094892..e205375b 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
@@ -44,14 +44,52 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@Autowired
private SessionFactory sessionFactory;
- private Session getSession() {
+
+ 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 = getSession();) {
+ try(Session session = getSessionFactory();) {
if (null == performanceInformation) {
logger.error("performanceInformation savePerformanceInformation performanceInformation is null!");
}
@@ -71,7 +109,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@Override
public String updatePerformanceInformation(PerformanceInformation performanceInformation) {
- try(Session session = getSession();) {
+ try(Session session = getSessionFactory();) {
if (null == performanceInformation) {
logger.error("performanceInformation updatePerformanceInformation performanceInformation is null!");
}
@@ -89,10 +127,10 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
public int getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize) {
- try(Session session = getSession();){
+ try(Session session = getSessionFactory();){
StringBuffer hql = new StringBuffer("select count(*) from PerformanceInformation a where 1=1");
if (null == performanceInformation) {
- //logger.error("AlarmsInformationServiceImpl getAllCount performanceInformation is null!");
+ //logger.error("PerformanceInformationServiceImpl getAllCount performanceInformation is null!");
}else {
if(null!=performanceInformation.getName()) {
String ver=performanceInformation.getName();
@@ -132,7 +170,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
int allRow =this.getAllCount(performanceInformation,currentPage,pageSize);
int offset = page.countOffset(currentPage, pageSize);
- try(Session session = getSession()){
+ try(Session session = getSessionFactory()){
StringBuffer hql =new StringBuffer("from PerformanceInformation a where 1=1 ");
if (null == performanceInformation) {
@@ -180,7 +218,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@SuppressWarnings("unchecked")
@Override
public List<PerformanceInformation> queryId(String[] id) {
- try(Session session = getSession();) {
+ try(Session session = getSessionFactory();) {
List<PerformanceInformation> list;
Query query = session.createQuery("from PerformanceInformation a where a.eventId IN (:alist)");
list = query.setParameterList("alist", id).list();
@@ -193,10 +231,10 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
}
- @SuppressWarnings("unchecked")
+ /*@SuppressWarnings("unchecked")*/
@Override
public List<PerformanceInformation> queryDateBetween(String eventId,Date startDate, Date endDate) {
- try(Session session = getSession()) {
+ try(Session session = getSessionFactory()) {
List<PerformanceInformation> list ;
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();
@@ -212,7 +250,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@Override
public List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime) {
- try(Session session = getSession()) {
+ try(Session session = getSessionFactory()) {
String hql = "from PerformanceInformation a where 1=1 ";
if (resourceId != null && !"".equals(resourceId)){
hql += " and a.eventId = :resourceId";
@@ -243,7 +281,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
@Override
public List<Map<String,String>> queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime) {
- try(Session session = getSession()) {
+ 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)){
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
new file mode 100644
index 00000000..fb7b7129
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationVmServiceImpl.java
@@ -0,0 +1,302 @@
+/*
+ * 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/DmaapSubscriber.java b/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java
index 3e71dd61..05e40c5e 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
@@ -65,13 +65,17 @@ 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) {
try {
@@ -265,8 +269,13 @@ public class DmaapSubscriber implements Runnable {
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) -> {
@@ -327,7 +336,11 @@ public class DmaapSubscriber implements Runnable {
e.printStackTrace();
}
}else{
-
+ try {
+ performance_informations.add(new PerformanceInformation(fields.get("name"), fields.get("value"), performance_header.getSourceId(), null, DateUtils.now()));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
}
} );
}
@@ -370,6 +383,52 @@ public class DmaapSubscriber implements Runnable {
+ 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{
@@ -384,7 +443,7 @@ public class DmaapSubscriber implements Runnable {
});
logger.info("performance data detail insert has finished. " + performance_informations.size() + " records have been inserted.");
- // }//else 结束
+ }
}
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 9f044fee..bd3c0a9a 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,18 +13,17 @@
* 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 org.omg.PortableInterceptor.INACTIVE;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
+import org.onap.usecaseui.server.service.AlarmsInformationService;
-import javax.servlet.http.HttpServletRequest;
-
-import java.text.ParseException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -34,19 +33,19 @@ import static org.mockito.Mockito.*;
* AlarmController Tester.
*
* @author <Authors name>
-* @since <pre>���� 28, 2018</pre>
+* @since <pre>���� 6, 2018</pre>
* @version 1.0
*/
public class AlarmControllerTest {
-
-
AlarmController controller = new AlarmController();
AlarmsHeaderService service;
-
+ AlarmsInformationService alService;
@Before
public void before() throws Exception {
- AlarmsHeaderService service = mock(AlarmsHeaderService.class);
+ service = mock(AlarmsHeaderService.class);
+ alService = mock(AlarmsInformationService.class);
controller.setAlarmsHeaderService(service);
+ controller.setAlarmsInformationService(alService);
}
@After
@@ -60,8 +59,7 @@ public void after() throws Exception {
*/
@Test
public void testSetAlarmsHeaderService() throws Exception {
-//TODO: Test goes here...
-
+//TODO: Test goes here...
}
/**
@@ -76,21 +74,7 @@ public void testSetAlarmsInformationService() throws Exception {
/**
*
-* Method: getAllByDatetime(@PathVariable(required = false) String eventId, @PathVariable(required = false) String eventServrity, @PathVariable(required = false) String startTime, @PathVariable(required = false) String endTime)
-*
-*/
-
-
-/**
-*
-* Method: getAlarmDataByStatus(@PathVariable String status, @PathVariable(required = false) String eventName, @PathVariable(required = false) String sourceName, @PathVariable(required = false) String eventServerity, @PathVariable(required = false) String reportingEntityName, @PathVariable(required = false) String createTime, @PathVariable(required = false) String endTime)
-*
-*/
-
-
-/**
-*
-* Method: 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)
+* 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
@@ -130,8 +114,38 @@ public void testGetAlarmData() throws Exception {
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);
+ }
-}
/**
*
@@ -150,77 +164,318 @@ public void testGetStatusCount() throws Exception {
verify(service,times(1)).queryStatusCount("active");
verify(service,times(1)).queryStatusCount("close");
-
-
-
-
}
/**
*
-* Method: getTopologyData(@PathVariable String serviceName)
+* Method: getSourceId()
*
*/
@Test
-public void testGetTopologyData() throws Exception {
+public void testGetSourceId() throws Exception {
//TODO: Test goes here...
- AlarmController controller = new AlarmController();
- AlarmsHeaderService service = mock(AlarmsHeaderService.class);
- controller.setAlarmsHeaderService(service);
-
- String serviceName="Fault_MultiCloud_VMFailureCleared";
- //controller.getTopologyData(serviceName);
- //controller.getAllVNFS().get("networkServices");
- //controller.getAllVNFS().get("VNFS");
-
-
-
+ controller.getSourceId();
+ AlarmsHeader alarmsHeader = new AlarmsHeader();
+ verify(service,times(1)).queryAlarmsHeader(alarmsHeader,1,12);
}
/**
*
-* Method: getTopologyServices()
+* Method: genDiagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String showMode)
*
*/
@Test
-public void testGetTopologyServices() throws Exception {
+public void testGenDiagram() throws Exception {
//TODO: Test goes here...
- AlarmController controller = new AlarmController();
- AlarmsHeaderService service = mock(AlarmsHeaderService.class);
- controller.setAlarmsHeaderService(service);
+ String sourceId="";
+ String startTime="";
+ String endTime="";
+ String nameParent="";
+ String format="";
+ controller.genDiagram(sourceId,startTime,endTime,format);
+}
- AlarmsHeader header = new AlarmsHeader();
- header.setSourceId("shentao-test-2001");
- //controller.getAllVNFS().get("services");
- //controller.getTopologyServices();
+ @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");
+ }
- //verify(service,times(1)).queryAlarmsHeader(header,1,10).getList();
-}
-/**
+ /**
*
-* Method: getAllVNFS()
+* Method: dateProcess(String sourceId, long startTimeL, long endTimeL, long timeIteraPlusVal, long keyVal, long keyValIteraVal, String keyUnit)
*
*/
-/*@Test
-public void testGetAllVNFS() throws Exception {
+@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: getSourceId()
+* 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) {
+}
+}
-/**
-*
-* Method: genDiagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String showMode)
-*
-*/
+ @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) {
+ }
+
+ }
+
+
+
+
+
+ @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) {
+ }
+
+ }
+
+
+
+
+ @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) {
+ }
+
+ }
+
+
+
+
+
+ @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) {
+ }
+
+ }
+
+
+
+
+ @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 b1f5b3f8..0d8432ca 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
@@ -25,6 +25,11 @@ import org.onap.usecaseui.server.service.PerformanceInformationService;
import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
import static org.mockito.Mockito.*;
/**
@@ -35,6 +40,7 @@ import static org.mockito.Mockito.*;
* @version 1.0
*/
public class PerformanceControllerTest {
+ PerformanceController controller_s;
PerformanceController controller = new PerformanceController();
PerformanceHeaderService service;
PerformanceInformationService perservece;
@@ -43,8 +49,10 @@ public class PerformanceControllerTest {
@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
@@ -75,7 +83,49 @@ public void testGetPerformanceData() throws Exception {
}
-/**
+
+
+ @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);
+
+ }
+
+
+
+ @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();
+
+
+ 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)
*
@@ -90,9 +140,22 @@ public void testGenerateDiagram() throws Exception {
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");
+ }
+
+ /**
*
* Method: getSourceIds()
*
@@ -112,10 +175,10 @@ public void testGetSourceIds() throws Exception {
@Test
public void testGetNames() throws Exception {
//TODO: Test goes here...
-Object sourceId="1101ZTHX1MNE1NK7E0";
+Object sourceId="1101ZTHX1MMEGJM1W1";
controller.getNames(sourceId);
- //verify(perservece,times(1)).queryDateBetween(sourceId.toString(),null,null,null);
-}
+ verify(perservece,times(1)).queryDateBetween(sourceId.toString(),null,null,null);
+}
/**
@@ -126,16 +189,35 @@ Object sourceId="1101ZTHX1MNE1NK7E0";
@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 = PerformanceController.getClass().getMethod("dateProcess", String.class, String.class, long.class, long.class, long.class, long.class, long.class, String.class);
+ 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(<Object>, <Parameters>);
+ method.invoke(per,sourceId,name, startTimeL,endTimeL,timeIteraPlusVal,keyVal,keyValIteraVal,keyUnit);
} catch(NoSuchMethodException e) {
} catch(IllegalAccessException e) {
} catch(InvocationTargetException e) {
}
-*/
+
}
/**
@@ -144,18 +226,206 @@ try {
*
*/
@Test
-public void testDiagramDate() throws Exception {
-//TODO: Test goes here...
-/*
+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 = PerformanceController.getClass().getMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
+ Method method = per.getClass().getDeclaredMethod("diagramDate", String.class, String.class, String.class, String.class, String.class);
method.setAccessible(true);
- method.invoke(<Object>, <Parameters>);
+ 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";
+ 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_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/impl/InitializationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/InitializationServiceImplTest.java
new file mode 100644
index 00000000..7362ac3f
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/InitializationServiceImplTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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/PerformanceInformationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
index acdb880f..fb0f29ca 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
@@ -202,7 +202,7 @@ public void testQueryDateBetweenForEventIdStartDateEndDate() throws Exception {
String end="2017-11-15 14:45:10";
Date stard = sdf.parse(star);
Date endd = sdf.parse(end);
- mockupUtil();
+ // mockupUtil();
service.queryDateBetween("1101ZTHX1MMEGJM1W1",stard,endd);
}