aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml8
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/ActiveAlarmInfo.java341
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java42
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java23
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java35
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java23
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java58
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java75
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java203
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java193
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java5
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java7
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java7
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java7
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmServiceImpl.java77
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java33
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java27
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java31
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java31
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/CSVUtils.java20
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/DataUtils.java19
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java162
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java63
-rw-r--r--server/src/main/resources/application.properties2
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java67
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java100
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java (renamed from server/src/main/java/org/onap/usecaseui/server/service/AlarmService.java)14
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java139
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java74
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java116
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java76
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java42
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java47
33 files changed, 1465 insertions, 702 deletions
diff --git a/pom.xml b/pom.xml
index f88d21cc..ad8a33f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -231,6 +231,14 @@
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19</version>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/ActiveAlarmInfo.java b/server/src/main/java/org/onap/usecaseui/server/bean/ActiveAlarmInfo.java
deleted file mode 100644
index d204d682..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/bean/ActiveAlarmInfo.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.usecaseui.server.bean;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-
-@Entity
-@Table(name = "EP_ACTIVE_ALARM")
-public class ActiveAlarmInfo
-{
-
- @Id
- @Column(name = "id", nullable = true)
- private String id;
-
-
- @Column(name = "devName")
- private String devName;
-
-
- @Column(name = "devIp")
- private String devIp;
-
-
- @Column(name = "serialNumber")
- private String serialNumber;
-
-
- @Column(name = "alarmRaisedTime")
- private String alarmRaisedTime;
-
-
- @Column(name = "alarmChangedTime")
- private String alarmChangedTime;
-
-
- @Column(name = "alarmIdentifier")
- private String alarmIdentifier;
-
-
- @Column(name = "notificationType")
- private String notificationType;
-
-
- @Column(name = "managedObjectInstance")
- private String managedObjectInstance;
-
-
- @Column(name = "eventType")
- private Integer eventType;
-
-
- @Column(name = "probableCause")
- private String probableCause;
-
-
- @Column(name = "specificProblem")
- private String specificProblem;
-
-
- @Column(name = "perceivedSeverity")
- private String perceivedSeverity;
-
-
- @Column(name = "additionalText")
- private String additionalText;
-
-
- @Column(name = "additionalInformation")
- private String additionalInformation;
-
-
- @Column(name = "clearedManner")
- private String clearedManner;
-
-
- @Column(name = "alarmState")
- private Integer alarmState;
-
-
- @Column(name = "ackTime")
- private String ackTime;
-
-
- @Column(name = "ackUser")
- private String ackUser;
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public String getDevName()
- {
- return devName;
- }
-
- public void setDevName(String devName)
- {
- this.devName = devName;
- }
-
- public String getDevIp()
- {
- return devIp;
- }
-
- public void setDevIp(String devIp)
- {
- this.devIp = devIp;
- }
-
- public String getSerialNumber()
- {
- return serialNumber;
- }
-
- public void setSerialNumber(String serialNumber)
- {
- this.serialNumber = serialNumber;
- }
-
- public String getAlarmRaisedTime()
- {
- return alarmRaisedTime;
- }
-
- public void setAlarmRaisedTime(String alarmRaisedTime)
- {
- this.alarmRaisedTime = alarmRaisedTime;
- }
-
- public String getAlarmChangedTime()
- {
- return alarmChangedTime;
- }
-
- public void setAlarmChangedTime(String alarmChangedTime)
- {
- this.alarmChangedTime = alarmChangedTime;
- }
-
- public String getAlarmIdentifier()
- {
- return alarmIdentifier;
- }
-
- public void setAlarmIdentifier(String alarmIdentifier)
- {
- this.alarmIdentifier = alarmIdentifier;
- }
-
- public String getNotificationType()
- {
- return notificationType;
- }
-
- public void setNotificationType(String notificationType)
- {
- this.notificationType = notificationType;
- }
-
- public String getManagedObjectInstance()
- {
- return managedObjectInstance;
- }
-
- public void setManagedObjectInstance(String managedObjectInstance)
- {
- this.managedObjectInstance = managedObjectInstance;
- }
-
- public Integer getEventType()
- {
- return eventType;
- }
-
- public void setEventType(Integer eventType)
- {
- this.eventType = eventType;
- }
-
- public String getProbableCause()
- {
- return probableCause;
- }
-
- public void setProbableCause(String probableCause)
- {
- this.probableCause = probableCause;
- }
-
- public String getSpecificProblem()
- {
- return specificProblem;
- }
-
- public void setSpecificProblem(String specificProblem)
- {
- this.specificProblem = specificProblem;
- }
-
- public String getPerceivedSeverity()
- {
- return perceivedSeverity;
- }
-
- public void setPerceivedSeverity(String perceivedSeverity)
- {
- this.perceivedSeverity = perceivedSeverity;
- }
-
- public String getAdditionalText()
- {
- return additionalText;
- }
-
- public void setAdditionalText(String additionalText)
- {
- this.additionalText = additionalText;
- }
-
- public String getAdditionalInformation()
- {
- return additionalInformation;
- }
-
- public void setAdditionalInformation(String additionalInformation)
- {
- this.additionalInformation = additionalInformation;
- }
-
- public Integer getAlarmState()
- {
- return alarmState;
- }
-
- public void setAlarmState(Integer alarmState)
- {
- this.alarmState = alarmState;
- }
-
- public String getClearedManner()
- {
- return clearedManner;
- }
-
- public void setClearedManner(String clearedManner)
- {
- this.clearedManner = clearedManner;
- }
-
- public String getAckTime()
- {
- return ackTime;
- }
-
- public void setAckTime(String ackTime)
- {
- this.ackTime = ackTime;
- }
-
- public String getAckUser()
- {
- return ackUser;
- }
-
- public void setAckUser(String ackUser)
- {
- this.ackUser = ackUser;
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append("ActiveAlarmInfo[");
- sb.append("id=");
- sb.append(id);
- sb.append(",devName=");
- sb.append(devName);
- sb.append(",devIp=");
- sb.append(devIp);
- sb.append(",serialNumber=");
- sb.append(serialNumber);
- sb.append(",alarmRaisedTime=");
- sb.append(alarmRaisedTime);
- sb.append(",alarmChangedTime=");
- sb.append(alarmChangedTime);
- sb.append(",alarmIdentifier=");
- sb.append(alarmIdentifier);
- sb.append(",notificationType=");
- sb.append(notificationType);
- sb.append(",managedObjectInstance=");
- sb.append(managedObjectInstance);
- sb.append(",eventType=");
- sb.append(eventType);
- sb.append(",probableCause=");
- sb.append(probableCause);
- sb.append(",specificProblem=");
- sb.append(specificProblem);
- sb.append(",perceivedSeverity=");
- sb.append(perceivedSeverity);
- sb.append(",additionalText=");
- sb.append(additionalText);
- sb.append(",additionalInformation=");
- sb.append(additionalInformation);
- sb.append(",clearedManner=");
- sb.append(clearedManner);
- sb.append(",alarmState=");
- sb.append(alarmState);
- sb.append(",ackTime=");
- sb.append(ackTime);
- sb.append(",ackUser=");
- sb.append(ackUser);
- sb.append("]");
- return sb.toString();
- }
-}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java
index 1bfc13c5..ddb5ded8 100644
--- a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java
@@ -23,7 +23,11 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-
+/**
+ *
+ * @author xuekui
+ *
+ */
@Entity
@Table(name="alarms_commoneventheader")
public class AlarmsHeader implements Serializable{
@@ -107,6 +111,42 @@ public class AlarmsHeader implements Serializable{
@Column(name = "updateTime")
private Date updateTime;
+ public AlarmsHeader() {
+ }
+
+ public AlarmsHeader(String eventId) {
+ this.eventId = eventId;
+ }
+
+ public AlarmsHeader(String version, String eventName, String domain, String eventId, String eventType, String nfcNamingCode, String nfNamingCode, String sourceId, String sourceName, String reportingEntityId, String reportingEntityName, String priority, String startEpochMicrosec, String lastEpochMicroSec, String sequence, String faultFieldsVersion, String eventServrity, String eventSourceType, String eventCategory, String alarmCondition, String specificProblem, String vfStatus, String alarmInterfaceA, String status, Date createTime, Date updateTime) {
+ this.version = version;
+ this.eventName = eventName;
+ this.domain = domain;
+ 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.faultFieldsVersion = faultFieldsVersion;
+ this.eventServrity = eventServrity;
+ this.eventSourceType = eventSourceType;
+ this.eventCategory = eventCategory;
+ this.alarmCondition = alarmCondition;
+ this.specificProblem = specificProblem;
+ this.vfStatus = vfStatus;
+ this.alarmInterfaceA = alarmInterfaceA;
+ this.status = status;
+ this.createTime = createTime;
+ this.updateTime = updateTime;
+ }
+
public String getVersion() {
return version;
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java
index 7a44a045..5c447d61 100644
--- a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsInformation.java
@@ -23,10 +23,14 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-
+/**
+ *
+ * @author xuekui
+ *
+ */
@Entity
@Table(name="alarms_additionalinformation")
-public class AlarmsInformation implements Serializable{
+public class AlarmsInformation implements Serializable {
@Id
@Column(name = "name")
@@ -45,6 +49,21 @@ public class AlarmsInformation implements Serializable{
@Column(name = "updateTime")
private Date updateTime;
+ public AlarmsInformation() {
+ }
+
+ public AlarmsInformation(String eventId) {
+ this.eventId = eventId;
+ }
+
+ public AlarmsInformation(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;
}
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 acaff0e3..30e33378 100644
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java
@@ -23,10 +23,14 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-
+/**
+ *
+ * @author xuekui
+ *
+ */
@Entity
@Table(name="alarms_commoneventheader")
-public class PerformanceHeader implements Serializable{
+public class PerformanceHeader implements Serializable {
@Column(name = "version")
private String version;
@@ -86,6 +90,33 @@ public class PerformanceHeader implements Serializable{
@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;
}
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 0e9124be..12bb7887 100644
--- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
+++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceInformation.java
@@ -23,10 +23,14 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-
+/**
+ *
+ * @author xuekui
+ *
+ */
@Entity
@Table(name="alarms_additionalinformation")
-public class PerformanceInformation implements Serializable{
+public class PerformanceInformation implements Serializable {
@Id
@Column(name = "name")
@@ -45,6 +49,21 @@ public class PerformanceInformation implements Serializable{
@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;
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java b/server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java
new file mode 100644
index 00000000..8904db55
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/bo/AlarmBo.java
@@ -0,0 +1,58 @@
+/*
+ * 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.bo;
+
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.util.Page;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+public class AlarmBo implements Serializable {
+
+ private AlarmsHeader alarmsHeader;
+
+ private List<AlarmsInformation> alarmsInformation;
+
+
+ public AlarmBo() {
+ }
+
+ public AlarmBo(AlarmsHeader alarmsHeader, List<AlarmsInformation> alarmsInformation) {
+ this.alarmsHeader = alarmsHeader;
+ this.alarmsInformation = alarmsInformation;
+ }
+
+ public AlarmsHeader getAlarmsHeader() {
+ return alarmsHeader;
+ }
+
+ public void setAlarmsHeader(AlarmsHeader alarmsHeader) {
+ this.alarmsHeader = alarmsHeader;
+ }
+
+ public List<AlarmsInformation> getAlarmsInformation() {
+ return alarmsInformation;
+ }
+
+ public void setAlarmsInformation(List<AlarmsInformation> alarmsInformation) {
+ this.alarmsInformation = alarmsInformation;
+ }
+
+
+}
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
new file mode 100644
index 00000000..b5a3fe5e
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/bo/PerformanceBo.java
@@ -0,0 +1,75 @@
+/*
+ * 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.bo;
+
+import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.onap.usecaseui.server.bean.PerformanceInformation;
+import org.onap.usecaseui.server.util.Page;
+
+import java.io.Serializable;
+
+public class PerformanceBo implements Serializable {
+
+ private PerformanceHeader performanceHeader;
+
+ private PerformanceInformation performanceInformation;
+
+ private int currentPage;
+
+ private int pageSize;
+
+ public PerformanceBo() {
+ }
+
+ public PerformanceBo(PerformanceHeader performanceHeader, PerformanceInformation performanceInformation, int currentPage, int pageSize) {
+ this.performanceHeader = performanceHeader;
+ this.performanceInformation = performanceInformation;
+ this.currentPage = currentPage;
+ this.pageSize = pageSize;
+ }
+
+ public PerformanceHeader getPerformanceHeader() {
+ return performanceHeader;
+ }
+
+ public void setPerformanceHeader(PerformanceHeader performanceHeader) {
+ this.performanceHeader = performanceHeader;
+ }
+
+ public PerformanceInformation getPerformanceInformation() {
+ return performanceInformation;
+ }
+
+ public void setPerformanceInformation(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/controller/AlarmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
index 8377dd50..001a4885 100644
--- a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
@@ -17,49 +17,46 @@ 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.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+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.*;
-/*
- * 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.
- */
-@Controller
+
+@RestController
@org.springframework.context.annotation.Configuration
@EnableAspectJAutoProxy
public class AlarmController
{
- private static final Logger logger = LoggerFactory.getLogger(AlarmController.class);
+ private final Logger logger = LoggerFactory.getLogger(AlarmController.class);
@Resource(name = "AlarmsHeaderService")
private AlarmsHeaderService alarmsHeaderService;
@@ -68,72 +65,120 @@ public class AlarmController
private AlarmsInformationService alarmsInformationService;
- @ResponseBody
- @RequestMapping(value = {"/alarm/getData"}, method = RequestMethod.GET , produces = "application/json")
- public String getAlarmData(HttpServletRequest request) throws JsonProcessingException {
- String eventId = request.getParameter("ALARM_eventId");
- String vfStatus = request.getParameter("ALARM_vfStatus");
- String status = request.getParameter("ALARM_status");
- String eventName = request.getParameter("ALARM_eventName");
- String name = request.getParameter("ALARM_name");
- String value = request.getParameter("ALARM_value");
- int currentPage = Integer.parseInt(request.getParameter("ALARM_currentPage"));
- int pageSize = Integer.parseInt(request.getParameter("ALARM_pageSize"));
- AlarmsHeader alarmsHeader = new AlarmsHeader();
- AlarmsInformation alarmsInformation = new AlarmsInformation();
- if (null != eventId){
- alarmsHeader.setEventId(eventId);
- alarmsInformation.setEventId(eventId);
+ @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 "";
}
- if (null != vfStatus)
- alarmsHeader.setVfStatus(vfStatus);
- if (null != status)
- alarmsHeader.setStatus(status);
- if (null != eventName)
- alarmsHeader.setEventName(eventName);
- if (null != name)
- alarmsInformation.setName(name);
- if (null != value)
- alarmsInformation.setValue(value);
- List<AlarmsHeader> alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(alarmsHeader,currentPage,pageSize).getList();
- List<AlarmsInformation> alarmsInformations = alarmsInformationService.queryAlarmsInformation(alarmsInformation,currentPage,pageSize).getList();
- Map<String,Object> maps = new HashMap<>();
- if (null != alarmsHeaders && alarmsHeaders.size() > 0)
- maps.put("alarms_header",alarmsHeaders);
- if (null != alarmsInformations && alarmsInformations.size() > 0)
- maps.put("alarms_information",alarmsInformations);
- return new ObjectMapper().writeValueAsString(maps);
}
- @RequestMapping(value = { "/alarm/genCsv" } , method = RequestMethod.GET , produces = "application/json")
- public String generateCsvFile(HttpServletRequest request){
+ @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","measurementsForVfScalingVersion","measurementInterval","value","name",
- "createTime","updateTime"};
- String event_ids = request.getParameter("ids");
- String[] eventId = event_ids.split(",");
-
- return "";
+ "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 = { "/alarm/updateStatus" } , method = RequestMethod.GET , produces = "application/json")
- public String updateStatus(HttpServletRequest request){
- String id = request.getParameter("ALARM_eventId");
- String vfStatus = request.getParameter("ALARM_vfstatus");
- String status = request.getParameter("ALARM_status");
- AlarmsHeader alarmsHeader = new AlarmsHeader();
- if (null != id)
- alarmsHeader.setEventId(id);
- if (null != vfStatus)
- alarmsHeader.setVfStatus(vfStatus);
- if (null != status)
- alarmsHeader.setStatus(status);
- String result = alarmsHeaderService.updateAlarmsHeader(alarmsHeader);
- return result;
+ @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'}";
}
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 bd39843d..684e36f7 100644
--- a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
@@ -15,12 +15,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.PerformanceHeader;
import org.onap.usecaseui.server.bean.PerformanceInformation;
+import org.onap.usecaseui.server.bo.PerformanceBo;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,32 +32,21 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;
+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.*;
-/*
- * 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.
- */
+
@Controller
@Configuration
@EnableAspectJAutoProxy
@@ -65,33 +58,12 @@ public class PerformanceController {
@Resource(name = "PerformanceInformationService")
private PerformanceInformationService performanceInformationService;
- private final String csvPath = "";
+ private Logger logger = LoggerFactory.getLogger(PerformanceController.class);
- private Logger looger = LoggerFactory.getLogger(PerformanceController.class);
-
- @ResponseBody
- @RequestMapping(value = {"/pro/getData"},method = RequestMethod.GET, produces = "application/json")
- public String getPerformanceData(HttpServletRequest request) throws JsonProcessingException {
- String eventId = request.getParameter("PERFORMANCE_eventId");
- String eventName = request.getParameter("PERFORMANCE_eventName");
- String name = request.getParameter("PERFORMANCE_name");
- String value = request.getParameter("PERFORMANCE_value");
- int currentPage = Integer.parseInt(request.getParameter("PERFORMANCE_currentPage"));
- int pageSize = Integer.parseInt(request.getParameter("PERFORMANCE_pageSize"));
- PerformanceHeader performanceHeader = new PerformanceHeader();
- PerformanceInformation performanceInformation = new PerformanceInformation();
- if (null != eventId){
- performanceHeader.setEventId(eventId);
- performanceInformation.setEventId(eventId);
- }
- if (null != eventName)
- performanceHeader.setEventName(eventName);
- if (null != name)
- performanceInformation.setName(name);
- if (null != value)
- performanceInformation.setValue(value);
- List<PerformanceHeader> performanceHeaders = performanceHeaderService.queryPerformanceHeader(performanceHeader,currentPage,pageSize).getList();
- List<PerformanceInformation> performanceInformations = performanceInformationService.queryPerformanceInformation(performanceInformation,currentPage,pageSize).getList();
+ @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);
@@ -100,64 +72,105 @@ public class PerformanceController {
return new ObjectMapper().writeValueAsString(maps);
}
- @RequestMapping(value = {"/pro/genCsv"}, method = RequestMethod.GET, produces = "application/json")
- public String generateCsvFile(HttpServletRequest request){
+ @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);
String[] headers = new String[]{"version",
"eventName","domain","eventId","eventType","nfcNamingCode",
"nfNamingCode","sourceId","sourceName","reportingEntityId",
"reportingEntityName","priority","startEpochMicrosec","lastEpochMicroSec",
- "sequence","measurementsForVfScalingVersion","measurementInterval","value","name",
- "createTime","updateTime"};
- List<PerformanceHeader> performanceHeaders = performanceHeaderService.queryPerformanceHeader(null,1,100).getList();
- List<PerformanceInformation> performanceInformations = performanceInformationService.queryPerformanceInformation(null,1,100).getList();
+ "sequence","measurementsForVfScalingVersion","measurementInterval",
+ "createTime","updateTime","value","name"};
+ List<PerformanceHeader> performanceHeaders = performanceHeaderService.queryId(eventId);
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()+",";
+ }
+ names = names.substring(0,names.lastIndexOf(','));
+ values = values.substring(0,values.lastIndexOf(','));
+ csvData.add(new String[]{
+ s.getVersion(),s.getEventName(),s.getDomain(),s.getEventId(),s.getEventType(),s.getNfcNamingCode(),s.getNfNamingCode(),
+ s.getSourceId(),s.getSourceName(),s.getReportingEntityId(),s.getReportingEntityName(),s.getPriority(),
+ s.getStartEpochMicrosec(),s.getLastEpochMicroSec(),s.getSequence(),s.getMeasurementsForVfScalingVersion(),
+ s.getMeasurementInterval(),DateUtils.dateToString(s.getCreateTime()),DateUtils.dateToString(s.getUpdateTime()),
+ names,values
+ });
- return "";
+ });
+ 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 = {"/pro/genDiaCsv"}, method = RequestMethod.GET, produces = "application/json")
- public String generateDiaCsvFile(HttpServletRequest request){
- String[] headers = new String[]{"","","",""};
- List<PerformanceHeader> performanceHeaders = performanceHeaderService.queryPerformanceHeader(null,1,100).getList();
- List<PerformanceInformation> performanceInformations = performanceInformationService.queryPerformanceInformation(null,1,100).getList();
- List<String[]> csvData = new ArrayList<>();
-
- return "";
+ @RequestMapping(value = {"/usecaseui-server/performance/genDiaCsv"}, method = RequestMethod.POST, produces = "application/json")
+ public String generateDiaCsvFile(HttpServletResponse response,@RequestBody Map<String,String> p) throws ParseException {
+ 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")});
+ }
+ }
+ 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);
+ }
+ return "{'result':'success'}";
+ }catch (IOException e){
+ logger.error("download csv File error :"+e.getMessage());
+ return "{'result':'failed'}";
+ }
}
@ResponseBody
- @RequestMapping(value = {"/pro/genDia"}, method = RequestMethod.GET, produces = "application/json")
- public String generateDiagram(HttpServletRequest request) throws ParseException, JsonProcessingException {
- String id = request.getParameter("PERFORMANCE_id");
- String data = request.getParameter("PERFORMANCE_data");
- SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
- Date beginDate = new Date();
- Calendar date = Calendar.getInstance();
- date.setTime(beginDate);
- PerformanceInformation p = new PerformanceInformation();
- p.setEventId(id);
- if ("hour".equals(data)){
- date.set(Calendar.DATE, date.get(Calendar.HOUR) - 1);
- Date endDate = dft.parse(dft.format(date.getTime()));
- p.setCreateTime(endDate);
- }
- if ("day".equals(data)){
- date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
- Date endDate = dft.parse(dft.format(date.getTime()));
- p.setCreateTime(endDate);
+ @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 {
+ String revDate = "";
+ switch (unit){
+ case "hour":
+ revDate = DateUtils.initDate(new Date(),1,1,1,-1,0,0);
+ break;
+ case "day":
+ revDate = DateUtils.initDate(new Date(),1,1,-1,0,0,0);
+ break;
+ case "month":
+ revDate = DateUtils.initDate(new Date(),1,-1,0,0,0,0);
+ break;
+ case "year":
+ revDate = DateUtils.initDate(new Date(),-1,0,0,0,0,0);
+ break;
}
- if ("month".equals(data)){
- date.set(Calendar.DATE, date.get(Calendar.MONTH) - 1);
- Date endDate = dft.parse(dft.format(date.getTime()));
- p.setCreateTime(endDate);
- }
- if ("year".equals(data)){
- date.set(Calendar.DATE, date.get(Calendar.YEAR) - 1);
- Date endDate = dft.parse(dft.format(date.getTime()));
- p.setCreateTime(endDate);
- }
- List<PerformanceInformation> informationList = performanceInformationService.queryPerformanceInformation(p,1,4).getList();
- return new ObjectMapper().writeValueAsString(informationList);
+ PerformanceInformation performanceInformation = new PerformanceInformation();
+ performanceInformation.setEventId(eventId);
+ performanceInformation.setCreateTime(new SimpleDateFormat().parse(revDate));
+ List<PerformanceInformation> informations = performanceInformationService.queryPerformanceInformation(performanceInformation,1,100).getList();
+ return new ObjectMapper().writeValueAsString(informations);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
index 7ea8aec9..1979115e 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsHeaderService.java
@@ -16,6 +16,8 @@
package org.onap.usecaseui.server.service;
+import java.util.List;
+
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.util.Page;
@@ -27,6 +29,7 @@ public interface AlarmsHeaderService {
int getAllCount();
- Page<AlarmsHeader> queryAlarmsHeader(AlarmsHeader alarmsHeader,int currentPage,int pageSize);
+ Page<AlarmsHeader> queryAlarmsHeader(AlarmsHeader alarmsHeader, int currentPage, int pageSize);
+ List<AlarmsHeader> queryId(String[] id);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java
index a9e01a56..cc9aa6ec 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/AlarmsInformationService.java
@@ -15,6 +15,9 @@
*/
package org.onap.usecaseui.server.service;
+import java.util.List;
+
+import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.util.Page;
@@ -27,5 +30,7 @@ public interface AlarmsInformationService {
int getAllCount();
- Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation,int currentPage,int pageSize);
+ Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation, int currentPage, int pageSize);
+
+ List<AlarmsInformation> queryId(String[] id);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java
index ed4226cd..5535aeb4 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceHeaderService.java
@@ -15,6 +15,9 @@
*/
package org.onap.usecaseui.server.service;
+import java.util.List;
+
+import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.PerformanceHeader;
import org.onap.usecaseui.server.util.Page;
@@ -27,5 +30,7 @@ public interface PerformanceHeaderService {
int getAllCount();
- Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder,int currentPage,int pageSize);
+ Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage, int pageSize);
+
+ List<PerformanceHeader> queryId(String[] id);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java
index 51c0e1a3..128966e7 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/PerformanceInformationService.java
@@ -15,6 +15,9 @@
*/
package org.onap.usecaseui.server.service;
+import java.util.List;
+
+import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.util.Page;
@@ -27,5 +30,7 @@ public interface PerformanceInformationService {
int getAllCount();
- Page<PerformanceInformation> queryPerformanceInformation(PerformanceInformation performanceInformation,int currentPage,int pageSize);
+ Page<PerformanceInformation> queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize);
+
+ List<PerformanceInformation> queryId(String[] id);
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmServiceImpl.java
deleted file mode 100644
index 4e0f8f9c..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmServiceImpl.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.usecaseui.server.service.impl;
-
-import java.util.UUID;
-
-import javax.transaction.Transactional;
-
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.onap.usecaseui.server.bean.ActiveAlarmInfo;
-import org.onap.usecaseui.server.service.AlarmService;
-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("AlarmService")
-@Transactional
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-public class AlarmServiceImpl implements AlarmService
-{
- private static final Logger logger = LoggerFactory.getLogger(AlarmServiceImpl.class);
-
- @Autowired
- private SessionFactory sessionFactory;
-
- public String hello()
- {
- return "Hello";
- }
-
-
- @Transactional
- public String saveActiveAlarmInfo(ActiveAlarmInfo acAlarmInfo)
- {
- try
- {
- if (null == acAlarmInfo)
- {
- logger.error("AlarmServiceImpl saveActiveAlarmInfo acAlarmInfo is null!");
- }
- logger.info("AlarmServiceImpl saveActiveAlarmInfo: acAlarmInfo={}", acAlarmInfo);
- Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
- acAlarmInfo.setId(UUID.randomUUID().toString());
- session.save(acAlarmInfo);
- tx.commit();
- session.flush();
- session.close();
- }
- catch (Exception e)
- {
- logger.error("Exception occurred while performing AlarmServiceImpl saveActiveAlarmInfo. Details:" + e.getMessage());
- }
-
- return acAlarmInfo.getId();
- }
-
-}
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 d0e571a3..2884a9fe 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
@@ -16,7 +16,7 @@
package org.onap.usecaseui.server.service.impl;
-import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -110,7 +110,7 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
int offset = page.countOffset(currentPage, pageSize);
try{
- Date date = new Date();
+// 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) {
@@ -189,14 +189,13 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
hql.append(" and a.status like '%"+ver+"%'");
}else if(null!=alarmsHeader.getCreateTime()) {
Date ver =alarmsHeader.getCreateTime();
- hql.append(" and a.createTime like '%"+ver+"%'");
+ 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();
- Transaction tx = session.beginTransaction();
Query query = session.createQuery(hql.toString());
query.setFirstResult(offset);
query.setMaxResults(pageSize);
@@ -205,7 +204,6 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
page.setPageSize(pageSize);
page.setTotalRecords(allRow);
page.setList(list);
- tx.commit();
session.flush();
session.close();
return page;
@@ -216,6 +214,31 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
}
+ @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;
+ }
+ }
+
+
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 8c9af44c..1f0b4bb6 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server.service.impl;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -90,9 +91,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
public int getAllCount() {
try{
Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
long q=(long)session.createQuery("select count(*) from AlarmsInformation").uniqueResult();
- tx.commit();
session.flush();
session.close();
return (int)q;
@@ -122,17 +121,16 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
hql.append(" and a.value like '%"+ver+"%'");
}else if(null!=alarmsInformation.getEventId()) {
String ver=alarmsInformation.getEventId();
- hql.append(" and a.eventId like '%"+ver+"%'");
+ hql.append(" and a.eventId = '"+ver+"'");
}else if(null!=alarmsInformation.getCreateTime()) {
Date ver =alarmsInformation.getCreateTime();
- hql.append(" and a.createTime like '%"+ver+"%'");
+ 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();
- Transaction tx = session.beginTransaction();
Query query = session.createQuery(hql.toString());
query.setFirstResult(offset);
query.setMaxResults(pageSize);
@@ -141,7 +139,6 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
page.setPageSize(pageSize);
page.setTotalRecords(allRow);
page.setList(list);
- tx.commit();
session.flush();
session.close();
return page;
@@ -151,6 +148,24 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
}
}
+ @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 244a96b2..79265114 100644
--- 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
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server.service.impl;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -93,9 +94,7 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
public int getAllCount() {
try{
Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
long q=(long)session.createQuery("select count(*) from PerformanceHeader").uniqueResult();
- tx.commit();
session.flush();
session.close();
return (int)q;
@@ -170,14 +169,13 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
hql.append(" and a.eventSourceType like '%"+ver+"%'");
}else if(null!=performanceHeder.getCreateTime()) {
Date ver =performanceHeder.getCreateTime();
- hql.append(" and a.createTime like '%"+ver+"%'");
+ 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();
- Transaction tx = session.beginTransaction();
Query query = session.createQuery(hql.toString());
query.setFirstResult(offset);
query.setMaxResults(pageSize);
@@ -186,7 +184,6 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
page.setPageSize(pageSize);
page.setTotalRecords(allRow);
page.setList(list);
- tx.commit();
session.flush();
session.close();
return page;
@@ -197,6 +194,30 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
}
+ @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;
+ }
+ }
+
+
}
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 04ef2fae..f1877137 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java
@@ -16,6 +16,7 @@
package org.onap.usecaseui.server.service.impl;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -92,9 +93,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
public int getAllCount() {
try{
Session session = sessionFactory.openSession();
- Transaction tx = session.beginTransaction();
long q=(long)session.createQuery("select count(*) from PerformanceInformation").uniqueResult();
- tx.commit();
session.flush();
session.close();
return (int)q;
@@ -127,14 +126,13 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
hql.append(" and a.eventId like '%"+ver+"%'");
}else if(null!=performanceInformation.getCreateTime()) {
Date ver =performanceInformation.getCreateTime();
- hql.append(" and a.createTime like '%"+ver+"%'");
+ 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();
- Transaction tx = session.beginTransaction();
Query query = session.createQuery(hql.toString());
query.setFirstResult(offset);
query.setMaxResults(pageSize);
@@ -143,7 +141,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
page.setPageSize(pageSize);
page.setTotalRecords(allRow);
page.setList(list);
- tx.commit();
session.flush();
session.close();
return page;
@@ -154,6 +151,30 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
}
+ @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;
+ }
+ }
+
+
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/CSVUtils.java b/server/src/main/java/org/onap/usecaseui/server/util/CSVUtils.java
index 8c7a4895..6d5532a8 100644
--- a/server/src/main/java/org/onap/usecaseui/server/util/CSVUtils.java
+++ b/server/src/main/java/org/onap/usecaseui/server/util/CSVUtils.java
@@ -28,16 +28,9 @@ import java.util.List;
public class CSVUtils {
- //CSV文件分隔符
- private final static String NEW_LINE_SEPARATOR="\n";
- private static Logger logger = LoggerFactory.getLogger(CSVUtils.class);
+ private static Logger logger = LoggerFactory.getLogger(CSVUtils.class);
- /**写入csv文件
- * @param headers 列头
- * @param data 数据内容
- * @param filePath 创建的csv文件路径
- * **/
public static void writeCsv(String[] headers,List<String[]> data,String filePath) {
try{
CSVFormat formator = CSVFormat.DEFAULT.withHeader(headers);
@@ -58,11 +51,12 @@ public class CSVUtils {
}
}
- /**读取csv文件
- * @param filePath 文件路径
- * @param headers csv列头
- * @return CSVRecord 列表
- * @throws IOException **/
+
+ public static boolean wCsv(){
+
+ return false;
+ }
+
public static List<CSVRecord> readCSV(String filePath, String[] headers) throws IOException{
//创建CSVFormat
CSVFormat formator = CSVFormat.DEFAULT.withHeader(headers);
diff --git a/server/src/main/java/org/onap/usecaseui/server/util/DataUtils.java b/server/src/main/java/org/onap/usecaseui/server/util/DataUtils.java
deleted file mode 100644
index beaa29b6..00000000
--- a/server/src/main/java/org/onap/usecaseui/server/util/DataUtils.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.usecaseui.server.util;
-
-public class DataUtils {
-}
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
new file mode 100644
index 00000000..068bc04d
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/util/DateUtils.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.util;
+
+import 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.Calendar;
+import java.util.Date;
+
+public class DateUtils {
+
+
+
+
+ public static String initDate(Date d,int year,int month,int day,int hour,int minute,int second) throws ParseException {
+ Instant instant = d.toInstant();
+ ZoneId zone = ZoneId.systemDefault();
+ LocalDateTime ldt = LocalDateTime.ofInstant(instant,zone);
+ if(year >= 0){
+ if(year == 0)
+ ldt = ldt.withYear(1);
+ } else
+ ldt = ldt.withYear(ldt.getYear()-1);
+ if(month >= 0){
+ if(month == 0)
+ ldt = ldt.withMonth(1);
+ } else
+ ldt = ldt.withMonth(ldt.getMonthValue()-1);
+ if(day >= 0){
+ if(day == 0)
+ ldt = ldt.withDayOfMonth(1);
+ } else
+ ldt = ldt.withDayOfMonth(ldt.getDayOfMonth()-1);
+ if(hour >= 0){
+ if(hour == 0)
+ ldt = ldt.withHour(1);
+ } else
+ ldt = ldt.withHour(ldt.getHour()-1);
+ if(minute >= 0){
+ if(minute == 0)
+ ldt = ldt.withMinute(0);
+ } else
+ ldt = ldt.withMinute(ldt.getMinute()-1);
+ if(second >= 0){
+ if(second == 0)
+ ldt = ldt.withSecond(0);
+ } else
+ ldt = ldt.withMinute(ldt.getSecond()-1);
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ }
+
+
+
+
+ /**
+ * param except data ,if int equal 0 then cleared zero,
+ * if equal -1 then minus 1 ,else unchanging
+ * @param d
+ * @param year
+ * @param month
+ * @param hour
+ * @param minute
+ * @param second
+ * @return
+ * @throws ParseException
+ */
+ public static Date initProcessDate(Date d,int year,int month,int day,int hour,int minute,int second) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yy:MM:dd hh:mm:ss");
+ Calendar c = Calendar.getInstance();
+ c.setTime(d);
+ if(year >= 0){
+ if(year == 0)
+ c.set(Calendar.YEAR,0);
+ } else
+ c.set(Calendar.YEAR,c.get(Calendar.YEAR)-1);
+ if(month >= 0){
+ if(month == 0)
+ c.set(Calendar.MONTH,0);
+ } else
+ c.set(Calendar.MONTH,c.get(Calendar.MONTH)-1);
+ if(day >= 0){
+ if(day == 0)
+ c.set(Calendar.DAY_OF_MONTH,0);
+ } else
+ c.set(Calendar.DAY_OF_MONTH,c.get(Calendar.DAY_OF_MONTH)-1);
+ if(hour >= 0){
+ if(hour == 0)
+ c.set(Calendar.HOUR_OF_DAY,0);
+ } else
+ c.set(Calendar.HOUR_OF_DAY,c.get(Calendar.HOUR_OF_DAY)-1);
+ if(minute >= 0){
+ if(minute == 0)
+ c.set(Calendar.MINUTE,0);
+ } else
+ c.set(Calendar.MINUTE,c.get(Calendar.MINUTE)-1);
+ if(second >= 0){
+ if(second == 0)
+ c.set(Calendar.SECOND,0);
+ } else
+ c.set(Calendar.SECOND,c.get(Calendar.SECOND)-1);
+ return sdf.parse(sdf.format(c.getTime()));
+ }
+
+ /**
+ *
+ * @param d
+ * @param unit time unit
+ * @param addVal add value
+ * @return
+ * @throws ParseException
+ */
+ public static String addDate(Date d,String unit,int addVal) throws ParseException {
+ Instant instant = d.toInstant();
+ ZoneId zone = ZoneId.systemDefault();
+ LocalDateTime ldt = LocalDateTime.ofInstant(instant,zone);
+ switch (unit.toLowerCase()){
+ case "month":
+ ldt = ldt.withMonth(ldt.getMonthValue()+addVal);
+ break;
+ case "day":
+ ldt = ldt.withDayOfMonth(ldt.getDayOfMonth()+addVal);
+ break;
+ case "hour":
+ ldt = ldt.withHour(ldt.getHour()+addVal);
+ break;
+ case "minute":
+ ldt = ldt.withMinute(ldt.getMinute()+addVal);
+ break;
+ }
+ return ldt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ }
+
+ public static String dateToString(Date d){
+ return new SimpleDateFormat("yy:MM:dd HH:mm:ss").format(d);
+ }
+
+ public static Date stringToDate(String d) throws ParseException {
+ return new SimpleDateFormat("yy:MM:dd HH:mm:ss").parse(d);
+ }
+
+ public static Date now() throws ParseException {
+ return new SimpleDateFormat("yy:MM:dd HH:mm:ss").parse(dateToString(new Date()));
+ }
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java b/server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java
new file mode 100644
index 00000000..17997116
--- /dev/null
+++ b/server/src/main/java/org/onap/usecaseui/server/wrapper/AlarmWrapper.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.wrapper;
+
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+
+public class AlarmWrapper {
+
+ private AlarmsHeader alarmsHeader;
+
+ private AlarmsInformation alarmsInformation;
+
+ private int currentPage = 1;
+
+ private int pageSize = 100;
+
+
+ public AlarmsHeader getAlarmsHeader() {
+ return alarmsHeader;
+ }
+
+ public void setAlarmsHeader(AlarmsHeader alarmsHeader) {
+ this.alarmsHeader = alarmsHeader;
+ }
+
+ public AlarmsInformation getAlarmsInformation() {
+ return alarmsInformation;
+ }
+
+ public void setAlarmsInformation(AlarmsInformation alarmsInformation) {
+ this.alarmsInformation = alarmsInformation;
+ }
+
+ public int getCurrentPage() {
+ return currentPage;
+ }
+
+ public void setCurrentPage(int currentPage) {
+ this.currentPage = currentPage;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+}
diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties
index 4630f2b4..c4f7d620 100644
--- a/server/src/main/resources/application.properties
+++ b/server/src/main/resources/application.properties
@@ -14,7 +14,7 @@
## limitations under the License.
##
## General App Properties
-server.contextPath=/usecase
+server.contextPath=/api/usecaseui/server/v1
server.port=8082
spring.http.multipart.max-file-size=128MB
spring.http.multipart.max-request-size=128MB
diff --git a/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java b/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java
index 4fc3e747..ae1e2990 100644
--- a/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java
+++ b/server/src/test/java/org/onap/usecaseui/server/UsecaseuiServerApplicationTests.java
@@ -15,57 +15,38 @@
*/
package org.onap.usecaseui.server;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.junit.Assert;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.bean.AlarmsHeader;
-import org.onap.usecaseui.server.bean.AlarmsInformation;
-import org.onap.usecaseui.server.service.AlarmsHeaderService;
-import org.onap.usecaseui.server.service.AlarmsInformationService;
-import org.onap.usecaseui.server.service.impl.AlarmsHeaderServiceImpl;
-import org.onap.usecaseui.server.service.impl.AlarmsInformationServiceImpl;
-import org.onap.usecaseui.server.util.Page;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
+import java.text.ParseException;
+
@RunWith(SpringRunner.class)
@SpringBootTest
public class UsecaseuiServerApplicationTests {
-
-// @Autowired
-// AlarmsInformationService info;
-
- @Autowired
- AlarmsHeaderService alarm;
-
+
+
+
+
@Test
- public void contextLoads() throws ParseException {
-// AlarmsInformation in= new AlarmsInformation();
-// Date date =new Date();
-// in.setName("name");
-// in.setEventId("eventId");
-// in.setValue("value");
-// in.setCreateTime(date);
-// in.setUpdateTime(date);
-// String d=info.saveAlarmsInformation(in);
-// String d=info.updateAlarmsInformation(in);
-
-// int c=alarm.getAllCount();
-
- AlarmsHeader a = new AlarmsHeader();
-// a.setVersion("1");
- a.setDomain("3");
-// SimpleDateFormat e =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-// a.setCreateTime(e.parse("2017-09-03 15:25:11"));
- Page<AlarmsHeader> b = alarm.queryAlarmsHeader(a, 1, 5);
- String c =b.getList().get(0).getEventName();
- System.out.println("============"+c);
- Assert.assertEquals("2", c);
-
+ public void contextLoads() throws JsonProcessingException, ParseException {
+ /*ObjectMapper objectMapper = new ObjectMapper();
+ AlarmsHeader alarmsHeader = new AlarmsHeader();
+ alarmsHeader.setAlarmCondition("send to my phone");
+ alarmsHeader.setAlarmInterfaceA("Baby have no fear");
+ alarmsHeader.setCreateTime(new Date());
+ alarmsHeader.setDomain("Hope they ready");
+ List<AlarmsHeader> alarmsHeaders = new ArrayList<>();
+ alarmsHeaders.add(alarmsHeader);
+ alarmsHeaders.add(alarmsHeader);
+ alarmsHeaders.add(alarmsHeader);
+ Map<String,Object> map = new HashMap<>();
+ map.put("alarms",alarmsHeaders);
+ map.put("asd",alarmsHeader);
+ String jsonStr = objectMapper.writeValueAsString(map);
+ System.out.println(jsonStr);*/
+ //System.out.println(alarmsInformationService.saveAlarmsInformation(new AlarmsInformation("11","22","123",new Date(),new Date())));
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
new file mode 100644
index 00000000..3dd2c57c
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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 org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.service.AlarmsHeaderService;
+import org.onap.usecaseui.server.service.AlarmsInformationService;
+import org.onap.usecaseui.server.util.CSVUtils;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+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));
+ }
+
+ @Test
+ public void getDataCarryParam(){
+ System.out.println(alarmController.getAlarmData("110","a","drop","down","1506331166000",1,1100));
+ }
+
+ @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);
+ }
+
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/AlarmService.java b/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
index 0834cece..f13e62c6 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/AlarmService.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.usecaseui.server.service;
+package org.onap.usecaseui.server.controller;
-import org.onap.usecaseui.server.bean.ActiveAlarmInfo;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
-public interface AlarmService
-{
- String hello();
-
- String saveActiveAlarmInfo(ActiveAlarmInfo acAlarmInfo);
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class PerformanceControllerTest {
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java
new file mode 100644
index 00000000..b4d24198
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsHeaderServiceTest.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AlarmsHeaderServiceTest {
+
+ @Resource(name = "AlarmsHeaderService")
+ private AlarmsHeaderService alarmsHeaderService;
+
+
+
+ @Test
+ public void save() throws ParseException {
+ AlarmsHeader a = new AlarmsHeader();
+ a.setEventName("a");
+ a.setStatus("1");
+ a.setVfStatus("1");
+ a.setEventId("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.saveAlarmsHeader(a));
+
+ }
+ @Test
+ public void update() 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.updateAlarmsHeader(a));
+ }
+
+ @Test
+ public void get(){
+
+ alarmsHeaderService.queryId(new String[]{"110"}).forEach( a -> System.out.println(a));
+ }
+
+ @Test
+ public void query() 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());
+ }
+
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
new file mode 100644
index 00000000..c07717d9
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/AlarmsInformationServiceTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AlarmsInformationServiceTest {
+
+
+ @Resource(name = "AlarmsInformationService")
+ AlarmsInformationService alarmsInformationService;
+
+ @Test
+ public void save() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setEventId("110");
+ a.setName("efw");
+ a.setValue("fre");
+ a.setCreateTime(DateUtils.now());
+ a.setUpdateTime(DateUtils.now());
+ System.out.println(alarmsInformationService.saveAlarmsInformation(a));
+ }
+
+ @Test
+ public void update() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setEventId("110");
+ a.setName("fw");
+ a.setValue("fko");
+ a.setUpdateTime(DateUtils.now());
+ a.setCreateTime(DateUtils.now());
+ System.out.println(alarmsInformationService.updateAlarmsInformation(a));
+ }
+
+ @Test
+ public void get() throws ParseException {
+ alarmsInformationService.queryId(new String[]{"110"}).forEach(ai -> System.out.println(ai));
+ }
+
+ @Test
+ public void query() throws ParseException {
+ AlarmsInformation a = new AlarmsInformation();
+ a.setEventId("110");
+ 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
new file mode 100644
index 00000000..ffc0f7db
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceHeaderServiceTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+
+import static org.apache.coyote.http11.Constants.a;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class PerformanceHeaderServiceTest {
+
+
+ @Resource(name = "PerformanceHeaderService")
+ PerformanceHeaderService performanceHeaderService;
+
+ @Test
+ public void save() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.setCreateTime(DateUtils.now());
+ p.setEventId("110");
+ p.setDomain("asb");
+ p.setCreateTime(DateUtils.now());
+ p.setEventType("q");
+ p.setLastEpochMicroSec("csa");
+ p.setNfcNamingCode("std");
+ p.setNfNamingCode("cout");
+ p.setPriority("cs");
+ p.setReportingEntityId("112");
+ p.setReportingEntityName("asfs");
+ p.setSequence("cgg");
+ p.setSourceId("123");
+ p.setSourceName("eggs");
+ p.setStartEpochMicrosec("wallet");
+ p.setUpdateTime(DateUtils.now());
+ p.setVersion("va2");
+ p.setMeasurementInterval("12");
+ p.setMeasurementsForVfScalingVersion("12");
+
+ System.out.println(performanceHeaderService.savePerformanceHeader(p));
+ }
+
+ @Test
+ public void update() throws ParseException {
+ PerformanceHeader p = new PerformanceHeader();
+ p.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");
+ System.out.println(performanceHeaderService.updatePerformanceHeader(p));
+ }
+
+ @Test
+ public void get() throws ParseException {
+ performanceHeaderService.queryId(new String[]{"110"})
+ .forEach(pe -> System.out.println(pe));
+ }
+
+ @Test
+ public void query() 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));
+ }
+
+}
+
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
new file mode 100644
index 00000000..3ed8d779
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/service/PerformanceInformationServiceTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.usecaseui.server.bean.PerformanceInformation;
+import org.onap.usecaseui.server.util.DateUtils;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class PerformanceInformationServiceTest {
+
+
+ @Resource(name = "PerformanceInformationService")
+ PerformanceInformationService performanceInformationService;
+
+ @Test
+ public void save() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
+ a.setEventId("110");
+ a.setName("efw");
+ a.setValue("fre");
+ a.setCreateTime(DateUtils.now());
+ a.setUpdateTime(DateUtils.now());
+ System.out.println(performanceInformationService.savePerformanceInformation(a));
+ }
+
+ @Test
+ public void update() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
+ a.setEventId("110");
+ a.setName("fw");
+ a.setValue("fko");
+ a.setUpdateTime(DateUtils.now());
+ a.setCreateTime(DateUtils.now());
+ System.out.println(performanceInformationService.updatePerformanceInformation(a));
+ }
+
+ @Test
+ public void get() throws ParseException {
+ performanceInformationService.queryId(new String[]{"110"})
+ .forEach(ai -> System.out.println(ai));
+ }
+
+ @Test
+ public void query() throws ParseException {
+ PerformanceInformation a = new PerformanceInformation();
+ a.setEventId("110");
+ a.setName("kl");
+ a.setUpdateTime(DateUtils.now());
+ a.setValue("yue");
+ 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
new file mode 100644
index 00000000..c9e2b03d
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/util/CSVUtilsTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.util;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class CSVUtilsTest {
+
+ @Test
+ public void CSVTest(){
+ String[] headers = new String[]{"name","age","birthday"};
+ List<String[]> data = new ArrayList<>();
+ data.add(new String[]{"Tom","15","2001-1-12"});
+ data.add(new String[]{"Jerry","18","2005-1-12"});
+ data.add(new String[]{"John","20","2011-1-12"});
+ String csvPath = "csvFiles/data.csv";
+ CSVUtils.writeCsv(headers,data,csvPath);
+ }
+
+
+}
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
new file mode 100644
index 00000000..8ac4935f
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.util;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
+@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")));
+ }
+
+}