diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-04-02 22:54:57 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-04-02 22:54:57 -0400 |
commit | 86f04e1d55b54a1a23bb274d211c6fca85980fef (patch) | |
tree | e8fb0a8c1d5e64761068df56faa8a8e509fa2f48 /mso-catalog-db/src/main/java | |
parent | d59fc0ad5db7b7cacf5996f86db34f41090061fa (diff) |
fix catalogdb cvfnc customization
Hibernate entities were all wrong and needed
a complete rewrite.
The scope kept growing and ended up touching a
lot more of the code than originally planned.
These changes make the db interactions much easier
and more straightforward from java.
The flyway script order had to change to make this
migration possible.
Change-Id: I6ce363a385661300eddb11923ac6a80538edaddc
Issue-ID: SO-1710
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-catalog-db/src/main/java')
16 files changed, 449 insertions, 618 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java index 7c6fb04079..ccfa71306b 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java @@ -81,7 +81,7 @@ public class ConfigurationResource implements Serializable { private Set<ConfigurationResourceCustomization> configurationResourceCustomization; @OneToMany(cascade = CascadeType.ALL, mappedBy = "configurationResource") - private Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization; + private Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization; @PrePersist protected void onCreate() { @@ -151,15 +151,14 @@ public class ConfigurationResource implements Serializable { } @LinkedResource - public Set<VnfVfmoduleCvnfcConfigurationCustomization> getVnfVfmoduleCvnfcConfigurationCustomization() { - return vnfVfmoduleCvnfcConfigurationCustomization; + public Set<CvnfcConfigurationCustomization> getCvnfcConfigurationCustomization() { + return cvnfcConfigurationCustomization; } - - public void setVnfVfmoduleCvnfcConfigurationCustomization( - Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization) { - this.vnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomization; + + public void setCvnfcConfigurationCustomization(Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization) { + this.cvnfcConfigurationCustomization = cvnfcConfigurationCustomization; } - + @Override public String toString() { return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java index e425ebbc64..1e09c6e671 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomization.java @@ -48,17 +48,17 @@ import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; @Entity -@Table(name = "vnf_vfmodule_cvnfc_configuration_customization") -public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable { +@Table(name = "cvnfc_configuration_customization") +public class CvnfcConfigurationCustomization implements Serializable { private static final long serialVersionUID = -3153216266280581103L; @Id - @Column(name = "ID") + @BusinessKey + @Column(name = "ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; - @BusinessKey @Column(name = "MODEL_CUSTOMIZATION_UUID") private String modelCustomizationUUID; @@ -76,7 +76,6 @@ public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable @Column(name = "POLICY_NAME") private String policyName; - @Column(name = "CREATION_TIMESTAMP", updatable = false) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") @@ -87,39 +86,25 @@ public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable @JoinColumn(name = "CONFIGURATION_MODEL_UUID") private ConfigurationResource configurationResource; - @BusinessKey @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "CVNFC_CUSTOMIZATION_ID") private CvnfcCustomization cvnfcCustomization; - - @BusinessKey - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "VF_MODULE_MODEL_CUSTOMIZATION_UUID") - private VfModuleCustomization vfModuleCustomization; - @BusinessKey - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID") - private VnfResourceCustomization vnfResourceCustomization; @Override public boolean equals(final Object other) { - if (!(other instanceof VnfVfmoduleCvnfcConfigurationCustomization)) { + if (!(other instanceof CvnfcConfigurationCustomization)) { return false; } - VnfVfmoduleCvnfcConfigurationCustomization castOther = (VnfVfmoduleCvnfcConfigurationCustomization) other; - return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) - .append(cvnfcCustomization, castOther.cvnfcCustomization) - .append(vfModuleCustomization, castOther.vfModuleCustomization) - .append(vnfResourceCustomization, castOther.vnfResourceCustomization).isEquals(); + CvnfcConfigurationCustomization castOther = (CvnfcConfigurationCustomization) other; + return new EqualsBuilder().append(id, castOther.id).isEquals(); } @Override public int hashCode() { - return new HashCodeBuilder().append(modelCustomizationUUID).append(cvnfcCustomization) - .append(vfModuleCustomization).append(vnfResourceCustomization).toHashCode(); + return new HashCodeBuilder().append(id).toHashCode(); } @@ -130,9 +115,7 @@ public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable .append("modelInstanceName", modelInstanceName).append("configurationType", configurationType) .append("configurationRole", configurationRole).append("configurationFunction", configurationFunction) .append("policyName", policyName).append("created", created) - .append("configurationResource", configurationResource).append("cvnfcCustomization", cvnfcCustomization) - .append("vfModuleCustomization", vfModuleCustomization) - .append("vnfResourceCustomization", vnfResourceCustomization).toString(); + .append("configurationResource", configurationResource).append("cvnfcCustomization", cvnfcCustomization).toString(); } @@ -224,21 +207,4 @@ public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable this.cvnfcCustomization = cvnfcCustomization; } - @LinkedResource - public VfModuleCustomization getVfModuleCustomization() { - return vfModuleCustomization; - } - - public void setVfModuleCustomization(VfModuleCustomization vfModuleCustomization) { - this.vfModuleCustomization = vfModuleCustomization; - } - - @LinkedResource - public VnfResourceCustomization getVnfResourceCustomization() { - return vnfResourceCustomization; - } - - public void setVnfResourceCustomization(VnfResourceCustomization vnfResourceCustomization) { - this.vnfResourceCustomization = vnfResourceCustomization; - } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java index 9f081ccd34..a7bbb9fb01 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java @@ -56,10 +56,10 @@ public class CvnfcCustomization implements Serializable { @Id @Column(name = "ID") + @BusinessKey @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; - @BusinessKey @Column(name = "MODEL_CUSTOMIZATION_UUID") private String modelCustomizationUUID; @@ -96,19 +96,15 @@ public class CvnfcCustomization implements Serializable { private Date created; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID") - private VfModuleCustomization vfModuleCustomization; + @JoinColumn(name = "VF_MODULE_CUSTOMIZATION_ID") + private VfModuleCustomization vfModuleCustomization; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "VNFC_CUST_MODEL_CUSTOMIZATION_UUID") private VnfcCustomization vnfcCustomization; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID") - private VnfResourceCustomization vnfResourceCustomization; - @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvnfcCustomization") - private Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization; + private Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization; @Override public boolean equals(final Object other) { @@ -116,12 +112,12 @@ public class CvnfcCustomization implements Serializable { return false; } CvnfcCustomization castOther = (CvnfcCustomization) other; - return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + return new EqualsBuilder().append(id, castOther.id).isEquals(); } @Override public int hashCode() { - return new HashCodeBuilder().append(modelCustomizationUUID).append(vfModuleCustomization).append(vnfcCustomization).append(vnfResourceCustomization).toHashCode(); + return new HashCodeBuilder().append(id).toHashCode(); } @Override @@ -132,27 +128,33 @@ public class CvnfcCustomization implements Serializable { .append("modelName", modelName).append("toscaNodeType", toscaNodeType) .append("description", description).append("nfcFunction", nfcFunction) .append("nfcNamingCode", nfcNamingCode).append("created", created) - .append("vfModuleCustomization", vfModuleCustomization).append("vnfcCustomization", vnfcCustomization) - .append("vnfResourceCustomization", vnfResourceCustomization) - .append("vnfVfmoduleCvnfcConfigurationCustomization", vnfVfmoduleCvnfcConfigurationCustomization) + .append("vnfVfmoduleCvnfcConfigurationCustomization", cvnfcConfigurationCustomization) .toString(); } + @LinkedResource + public VnfcCustomization getVnfcCustomization() { + return vnfcCustomization; + } + + public void setVnfcCustomization(VnfcCustomization vnfcCustomization) { + this.vnfcCustomization = vnfcCustomization; + } + @PrePersist protected void onCreate() { this.created = new Date(); } @LinkedResource - public Set<VnfVfmoduleCvnfcConfigurationCustomization> getVnfVfmoduleCvnfcConfigurationCustomization() { - return vnfVfmoduleCvnfcConfigurationCustomization; + public Set<CvnfcConfigurationCustomization> getCvnfcConfigurationCustomization() { + return cvnfcConfigurationCustomization; } - public void setVnfVfmoduleCvnfcConfigurationCustomization( - Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization) { - this.vnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomization; + public void setCvnfcConfigurationCustomization(Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization) { + this.cvnfcConfigurationCustomization = cvnfcConfigurationCustomization; } - + public Integer getId() { return id; } @@ -258,21 +260,4 @@ public class CvnfcCustomization implements Serializable { this.vfModuleCustomization = vfModuleCustomization; } - @LinkedResource - public VnfcCustomization getVnfcCustomization() { - return vnfcCustomization; - } - - public void setVnfcCustomization(VnfcCustomization vnfcCustomization) { - this.vnfcCustomization = vnfcCustomization; - } - - @LinkedResource - public VnfResourceCustomization getVnfResourceCustomization() { - return vnfResourceCustomization; - } - - public void setVnfResourceCustomization(VnfResourceCustomization vnfResourceCustomization) { - this.vnfResourceCustomization = vnfResourceCustomization; - } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java index fdd250089a..43d4acffcc 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java @@ -21,6 +21,7 @@ package org.onap.so.db.catalog.beans; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -97,7 +98,7 @@ public class InstanceGroup implements Serializable { private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations; @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup") - private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations; + private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>(); @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup") private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java index 428736eddc..2a8e86c5b0 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java @@ -7,9 +7,9 @@ * 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. @@ -25,10 +25,12 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; @@ -99,8 +101,7 @@ public class Service implements Serializable { @JoinTable(name = "network_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) private List<NetworkResourceCustomization> networkCustomizations; - @OneToMany(cascade = CascadeType.ALL) - @JoinTable(name = "vnf_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) + @OneToMany(cascade = CascadeType.ALL, mappedBy = "service") private List<VnfResourceCustomization> vnfCustomizations; @OneToMany(cascade = CascadeType.ALL) @@ -114,11 +115,11 @@ public class Service implements Serializable { @OneToMany(cascade = CascadeType.ALL) @JoinTable(name = "service_proxy_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) private List<ServiceProxyResourceCustomization> serviceProxyCustomizations; - + @OneToMany(cascade = CascadeType.ALL) @JoinTable(name = "configuration_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) private List<ConfigurationResourceCustomization> configurationCustomizations; - + @OneToMany(cascade = CascadeType.ALL) @JoinTable(name = "pnf_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) private List<PnfResourceCustomization> pnfCustomizations; @@ -126,7 +127,7 @@ public class Service implements Serializable { @OneToMany(cascade = CascadeType.ALL, mappedBy = "service") @MapKey(name = "action") private Map<String, ServiceRecipe> recipes; - + @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "TOSCA_CSAR_ARTIFACT_UUID") private ToscaCsar csar; @@ -134,18 +135,18 @@ public class Service implements Serializable { @Override public String toString() { return new ToStringBuilder(this).append("modelName", modelName).append("description", description) - .append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) - .append("created", created).append("modelVersion", modelVersion).append("serviceType", serviceType) - .append("serviceRole", serviceRole).append("environmentContext", environmentContext) - .append("workloadContext", workloadContext).append("category", category) - .append("networkCustomizations", networkCustomizations).append("vnfCustomizations", vnfCustomizations) - .append("allottedCustomizations", allottedCustomizations) - .append("collectionResourceCustomizations", collectionResourceCustomizations) - .append("serviceProxyCustomizations", serviceProxyCustomizations) + .append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) + .append("created", created).append("modelVersion", modelVersion).append("serviceType", serviceType) + .append("serviceRole", serviceRole).append("environmentContext", environmentContext) + .append("workloadContext", workloadContext).append("category", category) + .append("networkCustomizations", networkCustomizations).append("vnfCustomizations", vnfCustomizations) + .append("allottedCustomizations", allottedCustomizations) + .append("collectionResourceCustomizations", collectionResourceCustomizations) + .append("serviceProxyCustomizations", serviceProxyCustomizations) .append("configurationCustomizations", configurationCustomizations) .append("pnfCustomizations", pnfCustomizations) .append("recipes", recipes) - .append("csar", csar).toString(); + .append("csar", csar).toString(); } @PrePersist @@ -221,7 +222,7 @@ public class Service implements Serializable { } public void setCollectionResourceCustomizations( - List<CollectionResourceCustomization> collectionResourceCustomizations) { + List<CollectionResourceCustomization> collectionResourceCustomizations) { this.collectionResourceCustomizations = collectionResourceCustomizations; } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java index 5a7d0d5425..4ec2a92a73 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java @@ -29,6 +29,8 @@ import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @@ -54,8 +56,12 @@ public class VfModuleCustomization implements Serializable { public static final long serialVersionUID = -1322322139926390329L; - @BusinessKey @Id + @BusinessKey + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @Column(name = "MODEL_CUSTOMIZATION_UUID") private String modelCustomizationUUID; @@ -91,15 +97,27 @@ public class VfModuleCustomization implements Serializable { @JoinColumn(name = "VF_MODULE_MODEL_UUID") private VfModule vfModule; - @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") - private Set<VnfcCustomization> vnfcCustomization; + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "VNF_RESOURCE_CUSTOMIZATION_ID") + private VnfResourceCustomization vnfCustomization; - @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") + @OneToMany(cascade = CascadeType.ALL, mappedBy = "vfModuleCustomization") private Set<CvnfcCustomization> cvnfcCustomization; - - @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") - private Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization; + @Override + public boolean equals(final Object other) { + if (!(other instanceof VfModuleCustomization)) { + return false; + } + VfModuleCustomization castOther = (VfModuleCustomization) other; + return new EqualsBuilder().append(id, castOther.id).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(id).toHashCode(); + } + @PrePersist protected void onCreate() { this.created = new Date(); @@ -113,19 +131,23 @@ public class VfModuleCustomization implements Serializable { .append("created", created).append("volumeHeatEnv", volumeHeatEnv) .append("heatEnvironment", heatEnvironment).append("vfModule", vfModule).toString(); } + + - @Override - public boolean equals(final Object other) { - if (!(other instanceof VfModuleCustomization)) { - return false; - } - VfModuleCustomization castOther = (VfModuleCustomization) other; - return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + public Integer getId() { + return id; } - @Override - public int hashCode() { - return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + public void setId(Integer id) { + this.id = id; + } + + public VnfResourceCustomization getVnfCustomization() { + return vnfCustomization; + } + + public void setVnfCustomization(VnfResourceCustomization vnfCustomization) { + this.vnfCustomization = vnfCustomization; } public VfModuleCustomization() { @@ -212,28 +234,6 @@ public class VfModuleCustomization implements Serializable { } @LinkedResource - public Set<VnfVfmoduleCvnfcConfigurationCustomization> getVnfVfmoduleCvnfcConfigurationCustomization() { - if (vnfVfmoduleCvnfcConfigurationCustomization == null) - vnfVfmoduleCvnfcConfigurationCustomization = new HashSet<>(); - return vnfVfmoduleCvnfcConfigurationCustomization; - } - - public void setVnfVfmoduleCvnfcConfigurationCustomization( - Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization) { - this.vnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomization; - } - - @LinkedResource - public Set<VnfcCustomization> getVnfcCustomization() { - return vnfcCustomization; - } - - public void setVnfcCustomization( - Set<VnfcCustomization> vnfcCustomization) { - this.vnfcCustomization = vnfcCustomization; - } - - @LinkedResource public Set<CvnfcCustomization> getCvnfcCustomization() { if (cvnfcCustomization == null) cvnfcCustomization = new HashSet<>(); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java index c75199ed41..e569c3b994 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java @@ -7,9 +7,9 @@ * 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. @@ -31,6 +31,8 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; @@ -55,9 +57,13 @@ import uk.co.blackpepper.bowman.annotation.LinkedResource; public class VnfResourceCustomization implements Serializable { private static final long serialVersionUID = 768026109321305392L; - - @BusinessKey + @Id + @BusinessKey + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @Column(name = "MODEL_CUSTOMIZATION_UUID") private String modelCustomizationUUID; @@ -69,10 +75,6 @@ public class VnfResourceCustomization implements Serializable { @Temporal(TemporalType.TIMESTAMP) private Date created; - public void setCreated(Date created) { - this.created = created; - } - @Column(name = "MIN_INSTANCES") private Integer minInstances; @@ -103,20 +105,17 @@ public class VnfResourceCustomization implements Serializable { @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID") private VnfResource vnfResources; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "SERVICE_MODEL_UUID") + private Service service; - @OneToMany(cascade = CascadeType.ALL) - @JoinTable(name = "vnf_res_custom_to_vf_module_custom", joinColumns = @JoinColumn(name = "VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID"), inverseJoinColumns = @JoinColumn(name = "VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID")) + @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER, mappedBy = "vnfCustomization") private List<VfModuleCustomization> vfModuleCustomizations; @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResourceCust") - private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations; - - @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") - private Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization; - - @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") - private List<CvnfcCustomization> cvnfcCustomization; - + private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>(); + @Column(name = "CDS_BLUEPRINT_NAME") private String blueprintName; @@ -124,29 +123,33 @@ public class VnfResourceCustomization implements Serializable { private String blueprintVersion; @Override - public String toString() { - return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) - .append("modelInstanceName", modelInstanceName).append("created", created) - .append("minInstances", minInstances).append("maxInstances", maxInstances) - .append("availabilityZoneMaxCount", availabilityZoneMaxCount).append("nfFunction", nfFunction) - .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode) - .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources) - .append("vfModuleCustomizations", vfModuleCustomizations) - .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString(); - } - - @Override public boolean equals(final Object other) { if (!(other instanceof VnfResourceCustomization)) { return false; } VnfResourceCustomization castOther = (VnfResourceCustomization) other; - return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + return new EqualsBuilder().append(id, castOther.id).isEquals(); } @Override public int hashCode() { - return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + return new HashCodeBuilder().append(id).toHashCode(); + } + + public void setCreated(Date created) { + this.created = created; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("created", created) + .append("minInstances", minInstances).append("maxInstances", maxInstances) + .append("availabilityZoneMaxCount", availabilityZoneMaxCount).append("nfFunction", nfFunction) + .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode) + .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources) + .append("vfModuleCustomizations", vfModuleCustomizations) + .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString(); } @PrePersist @@ -162,6 +165,23 @@ public class VnfResourceCustomization implements Serializable { this.modelCustomizationUUID = modelCustomizationUUID; } + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @LinkedResource + public Service getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + public String getModelInstanceName() { return this.modelInstanceName; } @@ -269,32 +289,10 @@ public class VnfResourceCustomization implements Serializable { } public void setVnfcInstanceGroupCustomizations( - List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) { + List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) { this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations; } - - @LinkedResource - public Set<VnfVfmoduleCvnfcConfigurationCustomization> getVnfVfmoduleCvnfcConfigurationCustomization() { - if (vnfVfmoduleCvnfcConfigurationCustomization == null) { - vnfVfmoduleCvnfcConfigurationCustomization = new HashSet<>(); - } - return vnfVfmoduleCvnfcConfigurationCustomization; - } - - public void setVnfVfmoduleCvnfcConfigurationCustomization( - Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization) { - this.vnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomization; - } - - @LinkedResource - public List<CvnfcCustomization> getCvnfcCustomization() { - return cvnfcCustomization; - } - - public void setCvnfcCustomization(List<CvnfcCustomization> cvnfcCustomization) { - this.cvnfcCustomization = cvnfcCustomization; - } - + public String getResourceInput() { return resourceInput; } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java index 1d4cef158f..db1c929f9d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java @@ -27,6 +27,8 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.JoinColumn; @@ -45,7 +47,7 @@ import com.openpojo.business.annotation.BusinessKey; import uk.co.blackpepper.bowman.annotation.LinkedResource; @Entity -@IdClass(VnfcInstanceGroupCustomizationId.class) + @Table(name = "vnfc_instance_group_customization") public class VnfcInstanceGroupCustomization implements Serializable { @@ -54,22 +56,18 @@ public class VnfcInstanceGroupCustomization implements Serializable { */ private static final long serialVersionUID = -8288218040186901676L; - @BusinessKey @Id - @Column(name = "VNF_RESOURCE_CUSTOMIZATION_MODEL_UUID") - private String modelCustomizationUUID; - @BusinessKey - @Id - @Column(name = "INSTANCE_GROUP_MODEL_UUID") - private String modelUUID; - + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "VNF_RESOURCE_CUSTOMIZATION_MODEL_UUID", updatable = false, insertable = false) + @JoinColumn(name = "VNF_RESOURCE_CUSTOMIZATION_ID") private VnfResourceCustomization vnfResourceCust; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID", updatable = false, insertable = false) + @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID") private InstanceGroup instanceGroup; @Column(name = "FUNCTION") @@ -88,47 +86,38 @@ public class VnfcInstanceGroupCustomization implements Serializable { return false; } VnfcInstanceGroupCustomization castOther = (VnfcInstanceGroupCustomization) other; - return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) - .append(modelUUID, castOther.modelUUID).isEquals(); + return new EqualsBuilder().append(id, castOther.id).isEquals(); } @Override public int hashCode() { - return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).toHashCode(); + return new HashCodeBuilder().append(id).toHashCode(); } @Override public String toString() { - return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) - .append("modelUUID", modelUUID).append("function", function).append("description", description) + return new ToStringBuilder(this) + .append("function", function).append("description", description) .append("created", created).toString(); } + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + @PrePersist protected void onCreate() { this.created = new Date(); } - public Date getCreated() { + public Date getCreated(){ return created; } - public String getModelCustomizationUUID() { - return modelCustomizationUUID; - } - - public void setModelCustomizationUUID(String modelCustomizationUUID) { - this.modelCustomizationUUID = modelCustomizationUUID; - } - - public String getModelUUID() { - return modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } - public String getFunction() { return function; } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomizationId.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomizationId.java deleted file mode 100644 index f22d4fe213..0000000000 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomizationId.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.db.catalog.beans; - -import java.io.Serializable; - -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ToStringBuilder; - -import com.openpojo.business.annotation.BusinessKey; - -public class VnfcInstanceGroupCustomizationId implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1628277798979456195L; - - @BusinessKey - private String modelCustomizationUUID; - @BusinessKey - private String modelUUID; - - @Override - public String toString() { - return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) - .append("modelUUID", modelUUID).toString(); - } - - @Override - public boolean equals(final Object other) { - if (!(other instanceof VnfcInstanceGroupCustomizationId)) { - return false; - } - VnfcInstanceGroupCustomizationId castOther = (VnfcInstanceGroupCustomizationId) other; - return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) - .append(modelUUID, castOther.modelUUID).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).toHashCode(); - } - - public String getModelCustomizationUUID() { - return this.modelCustomizationUUID; - } - - public void setModelCustomizationUUID(String modelCustomizationUUID) { - this.modelCustomizationUUID = modelCustomizationUUID; - } - - public String getModelUUID() { - return this.modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } -} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 3e35e78e7a..28b77cde79 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -7,9 +7,9 @@ * 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. @@ -24,14 +24,19 @@ import java.net.URI; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; + import javax.annotation.PostConstruct; +import javax.persistence.EntityNotFoundException; import javax.ws.rs.core.UriBuilder; + import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.HomingInstance; @@ -53,25 +58,31 @@ import org.onap.so.db.catalog.beans.VnfComponentsRecipe; import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.onap.so.logger.LogConstants; import org.onap.so.logging.jaxrs.filter.SpringClientFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + import uk.co.blackpepper.bowman.Client; import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; @Component("CatalogDbClient") public class CatalogDbClient { + + private static final Logger logger = LoggerFactory.getLogger(CatalogDbClient.class); private static final String CLOUD_SITE = "/cloudSite"; private static final String CLOUDIFY_MANAGER = "/cloudifyManager"; @@ -132,7 +143,7 @@ public class CatalogDbClient { private static final String CLLI = "clli"; private static final String CLOUD_VERSION = "cloudVersion"; private static final String HOMING_INSTANCE = "/homingInstance"; - + private static final String TARGET_ENTITY = "SO:CatalogDB"; private static final String ASTERISK = "*"; @@ -148,7 +159,7 @@ public class CatalogDbClient { private String findFirstResourceByModelInvariantUUIDAndModelVersion = "/findFirstResourceByModelInvariantUUIDAndModelVersion"; private String findByModelInstanceNameAndVnfResources = "/findByModelInstanceNameAndVnfResources"; private String findFirstVnfRecipeByNfRoleAndAction = "/findFirstVnfRecipeByNfRoleAndAction"; - private String findByModelCustomizationUUIDAndVfModuleModelUUID = "/findByModelCustomizationUUIDAndVfModuleModelUUID"; + private String findByModelCustomizationUUIDAndVfModuleModelUUID = "/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc"; private String findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction = "/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"; private String findFirstVnfComponentsRecipeByVnfComponentTypeAndAction = "/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"; private String findVfModuleByModelInvariantUUIDOrderByModelVersionDesc = "/findByModelInvariantUUIDOrderByModelVersionDesc"; @@ -229,7 +240,7 @@ public class CatalogDbClient { private final Client<HomingInstance> homingInstanceClient; private final Client<CloudifyManager> cloudifyManagerClient; - + private final Client<CvnfcCustomization> cvnfcCustomizationClient; private final Client<ControllerSelectionReference> controllerSelectionReferenceClient; @@ -244,71 +255,48 @@ public class CatalogDbClient { @Value("${mso.db.auth:#{null}}") private String msoAdaptersAuth; + @Autowired + RestTemplate restTemplate; @PostConstruct - public void init() { - findExternalToInternalServiceByServiceName = - endpoint + EXTERNAL_SERVICE_TO_INTERNAL_MODEL_MAPPING + SEARCH + findExternalToInternalServiceByServiceName; - findServiceByModelName = endpoint + SERVICE + SEARCH + findServiceByModelName; - findServiceRecipeByActionAndServiceModelUUID = - endpoint + SERVICE_RECIPE + SEARCH + findServiceRecipeByActionAndServiceModelUUID; - findServiceByModelUUID = endpoint + SERVICE + SEARCH + findServiceByModelUUID; + public void init(){ + findExternalToInternalServiceByServiceName = endpoint + EXTERNAL_SERVICE_TO_INTERNAL_MODEL_MAPPING + SEARCH + findExternalToInternalServiceByServiceName; + findServiceByModelName = endpoint + SERVICE + SEARCH + findServiceByModelName; + findServiceRecipeByActionAndServiceModelUUID = endpoint + SERVICE_RECIPE + SEARCH + findServiceRecipeByActionAndServiceModelUUID; + findServiceByModelUUID = endpoint + SERVICE + SEARCH + findServiceByModelUUID; findFirstByModelNameURI = endpoint + SERVICE + SEARCH + findFirstByModelNameURI; - findFirstByModelVersionAndModelInvariantUUIDURI = - endpoint + SERVICE + SEARCH + findFirstByModelVersionAndModelInvariantUUIDURI; + findFirstByModelVersionAndModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findFirstByModelVersionAndModelInvariantUUIDURI; findByModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findByModelInvariantUUIDURI; - findFirstByServiceModelUUIDAndActionURI = - endpoint + SERVICE_RECIPE + SEARCH + findFirstByServiceModelUUIDAndActionURI; + findFirstByServiceModelUUIDAndActionURI = endpoint + SERVICE_RECIPE + SEARCH + findFirstByServiceModelUUIDAndActionURI; findFirstByModelNameAndAction = endpoint + NETWORK_RECIPE + SEARCH + findFirstByModelNameAndAction; - findFirstResourceByModelInvariantUUIDAndModelVersion = - endpoint + VNF_RESOURCE + SEARCH + findFirstResourceByModelInvariantUUIDAndModelVersion; - findByModelInstanceNameAndVnfResources = - endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + findByModelInstanceNameAndVnfResources; + findFirstResourceByModelInvariantUUIDAndModelVersion = endpoint + VNF_RESOURCE + SEARCH + findFirstResourceByModelInvariantUUIDAndModelVersion; + findByModelInstanceNameAndVnfResources = endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + findByModelInstanceNameAndVnfResources; findFirstVnfRecipeByNfRoleAndAction = endpoint + VNF_RECIPE + SEARCH + findFirstVnfRecipeByNfRoleAndAction; - findByModelCustomizationUUIDAndVfModuleModelUUID = - endpoint + VFMODULE_CUSTOMIZATION + SEARCH + findByModelCustomizationUUIDAndVfModuleModelUUID; - findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction = - endpoint + VNF_COMPONENTS_RECIPE + SEARCH - + findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction; - findFirstVnfComponentsRecipeByVnfComponentTypeAndAction = - endpoint + VNF_COMPONENTS_RECIPE + SEARCH + findFirstVnfComponentsRecipeByVnfComponentTypeAndAction; - findVfModuleByModelInvariantUUIDOrderByModelVersionDesc = - endpoint + VFMODULE + SEARCH + findVfModuleByModelInvariantUUIDOrderByModelVersionDesc; - findFirstVfModuleByModelInvariantUUIDAndModelVersion = - endpoint + VFMODULE + SEARCH + findFirstVfModuleByModelInvariantUUIDAndModelVersion; + findByModelCustomizationUUIDAndVfModuleModelUUID = endpoint + VFMODULE_CUSTOMIZATION + SEARCH + findByModelCustomizationUUIDAndVfModuleModelUUID; + findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction = endpoint + VNF_COMPONENTS_RECIPE + SEARCH + findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction; + findFirstVnfComponentsRecipeByVnfComponentTypeAndAction = endpoint + VNF_COMPONENTS_RECIPE + SEARCH + findFirstVnfComponentsRecipeByVnfComponentTypeAndAction; + findVfModuleByModelInvariantUUIDOrderByModelVersionDesc = endpoint + VFMODULE + SEARCH +findVfModuleByModelInvariantUUIDOrderByModelVersionDesc; + findFirstVfModuleByModelInvariantUUIDAndModelVersion = endpoint + VFMODULE + SEARCH + findFirstVfModuleByModelInvariantUUIDAndModelVersion; findOneByBuildingBlockName = endpoint + BUILDING_BLOCK_DETAIL + SEARCH + findOneByBuildingBlockName; - findOneByResourceTypeAndOrchestrationStatusAndTargetAction = - endpoint + ORCHESTRATION_STATUS_STATE_TRANSITION_DIRECTIVE + SEARCH - + findOneByResourceTypeAndOrchestrationStatusAndTargetAction; + findOneByResourceTypeAndOrchestrationStatusAndTargetAction = endpoint + ORCHESTRATION_STATUS_STATE_TRANSITION_DIRECTIVE + SEARCH + findOneByResourceTypeAndOrchestrationStatusAndTargetAction; findByAction = endpoint + ORCHESTRATION_FLOW + SEARCH + findByAction; - findVnfcInstanceGroupCustomizationByModelCustomizationUUID = - endpoint + VNFC_INSTANCE_GROUP_CUSTOMIZATION + SEARCH - + findVnfcInstanceGroupCustomizationByModelCustomizationUUID; - findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID = - endpoint + COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION + SEARCH - + findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID; - findOneByActionAndRequestScopeAndIsAlacarte = - endpoint + NORTHBOUND_REQUEST_REF_LOOKUP + SEARCH + findOneByActionAndRequestScopeAndIsAlacarte; - findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwner = endpoint + NORTHBOUND_REQUEST_REF_LOOKUP + SEARCH - + findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwner; - findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType = - endpoint + NORTHBOUND_REQUEST_REF_LOOKUP + SEARCH - + findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType; - findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = endpoint + RAINY_DAY_HANDLER_MACRO + SEARCH - + findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep; + findVnfcInstanceGroupCustomizationByModelCustomizationUUID = endpoint + VNFC_INSTANCE_GROUP_CUSTOMIZATION + SEARCH + findVnfcInstanceGroupCustomizationByModelCustomizationUUID; + findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID = endpoint + COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION + SEARCH + findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID; + findOneByActionAndRequestScopeAndIsAlacarte = endpoint + NORTHBOUND_REQUEST_REF_LOOKUP + SEARCH + findOneByActionAndRequestScopeAndIsAlacarte; + findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwner = endpoint + NORTHBOUND_REQUEST_REF_LOOKUP + SEARCH + findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwner; + findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType = endpoint + NORTHBOUND_REQUEST_REF_LOOKUP + SEARCH + findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType; + findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = endpoint + RAINY_DAY_HANDLER_MACRO + SEARCH + findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep; findByClliAndCloudVersion = endpoint + CLOUD_SITE + SEARCH + findByClliAndCloudVersion; serviceURI = endpoint + SERVICE + URI_SEPARATOR; vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR; vnfResourceURI = endpoint + VNF_RESOURCE + URI_SEPARATOR; vfModuleCustomizationURI = endpoint + VFMODULE_CUSTOMIZATION + URI_SEPARATOR; - networkCollectionResourceCustomizationURI = - endpoint + NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; + networkCollectionResourceCustomizationURI = endpoint + NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; networkResourceCustomizationURI = endpoint + NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; cvnfcResourceCustomizationURI = endpoint + CVNFC_CUSTOMZIATION + URI_SEPARATOR; vnfResourceCustomizationURI = endpoint + VNF_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; - collectionNetworkResourceCustomizationURI = - endpoint + COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; + collectionNetworkResourceCustomizationURI = endpoint + COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR; cloudifyManagerURI = endpoint + CLOUDIFY_MANAGER + URI_SEPARATOR; cloudSiteURI = endpoint + CLOUD_SITE + URI_SEPARATOR; @@ -319,20 +307,18 @@ public class CatalogDbClient { } public CatalogDbClient() { - ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory( - new HttpComponentsClientHttpRequestFactory()); + ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); - ClientFactory clientFactory = Configuration.builder().setClientHttpRequestFactory(factory) - .setRestTemplateConfigurer(restTemplate -> { - restTemplate.getInterceptors().add((new SpringClientFilter())); + ClientFactory clientFactory = Configuration.builder().setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> { + restTemplate.getInterceptors().add((new SpringClientFilter())); - restTemplate.getInterceptors().add((request, body, execution) -> { + restTemplate.getInterceptors().add((request, body, execution) -> { - request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); - request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER, TARGET_ENTITY); - return execution.execute(request, body); - }); - }).build().buildClientFactory(); + request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); + request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER,TARGET_ENTITY); + return execution.execute(request, body); + }); + }).build().buildClientFactory(); serviceClient = clientFactory.create(Service.class); networkRecipeClient = clientFactory.create(NetworkRecipe.class); networkResourceCustomizationClient = clientFactory.create(NetworkResourceCustomization.class); @@ -347,15 +333,13 @@ public class CatalogDbClient { rainyDayHandlerStatusClient = clientFactory.create(RainyDayHandlerStatus.class); buildingBlockDetailClient = clientFactory.create(BuildingBlockDetail.class); orchestrationStatusStateTransitionDirectiveClient = clientFactory - .create(OrchestrationStatusStateTransitionDirective.class); + .create(OrchestrationStatusStateTransitionDirective.class); vnfcInstanceGroupCustomizationClient = clientFactory.create(VnfcInstanceGroupCustomization.class); collectionResourceInstanceGroupCustomizationClient = clientFactory - .create(CollectionResourceInstanceGroupCustomization.class); + .create(CollectionResourceInstanceGroupCustomization.class); instanceGroupClient = clientFactory.create(InstanceGroup.class); - networkCollectionResourceCustomizationClient = clientFactory - .create(NetworkCollectionResourceCustomization.class); - collectionNetworkResourceCustomizationClient = clientFactory - .create(CollectionNetworkResourceCustomization.class); + networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class); + collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class); cloudSiteClient = clientFactory.create(CloudSite.class); homingInstanceClient = clientFactory.create(HomingInstance.class); cloudifyManagerClient = clientFactory.create(CloudifyManager.class); @@ -368,20 +352,18 @@ public class CatalogDbClient { } public CatalogDbClient(String baseUri, String auth) { - ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory( - new HttpComponentsClientHttpRequestFactory()); + ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); - ClientFactory clientFactory = Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory) - .setRestTemplateConfigurer(restTemplate -> { - restTemplate.getInterceptors().add((new SpringClientFilter())); + ClientFactory clientFactory = Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> { + restTemplate.getInterceptors().add((new SpringClientFilter())); - restTemplate.getInterceptors().add((request, body, execution) -> { + restTemplate.getInterceptors().add((request, body, execution) -> { - request.getHeaders().add(HttpHeaders.AUTHORIZATION, auth); - request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER, TARGET_ENTITY); - return execution.execute(request, body); - }); - }).build().buildClientFactory(); + request.getHeaders().add(HttpHeaders.AUTHORIZATION, auth); + request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER,TARGET_ENTITY); + return execution.execute(request, body); + }); + }).build().buildClientFactory(); serviceClient = clientFactory.create(Service.class); networkRecipeClient = clientFactory.create(NetworkRecipe.class); networkResourceCustomizationClient = clientFactory.create(NetworkResourceCustomization.class); @@ -396,15 +378,13 @@ public class CatalogDbClient { rainyDayHandlerStatusClient = clientFactory.create(RainyDayHandlerStatus.class); buildingBlockDetailClient = clientFactory.create(BuildingBlockDetail.class); orchestrationStatusStateTransitionDirectiveClient = clientFactory - .create(OrchestrationStatusStateTransitionDirective.class); + .create(OrchestrationStatusStateTransitionDirective.class); vnfcInstanceGroupCustomizationClient = clientFactory.create(VnfcInstanceGroupCustomization.class); collectionResourceInstanceGroupCustomizationClient = clientFactory - .create(CollectionResourceInstanceGroupCustomization.class); + .create(CollectionResourceInstanceGroupCustomization.class); instanceGroupClient = clientFactory.create(InstanceGroup.class); - networkCollectionResourceCustomizationClient = clientFactory - .create(NetworkCollectionResourceCustomization.class); - collectionNetworkResourceCustomizationClient = clientFactory - .create(CollectionNetworkResourceCustomization.class); + networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class); + collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class); cloudSiteClient = clientFactory.create(CloudSite.class); homingInstanceClient = clientFactory.create(HomingInstance.class); cloudifyManagerClient = clientFactory.create(CloudifyManager.class); @@ -416,11 +396,9 @@ public class CatalogDbClient { pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class); } - public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID( - String modelCustomizationUUID) { + public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) { NetworkCollectionResourceCustomization networkCollectionResourceCustomization = - this.getSingleResource(networkCollectionResourceCustomizationClient, - getUri(networkCollectionResourceCustomizationURI + modelCustomizationUUID)); + this.getSingleResource(networkCollectionResourceCustomizationClient, getUri(networkCollectionResourceCustomizationURI + modelCustomizationUUID)); if (networkCollectionResourceCustomization != null) { networkCollectionResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); } @@ -428,7 +406,7 @@ public class CatalogDbClient { } public Service getServiceByID(String modelUUID) { - Service service = getSingleResource(serviceClient, getUri(serviceURI + modelUUID)); + Service service = getSingleResource(serviceClient,getUri(serviceURI + modelUUID)); if (service != null) { service.setModelUUID(modelUUID); } @@ -436,14 +414,14 @@ public class CatalogDbClient { } public VfModule getVfModuleByModelUUID(String modelUUID) { - VfModule vfModule = getSingleResource(vfModuleClient, getUri(vfModuleURI + modelUUID)); + VfModule vfModule = getSingleResource(vfModuleClient,getUri(vfModuleURI + modelUUID)); if (vfModule != null) { vfModule.setModelUUID(modelUUID); } return vfModule; } - public VnfResource getVnfResourceByModelUUID(String modelUUID) { + public VnfResource getVnfResourceByModelUUID(String modelUUID){ VnfResource vnfResource = this.getSingleResource(vnfResourceClient, getUri(vnfResourceURI + modelUUID)); if (vnfResource != null) { @@ -452,15 +430,17 @@ public class CatalogDbClient { return vnfResource; } - public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationUUID(String modelCustomizationUUID) { - VnfResourceCustomization vnfResourceCustomization = getSingleResource(vnfResourceCustomizationClient, - getUri(vnfResourceCustomizationURI + modelCustomizationUUID)); - if (vnfResourceCustomization != null) { - vnfResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); + //A VNFResource customization UUID is the same object across services, so we can return anyone from the list + // In the future the client should query starting at a service model uuid + public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationUUID(String modelCustomizationUUID){ + List<VnfResourceCustomization> vnfResourceCustomization = this.getMultipleResources(vnfResourceCustomizationClient,getUri(endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + "/findByModelCustomizationUUID" + "?MODEL_CUSTOMIZATION_UUID="+ modelCustomizationUUID)); + if(vnfResourceCustomization != null && !vnfResourceCustomization.isEmpty()){ + return vnfResourceCustomization.get(0); + } + else{ + return null; } - return vnfResourceCustomization; } - public PnfResource getPnfResourceByModelUUID(String modelUUID) { PnfResource PnfResource = this.getSingleResource(pnfResourceClient, getUri(pnfResourceURI + modelUUID)); if (PnfResource != null) { @@ -478,11 +458,10 @@ public class CatalogDbClient { return pnfResourceCustomization; } - public CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomizationByID( - String modelCustomizationUUID) { + public CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomizationByID(String modelCustomizationUUID) { CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = - this.getSingleResource(collectionNetworkResourceCustomizationClient, getUri(UriBuilder - .fromUri(collectionNetworkResourceCustomizationURI + modelCustomizationUUID).build().toString())); + this.getSingleResource(collectionNetworkResourceCustomizationClient,getUri(UriBuilder + .fromUri(collectionNetworkResourceCustomizationURI + modelCustomizationUUID).build().toString())); if (collectionNetworkResourceCustomization != null) { collectionNetworkResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); } @@ -498,38 +477,22 @@ public class CatalogDbClient { } public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) { - VfModuleCustomization vfModuleCust = this - .getSingleResource(vfModuleCustomizationClient, getUri(vfModuleCustomizationURI + modelCustomizationUUID)); - if (vfModuleCust != null) { - vfModuleCust.setModelCustomizationUUID(modelCustomizationUUID); - } - return vfModuleCust; + return this.getSingleResource(vfModuleCustomizationClient, getUri(endpoint + VFMODULE_CUSTOMIZATION + SEARCH + "/findFirstByModelCustomizationUUIDOrderByCreatedDesc" + "?MODEL_CUSTOMIZATION_UUID="+ modelCustomizationUUID)); } - public NetworkResourceCustomization getNetworkResourceCustomizationByModelCustomizationUUID( - String modelCustomizationUUID) { + public NetworkResourceCustomization getNetworkResourceCustomizationByModelCustomizationUUID(String modelCustomizationUUID){ NetworkResourceCustomization networkResourceCustomization = - this.getSingleResource(networkResourceCustomizationClient, - getUri(networkResourceCustomizationURI + modelCustomizationUUID)); + this.getSingleResource(networkResourceCustomizationClient, getUri(networkResourceCustomizationURI + modelCustomizationUUID)); if (networkResourceCustomization != null) { networkResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); } return networkResourceCustomization; } - public CvnfcCustomization getCvnfcCustomizationByModelCustomizationUUID(String modelCustomizationUUID){ - CvnfcCustomization cvnfcResourceCustomization = - this.getSingleResource(cvnfcCustomizationClient, getUri(cvnfcResourceCustomizationURI + modelCustomizationUUID)); - if (cvnfcResourceCustomization != null) { - cvnfcResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); - } - return cvnfcResourceCustomization; - } public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) { BuildingBlockDetail buildingBlockDetail = getSingleResource(buildingBlockDetailClient, getUri(UriBuilder - .fromUri(findOneByBuildingBlockName).queryParam(BUILDING_BLOCK_NAME, buildingBlockName).build() - .toString())); + .fromUri(findOneByBuildingBlockName).queryParam(BUILDING_BLOCK_NAME, buildingBlockName).build().toString())); if (buildingBlockDetail != null) { buildingBlockDetail.setBuildingBlockName(buildingBlockName); } @@ -538,238 +501,229 @@ public class CatalogDbClient { public OrchestrationStatusStateTransitionDirective getOrchestrationStatusStateTransitionDirective( - ResourceType resourceType, OrchestrationStatus orchestrationStatus, OrchestrationAction targetAction) { + ResourceType resourceType, OrchestrationStatus orchestrationStatus, OrchestrationAction targetAction) { return getSingleResource(orchestrationStatusStateTransitionDirectiveClient, UriBuilder - .fromUri(findOneByResourceTypeAndOrchestrationStatusAndTargetAction) - .queryParam(RESOURCE_TYPE, resourceType.name()) - .queryParam(ORCHESTRATION_STATUS, orchestrationStatus.name()) - .queryParam(TARGET_ACTION, targetAction.name()).build()); + .fromUri(findOneByResourceTypeAndOrchestrationStatusAndTargetAction) + .queryParam(RESOURCE_TYPE, resourceType.name()) + .queryParam(ORCHESTRATION_STATUS, orchestrationStatus.name()) + .queryParam(TARGET_ACTION, targetAction.name()).build()); } public List<OrchestrationFlow> getOrchestrationFlowByAction(String action) { return this.getMultipleResources(orchestrationClient, UriBuilder - .fromUri(findByAction).queryParam(ACTION, action).build()); + .fromUri(findByAction).queryParam(ACTION, action).build()); } public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupsByVnfResourceCust(String modelCustomizationUUID) { return this.getMultipleResources(vnfcInstanceGroupCustomizationClient, UriBuilder - .fromUri(findVnfcInstanceGroupCustomizationByModelCustomizationUUID) - .queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build()); + .fromUri(findVnfcInstanceGroupCustomizationByModelCustomizationUUID) + .queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build()); } public List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomizationByModelCustUUID( - String modelCustomizationUUID) { + String modelCustomizationUUID) { return this.getMultipleResources(collectionResourceInstanceGroupCustomizationClient, UriBuilder - .fromUri(findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID) - .queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build()); + .fromUri(findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID) + .queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build()); } - public VfModuleCustomization getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( - String modelCustomizationUUID, String vfModuleModelUUID) { + public VfModuleCustomization getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(String modelCustomizationUUID, String vfModuleModelUUID) { return this.getSingleResource(vfModuleCustomizationClient, getUri(UriBuilder - .fromUri(findByModelCustomizationUUIDAndVfModuleModelUUID) - .queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID) - .queryParam(VF_MODULE_MODEL_UUID, vfModuleModelUUID).build().toString())); + .fromUri(findByModelCustomizationUUIDAndVfModuleModelUUID) + .queryParam("MODEL_CUSTOMIZATION_UUID",modelCustomizationUUID) + .queryParam("MODEL_UUID",vfModuleModelUUID).build().toString())); } public NorthBoundRequest getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(String requestAction, - String resourceName, boolean aLaCarte) { + String resourceName, boolean aLaCarte) { return this.getSingleResource(northBoundRequestClient, UriBuilder - .fromUri(findOneByActionAndRequestScopeAndIsAlacarte) - .queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName) - .queryParam(IS_ALACARTE, aLaCarte).build()); + .fromUri(findOneByActionAndRequestScopeAndIsAlacarte) + .queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName) + .queryParam(IS_ALACARTE, aLaCarte).build()); } - + public NorthBoundRequest getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(String requestAction, - String resourceName, boolean aLaCarte, String cloudOwner) { + String resourceName, boolean aLaCarte, String cloudOwner) { return this.getSingleResource(northBoundRequestClient, getUri(UriBuilder - .fromUri(findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType) - .queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName) - .queryParam(IS_ALACARTE, aLaCarte) - .queryParam(CLOUD_OWNER, cloudOwner) - .queryParam(SERVICE_TYPE, ASTERISK).build().toString())); - } - - public NorthBoundRequest getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType( - String requestAction, - String resourceName, boolean aLaCarte, String cloudOwner, String serviceType) { + .fromUri(findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType) + .queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName) + .queryParam(IS_ALACARTE, aLaCarte) + .queryParam(CLOUD_OWNER, cloudOwner) + .queryParam(SERVICE_TYPE, ASTERISK).build().toString())); + } + + public NorthBoundRequest getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(String requestAction, + String resourceName, boolean aLaCarte, String cloudOwner, String serviceType) { return this.getSingleResource(northBoundRequestClient, getUri(UriBuilder - .fromUri(findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType) - .queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName) - .queryParam(IS_ALACARTE, aLaCarte) - .queryParam(CLOUD_OWNER, cloudOwner) - .queryParam(SERVICE_TYPE, serviceType).build().toString())); + .fromUri(findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType) + .queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName) + .queryParam(IS_ALACARTE, aLaCarte) + .queryParam(CLOUD_OWNER, cloudOwner) + .queryParam(SERVICE_TYPE, serviceType).build().toString())); } public RainyDayHandlerStatus getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - String flowName, String serviceType, String vnfType, String errorCode, String workStep) { + String flowName, String serviceType, String vnfType, String errorCode, String workStep) { return this.getSingleResource(rainyDayHandlerStatusClient, getUri(UriBuilder - .fromUri(findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep) - .queryParam(FLOW_NAME, flowName).queryParam(SERVICE_TYPE, serviceType) - .queryParam(VNF_TYPE, vnfType).queryParam(ERROR_CODE, errorCode).queryParam(WORK_STEP, workStep) - .build().toString())); + .fromUri(findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep) + .queryParam(FLOW_NAME, flowName).queryParam(SERVICE_TYPE, serviceType) + .queryParam(VNF_TYPE, vnfType).queryParam(ERROR_CODE, errorCode).queryParam(WORK_STEP, workStep) + .build().toString())); } - public ServiceRecipe getFirstByServiceModelUUIDAndAction(String modelUUID, String action) { + public ServiceRecipe getFirstByServiceModelUUIDAndAction(String modelUUID, String action){ return this.getSingleResource(serviceRecipeClient, getUri(UriBuilder - .fromUri(findFirstByServiceModelUUIDAndActionURI) - .queryParam(SERVICE_MODEL_UUID, modelUUID) - .queryParam(ACTION, action).build().toString())); + .fromUri(findFirstByServiceModelUUIDAndActionURI) + .queryParam(SERVICE_MODEL_UUID,modelUUID) + .queryParam(ACTION,action).build().toString())); } - public NetworkRecipe getFirstNetworkRecipeByModelNameAndAction(String modelName, String action) { + public NetworkRecipe getFirstNetworkRecipeByModelNameAndAction(String modelName, String action){ return this.getSingleResource(networkRecipeClient, UriBuilder - .fromUri(findFirstByModelNameAndAction) - .queryParam(MODEL_NAME, modelName) - .queryParam(ACTION, action).build()); + .fromUri(findFirstByModelNameAndAction) + .queryParam(MODEL_NAME,modelName) + .queryParam(ACTION,action).build()); } - - public ControllerSelectionReference getControllerSelectionReferenceByVnfTypeAndActionCategory(String vnfType, - String actionCategory) { + + public ControllerSelectionReference getControllerSelectionReferenceByVnfTypeAndActionCategory(String vnfType, String actionCategory) { return this.getSingleResource(controllerSelectionReferenceClient, UriBuilder - .fromUri(endpoint - + "/controllerSelectionReference/search/findControllerSelectionReferenceByVnfTypeAndActionCategory") - .queryParam("VNF_TYPE", vnfType).queryParam("ACTION_CATEGORY", actionCategory).build()); + .fromUri(endpoint + "/controllerSelectionReference/search/findControllerSelectionReferenceByVnfTypeAndActionCategory") + .queryParam("VNF_TYPE", vnfType).queryParam("ACTION_CATEGORY", actionCategory).build()); } - public Service getFirstByModelNameOrderByModelVersionDesc(String modelName) { - return this.getSingleResource(serviceClient, UriBuilder - .fromUri(findFirstByModelNameURI) - .queryParam(MODEL_NAME, modelName).build()); + public Service getFirstByModelNameOrderByModelVersionDesc(String modelName){ + return this.getSingleResource(serviceClient,UriBuilder + .fromUri(findFirstByModelNameURI) + .queryParam(MODEL_NAME,modelName).build()); } - public ExternalServiceToInternalService findExternalToInternalServiceByServiceName(String serviceName) { + public ExternalServiceToInternalService findExternalToInternalServiceByServiceName(String serviceName){ return this.getSingleResource(externalServiceToInternalServiceClient, getUri(UriBuilder - .fromUri(findExternalToInternalServiceByServiceName) - .queryParam(SERVICE_NAME, serviceName).build().toString())); + .fromUri(findExternalToInternalServiceByServiceName) + .queryParam(SERVICE_NAME,serviceName).build().toString())); } - public ServiceRecipe findServiceRecipeByActionAndServiceModelUUID(String action, String modelUUID) { + public ServiceRecipe findServiceRecipeByActionAndServiceModelUUID(String action,String modelUUID){ return this.getSingleResource(serviceRecipeClient, getUri(UriBuilder - .fromUri(findServiceRecipeByActionAndServiceModelUUID) - .queryParam(ACTION, action) - .queryParam(SERVICE_MODEL_UUID, modelUUID).build().toString())); + .fromUri(findServiceRecipeByActionAndServiceModelUUID) + .queryParam(ACTION,action) + .queryParam(SERVICE_MODEL_UUID,modelUUID).build().toString())); } - public Service getServiceByModelName(String modelName) { - return this.getSingleResource(serviceClient, getUri(UriBuilder - .fromUri(findServiceByModelName) - .queryParam(MODEL_NAME, modelName).build().toString())); + public Service getServiceByModelName(String modelName){ + return this.getSingleResource(serviceClient,getUri(UriBuilder + .fromUri(findServiceByModelName) + .queryParam(MODEL_NAME,modelName).build().toString())); } - public Service getServiceByModelUUID(String modelModelUUID) { - return this.getSingleResource(serviceClient, getUri(UriBuilder - .fromUri(findServiceByModelUUID) - .queryParam(MODEL_UUID, modelModelUUID).build().toString())); + public Service getServiceByModelUUID(String modelModelUUID){ + return this.getSingleResource(serviceClient,getUri(UriBuilder + .fromUri(findServiceByModelUUID) + .queryParam(MODEL_UUID,modelModelUUID).build().toString())); } - public VnfResource getFirstVnfResourceByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, - String modelVersion) { + public VnfResource getFirstVnfResourceByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion){ return this.getSingleResource(vnfResourceClient, getUri(UriBuilder - .fromUri(findFirstResourceByModelInvariantUUIDAndModelVersion) - .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID) - .queryParam(MODEL_VERSION, modelVersion).build().toString())); + .fromUri(findFirstResourceByModelInvariantUUIDAndModelVersion) + .queryParam(MODEL_INVARIANT_UUID,modelInvariantUUID) + .queryParam(MODEL_VERSION,modelVersion).build().toString())); } - public VnfResourceCustomization getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources( - String modelInstanceName, VnfResource vnfResource) { + public VnfResourceCustomization getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources(String modelInstanceName, VnfResource vnfResource){ return this.getSingleResource(vnfResourceCustomizationClient, getUri(UriBuilder - .fromUri(findByModelInstanceNameAndVnfResources) - .queryParam(MODEL_INSTANCE_NAME, modelInstanceName) - .queryParam(VNF_RESOURCE_MODEL_UUID, vnfResource.getModelUUID()).build().toString())); + .fromUri(findByModelInstanceNameAndVnfResources) + .queryParam("MODEL_INSTANCE_NAME",modelInstanceName) + .queryParam("VNF_RESOURCE_MODEL_UUID",vnfResource.getModelUUID()).build().toString())); } - public VnfRecipe getFirstVnfRecipeByNfRoleAndAction(String nfRole, String action) { - return this.getSingleResource(vnfRecipeClient, getUri(UriBuilder - .fromUri(findFirstVnfRecipeByNfRoleAndAction) - .queryParam(NF_ROLE, nfRole) - .queryParam(ACTION, action).build().toString())); + public VnfRecipe getFirstVnfRecipeByNfRoleAndAction(String nfRole, String action){ + return this.getSingleResource(vnfRecipeClient,getUri(UriBuilder + .fromUri(findFirstVnfRecipeByNfRoleAndAction) + .queryParam(NF_ROLE,nfRole) + .queryParam(ACTION,action).build().toString())); } - public VnfComponentsRecipe getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( - String vfModuleModelUUID, String vnfComponentType, String action) { - return this.getSingleResource(vnfComponentsRecipeClient, getUri(UriBuilder - .fromUri(findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction) - .queryParam(VF_MODULE_MODEL_UUID, vfModuleModelUUID) - .queryParam(VNF_COMPONENT_TYPE, vnfComponentType) - .queryParam(ACTION, action).build().toString())); + public VnfComponentsRecipe getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(String vfModuleModelUUID, String vnfComponentType, String action){ + return this.getSingleResource(vnfComponentsRecipeClient,getUri(UriBuilder + .fromUri(findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction) + .queryParam(VF_MODULE_MODEL_UUID,vfModuleModelUUID) + .queryParam(VNF_COMPONENT_TYPE,vnfComponentType) + .queryParam(ACTION,action).build().toString())); } - public VnfComponentsRecipe getFirstVnfComponentsRecipeByVnfComponentTypeAndAction(String vnfComponentType, - String action) { - return this.getSingleResource(vnfComponentsRecipeClient, getUri(UriBuilder - .fromUri(findFirstVnfComponentsRecipeByVnfComponentTypeAndAction) - .queryParam(VNF_COMPONENT_TYPE, vnfComponentType) - .queryParam(ACTION, action).build().toString())); + public VnfComponentsRecipe getFirstVnfComponentsRecipeByVnfComponentTypeAndAction(String vnfComponentType, String action) { + return this.getSingleResource(vnfComponentsRecipeClient,getUri(UriBuilder + .fromUri(findFirstVnfComponentsRecipeByVnfComponentTypeAndAction) + .queryParam(VNF_COMPONENT_TYPE,vnfComponentType) + .queryParam(ACTION,action).build().toString())); } - - protected URI getUri(String template) { + protected URI getUri(String template){ return URI.create(template); } public CloudifyManager getCloudifyManager(String id) { - return this.getSingleResource(cloudifyManagerClient, getUri(cloudifyManagerURI + id)); + return this.getSingleResource(cloudifyManagerClient,getUri(cloudifyManagerURI + id)); } - public CloudSite getCloudSite(String id) { + public CloudSite getCloudSite(String id){ return this.getSingleResource(cloudSiteClient, - getUri(cloudSiteURI + id)); + getUri(cloudSiteURI + id)); } - public CloudSite getCloudSite(String id, String uri) { + public CloudSite getCloudSite(String id, String uri){ return this.getSingleResource(cloudSiteClient, - getUri(uri + id)); + getUri(uri + id)); } - public void postCloudSite(CloudSite cloudSite) { + public void postCloudSite(CloudSite cloudSite){ this.postSingleResource(cloudSiteClient, cloudSite); } - public CloudSite getCloudSiteByClliAndAicVersion(String clli, String cloudVersion) { + public CloudSite getCloudSiteByClliAndAicVersion (String clli, String cloudVersion){ return this.getSingleResource(cloudSiteClient, getUri(UriBuilder - .fromUri(findByClliAndCloudVersion) - .queryParam(CLLI, clli).queryParam(CLOUD_VERSION, cloudVersion).build().toString())); + .fromUri(findByClliAndCloudVersion) + .queryParam(CLLI,clli).queryParam(CLOUD_VERSION,cloudVersion).build().toString())); } - public HomingInstance getHomingInstance(String serviceInstanceId) { + public HomingInstance getHomingInstance (String serviceInstanceId){ return this.getSingleResource(homingInstanceClient, - getUri(homingInstanceURI + serviceInstanceId)); + getUri(homingInstanceURI + serviceInstanceId)); } - public HomingInstance getHomingInstance(String serviceInstanceId, String uri) { + public HomingInstance getHomingInstance (String serviceInstanceId, String uri){ return this.getSingleResource(homingInstanceClient, - getUri(uri + serviceInstanceId)); + getUri(uri + serviceInstanceId)); } - public void postHomingInstance(HomingInstance homingInstance) { + public void postHomingInstance(HomingInstance homingInstance){ this.postSingleResource(homingInstanceClient, homingInstance); } public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) { return this.getSingleResource(serviceClient, getUri(UriBuilder - .fromUri(findFirstByModelVersionAndModelInvariantUUIDURI) - .queryParam(MODEL_VERSION, modelVersion) - .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); + .fromUri(findFirstByModelVersionAndModelInvariantUUIDURI) + .queryParam(MODEL_VERSION, modelVersion) + .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); } - public VfModule getVfModuleByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion) { - return this.getSingleResource(vfModuleClient, getUri(UriBuilder - .fromUri(findFirstVfModuleByModelInvariantUUIDAndModelVersion) - .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID) - .queryParam(MODEL_VERSION, modelVersion).build().toString())); + public VfModule getVfModuleByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion){ + return this.getSingleResource(vfModuleClient,getUri(UriBuilder + .fromUri(findFirstVfModuleByModelInvariantUUIDAndModelVersion) + .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID) + .queryParam(MODEL_VERSION, modelVersion).build().toString())); } public List<Service> getServiceByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID) { return this.getMultipleResources(serviceClient, getUri(UriBuilder - .fromUri(findByModelInvariantUUIDURI) - .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); + .fromUri(findByModelInvariantUUIDURI) + .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); } public List<VfModule> getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID) { return this.getMultipleResources(vfModuleClient, getUri(UriBuilder - .fromUri(findVfModuleByModelInvariantUUIDOrderByModelVersionDesc) - .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); + .fromUri(findVfModuleByModelInvariantUUIDOrderByModelVersionDesc) + .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); } private <T> T getSingleResource(Client<T> client, URI uri) { @@ -784,39 +738,59 @@ public class CatalogDbClient { return list; } - private <T> URI postSingleResource(Client<T> client, T type) { + private <T> URI postSingleResource(Client<T> client, T type){ return client.post(type); } - - public List<CvnfcCustomization> getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID( - String vnfCustomizationUUID, String vfModuleCustomizationUUID) { - - return this.getMultipleResources(cvnfcCustomizationClient, getUri(UriBuilder - .fromUri(endpoint + "/cvnfcCustomization/search/findByVnfResourceCustomizationAndVfModuleCustomization") - .queryParam("VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID", vnfCustomizationUUID) - .queryParam("VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID", vfModuleCustomizationUUID).build().toString())); - } - - public CvnfcCustomization getCvnfcCustomizationByCustomizationUUID(String cvnfcCustomizationUuid){ - return this.getSingleResource(cvnfcCustomizationClient,getUri(UriBuilder - .fromUri(endpoint + "/cvnfcCustomization/search/findOneByModelCustomizationUUID").queryParam("modelCustomizationUuid", cvnfcCustomizationUuid) - .build().toString())); + + public List<CvnfcCustomization> getCvnfcCustomization(String serviceModelUUID, String vnfCustomizationUUID, + String vfModuleCustomizationUUID) { + Service service = this.getServiceByID(serviceModelUUID); + VnfResourceCustomization vnfResourceCust = findVnfResourceCustomizationInList(vnfCustomizationUUID, service.getVnfCustomizations()); + VfModuleCustomization vfModuleCust = findVfModuleCustomizationInList(vfModuleCustomizationUUID , vnfResourceCust.getVfModuleCustomizations()); + return vfModuleCust.getCvnfcCustomization().stream().collect(Collectors.toList()); + } + + private VnfResourceCustomization findVnfResourceCustomizationInList(String vnfCustomizationUUID , List<VnfResourceCustomization> vnfResourceCusts){ + List<VnfResourceCustomization> filtered = vnfResourceCusts.stream() + .filter(vnfCustRes -> vnfCustomizationUUID.equals(vnfCustRes.getModelCustomizationUUID())) + .collect(Collectors.toList()); + if(filtered != null && !filtered.isEmpty() && filtered.size() == 1){ + return filtered.get(0); + }else + throw new EntityNotFoundException("Unable to find VnfResourceCustomization ModelCustomizationUUID:" + vnfCustomizationUUID); + } + + private VfModuleCustomization findVfModuleCustomizationInList(String vfModuleCustomizationUUID , List<VfModuleCustomization> vfModuleList){ + List<VfModuleCustomization> filtered = vfModuleList.stream() + .filter(vfModuleCust -> vfModuleCustomizationUUID.equals(vfModuleCust.getModelCustomizationUUID())) + .collect(Collectors.toList()); + if(filtered != null && !filtered.isEmpty() && filtered.size() == 1){ + return filtered.get(0); + }else + throw new EntityNotFoundException("Unable to find VfModuleCustomization ModelCustomizationUUID:" + vfModuleCustomizationUUID); + } + + private CvnfcCustomization findCvnfcCustomizationInAList(String cvnfcCustomizationUuid , List<CvnfcCustomization> cvnfcCustomList){ + List<CvnfcCustomization> filtered = cvnfcCustomList.stream() + .filter(cvnfc -> cvnfcCustomizationUuid.equals(cvnfc.getModelCustomizationUUID())) + .collect(Collectors.toList()); + if(filtered != null && !filtered.isEmpty() && filtered.size() == 1){ + logger.debug("Found CvnfcCustomization: {}", filtered.get(0)); + return filtered.get(0); + }else + throw new EntityNotFoundException("Unable to find VfModuleCustomization ModelCustomizationUUID:" + cvnfcCustomizationUuid); + } + + public CvnfcConfigurationCustomization getCvnfcCustomization(String serviceModelUUID, String vnfCustomizationUuid, + String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) { + List<CvnfcCustomization> cvnfcCustomization = getCvnfcCustomization(serviceModelUUID,vnfCustomizationUuid,vfModuleCustomizationUuid); + CvnfcCustomization cvnfc = findCvnfcCustomizationInAList(cvnfcCustomizationUuid,cvnfcCustomization ); + List<CvnfcConfigurationCustomization> fabricConfigs = cvnfc.getCvnfcConfigurationCustomization().stream().filter(cvnfcCustom -> cvnfcCustom.getConfigurationResource().getToscaNodeType().contains("FabricConfiguration")).collect(Collectors.toList()); + if(fabricConfigs != null && !fabricConfigs.isEmpty() && fabricConfigs.size() == 1){ + logger.debug("Found Fabric Configuration: {}", fabricConfigs.get(0)); + return fabricConfigs.get(0); + }else + throw new EntityNotFoundException("Unable to find CvnfcConfigurationCustomization ModelCustomizationUUID:" + cvnfcCustomizationUuid); } - //fetch all VnfVfmoduleCvnfcConfigurationCustomization underneath a vnfc - //find the VnfVfmoduleCvnfcConfigurationCustomization that is related to our vnf and our vf-module, filter all others. - public VnfVfmoduleCvnfcConfigurationCustomization getVnfVfmoduleCvnfcConfigurationCustomizationByVnfCustomizationUuidAndVfModuleCustomizationUuidAndCvnfcCustomizationUuid( - String vnfCustomizationUuid, String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) { - CvnfcCustomization cvnfc = getCvnfcCustomizationByCustomizationUUID(cvnfcCustomizationUuid); - if (cvnfc != null) { - for(VnfVfmoduleCvnfcConfigurationCustomization vnfVfModuleCvnfcCust: cvnfc.getVnfVfmoduleCvnfcConfigurationCustomization()){ - if(vnfVfModuleCvnfcCust.getVnfResourceCustomization().getModelCustomizationUUID().equals(vnfCustomizationUuid) && - vnfVfModuleCvnfcCust.getVfModuleCustomization().getModelCustomizationUUID().equals(vfModuleCustomizationUuid)){ - return vnfVfModuleCvnfcCust; - } - } - } - return null; - - } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcConfigurationCustomizationRepository.java index 8664c1e2bc..ddb089dede 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcConfigurationCustomizationRepository.java @@ -20,11 +20,11 @@ package org.onap.so.db.catalog.data.repository; -import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -@RepositoryRestResource(collectionResourceRel = "vnfVfmoduleCvnfcConfigurationCustomization", path = "vnfVfmoduleCvnfcConfigurationCustomization") -public interface VnfVfmoduleCvnfcConfigurationCustomizationRepository extends JpaRepository<VnfVfmoduleCvnfcConfigurationCustomization, Integer> { +@RepositoryRestResource(collectionResourceRel = "cvnfcConfigurationCustomization", path = "cvnfcConfigurationCustomization") +public interface CvnfcConfigurationCustomizationRepository extends JpaRepository<CvnfcConfigurationCustomization, Integer> { }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepository.java index 059d0da498..879d7bf82f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepository.java @@ -32,7 +32,5 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; public interface CvnfcCustomizationRepository extends JpaRepository<CvnfcCustomization, Integer> { CvnfcCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid); List<CvnfcCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); - - @Query(value = "SELECT * FROM cvnfc_customization WHERE VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID = ?1 AND VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID = ?2", nativeQuery = true) - List<CvnfcCustomization> findByVnfResourceCustomizationAndVfModuleCustomization (@Param("VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID") String vnfResourceCustomization,@Param("VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID") String vfModuleCustomization); + }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleCustomizationRepository.java index ee2d08b6f2..e8fb654f57 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleCustomizationRepository.java @@ -22,11 +22,12 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "vfModuleCustomization", path = "vfModuleCustomization") -public interface VFModuleCustomizationRepository extends JpaRepository<VfModuleCustomization, String> { - VfModuleCustomization findByModelCustomizationUUID(String modelCustomizationUUID); +public interface VFModuleCustomizationRepository extends JpaRepository<VfModuleCustomization, Integer> { + VfModuleCustomization findFirstByModelCustomizationUUIDOrderByCreatedDesc(@Param("MODEL_CUSTOMIZATION_UUID")String modelCustomizationUUID); - VfModuleCustomization findByModelCustomizationUUIDAndVfModuleModelUUID(String modelCustomizationUUID, String vfModuleModelUUID); + VfModuleCustomization findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc(@Param("MODEL_CUSTOMIZATION_UUID")String modelCustomizationUUID, @Param("MODEL_UUID")String vfModuleModelUUID); }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleRepository.java index cd985dba9f..56ae11f4cb 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleRepository.java @@ -43,9 +43,9 @@ public interface VFModuleRepository extends JpaRepository<VfModule, String> { @Query(value = "SELECT * FROM vf_module WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true) VfModule findFirstByModelNameOrderByModelVersionDesc(String modelName); - VfModule findByModelInvariantUUIDAndModelUUID(String modelCustomizationUUID, String modelUUID); + VfModule findFirstByModelInvariantUUIDAndModelUUID(String modelCustomizationUUID, String modelUUID); - VfModule findByModelInvariantUUID(String modelCustomizationUUID); + VfModule findFirstByModelInvariantUUID(String modelCustomizationUUID); /** * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java index 525c628e1c..fa8d8c065e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java @@ -24,17 +24,16 @@ import java.util.List; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "vnfResourceCustomization", path = "vnfResourceCustomization") -public interface VnfCustomizationRepository extends JpaRepository<VnfResourceCustomization, String> { - - List<VnfResourceCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); +public interface VnfCustomizationRepository extends JpaRepository<VnfResourceCustomization, Integer> { + List<VnfResourceCustomization> findByModelCustomizationUUID(@Param("MODEL_CUSTOMIZATION_UUID")String modelCustomizationUUID); VnfResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid); @Query(value = "SELECT * FROM vnf_resource_customization WHERE MODEL_INSTANCE_NAME = ?1 AND VNF_RESOURCE_MODEL_UUID = ?2 LIMIT 1;", nativeQuery = true) - VnfResourceCustomization findByModelInstanceNameAndVnfResources(String modelInstanceName, - String vnfResourceModelUUID); + VnfResourceCustomization findByModelInstanceNameAndVnfResources(@Param("MODEL_INSTANCE_NAME")String modelInstanceName, @Param("VNF_RESOURCE_MODEL_UUID")String vnfResourceModelUUID); -}
\ No newline at end of file +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java index f2fbbe6b57..c18bf006da 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java @@ -29,5 +29,4 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "vnfcInstanceGroupCustomization", path = "vnfcInstanceGroupCustomization") public interface VnfcInstanceGroupCustomizationRepository extends JpaRepository<VnfcInstanceGroupCustomization, String> { - List<VnfcInstanceGroupCustomization> findByModelCustomizationUUID(String modelCustomizationlUUID); } |