summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshentao <shentao@chinamobile.com>2017-09-29 18:05:28 +0800
committershentao <shentao@chinamobile.com>2017-09-29 18:05:40 +0800
commit9cb0aa38d2c59700b87b7b793899b98db8bcbce6 (patch)
tree57c4c6eb65d0da40a0c766b8c8b6add813673e2a
parent658fac23071930ed1c8332b0b7323131f3b66eff (diff)
Add UT code for usecase-ui server
Change-Id: Ic0da039bfb51ab723e626137113dc312fac6bd15 Issue-Id: USECASEUI-47 Signed-off-by: shentao <shentao@chinamobile.com>
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java546
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java212
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java30
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/constant/Constant.java46
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java402
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java184
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java114
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java483
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java345
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java442
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java358
-rwxr-xr-x[-rw-r--r--]server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java10
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java56
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java67
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java188
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java34
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java169
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java34
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java12
-rwxr-xr-x[-rw-r--r--]server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java66
20 files changed, 2105 insertions, 1693 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
index 30e33378..a5afae8d 100644..100755
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
@@ -1,275 +1,271 @@
-/*
- * 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;
-
-/**
- *
- * @author xuekui
- *
- */
-@Entity
-@Table(name="alarms_commoneventheader")
-public class PerformanceHeader implements Serializable {
-
- @Column(name = "version")
- private String version;
-
- @Column(name = "eventName")
- private String eventName;
-
- @Column(name = "domain")
- private String domain;
-
- @Id
- @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 PerformanceHeader() {
- }
-
-
-
- public PerformanceHeader(String version, String eventName, String domain, String eventId, String eventType, String nfcNamingCode, String nfNamingCode, String sourceId, String sourceName, String reportingEntityId, String reportingEntityName, String priority, String startEpochMicrosec, String lastEpochMicroSec, String sequence, String measurementsForVfScalingVersion, String measurementInterval, Date createTime, Date updateTime) {
- this.version = version;
- 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;
- }
-
-
-
-
-}
+/*
+ * 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")
+public class PerformanceHeader implements Serializable {
+
+ @Column(name = "version")
+ private String version;
+
+ @Column(name = "eventName")
+ private String eventName;
+
+ @Column(name = "domain")
+ private String domain;
+
+ @Id
+ @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 PerformanceHeader() {
+ }
+
+
+
+ public PerformanceHeader(String version, String eventName, String domain, String eventId, String eventType, String nfcNamingCode, String nfNamingCode, String sourceId, String sourceName, String reportingEntityId, String reportingEntityName, String priority, String startEpochMicrosec, String lastEpochMicroSec, String sequence, String measurementsForVfScalingVersion, String measurementInterval, Date createTime, Date updateTime) {
+ this.version = version;
+ 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;
+ }
+
+
+
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
index 12bb7887..d2c71ade 100644..100755
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
@@ -1,108 +1,104 @@
-/*
- * 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;
-
-/**
- *
- * @author xuekui
- *
- */
-@Entity
-@Table(name="alarms_additionalinformation")
-public class PerformanceInformation implements Serializable {
-
- @Id
- @Column(name = "name")
- private String name;
-
- @Column(name = "value")
- private String value;
-
- @Id
- @Column(name = "eventId")
- private String eventId;
-
- @Column(name = "createTime")
- private Date createTime;
-
- @Column(name = "updateTime")
- private Date updateTime;
-
- public PerformanceInformation() {
- }
-
- public PerformanceInformation(String eventId) {
- this.eventId = eventId;
- }
-
- public PerformanceInformation(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;
- }
-
-
-}
+/*
+ * 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")
+public class PerformanceInformation implements Serializable {
+
+ @Id
+ @Column(name = "name")
+ private String name;
+
+ @Column(name = "value")
+ private String value;
+
+ @Id
+ @Column(name = "eventId")
+ private String eventId;
+
+ @Column(name = "createTime")
+ private Date createTime;
+
+ @Column(name = "updateTime")
+ private Date updateTime;
+
+ public PerformanceInformation() {
+ }
+
+ public PerformanceInformation(String eventId) {
+ this.eventId = eventId;
+ }
+
+ public PerformanceInformation(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;
+ }
+
+
+}
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 b5a3fe5e..b3bd5965 100644..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
@@ -20,25 +20,21 @@ import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.util.Page;
import java.io.Serializable;
+import java.util.List;
public class PerformanceBo implements Serializable {
private PerformanceHeader performanceHeader;
- private PerformanceInformation performanceInformation;
+ private List<PerformanceInformation> performanceInformation;
- private int currentPage;
-
- private int pageSize;
public PerformanceBo() {
}
- public PerformanceBo(PerformanceHeader performanceHeader, PerformanceInformation performanceInformation, int currentPage, int pageSize) {
+ public PerformanceBo(PerformanceHeader performanceHeader, List<PerformanceInformation> performanceInformation) {
this.performanceHeader = performanceHeader;
this.performanceInformation = performanceInformation;
- this.currentPage = currentPage;
- this.pageSize = pageSize;
}
public PerformanceHeader getPerformanceHeader() {
@@ -49,27 +45,11 @@ public class PerformanceBo implements Serializable {
this.performanceHeader = performanceHeader;
}
- public PerformanceInformation getPerformanceInformation() {
+ public List<PerformanceInformation> getPerformanceInformation() {
return performanceInformation;
}
- public void setPerformanceInformation(PerformanceInformation performanceInformation) {
+ public void setPerformanceInformation(List<PerformanceInformation> performanceInformation) {
this.performanceInformation = performanceInformation;
}
-
- public int getCurrentPage() {
- return currentPage;
- }
-
- public void setCurrentPage(int currentPage) {
- this.currentPage = currentPage;
- }
-
- public int getPageSize() {
- return pageSize;
- }
-
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
index bf311d6c..ab95eb2d 100644..100755
--- a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
+++ b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
@@ -1,22 +1,24 @@
-/*
- * 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.constant;
-
-
-public final class Constant
-{
-
-}
+/*
+ * 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.constant;
+
+
+public final class Constant
+{
+
+ public static final String DATE_FROMAT= "yyyy-MM-dd HH:mm:ss";
+
+}
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 001a4885..e01bf043 100644..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
@@ -1,187 +1,215 @@
-/*
- * 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 javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.hibernate.annotations.Parameter;
-import org.onap.usecaseui.server.bean.AlarmsHeader;
-import org.onap.usecaseui.server.bean.AlarmsInformation;
-import org.onap.usecaseui.server.bean.PerformanceHeader;
-import org.onap.usecaseui.server.bean.PerformanceInformation;
-import org.onap.usecaseui.server.bo.AlarmBo;
-import org.onap.usecaseui.server.service.AlarmsHeaderService;
-import org.onap.usecaseui.server.service.AlarmsInformationService;
-import org.onap.usecaseui.server.util.CSVUtils;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.wrapper.AlarmWrapper;
-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.Controller;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.servlet.ModelAndView;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-
-@RestController
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class AlarmController
-{
-
-
- private final Logger logger = LoggerFactory.getLogger(AlarmController.class);
-
- @Resource(name = "AlarmsHeaderService")
- private AlarmsHeaderService alarmsHeaderService;
-
- @Resource(name = "AlarmsInformationService")
- private AlarmsInformationService alarmsInformationService;
-
-
- @RequestMapping(value = {"/usecase-ui"}, method = RequestMethod.GET)
- public ModelAndView index(){
- return new ModelAndView("index");
- }
-
- @RequestMapping(value = {"/usecaseui-server/alarm/{currentPage}/{pageSize}","/usecaseui-server/alarm/{currentPage}/{pageSize}/{eventId}/{eventName}/{name}/{value}/{createTime}"}, method = RequestMethod.GET , produces = "application/json")
- public String getAlarmData(@PathVariable(required = false) String eventId,@PathVariable(required = false) String eventName,
- @PathVariable(required = false) String name,@PathVariable(required = false) String value,
- @PathVariable(required = false) String createTime,@PathVariable int currentPage,
- @PathVariable int pageSize) {
- List<AlarmsHeader> alarmsHeaders = null;
- List<AlarmBo> maps = new ArrayList<>();
- if (null != eventId || null != eventName || null != name || null != value || null != createTime ){
- AlarmsHeader alarm = new AlarmsHeader();
- alarm.setEventId(!"null".equals(eventId)?eventId:null);
- alarm.setEventName(!"null".equals(eventName)?eventName:null);
- try {
- alarm.setCreateTime(!"null".equals(createTime)?DateUtils.stringToDate(createTime):null);
- } catch (ParseException e) {
- logger.error("Parse date error :"+e.getMessage());
- }
- alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(alarm,currentPage,pageSize).getList();
- if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
- alarmsHeaders.forEach(a ->{
- AlarmBo abo = new AlarmBo();
- abo.setAlarmsHeader(a);
- AlarmsInformation information = new AlarmsInformation();
- information.setName(!"null".equals(name)?name:null);
- information.setValue(!"null".equals(value)?value:null);
- information.setEventId(a.getEventId());
- abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(information,1,100).getList());
- maps.add(abo);
- });
- }
- }else {
- alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(null, currentPage, pageSize).getList();
- if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
- alarmsHeaders.forEach(a -> {
- AlarmBo abo = new AlarmBo();
- abo.setAlarmsHeader(a);
- abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(a.getEventId()),currentPage,pageSize).getList());
- maps.add(abo);
- });
- }
- }
- try {
- return new ObjectMapper().writeValueAsString(maps);
- } catch (JsonProcessingException e) {
- logger.debug("JsonProcessingException :"+e.getMessage());
- return "";
- }
- }
-
- @RequestMapping(value = { "/usecaseui-server/alarm/genCsv/{eventId}" } , method = RequestMethod.GET , produces = "application/json")
- public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId){
- String csvFile = "csvFiles/vnf_alarm_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
- response.setCharacterEncoding("utf-8");
- response.setContentType("application/csv");
- response.setHeader("Content-Disposition","attachment;filename="+csvFile);
- String[] headers = new String[]{"version",
- "eventName","domain","eventId","eventType","nfcNamingCode",
- "nfNamingCode","sourceId","sourceName","reportingEntityId",
- "reportingEntityName","priority","startEpochMicrosec","lastEpochMicroSec",
- "sequence","faultFieldsVersion","eventServrity","eventSourceType",
- "eventCategory","alarmCondition","specificProblem","vfStatus",
- "alarmInterfaceA","status",
- "createTime","updateTime","name","value"};
- List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryId(eventId);
- List<String[]> csvData = new ArrayList<>();
- alarmsHeaders.forEach(ala ->{
- List<AlarmsInformation> information = alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(ala.getEventId()),1,100).getList();
- String names = new String();
- String values = new String();
- if (0 < information.size() && null != information){
- for (AlarmsInformation a : information){
- names += a.getName()+",";
- values += a.getValue()+",";
- }
- names = names.substring(0,names.lastIndexOf(','));
- values = values.substring(0,values.lastIndexOf(','));
- }
- csvData.add(new String[]{
- ala.getVersion(),ala.getEventName(),ala.getDomain(),ala.getEventId(),ala.getEventType(),
- ala.getNfcNamingCode(),ala.getNfNamingCode(),ala.getSourceId(),ala.getSourceName(),
- ala.getReportingEntityId(),ala.getReportingEntityName(),ala.getPriority(),ala.getStartEpochMicrosec(),
- ala.getLastEpochMicroSec(),ala.getSequence(),ala.getFaultFieldsVersion(),ala.getEventServrity(),
- ala.getEventSourceType(),ala.getEventCategory(),ala.getAlarmCondition(),ala.getSpecificProblem(),
- ala.getVfStatus(),ala.getAlarmInterfaceA(),ala.getStatus(),DateUtils.dateToString(ala.getCreateTime()),
- DateUtils.dateToString(ala.getUpdateTime()),names,values
- });
- });
- CSVUtils.writeCsv(headers,csvData,csvFile);
- try(InputStream is = new FileInputStream(csvFile);
- OutputStream os = response.getOutputStream()){
- byte[] b = new byte[2048];
- int length;
- while ((length = is.read(b)) > 0) {
- os.write(b, 0, length);
- }
- return "{'result':'success'}";
- }catch (IOException e){
- logger.error("download csv File error :"+e.getMessage());
- return "{'result':'failed'}";
- }
- }
-
-
- @RequestMapping(value = { "/usecaseui-server/alarm" } , method = RequestMethod.PUT )
- public String updateStatus(@RequestBody List<AlarmsHeader> alarmsHeaders){
- for (AlarmsHeader a : alarmsHeaders){
- if ("0".equals(alarmsHeaderService.updateAlarmsHeader(a)))
- return "{'result':'failed'}";
- }
- return "{'result':'success'}";
- }
-
-
-
-
-}
+/*
+ * 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 javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.hibernate.annotations.Parameter;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.onap.usecaseui.server.bean.PerformanceInformation;
+import org.onap.usecaseui.server.bo.AlarmBo;
+import org.onap.usecaseui.server.constant.Constant;
+import org.onap.usecaseui.server.service.AlarmsHeaderService;
+import org.onap.usecaseui.server.service.AlarmsInformationService;
+import org.onap.usecaseui.server.util.CSVUtils;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.onap.usecaseui.server.wrapper.AlarmWrapper;
+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.Controller;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+@RestController
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class AlarmController
+{
+
+
+ private final Logger logger = LoggerFactory.getLogger(AlarmController.class);
+
+ @Resource(name = "AlarmsHeaderService")
+ private AlarmsHeaderService alarmsHeaderService;
+
+ @Resource(name = "AlarmsInformationService")
+ private AlarmsInformationService alarmsInformationService;
+
+
+ @RequestMapping(value = {"/usecase-ui"}, method = RequestMethod.GET)
+ public ModelAndView index(){
+ return new ModelAndView("index");
+ }
+
+ @RequestMapping(value = {"/alarm/{currentPage}/{pageSize}",
+ "/alarm/{currentPage}/{pageSize}/{eventId}/{eventName}/{name}/{value}/{createTime}/{status}/{vfStatus}"},
+ method = RequestMethod.GET , produces = "application/json")
+ public String getAlarmData(@PathVariable(required = false) String eventId,@PathVariable(required = false) String eventName,
+ @PathVariable(required = false) String name,@PathVariable(required = false) String value,
+ @PathVariable(required = false) String createTime,@PathVariable(required = false) String status,
+ @PathVariable(required = false) String vfStatus,
+ @PathVariable int currentPage, @PathVariable int pageSize) {
+ List<AlarmsHeader> alarmsHeaders = null;
+ List<AlarmBo> maps = new ArrayList<>();
+ if (null != eventId || null != eventName || null != name || null != value || null != createTime
+ || null != status || null != vfStatus ){
+ AlarmsHeader alarm = new AlarmsHeader();
+ alarm.setEventId(!"null".equals(eventId)?eventId:null);
+ alarm.setEventName(!"null".equals(eventName)?eventName:null);
+ alarm.setStatus(!"null".equals(status)?status:null);
+ alarm.setVfStatus(!"null".equals(vfStatus)?vfStatus:null);
+ try {
+ alarm.setCreateTime(!"null".equals(createTime)?DateUtils.stringToDate(createTime):null);
+ } catch (ParseException e) {
+ logger.error("Parse date error :"+e.getMessage());
+ }
+ alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(alarm,currentPage,pageSize).getList();
+ if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
+ alarmsHeaders.forEach(a ->{
+ AlarmBo abo = new AlarmBo();
+ abo.setAlarmsHeader(a);
+ AlarmsInformation information = new AlarmsInformation();
+ information.setName(!"null".equals(name)?name:null);
+ information.setValue(!"null".equals(value)?value:null);
+ information.setEventId(a.getEventId());
+ abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(information,1,100).getList());
+ maps.add(abo);
+ });
+ }
+ }else {
+ alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(null, currentPage, pageSize).getList();
+ if (null != alarmsHeaders && alarmsHeaders.size() > 0) {
+ alarmsHeaders.forEach(a -> {
+ AlarmBo abo = new AlarmBo();
+ abo.setAlarmsHeader(a);
+ abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(a.getEventId()),currentPage,pageSize).getList());
+ maps.add(abo);
+ });
+ }
+ }
+ try {
+ ObjectMapper ojm = new ObjectMapper();
+ ojm.setDateFormat(new SimpleDateFormat(Constant.DATE_FROMAT));
+ return ojm.writeValueAsString(maps);
+ } catch (JsonProcessingException e) {
+ logger.debug("JsonProcessingException :"+e.getMessage());
+ return "";
+ }
+ }
+
+ @RequestMapping(value = { "/alarm/genCsv/{eventId}" } , method = RequestMethod.GET , produces = "application/json")
+ public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId){
+ String csvFile = "csvFiles/vnf_alarm_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
+ String[] headers = new String[]{"version",
+ "eventName","domain","eventId","eventType","nfcNamingCode",
+ "nfNamingCode","sourceId","sourceName","reportingEntityId",
+ "reportingEntityName","priority","startEpochMicrosec","lastEpochMicroSec",
+ "sequence","faultFieldsVersion","eventServrity","eventSourceType",
+ "eventCategory","alarmCondition","specificProblem","vfStatus",
+ "alarmInterfaceA","status",
+ "createTime","updateTime","name","value"};
+ List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryId(eventId);
+ List<String[]> csvData = new ArrayList<>();
+ try{
+ alarmsHeaders.forEach(ala ->{
+ List<AlarmsInformation> information = alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(ala.getEventId()),1,100).getList();
+ String names = new String();
+ String values = new String();
+ if (0 < information.size() && null != information){
+ for (AlarmsInformation a : information){
+ names += a.getName()+",";
+ values += a.getValue()+",";
+ }
+ names = names.substring(0,names.lastIndexOf(','));
+ values = values.substring(0,values.lastIndexOf(','));
+ }
+ csvData.add(new String[]{
+ ala.getVersion(),ala.getEventName(),ala.getDomain(),ala.getEventId(),ala.getEventType(),
+ ala.getNfcNamingCode(),ala.getNfNamingCode(),ala.getSourceId(),ala.getSourceName(),
+ ala.getReportingEntityId(),ala.getReportingEntityName(),ala.getPriority(),ala.getStartEpochMicrosec(),
+ ala.getLastEpochMicroSec(),ala.getSequence(),ala.getFaultFieldsVersion(),ala.getEventServrity(),
+ ala.getEventSourceType(),ala.getEventCategory(),ala.getAlarmCondition(),ala.getSpecificProblem(),
+ ala.getVfStatus(),ala.getAlarmInterfaceA(),ala.getStatus(),DateUtils.dateToString(ala.getCreateTime()),
+ DateUtils.dateToString(ala.getUpdateTime()),names,values
+ });
+ });
+ CSVUtils.writeCsv(headers,csvData,csvFile);
+ }catch (Exception e){
+ logger.error(e.getMessage());
+ }
+ if (null != response){
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("application/csv");
+ response.setHeader("Content-Disposition","attachment;filename="+csvFile);
+ try(InputStream is = new FileInputStream(csvFile);
+ OutputStream os = response.getOutputStream()){
+ byte[] b = new byte[2048];
+ int length;
+ while ((length = is.read(b)) > 0) {
+ os.write(b, 0, length);
+ }
+ return "{'result':'success'}";
+ }catch (IOException e){
+ logger.error("download csv File error :"+e.getMessage());
+ return "{'result':'failed'}";
+ }
+ }else
+ return "csvFile generate success,response is null,don't download to local";
+ }
+
+
+ @RequestMapping(value = { "/alarm/{eventId}/{status}/{type}" } , method = RequestMethod.PUT )
+ public String updateStatus(HttpServletResponse response,@PathVariable String[] eventId,@PathVariable String[] status,@PathVariable String type){
+ List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryId(eventId);
+ for (AlarmsHeader ala: alarmsHeaders) {
+ if ("vf".equals(type))
+ ala.setVfStatus(status[0]);
+ else if ("many".equals(type)){
+ ala.setStatus(status[0]);
+ ala.setVfStatus(status[1]);
+ }else {
+ ala.setStatus(status[0]);
+ }
+ if ("0".equals(alarmsHeaderService.updateAlarmsHeader(ala))) {
+ if (null != response)
+ response.setStatus(400);
+ return "{'result':'update failed'}";
+ }
+ }
+ return "{'result':'update success'}";
+ }
+
+
+
+
+}
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 684e36f7..422074a7 100644..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
@@ -18,13 +18,16 @@ package org.onap.usecaseui.server.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
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.util.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -47,7 +50,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
-@Controller
+@RestController
@Configuration
@EnableAspectJAutoProxy
public class PerformanceController {
@@ -60,24 +63,60 @@ public class PerformanceController {
private Logger logger = LoggerFactory.getLogger(PerformanceController.class);
- @RequestMapping(value = {"/usecaseui-server/performance"},method = RequestMethod.GET, produces = "application/json")
- public String getPerformanceData(HttpServletRequest request, @RequestBody PerformanceBo performanceBo) throws JsonProcessingException {
- List<PerformanceHeader> performanceHeaders = performanceHeaderService.queryPerformanceHeader(performanceBo.getPerformanceHeader(),performanceBo.getCurrentPage(),performanceBo.getPageSize()).getList();
- List<PerformanceInformation> performanceInformations = performanceInformationService.queryPerformanceInformation(performanceBo.getPerformanceInformation(),performanceBo.getCurrentPage(),performanceBo.getPageSize()).getList();
- Map<String,Object> maps = new HashMap<>();
- if (null != performanceHeaders && performanceHeaders.size() > 0)
- maps.put("performance_header",performanceHeaders);
- if (null != performanceInformations && performanceInformations.size() > 0)
- maps.put("performance_information",performanceInformations);
- return new ObjectMapper().writeValueAsString(maps);
+ @RequestMapping(value = {"/performance/{currentPage}/{pageSize}","/performance/{currentPage}/{pageSize}/{eventId}/{eventName}/{name}/{value}/{createTime}"},method = RequestMethod.GET, produces = "application/json")
+ public String getPerformanceData(HttpServletResponse response,@PathVariable int currentPage,
+ @PathVariable int pageSize,@PathVariable(required = false) String eventId,
+ @PathVariable(required = false) String eventName,@PathVariable(required = false) String name,
+ @PathVariable(required = false) String value,@PathVariable(required = false) String createTime) {
+ List<Object> list = new ArrayList<>();
+ if (null != eventId || null != eventName || null != name || null != value || null != createTime){
+ PerformanceHeader performanceHeader = new PerformanceHeader();
+ performanceHeader.setEventId(!"null".equals(eventId)?eventId:null);
+ performanceHeader.setEventName(!"null".equals(eventName)?eventName:null);
+ try {
+ performanceHeader.setCreateTime(!"null".equals(createTime)?DateUtils.stringToDate(createTime):null);
+ } catch (ParseException e) {
+ if (null != response)
+ response.setStatus(400);
+ logger.error("ParseException["+createTime+"]:"+e.getMessage());
+ return "{'result':'error'}";
+ }
+ List<PerformanceHeader> performanceHeaders = performanceHeaderService.queryPerformanceHeader(performanceHeader,currentPage,pageSize).getList();
+ performanceHeaders.forEach( per ->{
+ PerformanceBo pbo = new PerformanceBo();
+ PerformanceInformation pe = new PerformanceInformation();
+ pe.setEventId(per.getEventId());
+ pe.setName(!"null".equals(name)?name:null);
+ pe.setValue(!"null".equals(value)?value:null);
+ List<PerformanceInformation> performanceInformations = performanceInformationService.queryPerformanceInformation(pe,1,100).getList();
+ pbo.setPerformanceHeader(per);
+ pbo.setPerformanceInformation(performanceInformations);
+ list.add(pbo);
+ });
+ }else{
+ Page pa = performanceHeaderService.queryPerformanceHeader(null,currentPage,pageSize);
+ List<PerformanceHeader> p = pa!=null?pa.getList():null;
+ if (null != p && p.size() > 0)
+ p.forEach( per ->{
+ PerformanceBo pbo = new PerformanceBo();
+ pbo.setPerformanceHeader(per);
+ pbo.setPerformanceInformation(performanceInformationService.queryPerformanceInformation(new PerformanceInformation(per.getEventId()),1,100).getList());
+ list.add(pbo);
+ });
+ }
+ try {
+ ObjectMapper ojm = new ObjectMapper();
+ ojm.setDateFormat(new SimpleDateFormat(Constant.DATE_FROMAT));
+ return ojm.writeValueAsString(list);
+ } catch (JsonProcessingException e) {
+ logger.error("JsonProcessingException"+e.getMessage());
+ return "{'result':'error'}";
+ }
}
- @RequestMapping(value = {"/usecaseui-server/performance/genCsv/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
- public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId){
- String csvFile = "vnf_performance_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
- response.setCharacterEncoding("utf-8");
- response.setContentType("application/csv");
- response.setHeader("Content-Disposition","attachment;filename="+csvFile);
+ @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";
String[] headers = new String[]{"version",
"eventName","domain","eventId","eventType","nfcNamingCode",
"nfNamingCode","sourceId","sourceName","reportingEntityId",
@@ -85,17 +124,21 @@ public class PerformanceController {
"sequence","measurementsForVfScalingVersion","measurementInterval",
"createTime","updateTime","value","name"};
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 ="";
- for (PerformanceInformation p : information){
- names += p.getName()+",";
- values += p.getValue()+",";
+ String names = new String();
+ String values = new String();
+ 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(','));
}
- 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(),
@@ -103,54 +146,68 @@ public class PerformanceController {
s.getMeasurementInterval(),DateUtils.dateToString(s.getCreateTime()),DateUtils.dateToString(s.getUpdateTime()),
names,values
});
-
});
CSVUtils.writeCsv(headers,csvData,csvFile);
- try(InputStream is = new FileInputStream(csvFile);
- OutputStream os = response.getOutputStream()){
- byte[] b = new byte[2048];
- int length;
- while ((length = is.read(b)) > 0) {
- os.write(b, 0, length);
+ if (null != response){
+ response.setCharacterEncoding("utf-8");
+ response.setContentType("application/csv");
+ response.setHeader("Content-Disposition","attachment;filename="+csvFile);
+ try(InputStream is = new FileInputStream(csvFile);
+ OutputStream os = response.getOutputStream()){
+ byte[] b = new byte[2048];
+ int length;
+ while ((length = is.read(b)) > 0) {
+ os.write(b, 0, length);
+ }
+ return "{'result':'success'}";
+ }catch (IOException e){
+ logger.error("download csv File error :"+e.getMessage());
+ return "{'result':'failed'}";
}
- return "{'result':'success'}";
- }catch (IOException e){
- logger.error("download csv File error :"+e.getMessage());
- return "{'result':'failed'}";
- }
+ }else
+ return "csvFile generate success,response is null,don't download to local";
+
}
- @RequestMapping(value = {"/usecaseui-server/performance/genDiaCsv"}, method = RequestMethod.POST, produces = "application/json")
- public String generateDiaCsvFile(HttpServletResponse response,@RequestBody Map<String,String> p) throws ParseException {
+ @RequestMapping(value = {"/performance/genDiaCsv"}, method = RequestMethod.POST, produces = "application/json")
+ public String generateDiaCsvFile(HttpServletResponse response,@RequestBody Map<String,String> p) {
String csvFileName = "csvFiles/"+p.get("name")+"_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
- response.setCharacterEncoding("utf-8");
- response.setContentType("application/csv");
- String[] headers = new String[]{"eventId","name","value","createTime","updateTime"};
- List<String[]> csvDatas = new ArrayList<>();
- if (null != p){
- for (int i =0;i<p.size();i++){
- csvDatas.add(new String[]{p.get("eventID"),p.get("name"),p.get("value"),p.get("createTime"),p.get("updateTime")});
+ try{
+ String[] headers = new String[]{"eventId","name","value","createTime","updateTime"};
+ List<String[]> csvDatas = new ArrayList<>();
+ if (null != p){
+ StringBuffer fileData = new StringBuffer();
+ p.forEach((k,v)->{
+ fileData.append(v+",");
+ });
+ csvDatas.add(fileData.toString().split(","));
}
+ CSVUtils.writeCsv(headers,csvDatas,csvFileName);
+ }catch (Exception pe){
+ logger.error(pe.getMessage());
}
- CSVUtils.writeCsv(headers,csvDatas,csvFileName);
- response.setHeader("Content-Disposition","attachment;filename="+csvFileName+"");
- try(InputStream is = new FileInputStream(csvFileName);
- OutputStream os = response.getOutputStream()){
- byte[] b = new byte[2048];
- int length;
- while ((length = is.read(b)) > 0) {
- os.write(b, 0, length);
+ if (null != response){
+ response.setContentType("application/csv");
+ response.setHeader("Content-Disposition","attachment;filename="+csvFileName+"");
+ try(InputStream is = new FileInputStream(csvFileName);
+ OutputStream os = response.getOutputStream()){
+ byte[] b = new byte[2048];
+ int length;
+ while ((length = is.read(b)) > 0) {
+ os.write(b, 0, length);
+ }
+ return "{'result':'success'}";
+ }catch (IOException e){
+ logger.error("download csv File error :"+e.getMessage());
+ return "{'result':'failed'}";
}
- return "{'result':'success'}";
- }catch (IOException e){
- logger.error("download csv File error :"+e.getMessage());
- return "{'result':'failed'}";
- }
+ }else
+ return "csvFile generate success,response is null,don't download to local";
}
@ResponseBody
- @RequestMapping(value = {"/usecaseui-server/performance/{unit}/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
- public String generateDiagram(HttpServletRequest request,@PathVariable String unit,@PathVariable String eventId) throws ParseException, JsonProcessingException {
+ @RequestMapping(value = {"/performance/diagram/{unit}/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
+ public String generateDiagram(@PathVariable String unit,@PathVariable String eventId) throws ParseException, JsonProcessingException {
String revDate = "";
switch (unit){
case "hour":
@@ -168,10 +225,11 @@ public class PerformanceController {
}
PerformanceInformation performanceInformation = new PerformanceInformation();
performanceInformation.setEventId(eventId);
- performanceInformation.setCreateTime(new SimpleDateFormat().parse(revDate));
+ performanceInformation.setCreateTime(DateUtils.stringToDate(revDate));
List<PerformanceInformation> informations = performanceInformationService.queryPerformanceInformation(performanceInformation,1,100).getList();
- return new ObjectMapper().writeValueAsString(informations);
+ ObjectMapper ojm = new ObjectMapper();
+ ojm.setDateFormat(new SimpleDateFormat(Constant.DATE_FROMAT));
+ return ojm.writeValueAsString(informations);
}
-
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java b/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java
index 70a3bce8..b47b2dfd 100644..100755
--- a/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java
+++ b/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java
@@ -1,57 +1,57 @@
-/*
- * 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.hibernate;
-
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
-import org.springframework.orm.jpa.JpaTransactionManager;
-import org.springframework.transaction.PlatformTransactionManager;
-
-
-@org.springframework.context.annotation.Configuration
-public class HibernateConfiguration
-{
- @Autowired
- private DataSource dataSource;
-
- @Bean
- public LocalSessionFactoryBean sessionFactory() {
-
- LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
- sessionFactory.setDataSource(dataSource);
- sessionFactory.setHibernateProperties(hibernateProperties());
- sessionFactory.setPackagesToScan(new String[] {"org.onap.usecaseui.server.bean"});
- return sessionFactory;
- }
-
- private Properties hibernateProperties() {
- Properties properties = new Properties();
- properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
- properties.put("hibernate.show_sql", "false");
- return properties;
- }
-
- @Bean
- public PlatformTransactionManager transactionManager() {
- return new JpaTransactionManager();
- }
-
-}
+/*
+ * 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.hibernate;
+
+import java.util.Properties;
+
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.transaction.PlatformTransactionManager;
+
+
+@org.springframework.context.annotation.Configuration
+public class HibernateConfiguration
+{
+ @Autowired
+ private DataSource dataSource;
+
+ @Bean
+ public LocalSessionFactoryBean sessionFactory() {
+
+ LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
+ sessionFactory.setDataSource(dataSource);
+ sessionFactory.setHibernateProperties(hibernateProperties());
+ sessionFactory.setPackagesToScan(new String[] {"org.onap.usecaseui.server.bean"});
+ return sessionFactory;
+ }
+
+ private Properties hibernateProperties() {
+ Properties properties = new Properties();
+ properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
+ properties.put("hibernate.show_sql", "true");
+ return properties;
+ }
+
+ @Bean
+ public PlatformTransactionManager transactionManager() {
+ return new JpaTransactionManager();
+ }
+
+}
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 2884a9fe..5aa0d18d 100644..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
@@ -1,245 +1,238 @@
-/*
- * 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.AlarmsHeader;
-import org.onap.usecaseui.server.service.AlarmsHeaderService;
-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("AlarmsHeaderService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
-
- private static final Logger logger = LoggerFactory.getLogger(AlarmsHeaderServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
-
- public String saveAlarmsHeader(AlarmsHeader alarmsHeader) {
- try{
- if (null == alarmsHeader) {
- logger.error("AlarmsHeaderServiceImpl saveAlarmsHeader alarmsHeader is null!");
- }
- logger.info("AlarmsHeaderServiceImpl saveAlarmsHeader: alarmsHeader={}", alarmsHeader);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.save(alarmsHeader);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsHeaderServiceImpl saveAlarmsHeader. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
-
- @Override
- public String updateAlarmsHeader(AlarmsHeader alarmsHeader) {
- try{
- if (null == alarmsHeader){
- logger.error("AlarmsHeaderServiceImpl saveAlarmsHeader alarmsHeader is null!");
- }
- logger.info("AlarmsHeaderServiceImpl saveAlarmsHeader: alarmsHeader={}", alarmsHeader);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.update(alarmsHeader);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsHeaderServiceImpl updateAlarmsHeader. Details:" + e.getMessage());
- return "0";
- }
- }
-
- public int getAllCount() {
- try{
- Session session = sessionFactory.openSession();
- long q=(long)session.createQuery("select count(*) from AlarmsHeader").uniqueResult();
- session.flush();
- session.close();
- return (int)q;
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsHeaderServiceImpl getAllCount. Details:" + e.getMessage());
- return -1;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<AlarmsHeader> queryAlarmsHeader(AlarmsHeader alarmsHeader,int currentPage,int pageSize) {
- Page<AlarmsHeader> page = new Page<AlarmsHeader>();
- int allRow =this.getAllCount();
- int offset = page.countOffset(currentPage, pageSize);
-
- try{
-// Date date = new Date();
-// SimpleDateFormat date = new SimpleDateFormat("yy-MM-dd hh:mm:ss");
- StringBuffer hql =new StringBuffer("from AlarmsHeader a where 1=1");
- if (null == alarmsHeader) {
- logger.error("AlarmsHeaderServiceImpl queryAlarmsHeader alarmsHeader is null!");
- }else if(null!=alarmsHeader.getVersion()) {
- String ver=alarmsHeader.getVersion();
- hql.append(" and a.version like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getEventName()) {
- String ver=alarmsHeader.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getAlarmCondition()) {
- String ver=alarmsHeader.getAlarmCondition();
- hql.append(" and a.alarmCondition like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getDomain()) {
- String ver=alarmsHeader.getDomain();
- hql.append(" and a.domain like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getEventId()) {
- String ver=alarmsHeader.getEventId();
- hql.append(" and a.eventId like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getNfcNamingCode()) {
- String ver=alarmsHeader.getNfcNamingCode();
- hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getNfNamingCode()) {
- String ver=alarmsHeader.getNfNamingCode();
- hql.append(" and a.nfNamingCode like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getSourceId()) {
- String ver =alarmsHeader.getSourceId();
- hql.append(" and a.sourceId like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getSourceName()) {
- String ver =alarmsHeader.getSourceName();
- hql.append(" and a.sourceName like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getReportingEntityId()) {
- String ver =alarmsHeader.getReportingEntityId();
- hql.append(" and a.reportingEntityId like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getReportingEntityName()) {
- String ver =alarmsHeader.getReportingEntityName();
- hql.append(" and a.reportingEntityName like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getPriority()) {
- String ver =alarmsHeader.getPriority();
- hql.append(" and a.priority like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getStartEpochMicrosec()) {
- String ver =alarmsHeader.getStartEpochMicrosec();
- hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getLastEpochMicroSec()) {
- String ver =alarmsHeader.getLastEpochMicroSec();
- hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getSequence()) {
- String ver =alarmsHeader.getSequence();
- hql.append(" and a.sequence like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getFaultFieldsVersion()) {
- String ver =alarmsHeader.getFaultFieldsVersion();
- hql.append(" and a.faultFieldsVersion like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getEventServrity()) {
- String ver =alarmsHeader.getEventServrity();
- hql.append(" and a.eventServrity like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getEventType()) {
- String ver =alarmsHeader.getEventType();
- hql.append(" and a.eventSourceType like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getEventCategory()) {
- String ver =alarmsHeader.getEventCategory();
- hql.append(" and a.eventCategory like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getAlarmCondition()) {
- String ver =alarmsHeader.getAlarmCondition();
- hql.append(" and a.alarmCondition like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getSpecificProblem()) {
- String ver =alarmsHeader.getSpecificProblem();
- hql.append(" and a.specificProblem like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getVfStatus()) {
- String ver =alarmsHeader.getVfStatus();
- hql.append(" and a.vfStatus like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getAlarmInterfaceA()) {
- String ver =alarmsHeader.getAlarmInterfaceA();
- hql.append(" and a.alarmInterfaceA like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getStatus()) {
- String ver =alarmsHeader.getStatus();
- hql.append(" and a.status like '%"+ver+"%'");
- }else if(null!=alarmsHeader.getCreateTime()) {
- Date ver =alarmsHeader.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }else if(null!=alarmsHeader.getUpdateTime()) {
- Date ver =alarmsHeader.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- logger.info("AlarmsHeaderServiceImpl saveAlarmsHeader: alarmsHeader={}", alarmsHeader);
- Session session = sessionFactory.openSession();
- Query query = session.createQuery(hql.toString());
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<AlarmsHeader> list= query.list();
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- session.close();
- return page;
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsHeaderServiceImpl queryAlarmsHeader. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @Override
- public List<AlarmsHeader> queryId(String[] id) {
- try {
- if(id.length==0) {
- logger.error("AlarmsHeaderServiceImpl queryId is null!");
- }
-
- AlarmsHeader alarm = new AlarmsHeader();
- List<AlarmsHeader> list = new ArrayList<AlarmsHeader>();
- Session session = sessionFactory.openSession();
- for(String b:id) {
- Query query = session.createQuery("from AlarmsHeader a where a.eventId =?0");
- alarm=(AlarmsHeader) query.setParameter("0", b).uniqueResult();
- list.add(alarm);
- }
- session.flush();
- session.close();
- return list;
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsHeaderServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
-
-
-
-}
+/*
+ * 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.AlarmsHeader;
+import org.onap.usecaseui.server.service.AlarmsHeaderService;
+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("AlarmsHeaderService")
+@Transactional
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
+
+ private static final Logger logger = LoggerFactory.getLogger(AlarmsHeaderServiceImpl.class);
+
+ @Autowired
+ private SessionFactory sessionFactory;
+
+
+ public String saveAlarmsHeader(AlarmsHeader alarmsHeader) {
+ try{
+ if (null == alarmsHeader) {
+ logger.error("AlarmsHeaderServiceImpl saveAlarmsHeader alarmsHeader is null!");
+ }
+ logger.info("AlarmsHeaderServiceImpl saveAlarmsHeader: alarmsHeader={}", alarmsHeader);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.save(alarmsHeader);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsHeaderServiceImpl saveAlarmsHeader. Details:" + e.getMessage());
+ return "0";
+ }
+
+ }
+
+
+ @Override
+ public String updateAlarmsHeader(AlarmsHeader alarmsHeader) {
+ try{
+ if (null == alarmsHeader){
+ logger.error("AlarmsHeaderServiceImpl updateAlarmsHeader alarmsHeader is null!");
+ }
+ logger.info("AlarmsHeaderServiceImpl updateAlarmsHeader: alarmsHeader={}", alarmsHeader);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.update(alarmsHeader);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsHeaderServiceImpl updateAlarmsHeader. Details:" + e.getMessage());
+ return "0";
+ }
+ }
+
+ public int getAllCount() {
+ try{
+ Session session = sessionFactory.openSession();
+ long q=(long)session.createQuery("select count(*) from AlarmsHeader").uniqueResult();
+ session.flush();
+ session.close();
+ return (int)q;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsHeaderServiceImpl getAllCount. Details:" + e.getMessage());
+ return -1;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Page<AlarmsHeader> queryAlarmsHeader(AlarmsHeader alarmsHeader,int currentPage,int pageSize) {
+ Page<AlarmsHeader> page = new Page<AlarmsHeader>();
+ int allRow =this.getAllCount();
+ int offset = page.countOffset(currentPage, pageSize);
+
+ try{
+ StringBuffer hql =new StringBuffer("from AlarmsHeader a where 1=1");
+ if (null == alarmsHeader) {
+ logger.error("AlarmsHeaderServiceImpl queryAlarmsHeader alarmsHeader is null!");
+ }else if(null!=alarmsHeader.getVersion()) {
+ String ver=alarmsHeader.getVersion();
+ hql.append(" and a.version like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getEventName()) {
+ String ver=alarmsHeader.getEventName();
+ hql.append(" and a.eventName like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getAlarmCondition()) {
+ String ver=alarmsHeader.getAlarmCondition();
+ hql.append(" and a.alarmCondition like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getDomain()) {
+ String ver=alarmsHeader.getDomain();
+ hql.append(" and a.domain like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getEventId()) {
+ String ver=alarmsHeader.getEventId();
+ hql.append(" and a.eventId = '"+ver+"'");
+ }else if(null!=alarmsHeader.getNfcNamingCode()) {
+ String ver=alarmsHeader.getNfcNamingCode();
+ hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getNfNamingCode()) {
+ String ver=alarmsHeader.getNfNamingCode();
+ hql.append(" and a.nfNamingCode like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getSourceId()) {
+ String ver =alarmsHeader.getSourceId();
+ hql.append(" and a.sourceId like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getSourceName()) {
+ String ver =alarmsHeader.getSourceName();
+ hql.append(" and a.sourceName like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getReportingEntityId()) {
+ String ver =alarmsHeader.getReportingEntityId();
+ hql.append(" and a.reportingEntityId like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getReportingEntityName()) {
+ String ver =alarmsHeader.getReportingEntityName();
+ hql.append(" and a.reportingEntityName like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getPriority()) {
+ String ver =alarmsHeader.getPriority();
+ hql.append(" and a.priority like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getStartEpochMicrosec()) {
+ String ver =alarmsHeader.getStartEpochMicrosec();
+ hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getLastEpochMicroSec()) {
+ String ver =alarmsHeader.getLastEpochMicroSec();
+ hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getSequence()) {
+ String ver =alarmsHeader.getSequence();
+ hql.append(" and a.sequence like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getFaultFieldsVersion()) {
+ String ver =alarmsHeader.getFaultFieldsVersion();
+ hql.append(" and a.faultFieldsVersion like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getEventServrity()) {
+ String ver =alarmsHeader.getEventServrity();
+ hql.append(" and a.eventServrity like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getEventType()) {
+ String ver =alarmsHeader.getEventType();
+ hql.append(" and a.eventSourceType like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getEventCategory()) {
+ String ver =alarmsHeader.getEventCategory();
+ hql.append(" and a.eventCategory like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getAlarmCondition()) {
+ String ver =alarmsHeader.getAlarmCondition();
+ hql.append(" and a.alarmCondition like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getSpecificProblem()) {
+ String ver =alarmsHeader.getSpecificProblem();
+ hql.append(" and a.specificProblem like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getVfStatus()) {
+ String ver =alarmsHeader.getVfStatus();
+ hql.append(" and a.vfStatus like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getAlarmInterfaceA()) {
+ String ver =alarmsHeader.getAlarmInterfaceA();
+ hql.append(" and a.alarmInterfaceA like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getStatus()) {
+ String ver =alarmsHeader.getStatus();
+ hql.append(" and a.status like '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getCreateTime()) {
+ Date ver =alarmsHeader.getCreateTime();
+ hql.append(" and a.createTime > '%"+ver+"%'");
+ }else if(null!=alarmsHeader.getUpdateTime()) {
+ Date ver =alarmsHeader.getUpdateTime();
+ hql.append(" and a.updateTime like '%"+ver+"%'");
+ }
+ logger.info("AlarmsHeaderServiceImpl queryAlarmsHeader: alarmsHeader={}", alarmsHeader);
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery(hql.toString());
+ query.setFirstResult(offset);
+ query.setMaxResults(pageSize);
+ List<AlarmsHeader> list= query.list();
+ page.setPageNo(currentPage);
+ page.setPageSize(pageSize);
+ page.setTotalRecords(allRow);
+ page.setList(list);
+ session.flush();
+ session.close();
+ return page;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsHeaderServiceImpl queryAlarmsHeader. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<AlarmsHeader> queryId(String[] id) {
+ try {
+ if(id.length==0) {
+ logger.error("AlarmsHeaderServiceImpl queryId is null!");
+ }
+ List<AlarmsHeader> list = new ArrayList<AlarmsHeader>();
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery("from AlarmsHeader a where a.eventId IN (:alist)");
+ list = query.setParameterList("alist", id).list();
+ session.close();
+ return list;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsHeaderServiceImpl queryId. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
+
+
+
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
index 1f0b4bb6..64495a29 100644..100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
@@ -1,172 +1,173 @@
-/*
- * 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.AlarmsInformation;
-import org.onap.usecaseui.server.service.AlarmsInformationService;
-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("AlarmsInformationService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class AlarmsInformationServiceImpl implements AlarmsInformationService {
- private static final Logger logger = LoggerFactory.getLogger(AlarmsInformationServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
- @Override
- public String saveAlarmsInformation(AlarmsInformation alarmsInformation) {
- try{
- if (null == alarmsInformation) {
- logger.error("alarmsInformation AlarmsInformation alarmsInformation is null!");
- }
- logger.info("AlarmsInformationServiceImpl saveAlarmsInformation: alarmsInformation={}", alarmsInformation);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.save(alarmsInformation);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsInformationServiceImpl saveAlarmsInformation. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
- @Override
- public String updateAlarmsInformation(AlarmsInformation alarmsInformation) {
- try{
- if (null == alarmsInformation) {
- logger.error("alarmsInformation AlarmsInformation alarmsInformation is null!");
- }
- logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}", alarmsInformation);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.update(alarmsInformation);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());
- return "0";
- }
- }
-
-
- public int getAllCount() {
- try{
- Session session = sessionFactory.openSession();
- long q=(long)session.createQuery("select count(*) from AlarmsInformation").uniqueResult();
- session.flush();
- session.close();
- return (int)q;
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsInformationServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation, int currentPage,
- int pageSize) {
- Page<AlarmsInformation> page = new Page<AlarmsInformation>();
- int allRow =this.getAllCount();
- int offset = page.countOffset(currentPage, pageSize);
-
- try{
- StringBuffer hql =new StringBuffer("from AlarmsInformation a where 1=1");
- if (null == alarmsInformation) {
- logger.error("AlarmsInformationServiceImpl queryAlarmsInformation alarmsInformation is null!");
- }else if(null!=alarmsInformation.getName()) {
- String ver=alarmsInformation.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }else if(null!=alarmsInformation.getValue()) {
- String ver=alarmsInformation.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }else if(null!=alarmsInformation.getEventId()) {
- String ver=alarmsInformation.getEventId();
- hql.append(" and a.eventId = '"+ver+"'");
- }else if(null!=alarmsInformation.getCreateTime()) {
- Date ver =alarmsInformation.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }else if(null!=alarmsInformation.getUpdateTime()) {
- Date ver =alarmsInformation.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- logger.info("AlarmsInformationServiceImpl queryAlarmsInformation: alarmsInformation={}", alarmsInformation);
- Session session = sessionFactory.openSession();
- Query query = session.createQuery(hql.toString());
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<AlarmsInformation> list= query.list();
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- session.close();
- return page;
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsInformationServiceImpl queryAlarmsInformation. Details:" + e.getMessage());
- return null;
- }
- }
-
- @Override
- public List<AlarmsInformation> queryId(String[] id) {
- try {
- if(id.length==0) {
- logger.error("AlarmsInformationServiceImpl queryId is null!");
- }
- List<AlarmsInformation> list = new ArrayList<AlarmsInformation>();
- Session session = sessionFactory.openSession();
- Query query = session.createQuery("from AlarmsInformation a where a.eventId IN (:alist)");
- list = query.setParameterList("alist", id).list();
- session.close();
- return list;
- } catch (Exception e) {
- logger.error("Exception occurred while performing AlarmsInformationServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
-
-
-}
+/*
+ * 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.AlarmsInformation;
+import org.onap.usecaseui.server.service.AlarmsInformationService;
+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("AlarmsInformationService")
+@Transactional
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class AlarmsInformationServiceImpl implements AlarmsInformationService {
+ private static final Logger logger = LoggerFactory.getLogger(AlarmsInformationServiceImpl.class);
+
+ @Autowired
+ private SessionFactory sessionFactory;
+
+ @Override
+ public String saveAlarmsInformation(AlarmsInformation alarmsInformation) {
+ try{
+ if (null == alarmsInformation) {
+ logger.error("alarmsInformation saveAlarmsInformation alarmsInformation is null!");
+ }
+ logger.info("AlarmsInformationServiceImpl saveAlarmsInformation: alarmsInformation={}", alarmsInformation);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.save(alarmsInformation);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsInformationServiceImpl saveAlarmsInformation. Details:" + e.getMessage());
+ return "0";
+ }
+
+ }
+
+ @Override
+ public String updateAlarmsInformation(AlarmsInformation alarmsInformation) {
+ try{
+ if (null == alarmsInformation) {
+ logger.error("alarmsInformation updateAlarmsInformation alarmsInformation is null!");
+ }
+ logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}", alarmsInformation);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.update(alarmsInformation);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());
+ return "0";
+ }
+ }
+
+
+ public int getAllCount() {
+ try{
+ Session session = sessionFactory.openSession();
+ long q=(long)session.createQuery("select count(*) from AlarmsInformation").uniqueResult();
+ session.flush();
+ session.close();
+ return (int)q;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsInformationServiceImpl getAllCount. Details:" + e.getMessage());
+ return 0;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation, int currentPage,
+ int pageSize) {
+ Page<AlarmsInformation> page = new Page<AlarmsInformation>();
+ int allRow =this.getAllCount();
+ int offset = page.countOffset(currentPage, pageSize);
+
+ try{
+ StringBuffer hql =new StringBuffer("from AlarmsInformation a where 1=1");
+ if (null == alarmsInformation) {
+ logger.error("AlarmsInformationServiceImpl queryAlarmsInformation alarmsInformation is null!");
+ }else if(null!=alarmsInformation.getName()) {
+ String ver=alarmsInformation.getName();
+ hql.append(" and a.name like '%"+ver+"%'");
+ }else if(null!=alarmsInformation.getValue()) {
+ String ver=alarmsInformation.getValue();
+ hql.append(" and a.value like '%"+ver+"%'");
+ }else if(null!=alarmsInformation.getEventId()) {
+ String ver=alarmsInformation.getEventId();
+ hql.append(" and a.eventId = '"+ver+"'");
+ }else if(null!=alarmsInformation.getCreateTime()) {
+ Date ver =alarmsInformation.getCreateTime();
+ hql.append(" and a.createTime > '%"+ver+"%'");
+ }else if(null!=alarmsInformation.getUpdateTime()) {
+ Date ver =alarmsInformation.getUpdateTime();
+ hql.append(" and a.updateTime like '%"+ver+"%'");
+ }
+ logger.info("AlarmsInformationServiceImpl queryAlarmsInformation: alarmsInformation={}", alarmsInformation);
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery(hql.toString());
+ query.setFirstResult(offset);
+ query.setMaxResults(pageSize);
+ List<AlarmsInformation> list= query.list();
+ page.setPageNo(currentPage);
+ page.setPageSize(pageSize);
+ page.setTotalRecords(allRow);
+ page.setList(list);
+ session.flush();
+ session.close();
+ return page;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsInformationServiceImpl queryAlarmsInformation. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<AlarmsInformation> queryId(String[] id) {
+ try {
+ if(id.length==0) {
+ logger.error("AlarmsInformationServiceImpl queryId is null!");
+ }
+ List<AlarmsInformation> list = new ArrayList<AlarmsInformation>();
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery("from AlarmsInformation a where a.eventId IN (:alist)");
+ list = query.setParameterList("alist", id).list();
+ session.close();
+ return list;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing AlarmsInformationServiceImpl queryId. 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 79265114..9595e8c4 100644..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
@@ -1,223 +1,219 @@
-/*
- * 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.PerformanceHeader;
-import org.onap.usecaseui.server.service.PerformanceHeaderService;
-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("PerformanceHeaderService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
-
- private static final Logger logger = LoggerFactory.getLogger(PerformanceHeaderServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
-
- @Override
- public String savePerformanceHeader(PerformanceHeader performanceHeder) {
- try{
- if (null == performanceHeder){
- logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");
- }
- logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.save(performanceHeder);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
-
- @Override
- public String updatePerformanceHeader(PerformanceHeader performanceHeder) {
- try{
- if (null == performanceHeder){
- logger.error("PerformanceHeaderServiceImpl updatePerformanceHeader performanceHeder is null!");
- }
- logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.update(performanceHeder);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceHeaderServiceImpl updatePerformanceHeader. Details:" + e.getMessage());
- return "0";
- }
- }
-
-
- public int getAllCount() {
- try{
- Session session = sessionFactory.openSession();
- long q=(long)session.createQuery("select count(*) from PerformanceHeader").uniqueResult();
- session.flush();
- session.close();
- return (int)q;
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceHeaderServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage,
- int pageSize) {
- Page<PerformanceHeader> page = new Page<PerformanceHeader>();
- int allRow =this.getAllCount();
- int offset = page.countOffset(currentPage, pageSize);
-
- try{
- StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");
- if (null == performanceHeder) {
- logger.error("PerformanceHeaderServiceImpl queryAlarmsHeader performanceHeder is null!");
- }else if(null!=performanceHeder.getVersion()) {
- String ver=performanceHeder.getVersion();
- hql.append(" and a.version like '%"+ver+"%'");
- }else if(null!=performanceHeder.getEventName()) {
- String ver=performanceHeder.getEventName();
- hql.append(" and a.eventName like '%"+ver+"%'");
- }else if(null!=performanceHeder.getDomain()) {
- String ver=performanceHeder.getDomain();
- hql.append(" and a.domain like '%"+ver+"%'");
- }else if(null!=performanceHeder.getEventId()) {
- String ver=performanceHeder.getEventId();
- hql.append(" and a.eventId like '%"+ver+"%'");
- }else if(null!=performanceHeder.getNfcNamingCode()) {
- String ver=performanceHeder.getNfcNamingCode();
- hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
- }else if(null!=performanceHeder.getNfNamingCode()) {
- String ver=performanceHeder.getNfNamingCode();
- hql.append(" and a.nfNamingCode like '%"+ver+"%'");
- }else if(null!=performanceHeder.getSourceId()) {
- String ver =performanceHeder.getSourceId();
- hql.append(" and a.sourceId like '%"+ver+"%'");
- }else if(null!=performanceHeder.getSourceName()) {
- String ver =performanceHeder.getSourceName();
- hql.append(" and a.sourceName like '%"+ver+"%'");
- }else if(null!=performanceHeder.getReportingEntityId()) {
- String ver =performanceHeder.getReportingEntityId();
- hql.append(" and a.reportingEntityId like '%"+ver+"%'");
- }else if(null!=performanceHeder.getReportingEntityName()) {
- String ver =performanceHeder.getReportingEntityName();
- hql.append(" and a.reportingEntityName like '%"+ver+"%'");
- }else if(null!=performanceHeder.getPriority()) {
- String ver =performanceHeder.getPriority();
- hql.append(" and a.priority like '%"+ver+"%'");
- }else if(null!=performanceHeder.getStartEpochMicrosec()) {
- String ver =performanceHeder.getStartEpochMicrosec();
- hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
- }else if(null!=performanceHeder.getLastEpochMicroSec()) {
- String ver =performanceHeder.getLastEpochMicroSec();
- hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
- }else if(null!=performanceHeder.getSequence()) {
- String ver =performanceHeder.getSequence();
- hql.append(" and a.sequence like '%"+ver+"%'");
- }else if(null!=performanceHeder.getMeasurementsForVfScalingVersion()) {
- String ver =performanceHeder.getMeasurementsForVfScalingVersion();
- hql.append(" and a.measurementsForVfScalingVersion like '%"+ver+"%'");
- }else if(null!=performanceHeder.getMeasurementInterval()) {
- String ver =performanceHeder.getMeasurementInterval();
- hql.append(" and a.measurementInterval like '%"+ver+"%'");
- }else if(null!=performanceHeder.getEventType()) {
- String ver =performanceHeder.getEventType();
- hql.append(" and a.eventSourceType like '%"+ver+"%'");
- }else if(null!=performanceHeder.getCreateTime()) {
- Date ver =performanceHeder.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }else if(null!=performanceHeder.getUpdateTime()) {
- Date ver =performanceHeder.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHeder);
- Session session = sessionFactory.openSession();
- Query query = session.createQuery(hql.toString());
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<PerformanceHeader> list= query.list();
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- session.close();
- return page;
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceHeaderServiceImpl queryPerformanceHeader. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @Override
- public List<PerformanceHeader> queryId(String[] id) {
- try {
- if(id.length==0) {
- logger.error("PerformanceHeaderServiceImpl queryId is null!");
- }
- PerformanceHeader performance = new PerformanceHeader();
- List<PerformanceHeader> list = new ArrayList<PerformanceHeader>();
- Session session = sessionFactory.openSession();
- Query query = session.createQuery("from PerformanceHeader a where a.eventId = ?0");
- for(String b:id) {
- performance=(PerformanceHeader) query.setParameter("0", b).uniqueResult();
- list.add(performance);
- }
- session.flush();
- session.close();
- return list;
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceHeaderServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
-
-
-}
+/*
+ * 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.PerformanceHeader;
+import org.onap.usecaseui.server.service.PerformanceHeaderService;
+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("PerformanceHeaderService")
+@Transactional
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
+
+ private static final Logger logger = LoggerFactory.getLogger(PerformanceHeaderServiceImpl.class);
+
+ @Autowired
+ private SessionFactory sessionFactory;
+
+
+ @Override
+ public String savePerformanceHeader(PerformanceHeader performanceHeder) {
+ try{
+ if (null == performanceHeder){
+ logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");
+ }
+ logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.save(performanceHeder);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());
+ return "0";
+ }
+
+ }
+
+
+ @Override
+ public String updatePerformanceHeader(PerformanceHeader performanceHeder) {
+ try{
+ if (null == performanceHeder){
+ logger.error("PerformanceHeaderServiceImpl updatePerformanceHeader performanceHeder is null!");
+ }
+ logger.info("PerformanceHeaderServiceImpl updatePerformanceHeader: performanceHeder={}", performanceHeder);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.update(performanceHeder);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceHeaderServiceImpl updatePerformanceHeader. Details:" + e.getMessage());
+ return "0";
+ }
+ }
+
+
+ public int getAllCount() {
+ try{
+ Session session = sessionFactory.openSession();
+ long q=(long)session.createQuery("select count(*) from PerformanceHeader").uniqueResult();
+ session.flush();
+ session.close();
+ return (int)q;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceHeaderServiceImpl getAllCount. Details:" + e.getMessage());
+ return 0;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage,
+ int pageSize) {
+ Page<PerformanceHeader> page = new Page<PerformanceHeader>();
+ int allRow =this.getAllCount();
+ int offset = page.countOffset(currentPage, pageSize);
+
+ try{
+ StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");
+ if (null == performanceHeder) {
+ logger.error("PerformanceHeaderServiceImpl queryPerformanceHeader performanceHeder is null!");
+ }else if(null!=performanceHeder.getVersion()) {
+ String ver=performanceHeder.getVersion();
+ hql.append(" and a.version like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getEventName()) {
+ String ver=performanceHeder.getEventName();
+ hql.append(" and a.eventName like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getDomain()) {
+ String ver=performanceHeder.getDomain();
+ hql.append(" and a.domain like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getEventId()) {
+ String ver=performanceHeder.getEventId();
+ hql.append(" and a.eventId = '"+ver+"'");
+ }else if(null!=performanceHeder.getNfcNamingCode()) {
+ String ver=performanceHeder.getNfcNamingCode();
+ hql.append(" and a.nfcNamingCode like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getNfNamingCode()) {
+ String ver=performanceHeder.getNfNamingCode();
+ hql.append(" and a.nfNamingCode like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getSourceId()) {
+ String ver =performanceHeder.getSourceId();
+ hql.append(" and a.sourceId like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getSourceName()) {
+ String ver =performanceHeder.getSourceName();
+ hql.append(" and a.sourceName like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getReportingEntityId()) {
+ String ver =performanceHeder.getReportingEntityId();
+ hql.append(" and a.reportingEntityId like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getReportingEntityName()) {
+ String ver =performanceHeder.getReportingEntityName();
+ hql.append(" and a.reportingEntityName like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getPriority()) {
+ String ver =performanceHeder.getPriority();
+ hql.append(" and a.priority like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getStartEpochMicrosec()) {
+ String ver =performanceHeder.getStartEpochMicrosec();
+ hql.append(" and a.startEpochMicrosec like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getLastEpochMicroSec()) {
+ String ver =performanceHeder.getLastEpochMicroSec();
+ hql.append(" and a.lastEpochMicroSec like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getSequence()) {
+ String ver =performanceHeder.getSequence();
+ hql.append(" and a.sequence like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getMeasurementsForVfScalingVersion()) {
+ String ver =performanceHeder.getMeasurementsForVfScalingVersion();
+ hql.append(" and a.measurementsForVfScalingVersion like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getMeasurementInterval()) {
+ String ver =performanceHeder.getMeasurementInterval();
+ hql.append(" and a.measurementInterval like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getEventType()) {
+ String ver =performanceHeder.getEventType();
+ hql.append(" and a.eventType like '%"+ver+"%'");
+ }else if(null!=performanceHeder.getCreateTime()) {
+ Date ver =performanceHeder.getCreateTime();
+ hql.append(" and a.createTime > '%"+ver+"%'");
+ }else if(null!=performanceHeder.getUpdateTime()) {
+ Date ver =performanceHeder.getUpdateTime();
+ hql.append(" and a.updateTime like '%"+ver+"%'");
+ }
+ logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHeder);
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery(hql.toString());
+ query.setFirstResult(offset);
+ query.setMaxResults(pageSize);
+ List<PerformanceHeader> list= query.list();
+ page.setPageNo(currentPage);
+ page.setPageSize(pageSize);
+ page.setTotalRecords(allRow);
+ page.setList(list);
+ session.flush();
+ session.close();
+ return page;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceHeaderServiceImpl queryPerformanceHeader. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<PerformanceHeader> queryId(String[] id) {
+ try {
+ if(id.length==0) {
+ logger.error("PerformanceHeaderServiceImpl queryId is null!");
+ }
+ List<PerformanceHeader> list = new ArrayList<PerformanceHeader>();
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery("from PerformanceHeader a where a.eventId IN (:alist)");
+ list = query.setParameterList("alist", id).list();
+ session.close();
+ return list;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceHeaderServiceImpl queryId. 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 f1877137..749e0a2c 100644..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
@@ -1,181 +1,177 @@
-/*
- * 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.PerformanceInformation;
-import org.onap.usecaseui.server.service.PerformanceInformationService;
-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("PerformanceInformationService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class PerformanceInformationServiceImpl implements PerformanceInformationService {
- private static final Logger logger = LoggerFactory.getLogger(PerformanceInformationServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
-
- @Override
- public String savePerformanceInformation(PerformanceInformation performanceInformation) {
- try {
- if (null == performanceInformation) {
- logger.error("performanceInformation PerformanceInformation performanceInformation is null!");
- }
- logger.info("PerformanceInformationServiceImpl savePerformanceInformation: performanceInformation={}", performanceInformation);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.save(performanceInformation);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceInformationServiceImpl savePerformanceInformation. Details:" + e.getMessage());
- return "0";
- }
-
- }
-
-
- @Override
- public String updatePerformanceInformation(PerformanceInformation performanceInformation) {
- try {
- if (null == performanceInformation) {
- logger.error("performanceInformation PerformanceInformation performanceInformation is null!");
- }
- logger.info("PerformanceInformationServiceImpl savePerformanceInformation: performanceInformation={}", performanceInformation);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- session.update(performanceInformation);
- tx.commit();
- session.flush();
- session.close();
- return "1";
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceInformationServiceImpl updatePerformanceInformation. Details:" + e.getMessage());
- return "0";
- }
- }
-
-
- public int getAllCount() {
- try{
- Session session = sessionFactory.openSession();
- long q=(long)session.createQuery("select count(*) from PerformanceInformation").uniqueResult();
- session.flush();
- session.close();
- return (int)q;
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceInformationServiceImpl getAllCount. Details:" + e.getMessage());
- return 0;
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Page<PerformanceInformation> queryPerformanceInformation(PerformanceInformation performanceInformation,
- int currentPage, int pageSize) {
- Page<PerformanceInformation> page = new Page<PerformanceInformation>();
- int allRow =this.getAllCount();
- int offset = page.countOffset(currentPage, pageSize);
-
- try{
- StringBuffer hql =new StringBuffer("from PerformanceInformation a where 1=1");
- if (null == performanceInformation) {
- logger.error("AlarmsInformationServiceImpl queryPerformanceInformation performanceInformation is null!");
- }else if(null!=performanceInformation.getName()) {
- String ver=performanceInformation.getName();
- hql.append(" and a.name like '%"+ver+"%'");
- }else if(null!=performanceInformation.getValue()) {
- String ver=performanceInformation.getValue();
- hql.append(" and a.value like '%"+ver+"%'");
- }else if(null!=performanceInformation.getEventId()) {
- String ver=performanceInformation.getEventId();
- hql.append(" and a.eventId like '%"+ver+"%'");
- }else if(null!=performanceInformation.getCreateTime()) {
- Date ver =performanceInformation.getCreateTime();
- hql.append(" and a.createTime > '%"+ver+"%'");
- }else if(null!=performanceInformation.getUpdateTime()) {
- Date ver =performanceInformation.getUpdateTime();
- hql.append(" and a.updateTime like '%"+ver+"%'");
- }
- logger.info("PerformanceInformationServiceImpl queryPerformanceInformation: performanceInformation={}", performanceInformation);
- Session session = sessionFactory.openSession();
- Query query = session.createQuery(hql.toString());
- query.setFirstResult(offset);
- query.setMaxResults(pageSize);
- List<PerformanceInformation> list= query.list();
- page.setPageNo(currentPage);
- page.setPageSize(pageSize);
- page.setTotalRecords(allRow);
- page.setList(list);
- session.flush();
- session.close();
- return page;
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceInformationServiceImpl queryPerformanceInformation. Details:" + e.getMessage());
- return null;
- }
- }
-
-
- @Override
- public List<PerformanceInformation> queryId(String[] id) {
- try {
- if(id.length==0) {
- logger.error("PerformanceInformationServiceImpl queryId is null!");
- }
- PerformanceInformation performance = new PerformanceInformation();
- List<PerformanceInformation> list = new ArrayList<>();
- Session session = sessionFactory.openSession();
- Query query = session.createQuery("from PerformanceInformation a where a.eventId = ?0");
- for(String b:id) {
- performance=(PerformanceInformation) query.setParameter("0", b).uniqueResult();
- list.add(performance);
- }
- session.flush();
- session.close();
- return list;
- } catch (Exception e) {
- logger.error("Exception occurred while performing PerformanceInformationServiceImpl queryId. Details:" + e.getMessage());
- return null;
- }
- }
-
-
-
-
-
-}
+/*
+ * 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.PerformanceInformation;
+import org.onap.usecaseui.server.service.PerformanceInformationService;
+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("PerformanceInformationService")
+@Transactional
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class PerformanceInformationServiceImpl implements PerformanceInformationService {
+ private static final Logger logger = LoggerFactory.getLogger(PerformanceInformationServiceImpl.class);
+
+ @Autowired
+ private SessionFactory sessionFactory;
+
+
+ @Override
+ public String savePerformanceInformation(PerformanceInformation performanceInformation) {
+ try {
+ if (null == performanceInformation) {
+ logger.error("performanceInformation savePerformanceInformation performanceInformation is null!");
+ }
+ logger.info("PerformanceInformationServiceImpl savePerformanceInformation: performanceInformation={}", performanceInformation);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.save(performanceInformation);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceInformationServiceImpl savePerformanceInformation. Details:" + e.getMessage());
+ return "0";
+ }
+
+ }
+
+
+ @Override
+ public String updatePerformanceInformation(PerformanceInformation performanceInformation) {
+ try {
+ if (null == performanceInformation) {
+ logger.error("performanceInformation updatePerformanceInformation performanceInformation is null!");
+ }
+ logger.info("PerformanceInformationServiceImpl updatePerformanceInformation: performanceInformation={}", performanceInformation);
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.update(performanceInformation);
+ tx.commit();
+ session.flush();
+ session.close();
+ return "1";
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceInformationServiceImpl updatePerformanceInformation. Details:" + e.getMessage());
+ return "0";
+ }
+ }
+
+
+ public int getAllCount() {
+ try{
+ Session session = sessionFactory.openSession();
+ long q=(long)session.createQuery("select count(*) from PerformanceInformation").uniqueResult();
+ session.flush();
+ session.close();
+ return (int)q;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceInformationServiceImpl getAllCount. Details:" + e.getMessage());
+ return 0;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Page<PerformanceInformation> queryPerformanceInformation(PerformanceInformation performanceInformation,
+ int currentPage, int pageSize) {
+ Page<PerformanceInformation> page = new Page<PerformanceInformation>();
+ int allRow =this.getAllCount();
+ int offset = page.countOffset(currentPage, pageSize);
+
+ try{
+ StringBuffer hql =new StringBuffer("from PerformanceInformation a where 1=1");
+ if (null == performanceInformation) {
+ logger.error("AlarmsInformationServiceImpl queryPerformanceInformation performanceInformation is null!");
+ }else if(null!=performanceInformation.getName()) {
+ String ver=performanceInformation.getName();
+ hql.append(" and a.name like '%"+ver+"%'");
+ }else if(null!=performanceInformation.getValue()) {
+ String ver=performanceInformation.getValue();
+ hql.append(" and a.value like '%"+ver+"%'");
+ }else if(null!=performanceInformation.getEventId()) {
+ String ver=performanceInformation.getEventId();
+ hql.append(" and a.eventId = '"+ver+"'");
+ }else if(null!=performanceInformation.getCreateTime()) {
+ Date ver =performanceInformation.getCreateTime();
+ hql.append(" and a.createTime > '%"+ver+"%'");
+ }else if(null!=performanceInformation.getUpdateTime()) {
+ Date ver =performanceInformation.getUpdateTime();
+ hql.append(" and a.updateTime like '%"+ver+"%'");
+ }
+ logger.info("PerformanceInformationServiceImpl queryPerformanceInformation: performanceInformation={}", performanceInformation);
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery(hql.toString());
+ query.setFirstResult(offset);
+ query.setMaxResults(pageSize);
+ List<PerformanceInformation> list= query.list();
+ page.setPageNo(currentPage);
+ page.setPageSize(pageSize);
+ page.setTotalRecords(allRow);
+ page.setList(list);
+ session.flush();
+ session.close();
+ return page;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceInformationServiceImpl queryPerformanceInformation. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<PerformanceInformation> queryId(String[] id) {
+ try {
+ if(id.length==0) {
+ logger.error("PerformanceInformationServiceImpl queryId is null!");
+ }
+ List<PerformanceInformation> list = new ArrayList<>();
+ Session session = sessionFactory.openSession();
+ Query query = session.createQuery("from PerformanceInformation a where a.eventId IN (:alist)");
+ list = query.setParameterList("alist", id).list();
+ session.close();
+ return list;
+ } catch (Exception e) {
+ logger.error("Exception occurred while performing PerformanceInformationServiceImpl queryId. Details:" + e.getMessage());
+ return null;
+ }
+ }
+
+
+
+
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java b/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java
index 068bc04d..f61094ca 100644..100755
--- a/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java
+++ b/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java
@@ -15,6 +15,8 @@
*/
package org.onap.usecaseui.server.util;
+import org.onap.usecaseui.server.constant.Constant;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
@@ -82,7 +84,7 @@ public class DateUtils {
* @throws ParseException
*/
public static Date initProcessDate(Date d,int year,int month,int day,int hour,int minute,int second) throws ParseException {
- SimpleDateFormat sdf = new SimpleDateFormat("yy:MM:dd hh:mm:ss");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss");
Calendar c = Calendar.getInstance();
c.setTime(d);
if(year >= 0){
@@ -148,15 +150,15 @@ public class DateUtils {
}
public static String dateToString(Date d){
- return new SimpleDateFormat("yy:MM:dd HH:mm:ss").format(d);
+ return new SimpleDateFormat(Constant.DATE_FROMAT).format(d);
}
public static Date stringToDate(String d) throws ParseException {
- return new SimpleDateFormat("yy:MM:dd HH:mm:ss").parse(d);
+ return new SimpleDateFormat(Constant.DATE_FROMAT).parse(d);
}
public static Date now() throws ParseException {
- return new SimpleDateFormat("yy:MM:dd HH:mm:ss").parse(dateToString(new Date()));
+ return new SimpleDateFormat(Constant.DATE_FROMAT).parse(dateToString(new Date()));
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
index 3dd2c57c..cc59616b 100644..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
@@ -26,7 +26,6 @@ import org.onap.usecaseui.server.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
@@ -41,60 +40,27 @@ public class AlarmControllerTest {
@Autowired
AlarmController alarmController;
- @Resource(name = "AlarmsHeaderService")
- AlarmsHeaderService alarmsHeaderService;
-
- @Resource(name = "AlarmsInformationService")
- AlarmsInformationService alarmsInformationService;
-
@Test
public void getDataNotParam(){
- System.out.println(alarmController.getAlarmData(null,null,null,null,null,1,1100));
+ System.out.println(alarmController.getAlarmData(null,null,null,null,null,null,null,1,100));
}
@Test
public void getDataCarryParam(){
- System.out.println(alarmController.getAlarmData("110","a","drop","down","1506331166000",1,1100));
+ System.out.println(alarmController.getAlarmData("110","a","drop","down","1506331166000","1","2",1,100));
}
@Test
- public void genCsvFile(){
- String[] eventId = new String[]{"110"};
- String csvFile = "csvFiles/vnf_alarm_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv";
- String[] headers = new String[]{"version",
- "eventName","domain","eventId","eventType","nfcNamingCode",
- "nfNamingCode","sourceId","sourceName","reportingEntityId",
- "reportingEntityName","priority","startEpochMicrosec","lastEpochMicroSec",
- "sequence","faultFieldsVersion","eventServrity","eventSourceType",
- "eventCategory","alarmCondition","specificProblem","vfStatus",
- "alarmInterfaceA","status",
- "createTime","updateTime","name","value"};
- List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryId(eventId);
- List<String[]> csvData = new ArrayList<>();
- alarmsHeaders.forEach(ala ->{
- List<AlarmsInformation> information = alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(ala.getEventId()),1,100).getList();
- String names = new String();
- String values = new String();
- if (0 < information.size() && null != information){
- for (AlarmsInformation a : information){
- names += a.getName()+",";
- values += a.getValue()+",";
- }
- names = names.substring(0,names.lastIndexOf(','));
- values = values.substring(0,values.lastIndexOf(','));
- }
- csvData.add(new String[]{
- ala.getVersion(),ala.getEventName(),ala.getDomain(),ala.getEventId(),ala.getEventType(),
- ala.getNfcNamingCode(),ala.getNfNamingCode(),ala.getSourceId(),ala.getSourceName(),
- ala.getReportingEntityId(),ala.getReportingEntityName(),ala.getPriority(),ala.getStartEpochMicrosec(),
- ala.getLastEpochMicroSec(),ala.getSequence(),ala.getFaultFieldsVersion(),ala.getEventServrity(),
- ala.getEventSourceType(),ala.getEventCategory(),ala.getAlarmCondition(),ala.getSpecificProblem(),
- ala.getVfStatus(),ala.getAlarmInterfaceA(),ala.getStatus(), DateUtils.dateToString(ala.getCreateTime()),
- DateUtils.dateToString(ala.getUpdateTime()),names,values
- });
- });
- CSVUtils.writeCsv(headers,csvData,csvFile);
+ public void csvFile(){
+ System.out.println(alarmController.generateCsvFile(null,new String[]{"110"}));
}
+ @Test
+ public void update(){
+ System.out.println(alarmController.updateStatus(null,new String[]{"110"},new String[]{"1"},"s"));
+ System.out.println(alarmController.updateStatus(null,new String[]{"110","1101"},new String[]{"1","1"},"many"));
+ System.out.println(alarmController.updateStatus(null,new String[]{"110"},new String[]{"1"},"vf"));
+
+ }
}
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 f13e62c6..c7461013 100644..100755
--- a/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
@@ -15,11 +15,78 @@
*/
package org.onap.usecaseui.server.controller;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.onap.usecaseui.server.bean.PerformanceInformation;
+import org.onap.usecaseui.server.service.PerformanceHeaderService;
+import org.onap.usecaseui.server.service.PerformanceInformationService;
+import org.onap.usecaseui.server.util.CSVUtils;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
+import javax.annotation.Resource;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
@RunWith(SpringRunner.class)
@SpringBootTest
public class PerformanceControllerTest {
+
+ @Autowired
+ private PerformanceController performanceController;
+
+ @Test
+ public void getPerformanceData(){
+ System.out.println(performanceController.getPerformanceData(null,1,100,null,null,null,null,null));
+ }
+
+ @Test
+ public void generateCsvFile() throws JsonProcessingException {
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","fre","2017-09-28 10:00:00"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","fre","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","null","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","null","null","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"null","null","null","null","null"));
+ System.out.println(performanceController.getPerformanceData(null,1,100,"110","fxc","efw","null","asdasdasda"));
+
+
+ }
+
+ @Test
+ public void generateDiaCsvFile() {
+ Map<String,String> p = new HashMap<>();
+ p.put("eventId","110");
+ p.put("name","110");
+ p.put("value","110");
+ p.put("createTime","110");
+ p.put("updateTime","110");
+ System.out.println(performanceController.generateDiaCsvFile(null,p));
+ }
+
+ @Test
+ public void generateDiagram(){
+ try {
+ System.out.println(performanceController.generateDiagram("hour","110"));
+ System.out.println(performanceController.generateDiagram("day","110"));
+ System.out.println(performanceController.generateDiagram("month","110"));
+ System.out.println(performanceController.generateDiagram("year","110"));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ }
+ }
+
+
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java
index b4d24198..5c4ea8dc 100644..100755
--- a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java
@@ -32,8 +32,6 @@ public class AlarmsHeaderServiceTest {
@Resource(name = "AlarmsHeaderService")
private AlarmsHeaderService alarmsHeaderService;
-
-
@Test
public void save() throws ParseException {
AlarmsHeader a = new AlarmsHeader();
@@ -69,9 +67,9 @@ public class AlarmsHeaderServiceTest {
@Test
public void update() throws ParseException {
AlarmsHeader a = new AlarmsHeader();
- a.setEventName("a");
- a.setStatus("1");
- a.setVfStatus("1");
+ a.setEventName("a1");
+ a.setStatus("2");
+ a.setVfStatus("3");
a.setEventId("1101");
a.setDomain("asb");
a.setEventCategory("s");
@@ -101,38 +99,164 @@ public class AlarmsHeaderServiceTest {
@Test
public void get(){
- alarmsHeaderService.queryId(new String[]{"110"}).forEach( a -> System.out.println(a));
+ alarmsHeaderService.queryId(new String[]{"1101"}).forEach( a -> System.out.println(a));
}
@Test
- public void query() throws ParseException {
+ public void queryEventName() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventName("a");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+
+ @Test
+ public void queryStatus() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setStatus("1");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventId() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventId("1101");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryDomain() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setDomain("asb");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventCategory() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventCategory("s");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryAlarmCondition() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setAlarmCondition("ea");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryAlarmInterfaceA() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setAlarmInterfaceA("cs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventServrity() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventServrity("s");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventSourceType() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventSourceType("q");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryEventType() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setEventType("q");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryFaultFieldsVersion() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setFaultFieldsVersion("v1");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryLastEpochMicroSec() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setLastEpochMicroSec("csa");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryNfcNamingCode() throws ParseException {
AlarmsHeader a=new AlarmsHeader();
- a.setEventName("a");
- a.setStatus("1");
- a.setVfStatus("1");
- a.setEventId("1101");
- a.setDomain("asb");
- a.setEventCategory("s");
- a.setAlarmCondition("ea");
- a.setAlarmInterfaceA("cs");
- a.setCreateTime(DateUtils.now());
- a.setEventServrity("s");
- a.setEventSourceType("q");
- a.setEventType("q");
- a.setFaultFieldsVersion("v1");
- a.setLastEpochMicroSec("csa");
a.setNfcNamingCode("std");
- a.setNfNamingCode("cout");
- a.setPriority("cs");
- a.setReportingEntityId("112");
- a.setReportingEntityName("asfs");
- a.setSequence("cgg");
- a.setSourceId("123");
- a.setSourceName("eggs");
- a.setSpecificProblem("especially");
- a.setStartEpochMicrosec("wallet");
- a.setUpdateTime(DateUtils.now());
- a.setVersion("va2");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryNfNamingCode() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setNfNamingCode("cout");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryPriority() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setPriority("cs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryReportingEntityId() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setReportingEntityId("112");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryReportingEntityName() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setReportingEntityName("asfs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySequence() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSequence("cgg");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySourceId() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSourceId("123");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySourceName() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSourceName("eggs");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void querySpecificProblem() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setSpecificProblem("especially");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryStartEpochMicrosec() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setStartEpochMicrosec("wallet");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryVersion() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setVersion("va2");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryVfStatus() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setVfStatus("1");
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryCreateTime() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setCreateTime(DateUtils.now());
+ System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
+ }
+ @Test
+ public void queryUpdateTime() throws ParseException {
+ AlarmsHeader a=new AlarmsHeader();
+ a.setUpdateTime(DateUtils.now());
System.out.println(alarmsHeaderService.queryAlarmsHeader(a,1,100).getList().size());
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
index c07717d9..8f9d4f6b 100644..100755
--- a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
@@ -17,7 +17,6 @@ package org.onap.usecaseui.server.service;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.util.DateUtils;
import org.springframework.boot.test.context.SpringBootTest;
@@ -49,7 +48,7 @@ public class AlarmsInformationServiceTest {
public void update() throws ParseException {
AlarmsInformation a = new AlarmsInformation();
a.setEventId("110");
- a.setName("fw");
+ a.setName("1");
a.setValue("fko");
a.setUpdateTime(DateUtils.now());
a.setCreateTime(DateUtils.now());
@@ -62,12 +61,41 @@ public class AlarmsInformationServiceTest {
}
@Test
- public void query() throws ParseException {
+ public void queryEventId() throws ParseException {
AlarmsInformation a = new AlarmsInformation();
a.setEventId("110");
alarmsInformationService.queryAlarmsInformation(a,1,100)
.getList().forEach( al -> System.out.println(al.getEventId()));
}
+ @Test
+ public void queryName() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setName("efw");
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
+ @Test
+ public void queryValue() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setValue("fko");
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
+
+ @Test
+ public void queryCreateTime() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setCreateTime(DateUtils.now());
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
+ @Test
+ public void queryUpdateTime() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setUpdateTime(DateUtils.now());
+ alarmsInformationService.queryAlarmsInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al.getEventId()));
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
index ffc0f7db..c1f6a694 100644..100755
--- a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
@@ -17,8 +17,6 @@ package org.onap.usecaseui.server.service;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.bean.AlarmsHeader;
-import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.bean.PerformanceHeader;
import org.onap.usecaseui.server.util.DateUtils;
import org.springframework.boot.test.context.SpringBootTest;
@@ -28,8 +26,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.text.ParseException;
-import static org.apache.coyote.http11.Constants.a;
-
@RunWith(SpringRunner.class)
@SpringBootTest
public class PerformanceHeaderServiceTest {
@@ -43,6 +39,7 @@ public class PerformanceHeaderServiceTest {
PerformanceHeader p = new PerformanceHeader();
p.setCreateTime(DateUtils.now());
p.setEventId("110");
+ p.setEventName("fxc");
p.setDomain("asb");
p.setCreateTime(DateUtils.now());
p.setEventType("q");
@@ -66,22 +63,27 @@ public class PerformanceHeaderServiceTest {
@Test
public void update() throws ParseException {
- PerformanceHeader p = new PerformanceHeader();
- p.setEventId("110");
- p.setPriority("we");
- p.setReportingEntityName("xddw");
- p.setSequence("dwd");
- p.setSourceName("swde");
- p.setStartEpochMicrosec("lala");
- p.setVersion("bgf3");
- p.setEventName("ds");
- p.setDomain("ef");
- p.setEventType("l");
- p.setLastEpochMicroSec("vf");
- p.setNfcNamingCode("vds");
- p.setNfNamingCode("f");
- p.setCreateTime(DateUtils.now());
- p.setMeasurementInterval("cdhs");
+ PerformanceHeader p = new PerformanceHeader();
+ p.setCreateTime(DateUtils.now());
+ p.setEventId("110");
+ p.setEventName("fxc");
+ p.setDomain("asb");
+ p.setCreateTime(DateUtils.now());
+ p.setEventType("q");
+ p.setLastEpochMicroSec("csa");
+ p.setNfcNamingCode("std");
+ p.setNfNamingCode("cout");
+ p.setPriority("cs");
+ p.setReportingEntityId("112");
+ p.setReportingEntityName("asfs");
+ p.setSequence("cgg");
+ p.setSourceId("123");
+ p.setSourceName("eggs");
+ p.setStartEpochMicrosec("wallet");
+ p.setUpdateTime(DateUtils.now());
+ p.setVersion("va2");
+ p.setMeasurementInterval("12");
+ p.setMeasurementsForVfScalingVersion("12");
System.out.println(performanceHeaderService.updatePerformanceHeader(p));
}
@@ -92,22 +94,121 @@ public class PerformanceHeaderServiceTest {
}
@Test
- public void query() throws ParseException {
+ public void queryEventId() throws ParseException {
PerformanceHeader p = new PerformanceHeader();
p.setEventId("110");
- p.setPriority("we");
- p.setReportingEntityName("xddw");
- p.setSequence("dwd");
- p.setSourceName("swde");
- p.setStartEpochMicrosec("lala");
- p.setVersion("bgf3");
- p.setEventName("ds");
- p.setDomain("ef");
- p.setEventType("l");
- p.setLastEpochMicroSec("vf");
- p.setNfcNamingCode("vds");
- p.setNfNamingCode("f");
- p.setCreateTime(DateUtils.now());
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryEventName() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setEventName("fxc");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryDomain() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setDomain("asb");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryEventType() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setEventType("q");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryLastEpochMicroSec() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setLastEpochMicroSec("csa");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryNfcNamingCode() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setNfcNamingCode("std");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryNfNamingCode() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setNfNamingCode("cout");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryPriority() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setPriority("cs");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryReportingEntityId() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setReportingEntityId("112");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryReportingEntityName() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setReportingEntityName("asfs");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void querySequence() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setSequence("cgg");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void querySourceId() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setSourceId("123");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void querySourceName() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setSourceName("eggs");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryStartEpochMicrosec() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setStartEpochMicrosec("wallet");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryVersion() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setVersion("va2");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryMeasurementInterval() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setMeasurementInterval("12");
+ performanceHeaderService.queryPerformanceHeader(p,1,100)
+ .getList().forEach(per -> System.out.println(per));
+ }
+ @Test
+ public void queryMeasurementsForVfScalingVersion() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setMeasurementsForVfScalingVersion("12");
performanceHeaderService.queryPerformanceHeader(p,1,100)
.getList().forEach(per -> System.out.println(per));
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
index 3ed8d779..66d66f4f 100644..100755
--- a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
@@ -36,7 +36,7 @@ public class PerformanceInformationServiceTest {
@Test
public void save() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
- a.setEventId("110");
+ a.setEventId("112");
a.setName("efw");
a.setValue("fre");
a.setCreateTime(DateUtils.now());
@@ -48,8 +48,8 @@ public class PerformanceInformationServiceTest {
public void update() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
a.setEventId("110");
- a.setName("fw");
- a.setValue("fko");
+ a.setName("efw");
+ a.setValue("fko11");
a.setUpdateTime(DateUtils.now());
a.setCreateTime(DateUtils.now());
System.out.println(performanceInformationService.updatePerformanceInformation(a));
@@ -62,12 +62,36 @@ public class PerformanceInformationServiceTest {
}
@Test
- public void query() throws ParseException {
+ public void queryEventId() throws ParseException {
PerformanceInformation a = new PerformanceInformation();
a.setEventId("110");
+ performanceInformationService.queryPerformanceInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al));
+ }
+ @Test
+ public void queryName() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
a.setName("kl");
- a.setUpdateTime(DateUtils.now());
+ performanceInformationService.queryPerformanceInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al));
+ }
+ @Test
+ public void queryValue() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
a.setValue("yue");
+ performanceInformationService.queryPerformanceInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al));
+ }
+ @Test
+ public void queryUpdateTime() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
+ a.setUpdateTime(DateUtils.now());
+ performanceInformationService.queryPerformanceInformation(a,1,100)
+ .getList().forEach( al -> System.out.println(al));
+ }
+ @Test
+ public void queryCreateTime() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
a.setCreateTime(DateUtils.now());
performanceInformationService.queryPerformanceInformation(a,1,100)
.getList().forEach( al -> System.out.println(al));
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java b/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java
index c9e2b03d..50ee6e48 100644..100755
--- a/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java
@@ -20,6 +20,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -38,5 +39,16 @@ public class CSVUtilsTest {
CSVUtils.writeCsv(headers,data,csvPath);
}
+ @Test
+ public void CSVRead(){
+ String[] headers = new String[]{"name","age","birthday"};
+ String csvPath = "csvFiles/data.csv";
+ try {
+ CSVUtils.readCSV(csvPath,headers);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java b/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
index 8ac4935f..810a0dcd 100644..100755
--- a/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
@@ -20,28 +20,70 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
+import java.util.Date;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DateUtilsTest {
- @Test
- public void DateTest(){
- SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- LocalDateTime ldt = LocalDateTime.now();
- ldt = ldt.withMonth(2);
- ldt = ldt.withDayOfMonth(30);
- //ldt = ldt.withMonth(1);
- ldt = ldt.withHour(1);
- ZoneId zone = ZoneId.systemDefault();
- Instant instant = ldt.atZone(zone).toInstant();
- System.out.println(ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
- }
+ @Test
+ public void stringToDate(){
+ try {
+ System.out.println(DateUtils.stringToDate("2017-09-28 16:00:00"));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void dateToString(){
+ System.out.println(DateUtils.dateToString(new Date()));
+ }
+
+ @Test
+ public void initDate(){
+ try {
+ System.out.println(DateUtils.initDate(new Date(),0,0,0,0,0,0));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void initProcessDate(){
+ try {
+ System.out.println(DateUtils.initProcessDate(new Date(),0,0,0,0,0,0));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void now(){
+ try {
+ System.out.println(DateUtils.now());
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void addDate(){
+ try {
+ System.out.println(DateUtils.addDate(new Date(),"hour",5));
+ System.out.println(DateUtils.addDate(new Date(),"day",5));
+ System.out.println(DateUtils.addDate(new Date(),"month",5));
+ System.out.println(DateUtils.addDate(new Date(),"year",5));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
}