diff options
Diffstat (limited to 'mso-catalog-db')
57 files changed, 2565 insertions, 269 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java index 75461c6cde..1d3ee7c36e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java @@ -35,6 +35,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -70,7 +71,8 @@ public class AllottedResource implements Serializable { @Column(name = "DESCRIPTION") private String description; - + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") @Column(name = "CREATION_TIMESTAMP", updatable = false) @Temporal(TemporalType.TIMESTAMP) private Date created; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java index f68c6d2502..00ddf35a5f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java @@ -35,6 +35,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -55,6 +56,7 @@ public class AllottedResourceCustomization implements Serializable { private String modelCustomizationUUID; @Column(name = "CREATION_TIMESTAMP", updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") @Temporal(TemporalType.TIMESTAMP) private Date created; 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 173480172d..7c6fb04079 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 @@ -79,6 +79,9 @@ public class ConfigurationResource implements Serializable { @OneToMany(cascade = CascadeType.ALL, mappedBy = "configurationResource") private Set<ConfigurationResourceCustomization> configurationResourceCustomization; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "configurationResource") + private Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization; @PrePersist protected void onCreate() { @@ -147,6 +150,16 @@ public class ConfigurationResource implements Serializable { this.configurationResourceCustomization = configurationResourceCustomization; } + @LinkedResource + public Set<VnfVfmoduleCvnfcConfigurationCustomization> getVnfVfmoduleCvnfcConfigurationCustomization() { + return vnfVfmoduleCvnfcConfigurationCustomization; + } + + public void setVnfVfmoduleCvnfcConfigurationCustomization( + Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization) { + this.vnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomization; + } + @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/ControllerSelectionReference.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java new file mode 100644 index 0000000000..de0dd39edc --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReference.java @@ -0,0 +1,106 @@ +package org.onap.so.db.catalog.beans; +/*- + * ============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========================================================= + */ + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; + +@IdClass(ControllerSelectionReferenceId.class) +@Entity +@Table(name = "CONTROLLER_SELECTION_REFERENCE") +public class ControllerSelectionReference implements Serializable { + + private static final long serialVersionUID = -608098800737567188L; + + @BusinessKey + @Id + @Column(name = "VNF_TYPE") + private String vnfType; + + @BusinessKey + @Id + @Column(name = "CONTROLLER_NAME") + private String controllerName; + + @BusinessKey + @Id + @Column(name = "ACTION_CATEGORY") + private String actionCategory; + + + public String getVnfType() { + return vnfType; + } + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + public String getControllerName() { + return controllerName; + } + public void setControllerName(String controllerName) { + this.controllerName = controllerName; + } + public String getActionCategory() { + return actionCategory; + } + public void setActionCategory(String actionCategory) { + this.actionCategory = actionCategory; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return new ToStringBuilder(this).append("vnfType", vnfType).append("controllerName", controllerName) + .append("actionCategory", actionCategory).toString(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(final Object other) { + if (!(other instanceof ControllerSelectionReference)) { + return false; + } + ControllerSelectionReference castOther = (ControllerSelectionReference) other; + return new EqualsBuilder().append(vnfType, castOther.vnfType).append(controllerName, castOther.controllerName) + .append(actionCategory, castOther.actionCategory).isEquals(); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return new HashCodeBuilder().append(vnfType).append(controllerName).append(actionCategory).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReferenceId.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReferenceId.java new file mode 100644 index 0000000000..e6ee349be6 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ControllerSelectionReferenceId.java @@ -0,0 +1,83 @@ +/*- + * ============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 com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; + + +public class ControllerSelectionReferenceId implements Serializable { + + private static final long serialVersionUID = 1L; + @BusinessKey + private String vnfType; + @BusinessKey + private String controllerName; + @BusinessKey + private String actionCategory; + + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ControllerSelectionReferenceId)) { + return false; + } + ControllerSelectionReferenceId castOther = (ControllerSelectionReferenceId) other; + return new EqualsBuilder().append(vnfType, castOther.vnfType).append(controllerName, castOther.controllerName) + .append(actionCategory, castOther.actionCategory).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(vnfType).append(controllerName).append(actionCategory).toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("vnfType", vnfType).append("controllerName", controllerName) + .append("actionCategory", actionCategory).toString(); + } + + public String getVnfType() { + return vnfType; + } + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + public String getControllerName() { + return controllerName; + } + public void setControllerName(String controllerName) { + this.controllerName = controllerName; + } + public String getActionCategory() { + return actionCategory; + } + public void setActionCategory(String actionCategory) { + this.actionCategory = actionCategory; + } + + +} 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 new file mode 100644 index 0000000000..c02b1e3030 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java @@ -0,0 +1,275 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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 java.util.Date; +import java.util.Set; + +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.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "cvnfc_customization") +public class CvnfcCustomization implements Serializable { + + private static final long serialVersionUID = -3772469944364616486L; + + @Id + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @BusinessKey + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "TOSCA_NODE_TYPE") + private String toscaNodeType; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "NFC_FUNCTION") + private String nfcFunction; + + @Column(name = "NFC_NAMING_CODE") + private String nfcNamingCode; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID") + 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 = "modelCustomizationUUID") + private Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof CvnfcCustomization)) { + return false; + } + CvnfcCustomization castOther = (CvnfcCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("modelUUID", modelUUID) + .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion) + .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) + .toString(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @LinkedResource + public Set<VnfVfmoduleCvnfcConfigurationCustomization> getVnfVfmoduleCvnfcConfigurationCustomization() { + return vnfVfmoduleCvnfcConfigurationCustomization; + } + + public void setVnfVfmoduleCvnfcConfigurationCustomization( + Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization) { + this.vnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomization; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getModelCustomizationUUID() { + return modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelInstanceName() { + return modelInstanceName; + } + + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + + public String getModelUUID() { + return modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getModelInvariantUUID() { + return modelInvariantUUID; + } + + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } + + public String getModelVersion() { + return modelVersion; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNfcFunction() { + return nfcFunction; + } + + public void setNfcFunction(String nfcFunction) { + this.nfcFunction = nfcFunction; + } + + public String getNfcNamingCode() { + return nfcNamingCode; + } + + public void setNfcNamingCode(String nfcNamingCode) { + this.nfcNamingCode = nfcNamingCode; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public VfModuleCustomization getVfModuleCustomization() { + return vfModuleCustomization; + } + + public void setVfModuleCustomization(VfModuleCustomization vfModuleCustomization) { + this.vfModuleCustomization = vfModuleCustomization; + } + + public VnfcCustomization getVnfcCustomization() { + return vnfcCustomization; + } + + public void setVnfcCustomization(VnfcCustomization vnfcCustomization) { + this.vnfcCustomization = vnfcCustomization; + } + + 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/VfModule.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java index 47d82bff06..7d53a0b843 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java @@ -28,6 +28,7 @@ import java.util.List; 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; @@ -94,7 +95,7 @@ public class VfModule implements Serializable { @OneToMany(mappedBy = "vfModule") private List<VfModuleCustomization> vfModuleCustomization; - @ManyToOne + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID") private VnfResource vnfResources; 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 4a9b3bbbb5..5a7d0d5425 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 @@ -22,6 +22,9 @@ package org.onap.so.db.catalog.beans; import java.io.Serializable; import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -29,6 +32,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.PrePersist; import javax.persistence.Table; import javax.persistence.Temporal; @@ -37,6 +41,7 @@ import javax.persistence.TemporalType; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; +import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import com.fasterxml.jackson.annotation.JsonFormat; import com.openpojo.business.annotation.BusinessKey; @@ -85,7 +90,16 @@ public class VfModuleCustomization implements Serializable { @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "VF_MODULE_MODEL_UUID") private VfModule vfModule; - + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") + private Set<VnfcCustomization> vnfcCustomization; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") + private Set<CvnfcCustomization> cvnfcCustomization; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "modelCustomizationUUID") + private Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomization; + @PrePersist protected void onCreate() { this.created = new Date(); @@ -196,4 +210,37 @@ public class VfModuleCustomization implements Serializable { public void setVfModule(VfModule vfModule) { this.vfModule = vfModule; } + + @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<>(); + return cvnfcCustomization; + } + + public void setCvnfcCustomization(Set<CvnfcCustomization> cvnfcCustomization) { + this.cvnfcCustomization = cvnfcCustomization; + } } 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 fa0fe5636e..d286bc0727 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 @@ -23,7 +23,9 @@ package org.onap.so.db.catalog.beans; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -67,6 +69,10 @@ 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; @@ -101,6 +107,12 @@ public class VnfResourceCustomization implements Serializable { @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; @Override public String toString() { @@ -250,4 +262,25 @@ public class VnfResourceCustomization implements Serializable { 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; + } } 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/VnfVfmoduleCvnfcConfigurationCustomization.java new file mode 100644 index 0000000000..8ef797f8fa --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomization.java @@ -0,0 +1,236 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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 java.util.Date; + +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.ManyToOne; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "vnf_vfmodule_cvnfc_configuration_customization") +public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable { + + private static final long serialVersionUID = -3153216266280581103L; + + @Id + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @BusinessKey + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "CONFIGURATION_TYPE") + private String configurationType; + + @Column(name = "CONFIGURATION_ROLE") + private String configurationRole; + + @Column(name = "CONFIGURATION_FUNCTION") + private String configurationFunction; + + @Column(name = "POLICY_NAME") + private String policyName; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "CONFIGURATION_MODEL_UUID") + private ConfigurationResource configurationResource; + + @BusinessKey + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "CVNFC_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID") + 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)) { + 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(); + } + + + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).append(cvnfcCustomization) + .append(vfModuleCustomization).append(vnfResourceCustomization).toHashCode(); + } + + + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("modelCustomizationUUID", modelCustomizationUUID) + .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(); + } + + + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getModelCustomizationUUID() { + return modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelInstanceName() { + return modelInstanceName; + } + + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + + public String getConfigurationType() { + return configurationType; + } + + public void setConfigurationType(String configurationType) { + this.configurationType = configurationType; + } + + public String getConfigurationRole() { + return configurationRole; + } + + public void setConfigurationRole(String configurationRole) { + this.configurationRole = configurationRole; + } + + public String getConfigurationFunction() { + return configurationFunction; + } + + public void setConfigurationFunction(String configurationFunction) { + this.configurationFunction = configurationFunction; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public ConfigurationResource getConfigurationResource() { + return configurationResource; + } + + public void setConfigurationResource(ConfigurationResource configurationResource) { + this.configurationResource = configurationResource; + } + + public CvnfcCustomization getCvnfcCustomization() { + return cvnfcCustomization; + } + + public void setCvnfcCustomization(CvnfcCustomization cvnfcCustomization) { + this.cvnfcCustomization = cvnfcCustomization; + } + + public VfModuleCustomization getVfModuleCustomization() { + return vfModuleCustomization; + } + + public void setVfModuleCustomization(VfModuleCustomization vfModuleCustomization) { + this.vfModuleCustomization = vfModuleCustomization; + } + + 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/VnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java new file mode 100644 index 0000000000..8534242a58 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java @@ -0,0 +1,191 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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 java.util.Date; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@Entity +@Table(name = "vnfc_customization") +public class VnfcCustomization implements Serializable { + + private static final long serialVersionUID = -3772469944364616486L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "TOSCA_NODE_TYPE") + private String toscaNodeType; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "vnfcCustomization") + private List<CvnfcCustomization> cvnfcCustomization; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VnfcCustomization)) { + return false; + } + VnfcCustomization castOther = (VnfcCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("modelUUID", modelUUID) + .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion) + .append("modelName", modelName).append("toscaNodeType", toscaNodeType) + .append("description", description).append("created", created) + .append("cvnfcCustomization", cvnfcCustomization).toString(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public String getModelCustomizationUUID() { + return modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelInstanceName() { + return modelInstanceName; + } + + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + + public String getModelUUID() { + return modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getModelInvariantUUID() { + return modelInvariantUUID; + } + + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } + + public String getModelVersion() { + return modelVersion; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public List<CvnfcCustomization> getCvnfcCustomization() { + return cvnfcCustomization; + } + + public void setCvnfcCustomization(List<CvnfcCustomization> cvnfcCustomization) { + this.cvnfcCustomization = cvnfcCustomization; + } +} 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 0caafc794b..e29d88cb89 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 @@ -21,39 +21,45 @@ package org.onap.so.db.catalog.client; 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.CvnfcCustomization; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; +import org.onap.so.db.catalog.beans.NetworkRecipe; +import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; import org.onap.so.db.catalog.beans.ResourceType; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; +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.VnfcInstanceGroupCustomization; -import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.db.catalog.beans.CloudIdentity; -import org.onap.so.db.catalog.beans.CloudifyManager; -import org.onap.so.db.catalog.beans.ServiceRecipe; 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.logging.jaxrs.filter.jersey.SpringClientFilter; +import org.onap.so.logging.jaxrs.filter.SpringClientFilter; 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.SimpleClientHttpRequestFactory; +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; -import uk.co.blackpepper.bowman.RestTemplateConfigurer; import javax.annotation.PostConstruct; import javax.ws.rs.core.UriBuilder; -import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Iterator; @@ -62,48 +68,138 @@ import java.util.List; @Component("CatalogDbClient") public class CatalogDbClient { - private static final String SERVICE_RECIPE_SEARCH = "/serviceRecipe/search"; - private static final String SERVICE_MODEL_UUID = "SERVICE_MODEL_UUID"; - private static final String ACTION = "ACTION"; - private static final String MODEL_NAME = "MODEL_NAME"; - private static final String SERVICE_SEARCH = "/service/search"; - private static final String MODEL_VERSION = "MODEL_VERSION"; - private static final String MODEL_INVARIANT_UUID = "MODEL_INVARIANT_UUID"; + private static final String CLOUD_SITE = "/cloudSite"; + private static final String CLOUDIFY_MANAGER = "/cloudifyManager"; + private static final String RAINY_DAY_HANDLER_MACRO = "/rainy_day_handler_macro"; + private static final String NORTHBOUND_REQUEST_REF_LOOKUP = "/northbound_request_ref_lookup"; + private static final String NETWORK_RESOURCE_CUSTOMIZATION = "/networkResourceCustomization"; + private static final String COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION = "/collectionResourceInstanceGroupCustomization"; + private static final String VNFC_INSTANCE_GROUP_CUSTOMIZATION = "/vnfcInstanceGroupCustomization"; + private static final String ORCHESTRATION_FLOW = "/orchestrationFlow"; + private static final String ORCHESTRATION_STATUS_STATE_TRANSITION_DIRECTIVE = "/orchestrationStatusStateTransitionDirective"; + private static final String INSTANCE_GROUP = "/instanceGroup"; + private static final String COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION = "/collectionNetworkResourceCustomization"; + private static final String BUILDING_BLOCK_DETAIL = "/buildingBlockDetail"; + private static final String NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION = "/networkCollectionResourceCustomization"; + private static final String VNF_RESOURCE_CUSTOMIZATION = "/vnfResourceCustomization"; + private static final String SERVICE = "/service"; + private static final String VNF_RESOURCE = "/vnfResource"; + private static final String VNF_RECIPE = "/vnfRecipe"; + private static final String VFMODULE = "/vfModule"; + private static final String VFMODULE_CUSTOMIZATION = "/vfModuleCustomization"; + private static final String VNF_COMPONENTS_RECIPE = "/vnfComponentsRecipe"; + private static final String SERVICE_RECIPE = "/serviceRecipe"; + private static final String NETWORK_RECIPE = "/networkRecipe"; + + private static final String SEARCH = "/search"; + private static final String URI_SEPARATOR = "/"; + + private static final String SERVICE_MODEL_UUID = "serviceModelUUID"; + private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; + private static final String ACTION = "action"; + private static final String MODEL_NAME = "modelName"; + private static final String MODEL_VERSION = "modelVersion"; + private static final String MODEL_INVARIANT_UUID = "modelInvariantUUID"; + private static final String MODEL_INSTANCE_NAME = "modelInstanceName"; + private static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID"; + private static final String NF_ROLE = "nfRole"; + private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID"; + private static final String VNF_COMPONENT_TYPE = "vnfComponentType"; + private static final String BUILDING_BLOCK_NAME = "buildingBlockName"; + private static final String RESOURCE_TYPE = "resourceType"; + private static final String ORCHESTRATION_STATUS = "orchestrationStatus"; + private static final String TARGET_ACTION = "targetAction"; + private static final String REQUEST_SCOPE = "requestScope"; + private static final String IS_ALACARTE = "isALaCarte"; + private static final String FLOW_NAME = "flowName"; + private static final String SERVICE_TYPE = "serviceType"; + private static final String VNF_TYPE = "vnfType"; + private static final String ERROR_CODE = "errorCode"; + private static final String WORK_STEP = "workStep"; + private static final String CLLI = "clli"; + private static final String CLOUD_VERSION = "cloudVersion"; + private String findFirstByModelNameURI = "/findFirstByModelNameOrderByModelVersionDesc"; private String findFirstByServiceModelUUIDAndActionURI = "/findFirstByServiceModelUUIDAndAction"; - private String findByModelVersionAndModelInvariantUUIDURI = "/findByModelVersionAndModelInvariantUUID"; - - private Client<Service> serviceClient; + private String findFirstByModelVersionAndModelInvariantUUIDURI = "/findFirstByModelVersionAndModelInvariantUUID"; + private String findByModelInvariantUUIDURI = "/findByModelInvariantUUIDOrderByModelVersionDesc"; + private String findFirstByModelNameAndAction = "/findFirstByModelNameAndAction"; + private String findFirstResourceByModelInvariantUUIDAndModelVersion = "/findFirstResourceByModelInvariantUUIDAndModelVersion"; + private String findByModelInstanceNameAndVnfResources = "/findByModelInstanceNameAndVnfResources"; + private String findFirstVnfRecipeByNfRoleAndAction = "/findFirstVnfRecipeByNfRoleAndAction"; + private String findByModelCustomizationUUIDAndVfModuleModelUUID = "/findByModelCustomizationUUIDAndVfModuleModelUUID"; + private String findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction = "/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"; + private String findFirstVnfComponentsRecipeByVnfComponentTypeAndAction = "/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"; + private String findVfModuleByModelInvariantUUIDOrderByModelVersionDesc = "/findByModelInvariantUUIDOrderByModelVersionDesc"; + private String findFirstVfModuleByModelInvariantUUIDAndModelVersion = "/findFirstVfModuleByModelInvariantUUIDAndModelVersion"; + private String findOneByBuildingBlockName = "/findOneByBuildingBlockName"; + private String findOneByResourceTypeAndOrchestrationStatusAndTargetAction = "/findOneByResourceTypeAndOrchestrationStatusAndTargetAction"; + private String findByAction = "/findByAction"; + private String findVnfcInstanceGroupCustomizationByModelCustomizationUUID = "/findByModelCustomizationUUID"; + private String findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID = "/findByModelCustomizationUUID"; + private String findOneByActionAndRequestScopeAndIsAlacarte = "/findOneByActionAndRequestScopeAndIsAlacarte"; + private String findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = "/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep"; + private String findByClliAndCloudVersion = "/findByClliAndCloudVersion"; - private Client<VfModuleCustomization> vfModuleCustomizationClient; + private String serviceURI; + private String vfModuleURI; + private String vnfResourceURI; + private String vfModuleCustomizationURI; + private String networkCollectionResourceCustomizationURI; + private String networkResourceCustomizationURI; + private String vnfResourceCustomizationURI; + private String collectionNetworkResourceCustomizationURI; + private String instanceGroupURI; + private String cloudifyManagerURI; + private String cloudSiteURI; - private Client<OrchestrationFlow> orchestrationClient; + private final Client<Service> serviceClient; - private Client<NorthBoundRequest> northBoundRequestClient; + private final Client<NetworkRecipe> networkRecipeClient; - private Client<RainyDayHandlerStatus> rainyDayHandlerStatusClient; + private final Client<NetworkResourceCustomization> networkResourceCustomizationClient; - private Client<BuildingBlockDetail> buildingBlockDetailClient; + private final Client<VnfResource> vnfResourceClient; - private Client<OrchestrationStatusStateTransitionDirective> orchestrationStatusStateTransitionDirectiveClient; + private final Client<VnfResourceCustomization> vnfResourceCustomizationClient; - private Client<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizationClient; + private final Client<VnfRecipe> vnfRecipeClient; - private Client<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationClient; + private final Client<VfModuleCustomization> vfModuleCustomizationClient; - private Client<InstanceGroup> instanceGroupClient; - - private Client<NetworkCollectionResourceCustomization> networkCollectionResourceCustomizationClient; - - private Client<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationClient; + private final Client<VfModule> vfModuleClient; + + private final Client<VnfComponentsRecipe> vnfComponentsRecipeClient; + + private final Client<OrchestrationFlow> orchestrationClient; + + private final Client<NorthBoundRequest> northBoundRequestClient; - private Client<ServiceRecipe> serviceRecipeClient; + private final Client<RainyDayHandlerStatus> rainyDayHandlerStatusClient; - private Client<CloudSite> cloudSiteClient; + private final Client<BuildingBlockDetail> buildingBlockDetailClient; - private Client<CloudIdentity> cloudIdentityClient; + private final Client<OrchestrationStatusStateTransitionDirective> orchestrationStatusStateTransitionDirectiveClient; - private Client<CloudifyManager> cloudifyManagerClient; + private final Client<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizationClient; + + private final Client<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationClient; + + private final Client<InstanceGroup> instanceGroupClient; + + private final Client<NetworkCollectionResourceCustomization> networkCollectionResourceCustomizationClient; + + private final Client<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationClient; + + private final Client<ServiceRecipe> serviceRecipeClient; + + private final Client<CloudSite> cloudSiteClient; + + private final Client<CloudifyManager> cloudifyManagerClient; + + private Client<CvnfcCustomization> cvnfcCustomizationClient; + + private final Client<ControllerSelectionReference> controllerSelectionReferenceClient; @Value("${mso.catalog.db.spring.endpoint}") private String endpoint; @@ -111,28 +207,67 @@ public class CatalogDbClient { @Value("${mso.db.auth}") private String msoAdaptersAuth; + @PostConstruct public void init(){ - findFirstByModelNameURI = endpoint + SERVICE_SEARCH + findFirstByModelNameURI; - findByModelVersionAndModelInvariantUUIDURI = endpoint + SERVICE_SEARCH + findByModelVersionAndModelInvariantUUIDURI; - findFirstByServiceModelUUIDAndActionURI = endpoint + SERVICE_RECIPE_SEARCH + findFirstByServiceModelUUIDAndActionURI; + findFirstByModelNameURI = endpoint + SERVICE + SEARCH + findFirstByModelNameURI; + findFirstByModelVersionAndModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findFirstByModelVersionAndModelInvariantUUIDURI; + findByModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findByModelInvariantUUIDURI; + 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; + 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; + findOneByBuildingBlockName = endpoint + BUILDING_BLOCK_DETAIL + SEARCH + findOneByBuildingBlockName; + 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; + 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; + networkResourceCustomizationURI = endpoint + NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR; + vnfResourceCustomizationURI = endpoint + VNF_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; + } public CatalogDbClient() { - ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()); - + ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); + ClientFactory clientFactory = Configuration.builder().setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> { restTemplate.getInterceptors().add((new SpringClientFilter())); - + restTemplate.getInterceptors().add((request, body, execution) -> { - request.getHeaders().add("Authorization", msoAdaptersAuth); + request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); return execution.execute(request, body); }); }).build().buildClientFactory(); serviceClient = clientFactory.create(Service.class); + networkRecipeClient = clientFactory.create(NetworkRecipe.class); + networkResourceCustomizationClient = clientFactory.create(NetworkResourceCustomization.class); + vnfResourceClient = clientFactory.create(VnfResource.class); + vnfResourceCustomizationClient = clientFactory.create(VnfResourceCustomization.class); + vnfRecipeClient = clientFactory.create(VnfRecipe.class); orchestrationClient = clientFactory.create(OrchestrationFlow.class); vfModuleCustomizationClient = clientFactory.create(VfModuleCustomization.class); + vfModuleClient = clientFactory.create(VfModule.class); + vnfComponentsRecipeClient = clientFactory.create(VnfComponentsRecipe.class); northBoundRequestClient = clientFactory.create(NorthBoundRequest.class); rainyDayHandlerStatusClient = clientFactory.create(RainyDayHandlerStatus.class); buildingBlockDetailClient = clientFactory.create(BuildingBlockDetail.class); @@ -145,46 +280,58 @@ public class CatalogDbClient { networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class); collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class); cloudSiteClient = clientFactory.create(CloudSite.class); - cloudIdentityClient = clientFactory.create(CloudIdentity.class); cloudifyManagerClient = clientFactory.create(CloudifyManager.class); serviceRecipeClient = clientFactory.create(ServiceRecipe.class); + cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); + controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class); } - + public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) { - NetworkCollectionResourceCustomization networkCollectionResourceCustomization = - this.getSingleNetworkCollectionResourceCustomization(UriBuilder.fromUri(endpoint + "/networkCollectionResourceCustomization/" + modelCustomizationUUID).build()); + NetworkCollectionResourceCustomization networkCollectionResourceCustomization = + this.getSingleResource(networkCollectionResourceCustomizationClient, getUri(networkCollectionResourceCustomizationURI + modelCustomizationUUID)); if (networkCollectionResourceCustomization != null) { networkCollectionResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); } return networkCollectionResourceCustomization; } - private NetworkCollectionResourceCustomization getSingleNetworkCollectionResourceCustomization(URI uri) { - return networkCollectionResourceCustomizationClient.get(uri); - } - public Service getServiceByID(String modelUUID) { - Service service = this.getSingleService(UriBuilder.fromUri(endpoint + "/service/" + modelUUID).build()); + Service service = getSingleResource(serviceClient,getUri(serviceURI + modelUUID)); if (service != null) { service.setModelUUID(modelUUID); } return service; } - public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) { - BuildingBlockDetail buildingBlockDetail = buildingBlockDetailClient - .get(UriBuilder.fromUri(endpoint + "/buildingBlockDetail/search/findOneByBuildingBlockName") - .queryParam("buildingBlockName", buildingBlockName).build()); - if (buildingBlockDetail != null) { - buildingBlockDetail.setBuildingBlockName(buildingBlockName); + public VfModule getVfModuleByModelUUID(String modelUUID) { + VfModule vfModule = getSingleResource(vfModuleClient,getUri(vfModuleURI + modelUUID)); + if (vfModule != null) { + vfModule.setModelUUID(modelUUID); } - return buildingBlockDetail; + return vfModule; + } + + public VnfResource getVnfResourceByModelUUID(String modelUUID){ + + VnfResource vnfResource = this.getSingleResource(vnfResourceClient, getUri(vnfResourceURI + modelUUID)); + if (vnfResource != null) { + vnfResource.setModelUUID(modelUUID); + } + return vnfResource; + } + + public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationUUID(String modelCustomizationUUID){ + VnfResourceCustomization vnfResourceCustomization = getSingleResource(vnfResourceCustomizationClient, getUri(vnfResourceCustomizationURI + modelCustomizationUUID)); + if (vnfResourceCustomization != null) { + vnfResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); + } + return vnfResourceCustomization; } public CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomizationByID(String modelCustomizationUUID) { - CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = - this.getSingleCollectionNetworkResourceCustomization( - UriBuilder.fromUri(endpoint + "/collectionNetworkResourceCustomization/" + modelCustomizationUUID).build()); + CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = + this.getSingleResource(collectionNetworkResourceCustomizationClient,getUri(UriBuilder + .fromUri(collectionNetworkResourceCustomizationURI + modelCustomizationUUID).build().toString())); if (collectionNetworkResourceCustomization != null) { collectionNetworkResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); } @@ -192,186 +339,223 @@ public class CatalogDbClient { } public InstanceGroup getInstanceGroupByModelUUID(String modelUUID) { - InstanceGroup instanceGroup = this - .getSingleInstanceGroup(UriBuilder.fromUri(endpoint + "/instanceGroup/" + modelUUID).build()); + InstanceGroup instanceGroup = this.getSingleResource(instanceGroupClient, getUri(instanceGroupURI + modelUUID)); if (instanceGroup != null) { instanceGroup.setModelUUID(modelUUID); } return instanceGroup; } - public OrchestrationStatusStateTransitionDirective getOrchestrationStatusStateTransitionDirective( - ResourceType resourceType, OrchestrationStatus orchestrationStatus, OrchestrationAction targetAction) { - return orchestrationStatusStateTransitionDirectiveClient.get(UriBuilder - .fromUri( - endpoint + "/orchestrationStatusStateTransitionDirective/search/findOneByResourceTypeAndOrchestrationStatusAndTargetAction") - .queryParam("resourceType", resourceType.name()) - .queryParam("orchestrationStatus", orchestrationStatus.name()) - .queryParam("targetAction", targetAction.name()).build()); + public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) { + VfModuleCustomization vfModuleCust = this.getSingleResource(vfModuleCustomizationClient, getUri(vfModuleCustomizationURI + modelCustomizationUUID)); + if (vfModuleCust != null) { + vfModuleCust.setModelCustomizationUUID(modelCustomizationUUID); + } + return vfModuleCust; } - public List<OrchestrationFlow> getOrchestrationFlowByAction(String action) { - return this - .getMultipleOrchestrationFlows(UriBuilder.fromUri(endpoint + "/orchestrationFlow/search/findByAction") - .queryParam("COMPOSITE_ACTION", action).build()); + public NetworkResourceCustomization getNetworkResourceCustomizationByModelCustomizationUUID(String modelCustomizationUUID){ + NetworkResourceCustomization networkResourceCustomization = + this.getSingleResource(networkResourceCustomizationClient, getUri(networkResourceCustomizationURI + modelCustomizationUUID)); + if (networkResourceCustomization != null) { + networkResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); + } + return networkResourceCustomization; } - public List<OrchestrationFlow> getAllOrchestrationFlows() { - return this.getMultipleOrchestrationFlows(UriBuilder.fromUri(endpoint + "/orchestrationFlow/").build()); + public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) { + BuildingBlockDetail buildingBlockDetail = getSingleResource(buildingBlockDetailClient, getUri(UriBuilder + .fromUri(findOneByBuildingBlockName).queryParam(BUILDING_BLOCK_NAME, buildingBlockName).build().toString())); + if (buildingBlockDetail != null) { + buildingBlockDetail.setBuildingBlockName(buildingBlockName); + } + return buildingBlockDetail; } - private List<OrchestrationFlow> getMultipleOrchestrationFlows(URI uri) { - Iterable<OrchestrationFlow> orchIterator = orchestrationClient.getAll(uri); - List<OrchestrationFlow> orchList = new ArrayList<>(); - Iterator<OrchestrationFlow> it = orchIterator.iterator(); - it.forEachRemaining(orchList::add); - return orchList; - } - public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupsByVnfResourceCust(String modelCustomizationUUID) { - return this.getMultipleVnfcInstanceGroupCustomizations( - UriBuilder.fromUri(endpoint + "/vnfcInstanceGroupCustomization/search/findByModelCustomizationUUID") - .queryParam("MODEL_CUSTOMIZATION_UUID", modelCustomizationUUID).build()); + public OrchestrationStatusStateTransitionDirective getOrchestrationStatusStateTransitionDirective( + 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()); } - public List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomizationByModelCustUUID( - String modelCustomizationUUID) { - return this.getMultipleCollectionResourceInstanceGroupCustomizations(UriBuilder - .fromUri(endpoint + "/collectionResourceInstanceGroupCustomization/search/findByModelCustomizationUUID") - .queryParam("MODEL_CUSTOMIZATION_UUID", modelCustomizationUUID).build()); + public List<OrchestrationFlow> getOrchestrationFlowByAction(String action) { + return this.getMultipleResources(orchestrationClient, UriBuilder + .fromUri(findByAction).queryParam(ACTION, action).build()); } - private List<CollectionResourceInstanceGroupCustomization> getMultipleCollectionResourceInstanceGroupCustomizations( - URI uri) { - Iterable<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustIter = collectionResourceInstanceGroupCustomizationClient - .getAll(uri); - List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustList = new ArrayList<>(); - Iterator<CollectionResourceInstanceGroupCustomization> it = collectionInstanceGroupCustIter.iterator(); - it.forEachRemaining(collectionInstanceGroupCustList::add); - return collectionInstanceGroupCustList; + public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupsByVnfResourceCust(String modelCustomizationUUID) { + return this.getMultipleResources(vnfcInstanceGroupCustomizationClient, UriBuilder + .fromUri(findVnfcInstanceGroupCustomizationByModelCustomizationUUID) + .queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build()); } - private List<VnfcInstanceGroupCustomization> getMultipleVnfcInstanceGroupCustomizations(URI uri) { - Iterable<VnfcInstanceGroupCustomization> vnfcIterator = vnfcInstanceGroupCustomizationClient.getAll(uri); - List<VnfcInstanceGroupCustomization> vnfcList = new ArrayList<>(); - Iterator<VnfcInstanceGroupCustomization> it = vnfcIterator.iterator(); - it.forEachRemaining(vnfcList::add); - return vnfcList; + public List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomizationByModelCustUUID( + String modelCustomizationUUID) { + return this.getMultipleResources(collectionResourceInstanceGroupCustomizationClient, UriBuilder + .fromUri(findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID) + .queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build()); } - public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) { - VfModuleCustomization vfModuleCust = this.getSingleVfModuleCustomization( - UriBuilder.fromUri(endpoint + "/vfModuleCustomization/" + modelCustomizationUUID).build()); - if (vfModuleCust != null) { - vfModuleCust.setModelCustomizationUUID(modelCustomizationUUID); - } - return vfModuleCust; + 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())); } public NorthBoundRequest getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(String requestAction, String resourceName, boolean aLaCarte) { - return this.getSingleNorthBoundRequest(UriBuilder - .fromUri(endpoint + "/northbound_request_ref_lookup/search/findOneByActionAndRequestScopeAndIsAlacarte") - .queryParam("ACTION", requestAction).queryParam("REQUEST_SCOPE", resourceName) - .queryParam("IS_ALACARTE", aLaCarte).build()); + return this.getSingleResource(northBoundRequestClient, UriBuilder + .fromUri(findOneByActionAndRequestScopeAndIsAlacarte) + .queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName) + .queryParam(IS_ALACARTE, aLaCarte).build()); } public RainyDayHandlerStatus getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( String flowName, String serviceType, String vnfType, String errorCode, String workStep) { - return this.getSingleRainyDayHandlerStatus(UriBuilder - .fromUri( - endpoint + "/rainy_day_handler_macro/search/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep") - .queryParam("FLOW_NAME", flowName).queryParam("SERVICE_TYPE", serviceType) - .queryParam("VNF_TYPE", vnfType).queryParam("ERROR_CODE", errorCode).queryParam("WORK_STEP", workStep) + return this.getSingleResource(rainyDayHandlerStatusClient, UriBuilder + .fromUri(findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep) + .queryParam(FLOW_NAME, flowName).queryParam(SERVICE_TYPE, serviceType) + .queryParam(VNF_TYPE, vnfType).queryParam(ERROR_CODE, errorCode).queryParam(WORK_STEP, workStep) .build()); } - + public ServiceRecipe getFirstByServiceModelUUIDAndAction(String modelUUID, String action){ - return this.getSingleServiceRecipe(UriBuilder.fromUri(findFirstByServiceModelUUIDAndActionURI) + return this.getSingleResource(serviceRecipeClient, getUri(UriBuilder + .fromUri(findFirstByServiceModelUUIDAndActionURI) .queryParam(SERVICE_MODEL_UUID,modelUUID) - .queryParam(ACTION,action) - .build()); + .queryParam(ACTION,action).build().toString())); } - - public Service getFirstByModelNameOrderByModelVersionDesc(String modelName){ - return this.getSingleService(UriBuilder.fromUri(findFirstByModelNameURI) + + public NetworkRecipe getFirstNetworkRecipeByModelNameAndAction(String modelName, String action){ + return this.getSingleResource(networkRecipeClient, UriBuilder + .fromUri(findFirstByModelNameAndAction) .queryParam(MODEL_NAME,modelName) - .build()); + .queryParam(ACTION,action).build()); } - - private CollectionNetworkResourceCustomization getSingleCollectionNetworkResourceCustomization(URI uri) { - return collectionNetworkResourceCustomizationClient.get(uri); + 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()); } - public CloudifyManager getCloudifyManager(String id) { - return this.getSingleCloudifyManager(UriBuilder.fromUri(endpoint+"/cloudifyManager/"+id).build()); + public Service getFirstByModelNameOrderByModelVersionDesc(String modelName){ + return this.getSingleResource(serviceClient,UriBuilder + .fromUri(findFirstByModelNameURI) + .queryParam(MODEL_NAME,modelName).build()); } - - public CloudSite getCloudSite(String id){ - return this.getSinglCloudSite(UriBuilder.fromUri(endpoint+"/cloudSite/"+id).build()); + + + 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())); } - - public CloudIdentity getCloudIdentity(String id){ - return this.getSingleCloudIdentity(UriBuilder.fromUri(endpoint+"/cloudIdentity/"+id).build()); + + + 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())); } - - public CloudSite getCloudSiteByClliAndAicVersion (String clli, String aicVersion){ - return this.getSinglCloudSite(UriBuilder.fromUri(endpoint+"/cloud_sites/search/findByClliAndCloudVersion") - .queryParam("CLLI",clli).queryParam("AIC_VERSION",aicVersion) - .build()); + + public VnfRecipe getFirstVnfRecipeByNfRoleAndAction(String nfRole, String action){ + return this.getSingleResource(vnfRecipeClient,getUri(UriBuilder + .fromUri(findFirstVnfRecipeByNfRoleAndAction) + .queryParam(NF_ROLE,nfRole) + .queryParam(ACTION,action).build().toString())); } - private InstanceGroup getSingleInstanceGroup(URI uri) { - return instanceGroupClient.get(uri); + 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())); } - private Service getSingleService(URI uri) { - return serviceClient.get(uri); + 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){ + return URI.create(template); } - private VfModuleCustomization getSingleVfModuleCustomization(URI uri) { - return vfModuleCustomizationClient.get(uri); + public CloudifyManager getCloudifyManager(String id) { + return this.getSingleResource(cloudifyManagerClient,getUri(cloudifyManagerURI + id)); } - private NorthBoundRequest getSingleNorthBoundRequest(URI uri) { - return northBoundRequestClient.get(uri); + public CloudSite getCloudSite(String id){ + return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id)); } - private RainyDayHandlerStatus getSingleRainyDayHandlerStatus(URI uri) { - return rainyDayHandlerStatusClient.get(uri); + public CloudSite getCloudSiteByClliAndAicVersion (String clli, String cloudVersion){ + return this.getSingleResource(cloudSiteClient, getUri(UriBuilder + .fromUri(findByClliAndCloudVersion) + .queryParam(CLLI,clli).queryParam(CLOUD_VERSION,cloudVersion).build().toString())); } - - private ServiceRecipe getSingleServiceRecipe(URI uri){ - return serviceRecipeClient.get(uri); + + 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())); } - protected CloudSite getSinglCloudSite(URI uri) { - return cloudSiteClient.get(uri); + 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())); } - protected CloudIdentity getSingleCloudIdentity(URI uri) { - return cloudIdentityClient.get(uri); + public List<Service> getServiceByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID) { + return this.getMultipleResources(serviceClient, getUri(UriBuilder + .fromUri(findByModelInvariantUUIDURI) + .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); } - protected CloudifyManager getSingleCloudifyManager(URI uri) { - return cloudifyManagerClient.get(uri); + public List<VfModule> getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID) { + return this.getMultipleResources(vfModuleClient, getUri(UriBuilder + .fromUri(findVfModuleByModelInvariantUUIDOrderByModelVersionDesc) + .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString())); } - public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) { - return this.getSingleService( - UriBuilder.fromUri(findByModelVersionAndModelInvariantUUIDURI) - .queryParam(MODEL_VERSION, modelVersion) - .queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build()); + private <T> T getSingleResource(Client<T> client, URI uri) { + return client.get(uri); } - //USED FOR TEST ONLY - public void setPortToEndpoint(String port) { - endpoint = endpoint + port; + private <T> List<T> getMultipleResources(Client<T> client, URI uri) { + Iterable<T> iterator = client.getAll(uri); + List<T> list = new ArrayList<>(); + Iterator<T> it = iterator.iterator(); + it.forEachRemaining(list::add); + return list; + } + + public List<CvnfcCustomization> getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(String vnfCustomizationUUID, String vfModuleCustomizationUUID){ + return this.getMultipleVnfcCustomizations( + UriBuilder.fromUri(endpoint + "/vnfcCustomization/search/findByVnfCustomizationUUIDAndVfModuleCustomizationUUID") + .queryParam("VNF_CUSTOMIZATION_UUID", vnfCustomizationUUID) + .queryParam("VFMODULE_CUSTOMIZATION_UUID", vfModuleCustomizationUUID).build()); } - //USED FOR TEST ONLY - public void removePortFromEndpoint() { - endpoint = endpoint.substring(0, endpoint.lastIndexOf(':') + 1); + private List<CvnfcCustomization> getMultipleVnfcCustomizations(URI uri) { + Iterable<CvnfcCustomization> vnfcIterator = cvnfcCustomizationClient.getAll(uri); + List<CvnfcCustomization> vnfcList = new ArrayList<>(); + Iterator<CvnfcCustomization> it = vnfcIterator.iterator(); + it.forEachRemaining(vnfcList::add); + return vnfcList; } + } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java index 58058da380..1241dac4ee 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java @@ -27,5 +27,5 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "arRecipe", path = "arRecipe") public interface ArRecipeRepository extends JpaRepository<ArRecipe, String> { - public ArRecipe findByModelNameAndAction(String modelName, String action); + ArRecipe findByModelNameAndAction(String modelName, String action); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BuildingBlockDetailRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BuildingBlockDetailRepository.java index 79ad9c77d1..d86377127c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BuildingBlockDetailRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BuildingBlockDetailRepository.java @@ -22,10 +22,9 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "buildingBlockDetail", path = "buildingBlockDetail") public interface BuildingBlockDetailRepository extends JpaRepository<BuildingBlockDetail, String> { - BuildingBlockDetail findOneByBuildingBlockName(@Param("buildingBlockName") String buildingBlockName); + BuildingBlockDetail findOneByBuildingBlockName(String buildingBlockName); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudSiteRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudSiteRepository.java index 78f117b3ae..fc5a95769d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudSiteRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudSiteRepository.java @@ -1,3 +1,23 @@ +/*- + * ============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.data.repository; import org.onap.so.db.catalog.beans.CloudSite; @@ -10,5 +30,5 @@ import javax.transaction.Transactional; @Transactional public interface CloudSiteRepository extends JpaRepository<CloudSite, String> { - CloudSite findByClliAndCloudVersion(String clli, String aicVersion); + CloudSite findByClliAndCloudVersion(String clli,String cloudVersion); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepository.java index dfa677b402..3d2ecea2d6 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepository.java @@ -1,3 +1,23 @@ +/*- + * ============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.data.repository; import org.onap.so.db.catalog.beans.CloudifyManager; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepository.java index 79efe644bd..d27dce161e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepository.java @@ -26,4 +26,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "collectionNetworkResourceCustomization", path = "collectionNetworkResourceCustomization") public interface CollectionNetworkResourceCustomizationRepository extends JpaRepository<CollectionNetworkResourceCustomization, String> { + + CollectionNetworkResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUUID); + }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ControllerSelectionReferenceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ControllerSelectionReferenceRepository.java new file mode 100644 index 0000000000..ad162b547a --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ControllerSelectionReferenceRepository.java @@ -0,0 +1,35 @@ +/*- + * ============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.data.repository; + + +import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + + @RepositoryRestResource(collectionResourceRel = "controllerSelectionReference", path = "controllerSelectionReference") + public interface ControllerSelectionReferenceRepository extends JpaRepository<ControllerSelectionReference, String> { + + public ControllerSelectionReference findControllerSelectionReferenceByVnfTypeAndActionCategory(@Param("VNF_TYPE") String vnfType, + @Param("ACTION_CATEGORY") String actionCategory); + + } 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 new file mode 100644 index 0000000000..3eeef07c97 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepository.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.data.repository; + +import java.util.List; + +import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.data.projections.InlineVnf; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "cvnfcCustomization", path = "cvnfcCustomization", excerptProjection = InlineVnf.class) +public interface CvnfcCustomizationRepository extends JpaRepository<CvnfcCustomization, String> { + CvnfcCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid); + List<CvnfcCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); + 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/ModelRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRecipeRepository.java index 6ad1c64196..c54331b43d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRecipeRepository.java @@ -28,6 +28,6 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; public interface ModelRecipeRepository extends JpaRepository<ModelRecipe, Integer> { - public ModelRecipe findByModelIdAndAction(String modelId, String action); + ModelRecipe findByModelIdAndAction(String modelId, String action); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRepository.java index 4ace731817..e6e2904d43 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRepository.java @@ -28,6 +28,6 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; public interface ModelRepository extends JpaRepository<Model, Integer> { - public Model findByModelVersionIdAndModelType(String modelVersionid, String modelType); + Model findByModelVersionIdAndModelType(String modelVersionid, String modelType); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java index 3fb7d7aa19..10290b5877 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java @@ -26,5 +26,5 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "networkRecipe", path = "networkRecipe") public interface NetworkRecipeRepository extends JpaRepository<NetworkRecipe, String> { - NetworkRecipe findByModelNameAndAction(String modelName, String action); + NetworkRecipe findFirstByModelNameAndAction(String modelName, String action); }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java index 842c888091..94c57945d1 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java @@ -21,8 +21,6 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.NetworkResource; -import org.onap.so.db.catalog.beans.NetworkResourceCustomization; -import org.onap.so.db.catalog.beans.VnfResource; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @@ -38,6 +36,6 @@ public interface NetworkResourceRepository extends JpaRepository<NetworkResource @Query(value = "SELECT * FROM network_resource WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true) NetworkResource findFirstByModelNameOrderByModelVersionDesc(String modelName); - public NetworkResource findResourceByModelUUID(String modelUUID); + NetworkResource findResourceByModelUUID(String modelUUID); NetworkResource findOneByModelName(String modelName); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NorthBoundRequestRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NorthBoundRequestRepository.java index b568d6c09b..92a46d51f7 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NorthBoundRequestRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NorthBoundRequestRepository.java @@ -22,11 +22,9 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "northbound_request_ref_lookup", path = "northbound_request_ref_lookup") public interface NorthBoundRequestRepository extends JpaRepository<NorthBoundRequest, Integer> { - NorthBoundRequest findOneByActionAndRequestScopeAndIsAlacarte(@Param("ACTION") String action, - @Param("REQUEST_SCOPE") String requestScope, @Param("IS_ALACARTE") Boolean isALaCarte); + NorthBoundRequest findOneByActionAndRequestScopeAndIsAlacarte(String action, String requestScope, Boolean isALaCarte); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationFlowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationFlowRepository.java index db9cd745db..12fbc418f7 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationFlowRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationFlowRepository.java @@ -20,16 +20,15 @@ package org.onap.so.db.catalog.data.repository; -import java.util.List; - import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import java.util.List; + @RepositoryRestResource(collectionResourceRel = "orchestrationFlow", path = "orchestrationFlow") public interface OrchestrationFlowRepository extends JpaRepository<OrchestrationFlow, Integer> { - List<OrchestrationFlow> findByAction(@Param("COMPOSITE_ACTION") String action); + List<OrchestrationFlow> findByAction(String action); - OrchestrationFlow findOneByAction(@Param("COMPOSITE_ACTION") String action); + OrchestrationFlow findOneByAction(String action); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationStatusStateTransitionDirectiveRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationStatusStateTransitionDirectiveRepository.java index ab728f46bf..e88480a022 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationStatusStateTransitionDirectiveRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationStatusStateTransitionDirectiveRepository.java @@ -25,10 +25,9 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; import org.onap.so.db.catalog.beans.ResourceType; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "orchestrationStatusStateTransitionDirective", path = "orchestrationStatusStateTransitionDirective") public interface OrchestrationStatusStateTransitionDirectiveRepository extends JpaRepository<OrchestrationStatusStateTransitionDirective, String> { - OrchestrationStatusStateTransitionDirective findOneByResourceTypeAndOrchestrationStatusAndTargetAction(@Param("resourceType") ResourceType resourceType, @Param("orchestrationStatus") OrchestrationStatus orchestrationStatus, @Param("targetAction") OrchestrationAction targetAction); + OrchestrationStatusStateTransitionDirective findOneByResourceTypeAndOrchestrationStatusAndTargetAction(ResourceType resourceType, OrchestrationStatus orchestrationStatus, OrchestrationAction targetAction); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java index 283c9623c8..5039384845 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java @@ -22,13 +22,10 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "rainy_day_handler_macro", path = "rainy_day_handler_macro") public interface RainyDayHandlerStatusRepository extends JpaRepository<RainyDayHandlerStatus, Integer> { RainyDayHandlerStatus findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - @Param("FLOW_NAME") String flowName, @Param("SERVICE_TYPE") String serviceType, - @Param("VNF_TYPE") String vnfType, @Param("ERROR_CODE") String errorCode, - @Param("WORK_STEP") String workStep); + String flowName, String serviceType, String vnfType, String errorCode, String workStep); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java index cd46846d78..40ab1704fd 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java @@ -22,14 +22,13 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "serviceRecipe", path = "serviceRecipe") public interface ServiceRecipeRepository extends JpaRepository<ServiceRecipe, Long> { - public ServiceRecipe findByActionAndServiceModelUUID(String action, String serviceModelUUID); + ServiceRecipe findByActionAndServiceModelUUID(String action, String serviceModelUUID); - public ServiceRecipe findByAction(String action); + ServiceRecipe findByAction(String action); - public ServiceRecipe findFirstByServiceModelUUIDAndAction(@Param("SERVICE_MODEL_UUID") String serviceModelUUID, @Param("ACTION") String action); + ServiceRecipe findFirstByServiceModelUUIDAndAction(String serviceModelUUID, String action); }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java index 25b1757185..6d432c443c 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java @@ -20,15 +20,14 @@ package org.onap.so.db.catalog.data.repository; -import java.util.List; - import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.data.projections.InlineService; 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; +import java.util.List; + @RepositoryRestResource(collectionResourceRel = "service", path = "service", excerptProjection = InlineService.class) public interface ServiceRepository extends JpaRepository<Service, String> { List<Service> findByModelName(String modelName); @@ -41,7 +40,7 @@ public interface ServiceRepository extends JpaRepository<Service, String> { * @return */ @Query(value = "SELECT * FROM service WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true) - Service findFirstByModelNameOrderByModelVersionDesc(@Param("MODEL_NAME") String modelName); + Service findFirstByModelNameOrderByModelVersionDesc(String modelName); /** * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting @@ -73,8 +72,7 @@ public interface ServiceRepository extends JpaRepository<Service, String> { @Query(value = "SELECT * FROM service WHERE MODEL_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;", nativeQuery = true) Service findOneByModelUUIDOrderByModelVersionDesc(String modelUUID); - Service findByModelVersionAndModelInvariantUUID(@Param("MODEL_VERSION") String modelVersion, - @Param("MODEL_INVARIANT_UUID") String modelInvariantUUID); + Service findFirstByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID); /** * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting @@ -90,9 +88,9 @@ public interface ServiceRepository extends JpaRepository<Service, String> { /** * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting - * @param modelInvariantId + * @param modelInvariantUUID * @return */ @Query(value = "SELECT * FROM service WHERE MODEL_INVARIANT_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC;", nativeQuery = true) - List<Service> findByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantId); + List<Service> findByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID); }
\ 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 6b403b312e..cd985dba9f 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 @@ -20,25 +20,24 @@ package org.onap.so.db.catalog.data.repository; -import java.util.List; - import org.onap.so.db.catalog.beans.VfModule; 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; +import java.util.List; + @RepositoryRestResource(collectionResourceRel = "vfModule", path = "vfModule") public interface VFModuleRepository extends JpaRepository<VfModule, String> { VfModule findByModelUUID(String modelUUID); - VfModule findByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion); + VfModule findFirstVfModuleByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion); VfModule findByModelName(String modelName); /** * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting - * @param modelInvariantUUID + * @param modelName * @return */ @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) @@ -46,7 +45,7 @@ public interface VFModuleRepository extends JpaRepository<VfModule, String> { VfModule findByModelInvariantUUIDAndModelUUID(String modelCustomizationUUID, String modelUUID); - VfModule findByModelInvariantUUID(@Param("ACTION") String modelCustomizationUUID); + VfModule findByModelInvariantUUID(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/VnfComponentRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfComponentRecipeRepository.java index 822ac44be2..440a675c97 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfComponentRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfComponentRecipeRepository.java @@ -27,13 +27,13 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "vnfComponentsRecipe", path = "vnfComponentsRecipe") public interface VnfComponentRecipeRepository extends JpaRepository<VnfComponentsRecipe, String> { - VnfComponentsRecipe findVnfComponentsRecipeByVfModuleModelUUIDAndVnfTypeAndAction(String vfModuleModelUUID, + VnfComponentsRecipe findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfTypeAndAction(String vfModuleModelUUID, String vnfType, String action); - VnfComponentsRecipe findVnfComponentsRecipeByVnfTypeAndAction(String vnfType, String action); + VnfComponentsRecipe findFirstVnfComponentsRecipeByVnfTypeAndAction(String vnfType, String action); - VnfComponentsRecipe findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(String modelUUID, + VnfComponentsRecipe findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(String vfModuleModelUUID, String vnfComponentType, String action); - VnfComponentsRecipe findVnfComponentsRecipeByVnfComponentTypeAndAction(String vnfComponentType, String action); + VnfComponentsRecipe findFirstVnfComponentsRecipeByVnfComponentTypeAndAction(String vnfComponentType, String action); }
\ No newline at end of file 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 0d9ac2b33d..46a4cfba11 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 @@ -20,20 +20,21 @@ package org.onap.so.db.catalog.data.repository; -import java.util.List; - -import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.data.projections.InlineVnf; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import java.util.List; + @RepositoryRestResource(collectionResourceRel = "vnfResourceCustomization", path = "vnfResourceCustomization", excerptProjection = InlineVnf.class) public interface VnfCustomizationRepository extends JpaRepository<VnfResourceCustomization, String> { List<VnfResourceCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); VnfResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid); - VnfResourceCustomization findByModelInstanceNameAndVnfResources(String modelInstanceName, VnfResource vnfResource); + @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); }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java index 97d6669c58..dbc86cbb8f 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java @@ -28,5 +28,5 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; public interface VnfRecipeRepository extends JpaRepository<VnfRecipe, String> { VnfRecipe findVnfRecipeByServiceTypeAndAction(String serviceType, String action); - VnfRecipe findVnfRecipeByNfRoleAndAction(String nfRole, String action); + VnfRecipe findFirstVnfRecipeByNfRoleAndAction(String nfRole, String action); }
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfResourceRepository.java index 5b0258238e..e48f8bb653 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfResourceRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfResourceRepository.java @@ -35,7 +35,7 @@ public interface VnfResourceRepository extends JpaRepository<VnfResource, String VnfResource findResourceByModelUUID(String modelUUID); - VnfResource findResourceByModelInvariantUUID(String modelInvariantId); + VnfResource findResourceByModelInvariantUUID(String modelInvariantUUID); - VnfResource findResourceByModelInvariantUUIDAndModelVersion(String relatedInstanceModelInvariantId, String relatedInstanceVersion); + VnfResource findFirstResourceByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion); }
\ No newline at end of file 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/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java new file mode 100644 index 0000000000..f936933485 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepository.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.data.repository; + +import java.util.List; + +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; +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> { + List<VnfVfmoduleCvnfcConfigurationCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepository.java new file mode 100644 index 0000000000..4ccbf5831f --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepository.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.data.repository; + +import org.onap.so.db.catalog.beans.VnfcCustomization; +import org.onap.so.db.catalog.data.projections.InlineVnf; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "vnfcCustomization", path = "vnfcCustomization") +public interface VnfcCustomizationRepository extends JpaRepository<VnfcCustomization, String> { + VnfcCustomization findOneByModelCustomizationUUID(String modelCustomizationUuid); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/test/java/org/onap/so/BaseTest.java b/mso-catalog-db/src/test/java/org/onap/so/BaseTest.java deleted file mode 100644 index 6e6db11c45..0000000000 --- a/mso-catalog-db/src/test/java/org/onap/so/BaseTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.onap.so; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class BaseTest { - @Test - public void testNothing(){} -} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java new file mode 100644 index 0000000000..5bfa300a03 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java @@ -0,0 +1,84 @@ +/*- + * ============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; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.beans.VnfResource; +import org.onap.so.db.catalog.beans.VnfcCustomization; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class BaseTest { + + protected VnfcCustomization setUpVnfcCustomization(){ + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + vnfcCustomization.setModelInstanceName("testVnfcCustomizationModelInstanceName"); + vnfcCustomization.setModelUUID("321228a4-9f15-11e8-98d0-529269fb1459"); + vnfcCustomization.setModelInvariantUUID("c0659136-9f15-11e8-98d0-529269fb1459"); + vnfcCustomization.setModelVersion("testModelVersion"); + vnfcCustomization.setModelName("testModelName"); + vnfcCustomization.setToscaNodeType("testToscaModelType"); + vnfcCustomization.setDescription("testVnfcCustomizationDescription"); + return vnfcCustomization; + } + + protected CvnfcCustomization setUpCvnfcCustomization(){ + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization.setModelInstanceName("cvfncCustomizationTestModelInstanceName"); + cvnfcCustomization.setModelUUID("321228a4-9f15-11e8-98d0-529269fb1459"); + cvnfcCustomization.setModelInvariantUUID("c0659136-9f15-11e8-98d0-529269fb1459"); + cvnfcCustomization.setModelVersion("testModelVersion"); + cvnfcCustomization.setModelName("testModelName"); + cvnfcCustomization.setToscaNodeType("testToscaNodeType"); + cvnfcCustomization.setDescription("description"); + cvnfcCustomization.setNfcFunction("testNfcFunction"); + cvnfcCustomization.setNfcNamingCode("testNfcNamingCode"); + return cvnfcCustomization; + } + + protected VfModule setUpVfModule(){ + VfModule vFModule = new VfModule(); + vFModule.setModelUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); + vFModule.setModelVersion("testModelVersion"); + vFModule.setModelName("testModelName"); + vFModule.setIsBase(false); + return vFModule; + } + + protected VnfResource setUpVnfResource(){ + VnfResource vnfResource = new VnfResource(); + vnfResource.setModelUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); + vnfResource.setModelInvariantUUID("az82ffd8-252a-11e7-93ae-92361f002677"); + vnfResource.setModelVersion("testModelVersion"); + vnfResource.setOrchestrationMode("HEAT"); + return vnfResource; + } + + @Test + public void testNothing(){} +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java index 7a9fc19fcb..73f1ef49fa 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.ResourceType; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java new file mode 100644 index 0000000000..489f8a0a3d --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import org.onap.so.db.catalog.data.repository.ControllerSelectionReferenceRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class ControllerSelectionReferenceTest { + + @Autowired + private ControllerSelectionReferenceRepository controllerSelectionReferenceRepository; + + @Test + public void Find_ControllerNameByVnfTypeAndAction_Test() { + String vnfType = "vLoadBalancerMS/vLoadBalancerMS 0"; + String controllerName = "APPC"; + String actionCategory = "ConfigScaleOut"; + ControllerSelectionReference controller = + controllerSelectionReferenceRepository.findControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory); + assertEquals(vnfType, controller.getVnfType()); + assertEquals(controllerName, controller.getControllerName()); + assertEquals(actionCategory, controller.getActionCategory()); + } + + @Test + public final void controllerDataTest() { + ControllerSelectionReference controller = new ControllerSelectionReference(); + + controller.setVnfType("vnfType"); + assertTrue(controller.getVnfType().equalsIgnoreCase("vnfType")); + + controller.setControllerName("controllerName"); + assertTrue(controller.getControllerName().equalsIgnoreCase("controllerName")); + + controller.setActionCategory("actionCategory"); + assertTrue(controller.getActionCategory().equalsIgnoreCase("actionCategory")); + } +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java index 60f8de6c2e..147de51c67 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so; +package org.onap.so.db.catalog; import ch.vorburger.exec.ManagedProcessException; import ch.vorburger.mariadb4j.DBConfigurationBuilder; import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java index 55c5c8351b..456c826d19 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java index 52cac88402..b6aa408185 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java index 0ecaa5fbba..ffa56a9ce3 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java @@ -26,7 +26,6 @@ import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.data.repository.ServiceRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java index 6ee88e407d..0226b86739 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so; +package org.onap.so.db.catalog; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -26,9 +26,9 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Profile; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -@SpringBootApplication(scanBasePackages = { "org.onap"}) +@SpringBootApplication(scanBasePackages = { "org.onap.so.db.catalog"}) @EnableJpaRepositories("org.onap.so.db.catalog.data.repository") -@EntityScan("org.onap.so.db.catalog.beans") +@EntityScan("org.onap.so.db.catalog") @Profile("test") public class TestApplication { private static final String LOGS_DIR = "logs_dir"; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java index 44e7a03855..1f13bd946a 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java @@ -26,7 +26,6 @@ import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.data.repository.VFModuleRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java new file mode 100644 index 0000000000..7ec28205d6 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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 static org.junit.Assert.assertTrue; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.Test; + +public class CvnfcCustomizationTest { + + private static final Integer ID = new Integer(1); + private static final String DESCRIPTION = "testDescription"; + private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; + private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; + private static final String MODEL_INVARIANT_UUID = "testModelInvariantUUID"; + private static final String MODEL_NAME = "testModelName"; + private static final String MODEL_UUID = "testModelUUID"; + private static final String MODEL_VERSION = "testModelVersion"; + private static final String TOSCA_NODE_TYPE = "testToscaNodeType"; + private static final String NFC_FUNCTION = "testNfcFunction"; + private static final String NFC_NAMING_CODE = "testNfcNamingCode"; + + @Test + public final void testCvnfcCustomization () { + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization.setDescription(DESCRIPTION); + cvnfcCustomization.setId(ID); + cvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + cvnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + cvnfcCustomization.setModelInvariantUUID(MODEL_INVARIANT_UUID); + cvnfcCustomization.setModelName(MODEL_NAME); + cvnfcCustomization.setModelUUID(MODEL_UUID); + cvnfcCustomization.setModelVersion(MODEL_VERSION); + cvnfcCustomization.setNfcFunction(NFC_FUNCTION); + cvnfcCustomization.setNfcNamingCode(NFC_NAMING_CODE); + cvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); + cvnfcCustomization.setVfModuleCustomization(setupVfModuleCustomization()); + cvnfcCustomization.setVnfcCustomization(setupVnfcCustomization()); + cvnfcCustomization.setVnfResourceCustomization(setupVnfResourceCustomization()); + Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizationSet = new HashSet(); + vnfVfmoduleCvnfcConfigurationCustomizationSet.add(setupVnfVfmoduleCvnfcConfigurationCustomization()); + cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizationSet); + + assertTrue (cvnfcCustomization.getId().equals (new Integer(1))); + assertTrue (cvnfcCustomization.getDescription().equals (DESCRIPTION)); + assertTrue (cvnfcCustomization.getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue (cvnfcCustomization.getModelInstanceName().equals (MODEL_INSTANCE_NAME)); + assertTrue (cvnfcCustomization.getModelInvariantUUID().equals (MODEL_INVARIANT_UUID)); + assertTrue (cvnfcCustomization.getModelName().equals (MODEL_NAME)); + assertTrue (cvnfcCustomization.getModelUUID().equals (MODEL_UUID)); + assertTrue (cvnfcCustomization.getModelVersion().equals (MODEL_VERSION)); + assertTrue (cvnfcCustomization.getNfcFunction().equals (NFC_FUNCTION)); + assertTrue (cvnfcCustomization.getNfcNamingCode().equals (NFC_NAMING_CODE)); + assertTrue (cvnfcCustomization.getToscaNodeType().equals (TOSCA_NODE_TYPE)); + assertTrue (cvnfcCustomization.getVnfcCustomization().getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue (cvnfcCustomization.getVfModuleCustomization().getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + } + + private VfModuleCustomization setupVfModuleCustomization(){ + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vfModuleCustomization; + } + + private VnfcCustomization setupVnfcCustomization(){ + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vnfcCustomization; + } + + private VnfResourceCustomization setupVnfResourceCustomization(){ + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vnfResourceCustomization; + } + + private VnfVfmoduleCvnfcConfigurationCustomization setupVnfVfmoduleCvnfcConfigurationCustomization(){ + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + vnfVfmoduleCvnfcConfigurationCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vnfVfmoduleCvnfcConfigurationCustomization; + } +}
\ No newline at end of file diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomizationTest.java new file mode 100644 index 0000000000..b3ad06cca4 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfVfmoduleCvnfcConfigurationCustomizationTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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 static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class VnfVfmoduleCvnfcConfigurationCustomizationTest { + + private static final String CONFIGURATION_FUNCTION = "testconfigurationFunction"; + private static final String CONFIGURATION_ROLE = "testconfigurationRole"; + private static final String CONFIGURATION_TYPE = "testconfigurationType"; + private static final Integer ID = new Integer(1); + private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; + private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; + private static final String MODEL_UUID = "testModelUUID"; + private static final String POLICY_NAME = "testPolicyName"; + + @Test + public final void testVnfVfmoduleCvnfcConfigurationCustomization () { + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationFunction(CONFIGURATION_FUNCTION); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(setupConfigurationResource()); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationRole(CONFIGURATION_ROLE); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationType(CONFIGURATION_TYPE); + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization); + vnfVfmoduleCvnfcConfigurationCustomization.setId(ID); + vnfVfmoduleCvnfcConfigurationCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + vnfVfmoduleCvnfcConfigurationCustomization.setPolicyName(POLICY_NAME); + + vnfVfmoduleCvnfcConfigurationCustomization.setVfModuleCustomization(setupVfModuleCustomization()); + vnfVfmoduleCvnfcConfigurationCustomization.setVnfResourceCustomization(setupVnfResourceCustomization()); + + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getId().equals (new Integer(1))); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationFunction().equals (CONFIGURATION_FUNCTION)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationRole().equals (CONFIGURATION_ROLE)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationType().equals (CONFIGURATION_TYPE)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getModelInstanceName().equals (MODEL_INSTANCE_NAME)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName().equals (POLICY_NAME)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getCvnfcCustomization().getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getVnfResourceCustomization().getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getVfModuleCustomization().getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + } + + private VfModuleCustomization setupVfModuleCustomization(){ + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vfModuleCustomization; + } + + private VnfResourceCustomization setupVnfResourceCustomization(){ + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vnfResourceCustomization; + } + + private ConfigurationResource setupConfigurationResource(){ + ConfigurationResource configurationResource = new ConfigurationResource(); + configurationResource.setModelUUID(MODEL_UUID); + return configurationResource; + } +}
\ No newline at end of file diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfcCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfcCustomizationTest.java new file mode 100644 index 0000000000..2a315d83b6 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfcCustomizationTest.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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 static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class VnfcCustomizationTest { + + private static final String DESCRIPTION = "testDescription"; + private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; + private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; + private static final String MODEL_INVARIANT_UUID = "testModelInvariantUUID"; + private static final String MODEL_NAME = "testModelName"; + private static final String MODEL_UUID = "testModelUUID"; + private static final String MODEL_VERSION = "testModelVersion"; + private static final String TOSCA_NODE_TYPE = "testToscaNodeType"; + + @Test + public final void testVnfcCustomization () { + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + vnfcCustomization.setCvnfcCustomization(setupCvnfcCustomizationList()); + vnfcCustomization.setDescription(DESCRIPTION); + vnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + vnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + vnfcCustomization.setModelInvariantUUID(MODEL_INVARIANT_UUID); + vnfcCustomization.setModelName(MODEL_NAME); + vnfcCustomization.setModelUUID(MODEL_UUID); + vnfcCustomization.setModelVersion(MODEL_VERSION); + vnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); + + assertTrue (vnfcCustomization.getDescription().equals (DESCRIPTION)); + assertTrue (vnfcCustomization.getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue (vnfcCustomization.getModelInstanceName().equals (MODEL_INSTANCE_NAME)); + assertTrue (vnfcCustomization.getModelInvariantUUID().equals (MODEL_INVARIANT_UUID)); + assertTrue (vnfcCustomization.getModelName().equals (MODEL_NAME)); + assertTrue (vnfcCustomization.getModelUUID().equals (MODEL_UUID)); + assertTrue (vnfcCustomization.getModelVersion().equals (MODEL_VERSION)); + assertTrue (vnfcCustomization.getToscaNodeType().equals (TOSCA_NODE_TYPE)); + assertTrue (vnfcCustomization.getCvnfcCustomization().get(0).getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + } + + private List<CvnfcCustomization> setupCvnfcCustomizationList(){ + CvnfcCustomization testCvnfcCustomization = new CvnfcCustomization(); + testCvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + testCvnfcCustomization.setDescription(DESCRIPTION); + testCvnfcCustomization.setModelVersion(MODEL_VERSION); + testCvnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + testCvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); + List<CvnfcCustomization> testCvnfcCustomizationList = new ArrayList(); + testCvnfcCustomizationList.add(testCvnfcCustomization); + return testCvnfcCustomizationList; + } + +}
\ No newline at end of file diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java index 5a0770ead6..c5ae3cc83c 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java @@ -1,8 +1,28 @@ +/*- + * ============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.data.repository; import org.junit.Assert; import org.junit.Test; -import org.onap.so.BaseTest; +import org.onap.so.db.catalog.BaseTest; import org.onap.so.db.catalog.beans.CloudSite; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; @@ -34,4 +54,4 @@ public class CloudSiteRepositoryTest extends BaseTest { Assert.assertFalse(CollectionUtils.isEmpty(cloudSiteList)); } -}
\ No newline at end of file +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java index 21f95a7727..34c22b07b2 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java @@ -1,8 +1,28 @@ +/*- + * ============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.data.repository; import org.junit.Assert; import org.junit.Test; -import org.onap.so.BaseTest; +import org.onap.so.db.catalog.BaseTest; import org.onap.so.db.catalog.beans.CloudifyManager; import org.springframework.beans.factory.annotation.Autowired; @@ -18,4 +38,4 @@ public class CloudifyManagerRepositoryTest extends BaseTest { Assert.assertEquals("mtn13", cloudifyManager.getId()); } -}
\ No newline at end of file +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepositoryTest.java new file mode 100644 index 0000000000..90ec07f154 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepositoryTest.java @@ -0,0 +1,49 @@ +/*- + * ============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.data.repository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.so.db.catalog.BaseTest; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; + +public class CollectionNetworkResourceCustomizationRepositoryTest extends BaseTest { + @Autowired + private CollectionNetworkResourceCustomizationRepository cnrcRepo; + + @Test + public void findAllTest() throws Exception { + List<CollectionNetworkResourceCustomization> cnrcList = cnrcRepo.findAll(); + Assert.assertFalse(CollectionUtils.isEmpty(cnrcList)); + } + + @Test + public void findOneByUuidTest() throws Exception { + CollectionNetworkResourceCustomization cnrc = cnrcRepo.findOneByModelCustomizationUUID("3bdbb104-ffff-483e-9f8b-c095b3d3068c"); + Assert.assertTrue(cnrc != null); + Assert.assertTrue("ExtVL 01".equals(cnrc.getModelInstanceName())); + } +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java new file mode 100644 index 0000000000..ae3c49ec7d --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java @@ -0,0 +1,103 @@ +/*- + * ============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.data.repository; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.so.db.catalog.BaseTest; +import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfResource; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.beans.VnfcCustomization; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +public class CvnfcCustomizationRepositoryTest extends BaseTest { + @Autowired + private CvnfcCustomizationRepository cvnfcCustomizationRepository; + + @Test + public void findAllTest() throws Exception { + List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findAll(); + Assert.assertFalse(CollectionUtils.isEmpty(cvnfcCustomizationList)); + } + + @Test + @Transactional + public void createAndGetTest() throws Exception { + + CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModule vFModule = setUpVfModule(); + VnfResource vnfResource = setUpVnfResource(); + + vFModule.setVnfResources(vnfResource); + vfModuleCustomization.setVfModule(vFModule); + cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); + + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); + + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList(); + vnfResourceCustomizations.add(vnfResourceCustomization); + vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); + vnfResourceCustomization.setVnfResources(vnfResource); + + cvnfcCustomization.setVnfResourceCustomization(vnfResourceCustomization); + + VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); + cvnfcCustomization.setVnfcCustomization(vnfcCustomization); + + cvnfcCustomizationRepository.save(cvnfcCustomization); + + List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findAll(); + boolean matchFound = false; + for (CvnfcCustomization foundCvnfcCustomization : cvnfcCustomizationList) { + if (foundCvnfcCustomization.getDescription().equalsIgnoreCase(cvnfcCustomization.getDescription())) { + + assertThat(cvnfcCustomization, sameBeanAs(foundCvnfcCustomization) + .ignoring("id") + .ignoring("created") + .ignoring("vnfVfmoduleCvnfcConfigurationCustomization") + .ignoring("vnfResourceCusteModelCustomizationUUID")); + + matchFound = true; + break; + } + } + Assert.assertTrue(matchFound); + } +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java new file mode 100644 index 0000000000..52cb46f391 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest.java @@ -0,0 +1,121 @@ +/*- + * ============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.data.repository; + +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.so.db.catalog.BaseTest; +import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +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.VnfcCustomization; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +public class VnfVfmoduleCvnfcConfigurationCustomizationRepositoryTest extends BaseTest { + @Autowired + private VnfVfmoduleCvnfcConfigurationCustomizationRepository vnfVfmoduleCvnfcConfigurationCustomizationRepository; + @Autowired + private CvnfcCustomizationRepository cvnfcCustomizationRepository; + + @Test + public void findAllTest() throws Exception { + List<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizationList = vnfVfmoduleCvnfcConfigurationCustomizationRepository.findAll(); + Assert.assertFalse(CollectionUtils.isEmpty(vnfVfmoduleCvnfcConfigurationCustomizationList)); + + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomizationRepository.findOne(1); + Assert.assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationFunction().equalsIgnoreCase("testConfigurationFunction")); + } + + @Test + @Transactional + public void createAndGetTest() throws Exception { + + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + vnfVfmoduleCvnfcConfigurationCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName("testModelInstanceName"); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationType("testConfigurationType"); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationRole("testConfigurationRole"); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationFunction("testConfigurationFunction"); + vnfVfmoduleCvnfcConfigurationCustomization.setPolicyName("testPolicyName"); + + ConfigurationResource configurationResource = new ConfigurationResource(); + configurationResource.setModelUUID("98b42780-9f13-11e8-98d0-529269fb1459"); + configurationResource.setModelInvariantUUID("c9338d1a-9f13-11e8-98d0-529269fb1459"); + configurationResource.setModelVersion("testModelVertsion"); + configurationResource.setModelName("testModelName"); + configurationResource.setToscaNodeType("testToscaNodeType"); + configurationResource.setDescription("testConfigurationDescription"); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource); + + CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModule vFModule = setUpVfModule(); + VnfResource vnfResource = setUpVnfResource(); + + vFModule.setVnfResources(vnfResource); + vfModuleCustomization.setVfModule(vFModule); + cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); + + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); + + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList(); + vnfResourceCustomizations.add(vnfResourceCustomization); + vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); + vnfResourceCustomization.setVnfResources(vnfResource); + + cvnfcCustomization.setVnfResourceCustomization(vnfResourceCustomization); + + VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID("0aa015ea-9ff3-11e8-98d0-529269fb1459"); + cvnfcCustomization.setVnfcCustomization(vnfcCustomization); + + cvnfcCustomizationRepository.save(cvnfcCustomization); + + vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization); + vnfVfmoduleCvnfcConfigurationCustomization.setVfModuleCustomization(vfModuleCustomization); + vnfVfmoduleCvnfcConfigurationCustomization.setVnfResourceCustomization(vnfResourceCustomization); + + vnfVfmoduleCvnfcConfigurationCustomizationRepository.save(vnfVfmoduleCvnfcConfigurationCustomization); + + VnfVfmoduleCvnfcConfigurationCustomization foundVnfVfmoduleCvnfcConfigurationCustomization = vnfVfmoduleCvnfcConfigurationCustomizationRepository.findOne(1); + + + if(foundVnfVfmoduleCvnfcConfigurationCustomization == null) + fail("should not be null"); + } +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepositoryTest.java new file mode 100644 index 0000000000..0f82c8abf0 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepositoryTest.java @@ -0,0 +1,62 @@ +/*- + * ============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.data.repository; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.so.db.catalog.BaseTest; +import org.onap.so.db.catalog.beans.VnfcCustomization; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +public class VnfcCustomizationRepositoryTest extends BaseTest { + @Autowired + private VnfcCustomizationRepository vnfcCustomizationRepository; + + @Test + public void findAllTest() throws Exception { + List<VnfcCustomization> vnfcCustomizationList = vnfcCustomizationRepository.findAll(); + Assert.assertFalse(CollectionUtils.isEmpty(vnfcCustomizationList)); + + VnfcCustomization vnfcCustomization = vnfcCustomizationRepository.findOne("9bcce658-9b37-11e8-98d0-529269fb1459"); + Assert.assertTrue(vnfcCustomization.getDescription().equalsIgnoreCase("testVnfcCustomizationDescription")); + } + + @Test + @Transactional + public void createAndGetTest() throws Exception { + + VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfcCustomizationRepository.save(vnfcCustomization); + + VnfcCustomization foundVnfcCustomization = vnfcCustomizationRepository.findOne("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + assertThat(vnfcCustomization, sameBeanAs(foundVnfcCustomization) + .ignoring("created")); + } +} diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql index e16ca0fe8f..3f3aabb17e 100644 --- a/mso-catalog-db/src/test/resources/data.sql +++ b/mso-catalog-db/src/test/resources/data.sql @@ -88,6 +88,19 @@ insert into network_resource(model_uuid, model_name, model_invariant_uuid, descr insert into network_resource_customization(model_customization_uuid, model_instance_name, network_technology, network_type, network_role, network_scope, creation_timestamp, network_resource_model_uuid) values ('3bdbb104-476c-483e-9f8b-c095b3d308ac', 'CONTRAIL30_GNDIRECT 9', '', '', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c47fc'); +insert into instance_group(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, role, object_type, cr_model_uuid, instance_group_type) values +('21e43a7c-d823-4f5b-a427-5235f63035ff', 'dror_cr_network_resource_1806..NetworkCollection..0', '81c94263-c01e-4046-b0c7-51878d658eab', '1', 'org.openecomp.groups.NetworkCollection', 'SUB_INTERFACE', 'L3_NETWORK', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'L3_NETWORK'); + +insert into collection_resource(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, description) values +('5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'Dror_CR_Network_Resource_1806', 'fe243154-ac18-405f-94c2-ef629d26b8bb', '2.0', 'org.openecomp.resource.cr.DrorCrNetworkResource1806', 'Creation date: 07/25/18'); + +insert into collection_resource_customization(model_customization_uuid, model_instance_name, role, object_type, function, collection_resource_type, cr_model_uuid) values +('c51096a4-6081-41f4-a540-3ed015a8064a', 'Dror_CR_Network_Resource_1806', 'Dror2', 'NetworkCollection', 'Dror1', 'Dror3', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c'); + +insert into collection_network_resource_customization(model_customization_uuid, model_instance_name, network_technology, network_type, network_role, network_scope, network_resource_model_uuid, instance_group_model_uuid, crc_model_customization_uuid) values +('3bdbb104-ffff-483e-9f8b-c095b3d30844', 'ExtVL 0', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c47fz', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a'), +('3bdbb104-ffff-483e-9f8b-c095b3d3068c', 'ExtVL 01', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c47fz', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a'); + insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values ('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002672', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '2.0', 'vSAMP10a', 'VF', null); @@ -642,9 +655,107 @@ VALUES ('CUSTOM', 'PENDING_DELETE', 'CUSTOM', 'CONTINUE'), ('CUSTOM', 'PRECREATED', 'CUSTOM', 'CONTINUE'); - INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08'); INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33'); -INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
\ No newline at end of file +INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28'); + +INSERT INTO `controller_selection_reference` (`VNF_TYPE`, `CONTROLLER_NAME`, `ACTION_CATEGORY`) VALUES +('vLoadBalancerMS/vLoadBalancerMS 0', 'APPC', 'ConfigScaleOut'), +('vLoadBalancerMS/vLoadBalancerMS 0', 'APPC', 'HealthCheck'); + +INSERT INTO `configuration` + (`model_uuid`, + `model_invariant_uuid`, + `model_version`, + `model_name`, + `tosca_node_type`, + `description`, + `creation_timestamp`) +VALUES ( 'c59a41ca-9b3b-11e8-98d0-529269fb1459', + '15881e64-9b3c-11e8-98d0-529269fb1459', + 'testModelVersion', + 'testModelName', + 'testToscaModelType', + 'testConfigurationDescription', + '2018-07-17 14:05:08' ); + + +INSERT INTO `vnfc_customization` + (`model_customization_uuid`, + `model_instance_name`, + `model_uuid`, + `model_invariant_uuid`, + `model_version`, + `model_name`, + `tosca_node_type`, + `description`, + `creation_timestamp`) +VALUES ( '9bcce658-9b37-11e8-98d0-529269fb1459', + 'testModelInstanceName', + 'b25735fe-9b37-11e8-98d0-529269fb1459', + 'ba7e6ef0-9b37-11e8-98d0-529269fb1459', + 'testModelVersion', + 'testModelName', + 'toscaNodeType', + 'testVnfcCustomizationDescription', + '2018-07-17 14:05:08'); + +INSERT INTO `cvnfc_customization` + (`id`, + `model_customization_uuid`, + `model_instance_name`, + `model_uuid`, + `model_invariant_uuid`, + `model_version`, + `model_name`, + `tosca_node_type`, + `description`, + `nfc_function`, + `nfc_naming_code`, + `creation_timestamp`, + `vnf_resource_cust_model_customization_uuid`, + `vf_module_cust_model_customization_uuid`, + `vnfc_cust_model_customization_uuid`) +VALUES ( '1', + '9bcce658-9b37-11e8-98d0-529269fb1459', + 'testModelInstanceName', + 'b25735fe-9b37-11e8-98d0-529269fb1459', + 'ba7e6ef0-9b37-11e8-98d0-529269fb1459', + 'testModelVersion', + 'testModelName', + 'testToscaNodeType', + 'testCvnfcCustomzationDescription', + 'testNfcFunction', + 'testNfcNamingCode', + '2018-07-17 14:05:08', + '68dc9a92-214c-11e7-93ae-92361f002671', + 'cb82ffd8-252a-11e7-93ae-92361f002671', + '9bcce658-9b37-11e8-98d0-529269fb1459'); + +INSERT INTO vnf_vfmodule_cvnfc_configuration_customization + (id, + model_customization_uuid, + vnf_resource_cust_model_customization_uuid, + vf_module_model_customization_uuid, + cvnfc_model_customization_uuid, + model_instance_name, + configuration_type, + configuration_role, + configuration_function, + policy_name, + creation_timestamp, + configuration_model_uuid) +VALUES ( '1', + '7bcce658-9b37-11e8-98d0-529269fb1450', + '68dc9a92-214c-11e7-93ae-92361f002671', + 'cb82ffd8-252a-11e7-93ae-92361f002671', + '9bcce658-9b37-11e8-98d0-529269fb1459', + 'testModelInstanceName', + 'testConfigurationType', + 'testConfigurationRole', + 'testConfigurationFunction', + 'testPolicyName', + '2018-07-17 14:05:08', + 'c59a41ca-9b3b-11e8-98d0-529269fb1459'); diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index 8ff04ea038..6eaad260ea 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -822,6 +822,13 @@ create table if not exists model ( FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE IF NOT EXISTS `controller_selection_reference` ( + `VNF_TYPE` VARCHAR(50) NOT NULL, + `CONTROLLER_NAME` VARCHAR(100) NOT NULL, + `ACTION_CATEGORY` VARCHAR(15) NOT NULL, + PRIMARY KEY (`VNF_TYPE`, `CONTROLLER_NAME`, `ACTION_CATEGORY`) +) ; + ALTER TABLE `vnf_recipe` CHANGE COLUMN `VNF_TYPE` `NF_ROLE` VARCHAR(200) NULL DEFAULT NULL ; @@ -841,7 +848,6 @@ CREATE TABLE IF NOT EXISTS `identity_services` ( PRIMARY KEY (`ID`) ) ; - CREATE TABLE IF NOT EXISTS `cloudify_managers` ( `ID` varchar(50) NOT NULL, `CLOUDIFY_URL` varchar(200) DEFAULT NULL, @@ -854,9 +860,6 @@ CREATE TABLE IF NOT EXISTS `cloudify_managers` ( PRIMARY KEY (`ID`) ) ; - - - CREATE TABLE IF NOT EXISTS `cloud_sites` ( `ID` varchar(50) NOT NULL, `REGION_ID` varchar(11) DEFAULT NULL, @@ -872,4 +875,76 @@ CREATE TABLE IF NOT EXISTS `cloud_sites` ( PRIMARY KEY (`ID`), KEY `FK_cloud_sites_identity_services` (`IDENTITY_SERVICE_ID`), CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`) -) ;
\ No newline at end of file +) ; + +CREATE TABLE IF NOT EXISTS vnfc_customization ( +`MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, +`MODEL_UUID` VARCHAR(200) NOT NULL, +`MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL, +`MODEL_VERSION` VARCHAR(20) NOT NULL, +`MODEL_NAME` VARCHAR(200) NOT NULL, +`TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL, +`DESCRIPTION` VARCHAR(1200) NULL DEFAULT NULL, +`CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)) +ENGINE = InnoDB +AUTO_INCREMENT = 20654 +DEFAULT CHARACTER SET = latin1; + +CREATE TABLE IF NOT EXISTS cvnfc_customization ( +`ID` INT(11) NOT NULL AUTO_INCREMENT, +`MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, +`MODEL_UUID` VARCHAR(200) NOT NULL, +`MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL, +`MODEL_VERSION` VARCHAR(20) NOT NULL, +`MODEL_NAME` VARCHAR(200) NOT NULL, +`TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL, +`DESCRIPTION` VARCHAR(1200) NULL DEFAULT NULL, +`NFC_FUNCTION` VARCHAR(200) NULL, +`NFC_NAMING_CODE` VARCHAR(200) NULL, +`CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, +`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`VNFC_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, PRIMARY KEY (`ID`), INDEX `fk_cvnfc_customization__vf_module_customization1_idx` (`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnfc_customization1_idx` (`VNFC_CUST_MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnf_resource_customization1_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), UNIQUE INDEX `UK_cvnfc_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC, `VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` ASC, `MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnf_vfmod_cvnfc_config_cust1_idx` (`MODEL_CUSTOMIZATION_UUID` ASC), CONSTRAINT `fk_cvnfc_customization__vf_module_customization1` FOREIGN KEY (`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`) ON +DELETE CASCADE ON +UPDATE CASCADE, CONSTRAINT `fk_cvnfc_customization__vnfc_customization1` FOREIGN KEY (`VNFC_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vnfc_customization` (`MODEL_CUSTOMIZATION_UUID`) ON +DELETE CASCADE ON +UPDATE CASCADE, CONSTRAINT `fk_cvnfc_customization__vnf_resource_customization1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`) ON +DELETE CASCADE ON +UPDATE CASCADE) ENGINE = InnoDB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = latin1; + + +CREATE TABLE IF NOT EXISTS vnf_vfmodule_cvnfc_configuration_customization ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `VF_MODULE_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `CVNFC_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, + `CONFIGURATION_TYPE` VARCHAR(200) NULL, + `CONFIGURATION_ROLE` VARCHAR(200) NULL, + `CONFIGURATION_FUNCTION` VARCHAR(200) NULL, + `POLICY_NAME` VARCHAR(200) NULL, + `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CONFIGURATION_MODEL_UUID` VARCHAR(200) NOT NULL, + PRIMARY KEY (`ID`), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__configuration_idx` (`CONFIGURATION_MODEL_UUID` ASC), + UNIQUE INDEX `UK_vnf_vfmodule_cvnfc_configuration_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC , `VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC , `CVNFC_MODEL_CUSTOMIZATION_UUID` ASC , `MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__cvnfc_cust1_idx` (`CVNFC_MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vf_module_cust_idx` (`VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vnf_res_cust_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), + CONSTRAINT `fk_vnf_vfmod_cvnfc_config_cust__configuration_resource` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`) + REFERENCES `configuration` (`MODEL_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_cvnfc_configuration_customization__cvnfc_customization1` FOREIGN KEY (`CVNFC_MODEL_CUSTOMIZATION_UUID`) + REFERENCES `cvnfc_customization` (`MODEL_CUSTOMIZATION_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_vnf_configuration_cvnfc_customization__vf_module_customiza1` FOREIGN KEY (`VF_MODULE_MODEL_CUSTOMIZATION_UUID`) + REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_vfmodule_cvnfc_configuration_customization__vnf_resource_c1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`) + REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=INNODB AUTO_INCREMENT=20654 DEFAULT CHARACTER SET=LATIN1; |