aboutsummaryrefslogtreecommitdiffstats
path: root/configbackuprestore/vnfconfigreportsservice/src/main/java
diff options
context:
space:
mode:
authorSoumendu Sekhar Acharya <SA00498080@techmahindra.com>2018-08-07 15:23:28 +0530
committerSoumendu Sekhar Acharya <SA00498080@techmahindra.com>2018-08-24 06:39:48 +0000
commitcc49cb7753ff820dada996ab1d56263243630395 (patch)
tree71d1df55fadeb4a82d6dfd2e2bfd0bfdf9ade94b /configbackuprestore/vnfconfigreportsservice/src/main/java
parentdb386c7a0e9807b042a675208a1e7802501bca27 (diff)
Epic-231 cbr reports
SDN-C to support reporting feature for automated operations e.g. backup, versioning, restoration and added jacoco plugin in parent configbackuprestore Change-Id: I355fdf0ed30a5446eb0447e3f90755dff54811cc Issue-ID: SDNC-263 Signed-off-by: Soumendu Sekhar Acharya <SA00498080@techmahindra.com> Former-commit-id: 3fc03f8bde09d63f0c91c25bc95bb3419c3a6c0d
Diffstat (limited to 'configbackuprestore/vnfconfigreportsservice/src/main/java')
-rw-r--r--configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/controller/VnfReportsServiceController.java44
-rw-r--r--configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/dao/VnfReportsServiceRepo.java20
-rw-r--r--configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/model/VnfConfigDetailsDB.java110
-rw-r--r--configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImpl.java48
-rw-r--r--configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/Vnfreportsservice.java11
5 files changed, 233 insertions, 0 deletions
diff --git a/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/controller/VnfReportsServiceController.java b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/controller/VnfReportsServiceController.java
new file mode 100644
index 00000000..4ef15366
--- /dev/null
+++ b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/controller/VnfReportsServiceController.java
@@ -0,0 +1,44 @@
+package com.onap.sdnc.vnfreportsservice.controller;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.onap.sdnc.vnfreportsservice.model.VnfConfigDetailsDB;
+import com.onap.sdnc.vnfreportsservice.service.VnfReportsServiceImpl;
+
+@RestController
+public class VnfReportsServiceController {
+
+ private static final Logger logger = LogManager.getLogger(VnfReportsServiceController.class);
+
+ @Autowired
+ VnfReportsServiceImpl Vnfreportsservice;
+
+ @RequestMapping(value = "/getVnfDetBetDates/{startDate}/{endDate}", method = RequestMethod.GET, produces = "application/json")
+
+ public List<VnfConfigDetailsDB> getVnfConfigDetailsBetweenDates(
+ @PathVariable("startDate") @DateTimeFormat(pattern = "dd-MM-yyyy") Date startDate,
+ @PathVariable("endDate") @DateTimeFormat(pattern = "dd-MM-yyyy") Date endDate) {
+ logger.info("Get VNF Configuration Details Inbetween 2 Dates ");
+ return Vnfreportsservice.getVnfConfigDetailsBetweenDates(startDate, endDate);
+ }
+
+ @RequestMapping(value = "/getVnfDetByVnfidBetDates/{vnfid}/{startDate}/{endDate}", method = RequestMethod.GET, produces = "application/json")
+
+ public List<VnfConfigDetailsDB> getVnfConfigDetailsByVnfIdBetweenDates(@PathVariable("vnfid") String vnfId,
+ @PathVariable("startDate") @DateTimeFormat(pattern = "dd-MM-yyyy") Date startDate,
+ @PathVariable("endDate") @DateTimeFormat(pattern = "dd-MM-yyyy") Date endDate) {
+ logger.info("Get VNF Configuration Details Of a VnfID Inbetween 2 Dates ");
+ return Vnfreportsservice.getVnfIdDetailsBetweenDates(vnfId, startDate, endDate);
+ }
+
+}
diff --git a/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/dao/VnfReportsServiceRepo.java b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/dao/VnfReportsServiceRepo.java
new file mode 100644
index 00000000..1834ebe0
--- /dev/null
+++ b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/dao/VnfReportsServiceRepo.java
@@ -0,0 +1,20 @@
+package com.onap.sdnc.vnfreportsservice.dao;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import com.onap.sdnc.vnfreportsservice.controller.VnfReportsServiceController;
+import com.onap.sdnc.vnfreportsservice.model.VnfConfigDetailsDB;
+
+
+public interface VnfReportsServiceRepo extends JpaRepository<VnfConfigDetailsDB, Long> {
+
+ List<VnfConfigDetailsDB> findByLastupdatedBetween(Date startDate, Date endDate);
+ List<VnfConfigDetailsDB> findByVnfidAndLastupdatedBetween(String vnfid,Date startDate,Date endDate);
+
+}
+
+
diff --git a/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/model/VnfConfigDetailsDB.java b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/model/VnfConfigDetailsDB.java
new file mode 100644
index 00000000..a2c08ef7
--- /dev/null
+++ b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/model/VnfConfigDetailsDB.java
@@ -0,0 +1,110 @@
+package com.onap.sdnc.vnfreportsservice.model;
+
+import java.sql.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "vnfconfigdetails", schema = "testreports")
+public class VnfConfigDetailsDB {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @Column(name = "vnfid")
+ private String vnfid;
+
+ @Column(name = "vnfversion")
+ private String vnfversion;
+
+ @Column(name = "vnfname")
+ private String vnfname;
+
+ @Column(name = "configinfo")
+ @Lob
+ private String configinfo;
+
+ @Column(name = "creationdate")
+ private Date creationdate;
+
+ @Column(name = "lastupdated")
+ private Date lastupdated;
+
+ @Column(name = "status")
+ private String status;
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getVnfid() {
+ return vnfid;
+ }
+
+ public void setVnfid(String vnfid) {
+ this.vnfid = vnfid;
+ }
+
+ public String getVnfversion() {
+ return vnfversion;
+ }
+
+ public void setVnfversion(String vnfversion) {
+ this.vnfversion = vnfversion;
+ }
+
+ public String getVnfname() {
+ return vnfname;
+ }
+
+ public void setVnfname(String vnfname) {
+ this.vnfname = vnfname;
+ }
+
+ public String getConfiginfo() {
+ return configinfo;
+ }
+
+ public void setConfiginfo(String configinfo) {
+ this.configinfo = configinfo;
+ }
+
+ public Date getCreationdate() {
+ return creationdate;
+ }
+
+ public void setCreationdate(Date creationdate) {
+ this.creationdate = creationdate;
+ }
+
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public Date getLastupdated() {
+ return lastupdated;
+ }
+
+ public void setLastupdated(Date lastupdated) {
+ this.lastupdated = lastupdated;
+ }
+
+}
+
diff --git a/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImpl.java b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImpl.java
new file mode 100644
index 00000000..3b4a7f86
--- /dev/null
+++ b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/VnfReportsServiceImpl.java
@@ -0,0 +1,48 @@
+package com.onap.sdnc.vnfreportsservice.service;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.onap.sdnc.vnfreportsservice.dao.VnfReportsServiceRepo;
+import com.onap.sdnc.vnfreportsservice.model.VnfConfigDetailsDB;
+@Service
+public class VnfReportsServiceImpl implements Vnfreportsservice {
+
+ private static final Logger logger = LogManager.getLogger(VnfReportsServiceImpl.class);
+
+ @Autowired
+ VnfReportsServiceRepo vnfRepo;
+
+ List<VnfConfigDetailsDB> config = null;
+
+ @Override
+ public List<VnfConfigDetailsDB> getVnfConfigDetailsBetweenDates(Date startDate, Date endDate) {
+
+ logger.info("Start Date" + startDate + "End Date" + endDate);
+ try {
+ config = vnfRepo.findByLastupdatedBetween(startDate, endDate);
+ } catch (Exception e) {
+ logger.error("Exception Occered Not able to get details from DB : " + e);
+ }
+
+ return config;
+ }
+
+ @Override
+ public List<VnfConfigDetailsDB> getVnfIdDetailsBetweenDates(String vnfid, Date startDate, Date endDate) {
+
+ logger.info("Vnf ID: " + vnfid + "Start Date: " + startDate + "End Date: " + endDate);
+ try {
+ config = vnfRepo.findByVnfidAndLastupdatedBetween(vnfid, startDate, endDate);
+ } catch (Exception e) {
+ logger.error("Exception Occered Not able to get details from DB : " + e);
+ }
+ return config;
+ }
+
+}
diff --git a/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/Vnfreportsservice.java b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/Vnfreportsservice.java
new file mode 100644
index 00000000..3cbd2053
--- /dev/null
+++ b/configbackuprestore/vnfconfigreportsservice/src/main/java/com/onap/sdnc/vnfreportsservice/service/Vnfreportsservice.java
@@ -0,0 +1,11 @@
+package com.onap.sdnc.vnfreportsservice.service;
+
+import java.util.Date;
+import java.util.List;
+import com.onap.sdnc.vnfreportsservice.model.VnfConfigDetailsDB;
+
+public interface Vnfreportsservice {
+ public List<VnfConfigDetailsDB> getVnfConfigDetailsBetweenDates(Date startDate, Date endDate);
+ public List<VnfConfigDetailsDB> getVnfIdDetailsBetweenDates(String vnfId, Date startDate, Date endDate);
+
+}