diff options
Diffstat (limited to 'configbackuprestore/getBackupVnfDetailService/src/main/java')
9 files changed, 444 insertions, 0 deletions
diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/controller/VnfComparisonController.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/controller/VnfComparisonController.java new file mode 100644 index 00000000..2f83368c --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/controller/VnfComparisonController.java @@ -0,0 +1,68 @@ +package com.onap.sdnc.vnfcomparsion.controller; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +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.vnfconfigcomparsion.model.VnfCompareResponse; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfConfigDetailsDB; +import com.onap.sdnc.vnfconfigcomparsion.service.VnfComparisonService; + + +@RestController +public class VnfComparisonController { + + private static final Logger logger = Logger.getLogger(VnfComparisonController.class); + + @Autowired + VnfComparisonService vnfComparisonService; + + + @RequestMapping(value="/getAllBackupVnfIds", method=RequestMethod.GET,produces="application/json") + public List<VnfConfigDetailsDB> getAllBackupVnfIds() { + return vnfComparisonService.getAllBackupVnfIds(); + } + + + @RequestMapping(value="/configcomparison/{vnfid}", method = RequestMethod.POST,produces="application/json") + public VnfCompareResponse configComparison(@RequestBody String versionNames,@PathVariable("vnfid") String vnfId) { + VnfCompareResponse vnfCompareResponse = null; + try { + JSONObject versionId = new JSONObject(versionNames); + vnfCompareResponse = vnfComparisonService.getConfigurationDeatils(versionId,vnfId); + + } catch (JSONException e1) { + logger.error("exception occered"+e1); + } + + return vnfCompareResponse; +} + + @RequestMapping(value="/configDetailsByIdVersion/{vnfid}", method = RequestMethod.POST,produces="application/json") + public VnfCompareResponse getVnfDetailsOfVersionsAndVnfID(@RequestBody String versionNames,@PathVariable("vnfid") String vnfId) { + VnfCompareResponse vnfCompareResponse = null; + try { + JSONObject versionId = new JSONObject(versionNames); + vnfCompareResponse = vnfComparisonService.getConfigDeatilsByVnfIdVnfVersion(versionId,vnfId); + + } catch (JSONException e1) { + logger.error("exception occered"+e1); + } + + return vnfCompareResponse; +} + + @RequestMapping(value="/configDetailsById/{vnfid}", method = RequestMethod.GET,produces="application/json") + public List<VnfConfigDetailsDB> getVnfDetailsOfVnfID(@PathVariable("vnfid") String vnfId) { + List<VnfConfigDetailsDB> vnfConfigDetails = null; + vnfConfigDetails = vnfComparisonService.getConfigurationDeatils(vnfId); + return vnfConfigDetails; +} +} diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/dao/VnfComparisonRepository.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/dao/VnfComparisonRepository.java new file mode 100644 index 00000000..265206d2 --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/dao/VnfComparisonRepository.java @@ -0,0 +1,30 @@ +package com.onap.sdnc.vnfcomparsion.dao; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import com.onap.sdnc.vnfconfigcomparsion.model.VnfConfigDetailsDB; + + +@Repository +public interface VnfComparisonRepository extends JpaRepository<VnfConfigDetailsDB, Serializable>{ + + + @Query(value = "Select * from vnfconfigdetails where vnfid = :vnfid", nativeQuery = true) + List<VnfConfigDetailsDB> getVnfDetailsByVnfID(@Param("vnfid") String vnfid); + + @Query(value = "Select * from vnfconfigdetails where vnfversion = :vnfversion and vnfid = :vnfid", nativeQuery = true) + VnfConfigDetailsDB getVnfDetails(@Param("vnfversion") String vnfversion, @Param("vnfid") String vnfid); + + public static final String FIND_VNFID = "SELECT * FROM vnfconfigdetails group by vnfid"; + + @Query(value= FIND_VNFID,nativeQuery = true) + List<VnfConfigDetailsDB> findvnfidvnfname(); + +} diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/dao/VnfIds.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/dao/VnfIds.java new file mode 100644 index 00000000..51210b17 --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfcomparsion/dao/VnfIds.java @@ -0,0 +1,7 @@ +package com.onap.sdnc.vnfcomparsion.dao; + +public interface VnfIds { + + String getVnfID(); + +} diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfCompareResponse.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfCompareResponse.java new file mode 100644 index 00000000..b684541b --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfCompareResponse.java @@ -0,0 +1,16 @@ +package com.onap.sdnc.vnfconfigcomparsion.model; + +import java.util.List; + +public class VnfCompareResponse { + + private List<VnfDetails> vnfDetails; + + public List<VnfDetails> getVnfDetails() { + return vnfDetails; + } + + public void setVnfDetails(List<VnfDetails> vnfDetails) { + this.vnfDetails = vnfDetails; + } +} diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfConfigDetailsDB.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfConfigDetailsDB.java new file mode 100644 index 00000000..7a62dc20 --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfConfigDetailsDB.java @@ -0,0 +1,108 @@ +package com.onap.sdnc.vnfconfigcomparsion.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 String 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 getLastupdated() { + return lastupdated; + } + + public void setLastupdated(String lastupdated) { + this.lastupdated = lastupdated; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + +} diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfDetails.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfDetails.java new file mode 100644 index 00000000..56b5ee27 --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/model/VnfDetails.java @@ -0,0 +1,27 @@ +package com.onap.sdnc.vnfconfigcomparsion.model; + +public class VnfDetails { + + private String vnfId; + private String vnfDeatils; + private String vnfversion; + + public String getVnfversion() { + return vnfversion; + } + public void setVnfversion(String vnfversion) { + this.vnfversion = vnfversion; + } + public String getVnfDeatils() { + return vnfDeatils; + } + public void setVnfDeatils(String vnfDeatils) { + this.vnfDeatils = vnfDeatils; + } + public String getVnfId() { + return vnfId; + } + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } +} diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfComparisonService.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfComparisonService.java new file mode 100644 index 00000000..73111e62 --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfComparisonService.java @@ -0,0 +1,96 @@ +package com.onap.sdnc.vnfconfigcomparsion.service; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.onap.sdnc.vnfcomparsion.dao.VnfComparisonRepository; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfCompareResponse; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfConfigDetailsDB; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfDetails; + +@Service +public class VnfComparisonService { + + private static final Logger logger = LogManager.getLogger(VnfComparisonService.class); + + @Autowired + VnfComparisonRepository vnfComparisonRepository; + + //Returns vnfconfig details if at list 2 and at most 4 versions selected. + public VnfCompareResponse getConfigurationDeatils(JSONObject vnfVersionNames, String vnfId) { + VnfCompareResponse vnfCompareResponse = new VnfCompareResponse(); + List<VnfDetails> vnfDetailsList = new ArrayList<VnfDetails>(); + VnfDetails vnfDetails = null; + try { + JSONArray vnfIdArray = vnfVersionNames.getJSONArray("versionNames"); + if (vnfIdArray.length() >= 2 && vnfIdArray.length() <= 4) { + for (int i = 0; i < vnfIdArray.length(); i++) { + + VnfConfigDetailsDB vnfconfigdetails = vnfComparisonRepository + .getVnfDetails(vnfIdArray.get(i).toString(), vnfId); + vnfDetails = new VnfDetails(); + vnfDetails.setVnfDeatils(vnfconfigdetails.getConfiginfo()); + vnfDetails.setVnfId(vnfconfigdetails.getVnfid()); + vnfDetails.setVnfversion(vnfconfigdetails.getVnfversion()); + vnfDetailsList.add(vnfDetails); + logger.debug("Versions : " + vnfIdArray.get(i)); + } + }/*else { + throw new RuntimeException("At list 2 and at most 4 versions need to be selected"); + }*/ + } catch (JSONException jSONException1) { + + logger.debug("JSONException occered " + jSONException1); + + } + vnfCompareResponse.setVnfDetails(vnfDetailsList); + return vnfCompareResponse; + } + + //Returns vnfconfig details for any version. + public VnfCompareResponse getConfigDeatilsByVnfIdVnfVersion(JSONObject vnfVersionNames, String vnfId) { + VnfCompareResponse vnfCompareResponse = new VnfCompareResponse(); + List<VnfDetails> vnfDetailsList = new ArrayList<VnfDetails>(); + VnfDetails vnfDetails = null; + try { + JSONArray vnfIdArray = vnfVersionNames.getJSONArray("versionNames"); + for (int i = 0; i < vnfIdArray.length(); i++) { + VnfConfigDetailsDB vnfconfigdetails = vnfComparisonRepository + .getVnfDetails(vnfIdArray.get(i).toString(), vnfId); + vnfDetails = new VnfDetails(); + vnfDetails.setVnfDeatils(vnfconfigdetails.getConfiginfo()); + vnfDetails.setVnfId(vnfconfigdetails.getVnfid()); + vnfDetails.setVnfversion(vnfconfigdetails.getVnfversion()); + vnfDetailsList.add(vnfDetails); + logger.debug("Versions : " + vnfIdArray.get(i)); + } + } catch (JSONException jSONException2) { + + logger.debug("JSONException occered " + jSONException2); + } + vnfCompareResponse.setVnfDetails(vnfDetailsList); + return vnfCompareResponse; + } + + //Returns backup vnf details according to vnf id. + public List<VnfConfigDetailsDB> getConfigurationDeatils(String vnfId) { + List<VnfConfigDetailsDB> vnfconfigdetails = vnfComparisonRepository.getVnfDetailsByVnfID(vnfId); + return vnfconfigdetails; + } + + //Returns all backup vnf details. + public List<VnfConfigDetailsDB> getAllBackupVnfIds() { + List<VnfConfigDetailsDB> vnfconfigdetails = vnfComparisonRepository.findvnfidvnfname(); + + return vnfconfigdetails; + } + +} diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfDetailsForVnfIDAndVnfVersionService.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfDetailsForVnfIDAndVnfVersionService.java new file mode 100644 index 00000000..27db0ac4 --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfDetailsForVnfIDAndVnfVersionService.java @@ -0,0 +1,56 @@ +/*package com.onap.sdnc.vnfconfigcomparsion.service; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; + +import com.onap.sdnc.vnfcomparsion.dao.VnfComparisonRepository; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfCompareResponse; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfConfigDetailsDB; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfDetails; + +public class VnfDetailsForVnfIDAndVnfVersionService { + + private static final Logger logger = LogManager.getLogger(VnfComparisonService.class); + + @Autowired + VnfComparisonRepository vnfComparisonRepository; + + public VnfCompareResponse getConfigurationDeatils(JSONObject vnfVersionNames, String vnfId) { + + VnfCompareResponse vnfCompareResponse = new VnfCompareResponse(); + List<VnfDetails> vnfDetailsList = new ArrayList<VnfDetails>(); + VnfDetails vnfDetails = new VnfDetails(); + try { + JSONArray vnfIdArray = vnfVersionNames.getJSONArray("versionNames"); + for (int i = 0; i < vnfIdArray.length(); i++) { + try { + VnfConfigDetailsDB vnfconfigdetails = vnfComparisonRepository + .getVnfDetails(vnfIdArray.get(i).toString(), vnfId); + vnfDetails.setVnfDeatils(vnfconfigdetails.getConfiginfo()); + vnfDetails.setVnfId(vnfconfigdetails.getVnfid()); + vnfDetailsList.add(vnfDetails); + logger.debug("Versions : " + vnfIdArray.get(i)); + } catch (Exception e) { + // TODO Auto-generated catch block + // e.printStackTrace(); + } + } + } catch (JSONException jSONException) { + + throw new RuntimeException("Enter atlist 2 versions and maximum 4 versions"); + } + vnfCompareResponse.setVnfDetails(vnfDetailsList); + return vnfCompareResponse; + + } + +} +*/
\ No newline at end of file diff --git a/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfDetailsForVnfIDService.java b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfDetailsForVnfIDService.java new file mode 100644 index 00000000..2aff5bd1 --- /dev/null +++ b/configbackuprestore/getBackupVnfDetailService/src/main/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfDetailsForVnfIDService.java @@ -0,0 +1,36 @@ +/*package com.onap.sdnc.vnfconfigcomparsion.service; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.onap.sdnc.vnfcomparsion.dao.VnfComparisonRepository; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfCompareResponse; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfConfigDetailsDB; +import com.onap.sdnc.vnfconfigcomparsion.model.VnfDetails; + +public class VnfDetailsForVnfIDService { + + @Autowired + VnfComparisonRepository vnfComparisonRepository; + + public VnfCompareResponse getConfigurationDeatils(String vnfId) { + VnfCompareResponse vnfCompareResponse = new VnfCompareResponse(); + List<VnfDetails> vnfDetailsList = new ArrayList<VnfDetails>(); + VnfDetails vnfDetails = new VnfDetails(); + try { + VnfConfigDetailsDB vnfconfigdetails = vnfComparisonRepository.getVnfDetailsByVnfID(vnfId); + vnfDetails.setVnfDeatils(vnfconfigdetails.getConfiginfo()); + vnfDetails.setVnfId(vnfconfigdetails.getVnfid()); + vnfDetailsList.add(vnfDetails); + } catch (Exception e) { + // TODO Auto-generated catch block + // e.printStackTrace(); + } + vnfCompareResponse.setVnfDetails(vnfDetailsList); + return vnfCompareResponse; + } + +} +*/
\ No newline at end of file |