diff options
Diffstat (limited to 'mso-catalog-db/src')
193 files changed, 11510 insertions, 17961 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 new file mode 100644 index 0000000000..75461c6cde --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResource.java @@ -0,0 +1,179 @@ +/*- + * ============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.HashSet; +import java.util.Set; + +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 org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "allotted_resource") +public class AllottedResource implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + @BusinessKey + @Id + @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 = "SUBCATEGORY") + private String subcategory; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "allottedResource") + private Set<AllottedResourceCustomization> allotedResourceCustomization; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) + .append("modelVersion", modelVersion).append("modelName", modelName) + .append("toscaNodeType", toscaNodeType).append("subcategory", subcategory) + .append("description", description).append("created", created) + .append("allotedResourceCustomization", allotedResourceCustomization).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof AllottedResource)) { + return false; + } + AllottedResource castOther = (AllottedResource) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @LinkedResource + public Set<AllottedResourceCustomization> getAllotedResourceCustomization() { + if (allotedResourceCustomization == null) + allotedResourceCustomization = new HashSet<>(); + return allotedResourceCustomization; + } + + public void setAllotedResourceCustomization(Set<AllottedResourceCustomization> allotedResourceCustomization) { + this.allotedResourceCustomization = allotedResourceCustomization; + } + + public String getModelUUID() { + return this.modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getModelInvariantUUID() { + return this.modelInvariantUUID; + } + + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } + + public String getModelVersion() { + return this.modelVersion; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + public String getModelName() { + return this.modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getToscaNodeType() { + return this.toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public String getSubcategory() { + return this.subcategory; + } + + public void setSubcategory(String subcategory) { + this.subcategory = subcategory; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreated() { + return 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 new file mode 100644 index 0000000000..f68c6d2502 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java @@ -0,0 +1,242 @@ +/*- + * ============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.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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "allotted_resource_customization") +public class AllottedResourceCustomization implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "PROVIDING_SERVICE_MODEL_INVARIANT_UUID") + private String providingServiceModelInvariantUUID; + + @Column(name = "PROVIDING_SERVICE_MODEL_UUID") + private String providingServiceModelUUID; + + @Column(name = "PROVIDING_SERVICE_MODEL_NAME") + private String providingServiceModelName; + + @Column(name = "TARGET_NETWORK_ROLE") + private String targetNetworkRole; + + @Column(name = "NF_FUNCTION") + private String nfFunction; + + @Column(name = "NF_TYPE") + private String nfType; + + @Column(name = "NF_ROLE") + private String nfRole; + + @Column(name = "NF_NAMING_CODE") + private String nfNamingCode; + + @Column(name = "MIN_INSTANCES") + private Integer minInstances; + + @Column(name = "MAX_INSTANCES") + private Integer maxInstances; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "AR_MODEL_UUID") + private AllottedResource allottedResource; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("created", created).append("modelInstanceName", modelInstanceName) + .append("providingServiceModelInvariantUUID", providingServiceModelInvariantUUID) + .append("providingServiceModelUUID", providingServiceModelUUID) + .append("providingServiceModelName", providingServiceModelName) + .append("targetNetworkRole", targetNetworkRole).append("nfFunction", nfFunction) + .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode) + .append("minInstances", minInstances).append("maxInstances", maxInstances) + .append("allottedResource", allottedResource).toString(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof AllottedResourceCustomization)) { + return false; + } + AllottedResourceCustomization castOther = (AllottedResourceCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + + public String getProvidingServiceModelUUID() { + return providingServiceModelUUID; + } + + public void setProvidingServiceModelUUID(String providingServiceModelUUID) { + this.providingServiceModelUUID = providingServiceModelUUID; + } + + public String getProvidingServiceModelName() { + return providingServiceModelName; + } + + public void setProvidingServiceModelName(String providingServiceModelName) { + this.providingServiceModelName = providingServiceModelName; + } + + public AllottedResourceCustomization() { + super(); + } + + public String getModelCustomizationUUID() { + return this.modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public Date getCreated() { + return this.created; + } + + public String getModelInstanceName() { + return this.modelInstanceName; + } + + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + + @LinkedResource + public AllottedResource getAllottedResource() { + return this.allottedResource; + } + + public void setAllottedResource(AllottedResource allottedResource) { + this.allottedResource = allottedResource; + } + + public String getProvidingServiceModelInvariantUUID() { + return this.providingServiceModelInvariantUUID; + } + + public void setProvidingServiceModelInvariantUUID(String providingServiceModelInvariantUUID) { + this.providingServiceModelInvariantUUID = providingServiceModelInvariantUUID; + } + + public String getTargetNetworkRole() { + return this.targetNetworkRole; + } + + public void setTargetNetworkRole(String targetNetworkRole) { + this.targetNetworkRole = targetNetworkRole; + } + + public String getNfFunction() { + return this.nfFunction; + } + + public void setNfFunction(String nfFunction) { + this.nfFunction = nfFunction; + } + + public String getNfType() { + return this.nfType; + } + + public void setNfType(String nfType) { + this.nfType = nfType; + } + + public String getNfRole() { + return this.nfRole; + } + + public void setNfRole(String nfRole) { + this.nfRole = nfRole; + } + + public String getNfNamingCode() { + return this.nfNamingCode; + } + + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + public Integer getMinInstances() { + return this.minInstances; + } + + public void setMinInstances(Integer minInstances) { + this.minInstances = minInstances; + } + + public Integer getMaxInstances() { + return this.maxInstances; + } + + public void setMaxInstances(Integer maxInstances) { + this.maxInstances = maxInstances; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ArRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ArRecipe.java new file mode 100644 index 0000000000..86ff743475 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ArRecipe.java @@ -0,0 +1,184 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +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.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "ar_recipe") +public class ArRecipe implements Recipe, Serializable { + private static final long serialVersionUID = 768026109321305392L; + + @Id + @Column(name = "ID", nullable = false) + private Integer id; + @BusinessKey + @Column(name = "MODEL_NAME", nullable = false) + private String modelName; + @BusinessKey + @Column(name = "ACTION", nullable = false) + private String action; + + @Column(name = "VERSION_STR", nullable = false) + private String version; + @BusinessKey + @Column(name = "SERVICE_TYPE") + private String serviceType; + + @Column(name = "DESCRIPTION") + private String description; + @BusinessKey + @Column(name = "ORCHESTRATION_URI", nullable = false) + private String orchestrationUri; + + @Column(name = "AR_PARAM_XSD") + private String paramXsd; + + @Column(name = "RECIPE_TIMEOUT") + private Integer recipeTimeout; + + @Column(name = "CREATION_TIMESTAMP", nullable = false, updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getOrchestrationUri() { + return orchestrationUri; + } + + public void setOrchestrationUri(String orchestrationUri) { + this.orchestrationUri = orchestrationUri; + } + + public String getParamXsd() { + return paramXsd; + } + + public void setParamXsd(String paramXsd) { + this.paramXsd = paramXsd; + } + + public Integer getRecipeTimeout() { + return recipeTimeout; + } + + public void setRecipeTimeout(Integer recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelName", getModelName()).append("action", getAction()) + .append("version", getVersion()).append("serviceType", getServiceType()) + .append("description", getDescription()).append("orchestrationUri", getOrchestrationUri()) + .append("paramXSD", getParamXsd()).append("recipeTimeout", getRecipeTimeout()) + .append("created", getCreated()).toString(); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof ArRecipe)) { + return false; + } + ArRecipe castOther = (ArRecipe) other; + return new EqualsBuilder().append(getId(), castOther.getId()).append(getModelName(), castOther.getModelName()) + .append(getAction(), castOther.getAction()).append(getServiceType(), castOther.getServiceType()) + .append(getOrchestrationUri(), castOther.getOrchestrationUri()).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(getId()).append(getModelName()).append(getAction()).append(getServiceType()) + .append(getOrchestrationUri()).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockDetail.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockDetail.java new file mode 100644 index 0000000000..36a9db77ed --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BuildingBlockDetail.java @@ -0,0 +1,117 @@ +/*- + * ============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 java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +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.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "building_block_detail") +public class BuildingBlockDetail implements Serializable { + private static final long serialVersionUID = -2375223199178059155L; + + @Id + @Column(name = "id") + @GeneratedValue + private Integer id; + + @BusinessKey + @Column(name = "BUILDING_BLOCK_NAME") + private String buildingBlockName; + + @Enumerated(EnumType.STRING) + @Column(name = "RESOURCE_TYPE") + private ResourceType resourceType; + + @Enumerated(EnumType.STRING) + @Column(name = "TARGET_ACTION") + private OrchestrationAction targetAction; + + @Override + public String toString() { + return new ToStringBuilder(this).append("buildingBlockName", buildingBlockName) + .append("resourceType", resourceType).append("targetAction", targetAction).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof BuildingBlockDetail)) { + return false; + } + BuildingBlockDetail castOther = (BuildingBlockDetail) other; + return new EqualsBuilder().append(buildingBlockName, castOther.buildingBlockName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(buildingBlockName).toHashCode(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getBuildingBlockName() { + return buildingBlockName; + } + + public void setBuildingBlockName(String buildingBlockName) { + this.buildingBlockName = buildingBlockName; + } + + public ResourceType getResourceType() { + return resourceType; + } + + public void setResourceType(ResourceType resourceType) { + this.resourceType = resourceType; + } + + public OrchestrationAction getTargetAction() { + return targetAction; + } + + public void setTargetAction(OrchestrationAction targetAction) { + this.targetAction = targetAction; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionNetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionNetworkResourceCustomization.java new file mode 100644 index 0000000000..d4de5cbcdf --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionNetworkResourceCustomization.java @@ -0,0 +1,208 @@ +/*- + * ============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.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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "collection_network_resource_customization") +public class CollectionNetworkResourceCustomization implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 11115611315801079L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID = null; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @BusinessKey + @Column(name = "NETWORK_TECHNOLOGY") + private String networkTechnology; + + @BusinessKey + @Column(name = "NETWORK_TYPE") + private String networkType = null; + + @BusinessKey + @Column(name = "NETWORK_SCOPE") + private String networkScope; + + @BusinessKey + @Column(name = "NETWORK_ROLE") + private String networkRole; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "NETWORK_RESOURCE_MODEL_UUID") + private NetworkResource networkResource = null; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID") + private InstanceGroup instanceGroup = null; + + @BusinessKey + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "CRC_MODEL_CUSTOMIZATION_UUID") + private NetworkCollectionResourceCustomization networkResourceCustomization = null; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof CollectionNetworkResourceCustomization)) { + return false; + } + CollectionNetworkResourceCustomization castOther = (CollectionNetworkResourceCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) + .append(networkTechnology, castOther.networkTechnology).append(networkType, castOther.networkType) + .append(networkScope, castOther.networkScope).append(networkRole, castOther.networkRole) + .append(networkResourceCustomization, castOther.networkResourceCustomization).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).append(networkTechnology).append(networkType) + .append(networkScope).append(networkRole).append(networkResourceCustomization).toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("created", created) + .append("networkTechnology", networkTechnology).append("networkType", networkType) + .append("networkScope", networkScope).append("networkRole", networkRole) + .append("networkResource", networkResource).append("collectionResource", networkResourceCustomization) + .toString(); + } + + public String getModelCustomizationUUID() { + return this.modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + @LinkedResource + public NetworkCollectionResourceCustomization getNetworkResourceCustomization() { + return networkResourceCustomization; + } + + public void setNetworkResourceCustomization(NetworkCollectionResourceCustomization networkResourceCustomization) { + this.networkResourceCustomization = networkResourceCustomization; + } + + public String getModelInstanceName() { + return this.modelInstanceName; + } + + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + + @LinkedResource + public NetworkResource getNetworkResource() { + return this.networkResource; + } + + public void setNetworkResource(NetworkResource networkResource) { + this.networkResource = networkResource; + } + + public String getNetworkType() { + return this.networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public Date getCreated() { + return this.created; + } + + public String getNetworkTechnology() { + return this.networkTechnology; + } + + public void setNetworkTechnology(String networkTechnology) { + this.networkTechnology = networkTechnology; + } + + public String getNetworkScope() { + return this.networkScope; + } + + public void setNetworkScope(String networkScope) { + this.networkScope = networkScope; + } + + public void setNetworkRole(String networkRole) { + this.networkRole = networkRole; + } + + public String getNetworkRole() { + return this.networkRole; + } + + @LinkedResource + public InstanceGroup getInstanceGroup() { + return instanceGroup; + } + + public void setInstanceGroup(InstanceGroup instanceGroup) { + this.instanceGroup = instanceGroup; + } + +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResource.java new file mode 100644 index 0000000000..f8148aa781 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResource.java @@ -0,0 +1,181 @@ +/*- + * ============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.Id; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "collection_resource") +public class CollectionResource implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8612818857960992110L; + + @BusinessKey + @Id + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "TOSCA_NODE_TYPE") + private String toscaNodeType; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResource") + private Set<CollectionResourceCustomization> collectionResourceCustomization; + + @OneToOne(cascade = CascadeType.ALL, mappedBy = "collectionResource") + private InstanceGroup instanceGroup; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof CollectionResource)) { + return false; + } + CollectionResource castOther = (CollectionResource) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } + + public Set<CollectionResourceCustomization> getCollectionResourceCustomization() { + return collectionResourceCustomization; + } + + public void setCollectionResourceCustomization( + Set<CollectionResourceCustomization> collectionResourceCustomization) { + this.collectionResourceCustomization = collectionResourceCustomization; + } + + public String getModelUUID() { + return modelUUID; + } + + public Date getCreated() { + return this.created; + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + 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 getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @LinkedResource + public InstanceGroup getInstanceGroup() { + return instanceGroup; + } + + public void setInstanceGroup(InstanceGroup instanceGroup) { + this.instanceGroup = instanceGroup; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelName", modelName) + .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion) + .append("toscaNodeType", toscaNodeType).append("description", description).append("created", created) + .toString(); + } +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceCustomization.java new file mode 100644 index 0000000000..34389de22f --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceCustomization.java @@ -0,0 +1,180 @@ +/*- + * ============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.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@DiscriminatorColumn(name = "OBJECT_TYPE") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@Table(name = "collection_resource_customization") +public class CollectionResourceCustomization implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8328823396870652841L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "COLLECTION_RESOURCE_TYPE") + private String type; + + @Column(name = "ROLE") + private String role; + + @Column(name = "FUNCTION") + private String function; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "CR_MODEL_UUID") + private CollectionResource collectionResource; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResourceCust") + private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("type", type).append("role", role) + .append("function", function).append("created", created) + .append("collectionResource", collectionResource) + .append("collectionInstanceGroupCustomizations", collectionInstanceGroupCustomizations).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof CollectionResourceCustomization)) { + return false; + } + CollectionResourceCustomization castOther = (CollectionResourceCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + + public Date getCreated() { + return this.created; + } + + @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 getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getFunction() { + return function; + } + + public void setFunction(String function) { + this.function = function; + } + + @LinkedResource + public CollectionResource getCollectionResource() { + return collectionResource; + } + + public void setCollectionResource(CollectionResource collectionResource) { + this.collectionResource = collectionResource; + } + + @LinkedResource + public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() { + return collectionInstanceGroupCustomizations; + } + + public void setCollectionInstanceGroupCustomizations( + List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) { + this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations; + } +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomization.java new file mode 100644 index 0000000000..7379225a34 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomization.java @@ -0,0 +1,180 @@ +/*- + * ============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 java.util.Date; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.IdClass; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@IdClass(CollectionResourceInstanceGroupCustomizationId.class) +@Table(name = "collection_resource_instance_group_customization") +public class CollectionResourceInstanceGroupCustomization implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5169990063225044265L; + + @BusinessKey + @Id + @Column(name = "COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID") + private String modelCustomizationUUID; + + @BusinessKey + @Id + @Column(name = "INSTANCE_GROUP_MODEL_UUID") + private String modelUUID; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID", updatable = false, insertable = false) + private CollectionResourceCustomization collectionResourceCust; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID", updatable = false, insertable = false) + private InstanceGroup instanceGroup; + + @Column(name = "FUNCTION") + private String function; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "SUBINTERFACE_NETWORK_QUANTITY") + private Integer subInterfaceNetworkQuantity; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelUUID", modelUUID).append("collectionResourceCust", collectionResourceCust) + .append("instanceGroup", instanceGroup).append("function", function).append("description", description) + .append("created", created).append("subInterfaceNetworkQuantity", subInterfaceNetworkQuantity) + .toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof CollectionResourceInstanceGroupCustomization)) { + return false; + } + CollectionResourceInstanceGroupCustomization castOther = (CollectionResourceInstanceGroupCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) + .append(modelUUID, castOther.modelUUID).append(collectionResourceCust, castOther.collectionResourceCust) + .append(instanceGroup, castOther.instanceGroup).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).append(collectionResourceCust) + .append(instanceGroup).toHashCode(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public String getModelCustomizationUUID() { + return modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelUUID() { + return modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getFunction() { + return function; + } + + public void setFunction(String function) { + this.function = function; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreated() { + return created; + } + + public Integer getSubInterfaceNetworkQuantity() { + return subInterfaceNetworkQuantity; + } + + public void setSubInterfaceNetworkQuantity(Integer subInterfaceNetworkQuantity) { + this.subInterfaceNetworkQuantity = subInterfaceNetworkQuantity; + } + + @LinkedResource + public CollectionResourceCustomization getCollectionResourceCust() { + return collectionResourceCust; + } + + public void setCollectionResourceCust(CollectionResourceCustomization collectionResourceCust) { + this.collectionResourceCust = collectionResourceCust; + } + + @LinkedResource + public InstanceGroup getInstanceGroup() { + return instanceGroup; + } + + public void setInstanceGroup(InstanceGroup instanceGroup) { + this.instanceGroup = instanceGroup; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomizationId.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomizationId.java new file mode 100644 index 0000000000..ff35bdb390 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CollectionResourceInstanceGroupCustomizationId.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.catalog.beans; + +import java.io.Serializable; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +public class CollectionResourceInstanceGroupCustomizationId implements Serializable { + /** + * + */ + private static final long serialVersionUID = 7118300524797895317L; + + @BusinessKey + private String modelCustomizationUUID; + @BusinessKey + private String modelUUID; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelUUID", modelUUID).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof CollectionResourceInstanceGroupCustomizationId)) { + return false; + } + CollectionResourceInstanceGroupCustomizationId castOther = (CollectionResourceInstanceGroupCustomizationId) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) + .append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).toHashCode(); + } + + public String getModelCustomizationUUID() { + return this.modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelUUID() { + return this.modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java new file mode 100644 index 0000000000..173480172d --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResource.java @@ -0,0 +1,171 @@ +/*- + * ============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.Id; +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.JsonIgnoreProperties; +import com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" }) +@Entity +@Table(name = "configuration") +public class ConfigurationResource implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 6675926401792679171L; + + @BusinessKey + @Id + @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) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "configurationResource") + private Set<ConfigurationResourceCustomization> configurationResourceCustomization; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + 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; + } + + @LinkedResource + public Set<ConfigurationResourceCustomization> getConfigurationResourceCustomization() { + return configurationResourceCustomization; + } + + public void setConfigurationResourceCustomization( + Set<ConfigurationResourceCustomization> configurationResourceCustomization) { + this.configurationResourceCustomization = configurationResourceCustomization; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) + .append("modelVersion", modelVersion).append("modelName", modelName) + .append("toscaNodeType", toscaNodeType).append("description", description).append("created", created) + .append("configurationResourceCustomization", configurationResourceCustomization).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ConfigurationResource)) { + return false; + } + ConfigurationResource castOther = (ConfigurationResource) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java new file mode 100644 index 0000000000..4f21580b9c --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ConfigurationResourceCustomization.java @@ -0,0 +1,190 @@ +/*- + * ============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.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "configuration_customization") +public class ConfigurationResourceCustomization implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1230671937560638856L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "CONFIGURATION_FUNCTION") + private String nfFunction; + + @Column(name = "CONFIGURATION_TYPE") + private String nfType; + + @Column(name = "CONFIGURATION_ROLE") + private String nfRole; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID") + private ServiceProxyResourceCustomization serviceProxyResourceCustomization; + + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID") + private ConfigurationResourceCustomization configResourceCustomization; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "CONFIGURATION_MODEL_UUID") + private ConfigurationResource configurationResource; + + @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 getNfFunction() { + return nfFunction; + } + + public void setNfFunction(String nfFunction) { + this.nfFunction = nfFunction; + } + + public String getNfType() { + return nfType; + } + + public void setNfType(String nfType) { + this.nfType = nfType; + } + + public String getNfRole() { + return nfRole; + } + + public void setNfRole(String nfRole) { + this.nfRole = nfRole; + } + + public Date getCreated() { + return created; + } + + @LinkedResource + public ServiceProxyResourceCustomization getServiceProxyResourceCustomization() { + return serviceProxyResourceCustomization; + } + + public void setServiceProxyResourceCustomization( + ServiceProxyResourceCustomization serviceProxyResourceCustomization) { + this.serviceProxyResourceCustomization = serviceProxyResourceCustomization; + } + + @LinkedResource + public ConfigurationResourceCustomization getConfigResourceCustomization() { + return configResourceCustomization; + } + + public void setConfigResourceCustomization(ConfigurationResourceCustomization configResourceCustomization) { + this.configResourceCustomization = configResourceCustomization; + } + + @LinkedResource + public ConfigurationResource getConfigurationResource() { + return configurationResource; + } + + public void setConfigurationResource(ConfigurationResource configurationResource) { + this.configurationResource = configurationResource; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("nfFunction", nfFunction) + .append("nfType", nfType).append("nfRole", nfRole).append("created", created) + .append("serviceProxyResourceCustomization", serviceProxyResourceCustomization) + .append("configResourceCustomization", configResourceCustomization) + .append("configurationResource", configurationResource).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ConfigurationResourceCustomization)) { + return false; + } + ConfigurationResourceCustomization castOther = (ConfigurationResourceCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ExternalServiceToInternalService.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ExternalServiceToInternalService.java new file mode 100644 index 0000000000..d076aebf86 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ExternalServiceToInternalService.java @@ -0,0 +1,132 @@ +/*- + * ============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 javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "external_service_to_internal_model_mapping") +public class ExternalServiceToInternalService implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 3825246668050173010L; + + @Id + @Column(name = "Id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @BusinessKey + @Column(name = "SERVICE_NAME") + private String serviceName; + + @BusinessKey + @Column(name = "PRODUCT_FLAVOR") + private String productFlavor; + + @BusinessKey + @Column(name = "SUBSCRIPTION_SERVICE_TYPE") + private String subscriptionServiceType; + + @BusinessKey + @Column(name = "SERVICE_MODEL_UUID") + private String serviceModelUUID; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ExternalServiceToInternalService)) { + return false; + } + ExternalServiceToInternalService castOther = (ExternalServiceToInternalService) other; + return new EqualsBuilder().append(serviceName, castOther.serviceName) + .append(productFlavor, castOther.productFlavor) + .append(subscriptionServiceType, castOther.subscriptionServiceType) + .append(serviceModelUUID, castOther.serviceModelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(serviceName).append(productFlavor).append(subscriptionServiceType) + .append(serviceModelUUID).toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("serviceName", serviceName) + .append("productFlavor", productFlavor).append("subscriptionServiceType", subscriptionServiceType) + .append("serviceModelUUID", serviceModelUUID).toString(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getProductFlavor() { + return productFlavor; + } + + public void setProductFlavor(String productFlavor) { + this.productFlavor = productFlavor; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public String getServiceModelUUID() { + return serviceModelUUID; + } + + public void setServiceModelUUID(String serviceModelUUID) { + this.serviceModelUUID = serviceModelUUID; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatEnvironment.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatEnvironment.java new file mode 100644 index 0000000000..6abe8d5110 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatEnvironment.java @@ -0,0 +1,163 @@ +/*- + * ============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.text.DateFormat; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +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 com.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "heat_environment") +public class HeatEnvironment implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "ARTIFACT_UUID") + private String artifactUuid; + + @Column(name = "NAME") + private String name = null; + + @Column(name = "DESCRIPTION") + private String description = null; + + @Lob + @Column(name = "BODY", columnDefinition = "LONGTEXT") + private String environment = null; + + @Column(name = "ARTIFACT_CHECKSUM") + private String artifactChecksum; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @BusinessKey + @Column(name = "VERSION") + private String version; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof HeatEnvironment)) { + return false; + } + HeatEnvironment castOther = (HeatEnvironment) other; + return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).append(version, castOther.version) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(artifactUuid).append(version).toHashCode(); + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getArtifactUuid() { + return this.artifactUuid; + } + + public void setArtifactUuid(String artifactUuid) { + this.artifactUuid = artifactUuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getEnvironment() { + return this.environment; + } + + public void setEnvironment(String environment) { + this.environment = environment; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public Date getCreated() { + return created; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Artifact UUID=" + this.artifactUuid); + sb.append(", name="); + sb.append(name); + sb.append(", version="); + sb.append(version); + sb.append(", description="); + sb.append(this.description == null ? "null" : this.description); + sb.append(", body="); + sb.append(this.environment == null ? "null" : this.environment); + if (this.created != null) { + sb.append(",creationTimestamp="); + sb.append(DateFormat.getInstance().format(this.created)); + } + return sb.toString(); + } +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatFiles.java index 542cd45081..6fe1e08f0d 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatFiles.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,30 +18,87 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; +import java.util.Date; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +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.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "heat_files") +public class HeatFiles implements Serializable { -public class HeatFiles extends MavenLikeVersioning implements Serializable { - private static final long serialVersionUID = 768026109321305392L; - private String artifactUuid = null; + @BusinessKey + @Id + @Column(name = "ARTIFACT_UUID") + private String artifactUuid; + + @Column(name = "DESCRIPTION") private String description = null; - private String fileName = null; - private String fileBody = null; - private Timestamp created = null; - private String version = null; - private String artifactChecksum = null; + @Column(name = "NAME") + private String fileName; + + @Lob + @Column(name = "BODY", columnDefinition = "LONGTEXT") + private String fileBody; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "ARTIFACT_CHECKSUM") + private String artifactChecksum; + + @Column(name = "VERSION") + private String version; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("artifactUuid", artifactUuid).append("description", description) + .append("fileName", fileName).append("fileBody", fileBody).append("created", created) + .append("artifactChecksum", artifactChecksum).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof HeatFiles)) { + return false; + } + HeatFiles castOther = (HeatFiles) other; + return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(artifactUuid).toHashCode(); + } public String getArtifactUuid() { return this.artifactUuid; } + public void setArtifactUuid(String artifactUuid) { this.artifactUuid = artifactUuid; } @@ -49,6 +106,7 @@ public class HeatFiles extends MavenLikeVersioning implements Serializable { public String getDescription() { return this.description; } + public void setDescription(String description) { this.description = description; } @@ -56,6 +114,7 @@ public class HeatFiles extends MavenLikeVersioning implements Serializable { public String getFileName() { return this.fileName; } + public void setFileName(String fileName) { this.fileName = fileName; } @@ -63,66 +122,36 @@ public class HeatFiles extends MavenLikeVersioning implements Serializable { public String getFileBody() { return this.fileBody; } + public void setFileBody(String fileBody) { this.fileBody = fileBody; } - public Timestamp getCreated() { + public Date getCreated() { return created; } - public void setCreated(Timestamp created) { - this.created = created; - } - public String getAsdcUuid() { return this.artifactUuid; } + public void setAsdcUuid(String artifactUuid) { this.artifactUuid = artifactUuid; } - @Override - public String getVersion() { - return version; - } - - @Override - public void setVersion(String version) { - this.version = version; - } - public String getArtifactChecksum() { return artifactChecksum; } + public void setArtifactChecksum(String artifactChecksum) { this.artifactChecksum = artifactChecksum; } - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("artifactUuid=").append(this.artifactUuid); - if (this.description == null) { - sb.append(", description=null"); - } else { - sb.append(", description=").append(this.description); - } - if (this.fileName == null) { - sb.append(", fileName=null"); - } else { - sb.append(",fileName=").append(this.fileName); - } - if (this.fileBody == null) { - sb.append(", fileBody=null"); - } else { - sb.append(",fileBody=").append(this.fileBody); - } - sb.append(", artifactChecksum=").append(this.artifactChecksum); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplate.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplate.java new file mode 100644 index 0000000000..2389793f33 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplate.java @@ -0,0 +1,211 @@ +/*- + * ============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.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; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Lob; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "heat_template") +public class HeatTemplate implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "ARTIFACT_UUID", length = 200) + private String artifactUuid; + + @Column(name = "NAME", length = 200) + private String templateName; + + @Lob + @Column(name = "BODY", columnDefinition = "LONGTEXT") + private String templateBody = null; + + @Column(name = "TIMEOUT_MINUTES", length = 20) + private Integer timeoutMinutes; + + @BusinessKey + @Column(name = "VERSION") + private String version; + + @Column(name = "DESCRIPTION", length = 1200) + private String description; + + @Column(name = "ARTIFACT_CHECKSUM", length = 200) + private String artifactChecksum; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "heatTemplateArtifactUuid") + private Set<HeatTemplateParam> parameters; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "heat_nested_template", joinColumns = @JoinColumn(name = "PARENT_HEAT_TEMPLATE_UUID"), inverseJoinColumns = @JoinColumn(name = "CHILD_HEAT_TEMPLATE_UUID")) + private List<HeatTemplate> childTemplates; + + public enum TemplateStatus { + PARENT, CHILD, PARENT_COMPLETE + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("artifactUuid", artifactUuid).append("templateName", templateName) + .append("templateBody", templateBody).append("timeoutMinutes", timeoutMinutes) + .append("version", version).append("description", description) + .append("artifactChecksum", artifactChecksum).append("created", created) + .append("parameters", parameters).append("childTemplates", childTemplates).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof HeatTemplate)) { + return false; + } + HeatTemplate castOther = (HeatTemplate) other; + return new EqualsBuilder().append(artifactUuid, castOther.artifactUuid).append(version, castOther.version) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(artifactUuid).append(version).toHashCode(); + } + + @LinkedResource + public List<HeatTemplate> getChildTemplates() { + if (childTemplates == null) + childTemplates = new ArrayList<>(); + return childTemplates; + } + + public void setChildTemplates(List<HeatTemplate> childTemplates) { + this.childTemplates = childTemplates; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getArtifactUuid() { + return this.artifactUuid; + } + + public void setArtifactUuid(String artifactUuid) { + this.artifactUuid = artifactUuid; + } + + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + public String getTemplateBody() { + return templateBody; + } + + public void setTemplateBody(String templateBody) { + this.templateBody = templateBody; + } + + public Integer getTimeoutMinutes() { + return timeoutMinutes; + } + + public void setTimeoutMinutes(Integer timeout) { + this.timeoutMinutes = timeout; + } + + @LinkedResource + public Set<HeatTemplateParam> getParameters() { + if (parameters == null) + parameters = new HashSet<>(); + return parameters; + } + + public void setParameters(Set<HeatTemplateParam> parameters) { + this.parameters = parameters; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHeatTemplate() { + return this.templateBody; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public Date getCreated() { + return created; + } +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParam.java index 7f7dd2b4c6..cdbe7aee7a 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParam.java @@ -18,30 +18,74 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; 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 org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; import com.openpojo.business.annotation.BusinessKey; +@IdClass(HeatTemplateParamId.class) +@Entity +@Table(name = "heat_template_params") public class HeatTemplateParam implements Serializable { @BusinessKey - private String heatTemplateArtifactUuid = null; + @Id + @Column(name = "HEAT_TEMPLATE_ARTIFACT_UUID") + private String heatTemplateArtifactUuid; + @BusinessKey - private String paramName = null; - private boolean required; - private String paramType = null; - private String paramAlias = null; - public static final long serialVersionUID = -1322322139926390329L; - - public HeatTemplateParam() {} - + @Id + @Column(name = "PARAM_NAME") + private String paramName; + + @Column(name = "IS_REQUIRED") + private Boolean required; + + @Column(name = "PARAM_TYPE") + private String paramType; + + @Column(name = "PARAM_ALIAS") + private String paramAlias; + + public static final long serialVersionUID = -1322322139926390329L; + + @Override + public String toString() { + return new ToStringBuilder(this).append("heatTemplateArtifactUuid", heatTemplateArtifactUuid) + .append("paramName", paramName).append("required", required).append("paramType", paramType) + .append("paramAlias", paramAlias).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof HeatTemplateParam)) { + return false; + } + HeatTemplateParam castOther = (HeatTemplateParam) other; + return new EqualsBuilder().append(heatTemplateArtifactUuid, castOther.heatTemplateArtifactUuid) + .append(paramName, castOther.paramName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(heatTemplateArtifactUuid).append(paramName).toHashCode(); + } + public String getHeatTemplateArtifactUuid() { return this.heatTemplateArtifactUuid; } + public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; } @@ -49,49 +93,32 @@ public class HeatTemplateParam implements Serializable { public String getParamName() { return paramName; } + public void setParamName(String paramName) { this.paramName = paramName; } - public boolean isRequired() { + + public Boolean isRequired() { return required; } - public void setRequired(boolean required) { + + public void setRequired(Boolean required) { this.required = required; } + public String getParamAlias() { return paramAlias; } + public void setParamAlias(String paramAlias) { this.paramAlias = paramAlias; } - - public String getParamType() { - return paramType; - } - public void setParamType (String paramType) { - this.paramType = paramType; - } - - - @Override - public String toString () { - return "Param=" + paramName + ",type=" + paramType + ",required=" + required + ",paramAlias=" + paramAlias + ", heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid; - } - @Override - public boolean equals(final Object other) { - if (!(other instanceof HeatTemplateParam)) { - return false; - } - HeatTemplateParam castOther = (HeatTemplateParam) other; - return new EqualsBuilder().append(heatTemplateArtifactUuid, castOther.heatTemplateArtifactUuid) - .append(paramName, castOther.paramName).isEquals(); + public String getParamType() { + return paramType; } - @Override - public int hashCode () { - int result; - result = this.paramName == null ? 0 : this.paramName.hashCode() + this.heatTemplateArtifactUuid == null ? 0 : this.heatTemplateArtifactUuid.hashCode(); - return result; + public void setParamType(String paramType) { + this.paramType = paramType; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParamId.java index 9bfc41b675..61c199c43f 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HeatTemplateParamId.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,63 +18,58 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; import java.io.Serializable; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + import com.openpojo.business.annotation.BusinessKey; -// an embeddable class to represent the Composite key for NetworkResource in the 1707 db refactoring -public class HeatTemplateArtifactUuidModelUuid implements Serializable { - +public class HeatTemplateParamId implements Serializable { @BusinessKey - private String heatTemplateArtifactUuid = null; + private String heatTemplateArtifactUuid; @BusinessKey - private String modelUuid = null; + private String paramName; + public static final long serialVersionUID = -1322322139926390329L; - public HeatTemplateArtifactUuidModelUuid() { + @Override + public boolean equals(final Object other) { + if (!(other instanceof HeatTemplateParamId)) { + return false; + } + HeatTemplateParamId castOther = (HeatTemplateParamId) other; + return new EqualsBuilder().append(heatTemplateArtifactUuid, castOther.heatTemplateArtifactUuid) + .append(paramName, castOther.paramName).isEquals(); } - + + @Override + public int hashCode() { + return new HashCodeBuilder().append(heatTemplateArtifactUuid).append(paramName).toHashCode(); + } + public String getHeatTemplateArtifactUuid() { return this.heatTemplateArtifactUuid; } + public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; } - public String getModelUuid() { - return this.modelUuid; + + public String getParamName() { + return this.paramName; } - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; + + public void setParamName(String paramName) { + this.paramName = paramName; } @Override public String toString() { - return "heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid + " modelUuid=" + this.modelUuid; + return new ToStringBuilder(this).append("heatTemplateArtifactUuid", heatTemplateArtifactUuid) + .append("paramName", paramName).toString(); } - - @Override - public boolean equals (Object o) { - if (!(o instanceof HeatTemplateArtifactUuidModelUuid)) { - return false; - } - if (this == o) { - return true; - } - HeatTemplateArtifactUuidModelUuid htaumu = (HeatTemplateArtifactUuidModelUuid) o; - if (htaumu.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid()) - && htaumu.getModelUuid().equals(this.getModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - return this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode(); - } - } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java new file mode 100644 index 0000000000..fdd250089a --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroup.java @@ -0,0 +1,232 @@ +/*- + * ============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.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@DiscriminatorColumn(name = "OBJECT_TYPE") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@Table(name = "instance_group") +public class InstanceGroup implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -263859017727376578L; + + @BusinessKey + @Id + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "ROLE") + private String role; + + @Column(name = "TOSCA_NODE_TYPE") + private String toscaNodeType; + + @Enumerated(EnumType.STRING) + @Column(name = "INSTANCE_GROUP_TYPE") + private InstanceGroupType type; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "CR_MODEL_UUID") + private CollectionResource collectionResource; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup") + private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup") + private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup") + private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelName", modelName) + .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion) + .append("role", role).append("toscaNodeType", toscaNodeType).append("type", type) + .append("created", created).append("collectionResource", collectionResource) + .append("collectionInstanceGroupCustomizations", collectionInstanceGroupCustomizations) + .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof InstanceGroup)) { + return false; + } + InstanceGroup castOther = (InstanceGroup) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public String getModelUUID() { + return modelUUID; + } + + public Date getCreated() { + return created; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getModelName() { + return modelName; + } + + public String getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + 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 getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public InstanceGroupType getType() { + return type; + } + + public void setType(InstanceGroupType type) { + this.type = type; + } + + @LinkedResource + public CollectionResource getCollectionResource() { + return collectionResource; + } + + public void setCollectionResource(CollectionResource collectionResource) { + this.collectionResource = collectionResource; + } + + @LinkedResource + public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() { + return collectionInstanceGroupCustomizations; + } + + public void setCollectionInstanceGroupCustomizations( + List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) { + this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations; + } + + @LinkedResource + public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() { + return vnfcInstanceGroupCustomizations; + } + + public void setVnfcInstanceGroupCustomizations( + List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) { + this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations; + } + + @LinkedResource + public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomizations() { + return collectionNetworkResourceCustomizations; + } + + public void setCollectionNetworkResourceCustomizations( + List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations) { + this.collectionNetworkResourceCustomizations = collectionNetworkResourceCustomizations; + } +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroupType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroupType.java new file mode 100644 index 0000000000..e67078b104 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/InstanceGroupType.java @@ -0,0 +1,25 @@ +/*- + * ============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; + +public enum InstanceGroupType { + L3_NETWORK, VNFC; +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Model.java index 5cd6b58aee..9c5c23ef0e 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Model.java @@ -17,44 +17,71 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; +import java.util.Date; import java.util.Map; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; -public class Model extends MavenLikeVersioning implements Serializable { +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.MapKey; +import javax.persistence.OneToMany; +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.openpojo.business.annotation.BusinessKey; +@Entity +@Table(name = "model") +public class Model implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private int id; + @Id + @Column(name = "ID", nullable = false, updatable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @Column(name = "MODEL_CUSTOMIZATION_ID", length = 40) private String modelCustomizationId = null; + @Column(name = "MODEL_CUSTOMIZATION_NAME", length = 40) private String modelCustomizationName = null; + @Column(name = "MODEL_INVARIANT_ID", length = 40) private String modelInvariantId = null; + @Column(name = "MODEL_NAME", length = 40) private String modelName = null; + @BusinessKey + @Column(name = "MODEL_TYPE", length = 20) private String modelType = null; + @Column(name = "MODEL_VERSION", length = 20) private String modelVersion = null; + @BusinessKey + @Column(name = "MODEL_VERSION_ID", length = 40) private String modelVersionId = null; - private Timestamp created = null; - private Map<String,ServiceRecipe> recipes; + @Column(name = "CREATION_TIMESTAMP", nullable = false, updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created = null; + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy="modelId") + @MapKey(name = "action") + private Map<String,ModelRecipe> recipes; /** * @return the id */ - public int getId() { + public Integer getId() { return id; } - - /** - * @param id the id to set - */ - public void setId(int id) { - this.id = id; - } - + /** * @return the modelCustomizationId */ @@ -156,46 +183,47 @@ public class Model extends MavenLikeVersioning implements Serializable { /** * @return the created */ - public Timestamp getCreated() { + public Date getCreated() { return created; } /** - * @param created the created to set - */ - public void setCreated(Timestamp created) { - this.created = created; - } - - /** * @return the recipes */ - public Map<String, ServiceRecipe> getRecipes() { + public Map<String, ModelRecipe> getRecipes() { return recipes; } /** * @param recipes the recipes to set */ - public void setRecipes(Map<String, ServiceRecipe> recipes) { + public void setRecipes(Map<String, ModelRecipe> recipes) { this.recipes = recipes; } @Override + public boolean equals(final Object other) { + if (!(other instanceof Model)) { + return false; + } + Model castOther = (Model) other; + return new EqualsBuilder().append(getModelType(), castOther.getModelType()) + .append(getModelVersionId(), castOther.getModelVersionId()).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(getModelType()).append(getModelVersionId()).toHashCode(); + } + + @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Model: "); - sb.append("modelCustomizationId=").append(modelCustomizationId); - sb.append(",modelCustomizationName=").append(modelCustomizationName); - sb.append(",modelInvariantId=").append(modelInvariantId); - sb.append(",modelName=").append(modelName); - sb.append(",modelType=").append(modelType); - sb.append(",modelVersion=").append(modelVersion); - sb.append(",modelVersionId=").append(modelVersionId); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); + return new ToStringBuilder(this).append("id", getId()).append("modelCustomizationId", getModelCustomizationId()) + .append("modelCustomizationName", getModelCustomizationName()) + .append("modelInvariantId", getModelInvariantId()).append("modelName", getModelName()) + .append("modelType", getModelType()).append("modelVersion", getModelVersion()) + .append("modelVersionId", getModelVersionId()).append("created", getCreated()) + .append("recipes", getRecipes()).toString(); } + } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ModelRecipe.java index 4ba35f7f42..3d7cb68172 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ModelRecipe.java @@ -17,43 +17,65 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class ModelRecipe extends MavenLikeVersioning implements Serializable { +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +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.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "model_recipe") +public class ModelRecipe implements Serializable { private static final long serialVersionUID = 768026109321305392L; - private int id; + @Id + @Column(name = "ID", nullable = false, updatable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @BusinessKey + @Column(name = "MODEL_ID", nullable = false) private Integer modelId; + @BusinessKey + @Column(name = "ACTION", length = 50) private String action = null; - private String schemaVersion = null; + @Column(name = "SCHEMA_VERSION", length = 20) + private String schemaVersion = null; + @Column(name = "DESCRIPTION", length = 1200) private String description = null; + @Column(name = "ORCHESTRATION_URI", length = 256) private String orchestrationUri = null; + @Column(name = "MODEL_PARAM_XSD", length = 2048) private String modelParamXSD = null; + @Column(name = "RECIPE_TIMEOUT") private Integer recipeTimeout; - private Timestamp created = null; + @Column(name = "CREATION_TIMESTAMP", nullable = false, updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created = null; /** * @return the id */ - public int getId() { + public Integer getId() { return id; } /** - * @param id the id to set - */ - public void setId(int id) { - this.id = id; - } - - /** * @return the modelId */ public Integer getModelId() { @@ -154,31 +176,31 @@ public class ModelRecipe extends MavenLikeVersioning implements Serializable { /** * @return the created */ - public Timestamp getCreated() { + public Date getCreated() { return created; } - /** - * @param created the created to set - */ - public void setCreated(Timestamp created) { - this.created = created; + @Override + public boolean equals(final Object other) { + if (!(other instanceof ModelRecipe)) { + return false; + } + ModelRecipe castOther = (ModelRecipe) other; + return new EqualsBuilder().append(getModelId(), castOther.getModelId()) + .append(getAction(), castOther.getAction()).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(getModelId()).append(getAction()).toHashCode(); } @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ModelRecipe: "); - sb.append("modelId=").append(modelId); - sb.append(",action=").append(action); - sb.append(",schemaVersion=").append(schemaVersion); - sb.append(",orchestrationUri=").append(orchestrationUri); - sb.append(",modelParamXSD=").append(modelParamXSD); - sb.append(",recipeTimeout=").append(recipeTimeout); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); + return new ToStringBuilder(this).append("id", getId()).append("modelId", getModelId()) + .append("action", getAction()).append("schemaVersion", getSchemaVersion()) + .append("description", getDescription()).append("orchestrationUri", getOrchestrationUri()) + .append("modelParamXSD", getModelParamXSD()).append("recipeTimeout", getRecipeTimeout()) + .append("created", getCreated()).toString(); } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkCollectionResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkCollectionResourceCustomization.java new file mode 100644 index 0000000000..a1b51f9a6b --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkCollectionResourceCustomization.java @@ -0,0 +1,53 @@ +/*- + * ============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.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.OneToMany; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@DiscriminatorValue(value = "NetworkCollection") +public class NetworkCollectionResourceCustomization extends CollectionResourceCustomization { + + /** + * + */ + private static final long serialVersionUID = -4571173204548832466L; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "networkResourceCustomization") + private Set<CollectionNetworkResourceCustomization> networkResourceCustomization; + + @LinkedResource + public Set<CollectionNetworkResourceCustomization> getNetworkResourceCustomization() { + return networkResourceCustomization; + } + + public void setNetworkResourceCustomization( + Set<CollectionNetworkResourceCustomization> networkResourceCustomization) { + this.networkResourceCustomization = networkResourceCustomization; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkInstanceGroup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkInstanceGroup.java new file mode 100644 index 0000000000..edda4b8122 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkInstanceGroup.java @@ -0,0 +1,34 @@ +/*- + * ============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 javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +@Entity +@DiscriminatorValue(value = "L3_NETWORK") +public class NetworkInstanceGroup extends InstanceGroup { + + /** + * + */ + private static final long serialVersionUID = 1934855643166769237L; +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java new file mode 100644 index 0000000000..73056e2f8c --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java @@ -0,0 +1,174 @@ +/*- + * ============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.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +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 com.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "network_recipe") +public class NetworkRecipe implements Serializable, Recipe { + private static final long serialVersionUID = 768026109321305392L; + + @Id + @Column(name = "id") + private Integer id; + + @BusinessKey + @Column(name = "ACTION") + protected String action; + + @Column(name = "DESCRIPTION") + private String description; + + @BusinessKey + @Column(name = "ORCHESTRATION_URI") + protected String orchestrationUri; + + @Column(name = "RECIPE_TIMEOUT") + private Integer recipeTimeout; + + @BusinessKey + @Column(name = "SERVICE_TYPE") + private String serviceType; + + @BusinessKey + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "NETWORK_PARAM_XSD") + private String paramXsd; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof NetworkRecipe)) { + return false; + } + NetworkRecipe castOther = (NetworkRecipe) other; + return new EqualsBuilder().append(action, castOther.action).append(orchestrationUri, castOther.orchestrationUri) + .append(serviceType, castOther.serviceType).append(modelName, castOther.modelName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(action).append(orchestrationUri).append(serviceType).append(modelName) + .toHashCode(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getOrchestrationUri() { + return orchestrationUri; + } + + public void setOrchestrationUri(String orchestrationUri) { + this.orchestrationUri = orchestrationUri; + } + + public Integer getRecipeTimeout() { + return recipeTimeout; + } + + public void setRecipeTimeout(Integer recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public Date getCreated() { + return created; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getParamXsd() { + return paramXsd; + } + + public void setParamXsd(String paramXsd) { + this.paramXsd = paramXsd; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(super.toString()); + sb.append(",modelName=" + modelName); + sb.append(",networkParamXSD=" + paramXsd); + return sb.toString(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResource.java new file mode 100644 index 0000000000..c31cd61ce0 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResource.java @@ -0,0 +1,305 @@ +/*- + * ============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.text.DateFormat; +import java.util.ArrayList; +import java.util.Date; +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.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 com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "network_resource") +public class NetworkResource implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "ORCHESTRATION_MODE") + private String orchestrationMode = null; + + @Column(name = "DESCRIPTION") + private String description = null; + + @Column(name = "NEUTRON_NETWORK_TYPE") + private String neutronNetworkType = null; + + @Column(name = "AIC_VERSION_MIN") + private String aicVersionMin = null; + + @Column(name = "AIC_VERSION_MAX") + private String aicVersionMax = null; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "TOSCA_NODE_TYPE") + private String toscaNodeType; + + @Column(name = "RESOURCE_CATEGORY") + private String category; + + @Column(name = "RESOURCE_SUB_CATEGORY") + private String subCategory; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "networkResource") + private List<NetworkResourceCustomization> networkResourceCustomization; + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "networkResource") + private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomization; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID") + private HeatTemplate heatTemplate; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof NetworkResource)) { + return false; + } + NetworkResource castOther = (NetworkResource) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } + + @LinkedResource + public List<NetworkResourceCustomization> getNetworkResourceCustomization() { + return networkResourceCustomization; + } + + public void addNetworkResourceCustomization(NetworkResourceCustomization networkResourceCustomization) { + if (this.networkResourceCustomization == null) + this.networkResourceCustomization = new ArrayList<>(); + + this.networkResourceCustomization.add(networkResourceCustomization); + } + + public void setNetworkResourceCustomization(List<NetworkResourceCustomization> networkResourceCustomization) { + this.networkResourceCustomization = networkResourceCustomization; + } + + @LinkedResource + public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomization() { + return collectionNetworkResourceCustomization; + } + + public void setCollectionNetworkResourceCustomization( + List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomization) { + this.collectionNetworkResourceCustomization = collectionNetworkResourceCustomization; + } + + public String getOrchestrationMode() { + return orchestrationMode; + } + + public void setOrchestrationMode(String orchestrationMode) { + this.orchestrationMode = orchestrationMode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNeutronNetworkType() { + return neutronNetworkType; + } + + public void setNeutronNetworkType(String neutronNetworkType) { + this.neutronNetworkType = neutronNetworkType; + } + + public Date getCreated() { + return created; + } + + public String getAicVersionMin() { + return aicVersionMin; + } + + public void setAicVersionMin(String aicVersionMin) { + this.aicVersionMin = aicVersionMin; + } + + public String getAicVersionMax() { + return aicVersionMax; + } + + public void setAicVersionMax(String aicVersionMax) { + this.aicVersionMax = aicVersionMax; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getModelInvariantUUID() { + return modelInvariantUUID; + } + + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } + + public String getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public String getModelUUID() { + return modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + /** + * @return Returns the category. + */ + public String getCategory() { + return category; + } + + /** + * @param category + * The category to set. + */ + public void setCategory(String category) { + this.category = category; + } + + /** + * @return Returns the subCategory. + */ + public String getSubCategory() { + return subCategory; + } + + /** + * @param subCategory + * The subCategory to set. + */ + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + @LinkedResource + public HeatTemplate getHeatTemplate() { + return heatTemplate; + } + + public void setHeatTemplate(HeatTemplate heatTemplate) { + this.heatTemplate = heatTemplate; + } + + public String getModelVersion() { + return modelVersion; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("NETWORK Resource:"); + sb.append("modelVersion="); + sb.append(modelVersion); + sb.append(",mode="); + sb.append(orchestrationMode); + sb.append(",neutronType="); + sb.append(neutronNetworkType); + sb.append(",aicVersionMin="); + sb.append(aicVersionMin); + sb.append(",aicVersionMax="); + sb.append(aicVersionMax); + sb.append(",modelName="); + sb.append(modelName); + sb.append(",modelInvariantUUID="); + sb.append(modelInvariantUUID); + sb.append(",toscaNodeType="); + sb.append(toscaNodeType); + sb.append(",modelUUID="); + sb.append(modelUUID); + + if (created != null) { + sb.append(",created="); + sb.append(DateFormat.getInstance().format(created)); + } + + return sb.toString(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java new file mode 100644 index 0000000000..7afeac7710 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java @@ -0,0 +1,171 @@ +/*- + * ============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.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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "network_resource_customization") +public class NetworkResourceCustomization implements Serializable { + public static final long serialVersionUID = -1322322139926390329L; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("created", created) + .append("networkTechnology", networkTechnology).append("networkType", networkType) + .append("networkScope", networkScope).append("networkRole", networkRole) + .append("networkResource", networkResource).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof NetworkResourceCustomization)) { + return false; + } + NetworkResourceCustomization castOther = (NetworkResourceCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + + public NetworkResourceCustomization() { + super(); + } + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID = null; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "NETWORK_TECHNOLOGY") + private String networkTechnology; + + @Column(name = "NETWORK_TYPE") + private String networkType = null; + + @Column(name = "NETWORK_SCOPE") + private String networkScope; + + @Column(name = "NETWORK_ROLE") + private String networkRole; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "NETWORK_RESOURCE_MODEL_UUID") + private NetworkResource networkResource = null; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public String getModelCustomizationUUID() { + return this.modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelInstanceName() { + return this.modelInstanceName; + } + + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + + @LinkedResource + public NetworkResource getNetworkResource() { + return this.networkResource; + } + + public void setNetworkResource(NetworkResource networkResource) { + this.networkResource = networkResource; + } + + public String getNetworkType() { + return this.networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public Date getCreated() { + return this.created; + } + + public String getNetworkTechnology() { + return this.networkTechnology; + } + + public void setNetworkTechnology(String networkTechnology) { + this.networkTechnology = networkTechnology; + } + + public String getNetworkScope() { + return this.networkScope; + } + + public void setNetworkScope(String networkScope) { + this.networkScope = networkScope; + } + + public void setNetworkRole(String networkRole) { + this.networkRole = networkRole; + } + + public String getNetworkRole() { + return this.networkRole; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java new file mode 100644 index 0000000000..d831d1ebd2 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationAction.java @@ -0,0 +1,45 @@ +/*- + * ============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; + +//TODO find this file a new location? +public enum OrchestrationAction { + ASSIGN("Assign"), + UNASSIGN("Unassign"), + ACTIVATE("Activate"), + DEACTIVATE("Deactivate"), + CHANGE_MODEL("ChangeModel"), + CREATE("Create"), + DELETE("Delete"), + UPDATE("Update"), + CUSTOM("Custom"); + + private final String name; + + private OrchestrationAction(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java index 3796650364..b893cec0f2 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java @@ -18,38 +18,41 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; - - - -import java.io.Serializable; - -public class VfModuleToHeatFiles implements Serializable { - - private String vfModuleModelUuid = null; - private String heatFilesArtifactUuid = null; - public static final long serialVersionUID = -1322322139926390329L; - - public VfModuleToHeatFiles() { - super(); - } - - public String getVfModuleModelUuid() { - return this.vfModuleModelUuid; - } - public void setVfModuleModelUuid(String vfModuleModelUuid) { - this.vfModuleModelUuid = vfModuleModelUuid; - } - public String getHeatFilesArtifactUuid() { - return this.heatFilesArtifactUuid; - } - public void setHeatFilesArtifactUuid(String heatFilesArtifactUuid) { - this.heatFilesArtifactUuid = heatFilesArtifactUuid; +package org.onap.so.db.catalog.beans; + +public enum OrchestrationStatus { + ACTIVE("Active", "active"), + ASSIGNED("Assigned", "assigned"), + CREATED("Created", "created"), + INVENTORIED("Inventoried", "inventoried"), + PENDING("Pending", "pending"), + PENDING_ACTIVATION("PendingActivation", "pending.?activation"), + PENDING_CREATE("PendingCreate", "pending.?create"), + PENDING_DELETE("PendingDelete", "pending.?delete"), + PRECREATED("PreCreated", "pre.?created"); + + private final String name; + private final String fuzzyMatcher; + private OrchestrationStatus(String name, String fuzzyMatcher) { + this.name = name; + this.fuzzyMatcher = fuzzyMatcher; } @Override public String toString() { - return "vfModuleModelUuid=" + this.vfModuleModelUuid + ", heatFilesArtifactUuid=" + this.heatFilesArtifactUuid; + return name; + } + /** + * case insensitive regular expression match to enum value + * + * @param status + * @return + */ + public boolean fuzzyMap(String status) { + if (status != null) { + return status.matches("(?i)" + this.fuzzyMatcher); + } else { + return false; + } } - } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusStateTransitionDirective.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusStateTransitionDirective.java new file mode 100644 index 0000000000..517b17af91 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusStateTransitionDirective.java @@ -0,0 +1,133 @@ +/*- + * ============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 javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "orchestration_status_state_transition_directive") +public class OrchestrationStatusStateTransitionDirective implements Serializable { + private static final long serialVersionUID = -4626396955833442376L; + + @Id + @Column(name = "id") + @GeneratedValue + private Integer id; + + @Enumerated(EnumType.STRING) + @Column(name = "RESOURCE_TYPE") + @BusinessKey + private ResourceType resourceType; + + @Enumerated(EnumType.STRING) + @Column(name = "ORCHESTRATION_STATUS") + @BusinessKey + private OrchestrationStatus orchestrationStatus; + + @Enumerated(EnumType.STRING) + @Column(name = "TARGET_ACTION") + @BusinessKey + private OrchestrationAction targetAction; + + @Enumerated(EnumType.STRING) + @Column(name = "FLOW_DIRECTIVE") + @BusinessKey + private OrchestrationStatusValidationDirective flowDirective; + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("resourceType", resourceType) + .append("orchestrationStatus", orchestrationStatus).append("targetAction", targetAction) + .append("flowDirective", flowDirective).toString(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public ResourceType getResourceType() { + return resourceType; + } + + public void setResourceType(ResourceType resourceType) { + this.resourceType = resourceType; + } + + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public OrchestrationAction getTargetAction() { + return targetAction; + } + + public void setTargetAction(OrchestrationAction targetAction) { + this.targetAction = targetAction; + } + + public OrchestrationStatusValidationDirective getFlowDirective() { + return flowDirective; + } + + public void setFlowDirective(OrchestrationStatusValidationDirective flowDirective) { + this.flowDirective = flowDirective; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof OrchestrationStatusStateTransitionDirective)) { + return false; + } + OrchestrationStatusStateTransitionDirective castOther = (OrchestrationStatusStateTransitionDirective) other; + return new EqualsBuilder().append(getResourceType(), castOther.getResourceType()) + .append(getOrchestrationStatus(), castOther.getOrchestrationStatus()) + .append(getTargetAction(), castOther.getTargetAction()) + .append(getFlowDirective(), castOther.getFlowDirective()).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(getResourceType()).append(getOrchestrationStatus()) + .append(getTargetAction()).append(getFlowDirective()).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusValidationDirective.java index d3532886d5..544e1cbf08 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusValidationDirective.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * 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. @@ -18,25 +18,20 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; +//TODO find this file a new location? +public enum OrchestrationStatusValidationDirective { + SILENT_SUCCESS("SilentSuccess"), CONTINUE("Continue"), FAIL("Fail"); -import java.io.Serializable; + private final String name; -public class ArRecipe extends Recipe implements Serializable { - private static final long serialVersionUID = 768026109321305392L; - private String modelName = null; - public ArRecipe() {} - - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; + private OrchestrationStatusValidationDirective(String name) { + this.name = name; } - @Override - public String toString () { - return super.toString() + ",modelName=" + modelName + ",arParamXSD=" + getParamXSD(); + @Override + public String toString() { + return name; } } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Recipe.java index d10b633557..ff6b713e6b 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Recipe.java @@ -18,25 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; +public interface Recipe { + public Integer getId(); -import java.io.Serializable; + public String getAction(); -public class NetworkRecipe extends Recipe implements Serializable { - private static final long serialVersionUID = 768026109321305392L; - private String modelName = null; - public NetworkRecipe() {} + public String getDescription(); - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } + public String getParamXsd(); - @Override - public String toString () { - return super.toString() + ",modelName=" + modelName + ",networkParamXSD=" + getParamXSD(); - } + public String getOrchestrationUri(); + + public Integer getRecipeTimeout(); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java new file mode 100644 index 0000000000..8e1d498e42 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java @@ -0,0 +1,43 @@ +/*- + * ============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; + +public enum ResourceType { + SERVICE("Service"), + VNF("Vnf"), + VOLUME_GROUP("VolumeGroup"), + VF_MODULE("VfModule"), + NETWORK("Network"), + NETWORK_COLLECTION("NetworkCollection"), + CONFIGURATION("Configuration"), + CUSTOM("Custom"); + + private final String name; + + private ResourceType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java new file mode 100644 index 0000000000..6eb453805b --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java @@ -0,0 +1,335 @@ +/*- + * ============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.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToOne; +import javax.persistence.MapKey; +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 = "service") +public class Service implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "DESCRIPTION", length = 1200) + private String description; + + @BusinessKey + @Id + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "SERVICE_TYPE") + private String serviceType; + + @Column(name = "SERVICE_ROLE") + private String serviceRole; + + @Column(name = "ENVIRONMENT_CONTEXT") + private String environmentContext; + + @Column(name = "WORKLOAD_CONTEXT") + private String workloadContext; + + @Column(name = "SERVICE_CATEGORY") + private String category; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "network_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) + private List<NetworkResourceCustomization> networkCustomizations; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "vnf_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) + private List<VnfResourceCustomization> vnfCustomizations; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "allotted_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) + private List<AllottedResourceCustomization> allottedCustomizations; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "collection_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) + private List<CollectionResourceCustomization> collectionResourceCustomizations; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "service_proxy_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) + private List<ServiceProxyResourceCustomization> serviceProxyCustomizations; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "configuration_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) + private List<ConfigurationResourceCustomization> configurationCustomizations; + + @OneToMany(cascade = CascadeType.ALL) + @MapKey(name = "action") + @JoinColumn(name = "SERVICE_MODEL_UUID") + private Map<String, ServiceRecipe> recipes; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "TOSCA_CSAR_ARTIFACT_UUID") + private ToscaCsar csar; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelName", modelName).append("description", description) + .append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) + .append("created", created).append("modelVersion", modelVersion).append("serviceType", serviceType) + .append("serviceRole", serviceRole).append("environmentContext", environmentContext) + .append("workloadContext", workloadContext).append("category", category) + .append("networkCustomizations", networkCustomizations).append("vnfCustomizations", vnfCustomizations) + .append("allottedCustomizations", allottedCustomizations) + .append("collectionResourceCustomizations", collectionResourceCustomizations) + .append("serviceProxyCustomizations", serviceProxyCustomizations) + .append("configurationCustomizations", configurationCustomizations).append("recipes", recipes) + .append("csar", csar).toString(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof Service)) { + return false; + } + Service castOther = (Service) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } + + @LinkedResource + public List<ServiceProxyResourceCustomization> getServiceProxyCustomizations() { + return serviceProxyCustomizations; + } + + public void setServiceProxyCustomizations(List<ServiceProxyResourceCustomization> serviceProxyCustomizations) { + this.serviceProxyCustomizations = serviceProxyCustomizations; + } + + @LinkedResource + public List<NetworkResourceCustomization> getNetworkCustomizations() { + if (networkCustomizations == null) + networkCustomizations = new ArrayList<>(); + return networkCustomizations; + } + + public void setNetworkCustomizations(List<NetworkResourceCustomization> networkCustomizations) { + this.networkCustomizations = networkCustomizations; + } + + @LinkedResource + public List<VnfResourceCustomization> getVnfCustomizations() { + if (vnfCustomizations == null) + vnfCustomizations = new ArrayList<>(); + return vnfCustomizations; + } + + public void setVnfCustomizations(List<VnfResourceCustomization> vnfCustomizations) { + this.vnfCustomizations = vnfCustomizations; + } + + @LinkedResource + public List<AllottedResourceCustomization> getAllottedCustomizations() { + if (allottedCustomizations == null) + allottedCustomizations = new ArrayList<>(); + return allottedCustomizations; + } + + public void setAllottedCustomizations(List<AllottedResourceCustomization> allotedCustomizations) { + this.allottedCustomizations = allotedCustomizations; + } + + @LinkedResource + public List<CollectionResourceCustomization> getCollectionResourceCustomizations() { + if (collectionResourceCustomizations == null) + collectionResourceCustomizations = new ArrayList<>(); + return collectionResourceCustomizations; + } + + public void setCollectionResourceCustomizations( + List<CollectionResourceCustomization> collectionResourceCustomizations) { + this.collectionResourceCustomizations = collectionResourceCustomizations; + } + + @LinkedResource + public List<ConfigurationResourceCustomization> getConfigurationCustomizations() { + if(configurationCustomizations == null) + configurationCustomizations = new ArrayList<>(); + return configurationCustomizations; + } + + public void setConfigurationCustomizations(List<ConfigurationResourceCustomization> configurationCustomizations) { + this.configurationCustomizations = configurationCustomizations; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @LinkedResource + public Map<String, ServiceRecipe> getRecipes() { + return recipes; + } + + public void setRecipes(Map<String, ServiceRecipe> recipes) { + this.recipes = recipes; + } + + public Date getCreated() { + return created; + } + + 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; + } + + /** + * @return Returns the category. + */ + public String getCategory() { + return category; + } + + /** + * @param category + * The category to set. + */ + public void setCategory(String category) { + this.category = category; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceRole() { + return serviceRole; + } + + public void setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + } + + public String getEnvironmentContext() { + return this.environmentContext; + } + + public void setEnvironmentContext(String environmentContext) { + this.environmentContext = environmentContext; + } + + @LinkedResource + public ToscaCsar getCsar() { + return csar; + } + + public void setCsar(ToscaCsar csar) { + this.csar = csar; + } + + public String getWorkloadContext() { + return this.workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResource.java new file mode 100644 index 0000000000..a3f12edef4 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResource.java @@ -0,0 +1,158 @@ +/*- + * ============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.Id; +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.JsonIgnoreProperties; +import com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" }) +@Entity +@Table(name = "service_proxy") +public class ServiceProxyResource implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8113564204017394906L; + + @BusinessKey + @Id + @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 = "DESCRIPTION") + private String description; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "serviceProxyResource") + private Set<ServiceProxyResourceCustomization> serviceProxyCustomization; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + 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 getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreated() { + return created; + } + + @LinkedResource + public Set<ServiceProxyResourceCustomization> getServiceProxyCustomization() { + return serviceProxyCustomization; + } + + public void setServiceProxyCustomization(Set<ServiceProxyResourceCustomization> serviceProxyCustomization) { + this.serviceProxyCustomization = serviceProxyCustomization; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) + .append("modelVersion", modelVersion).append("modelName", modelName).append("description", description) + .append("created", created).append("serviceProxyCustomization", serviceProxyCustomization).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ServiceProxyResource)) { + return false; + } + ServiceProxyResource castOther = (ServiceProxyResource) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java new file mode 100644 index 0000000000..3df22bc716 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceProxyResourceCustomization.java @@ -0,0 +1,164 @@ +/*- + * ============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.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "service_proxy_customization") +public class ServiceProxyResourceCustomization implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -2822457299134903084L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "TOSCA_NODE_TYPE") + private String toscaNodeType; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "SOURCE_SERVICE_MODEL_UUID") + private Service sourceService; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "SERVICE_PROXY_MODEL_UUID") + private ServiceProxyResource serviceProxyResource; + + @OneToOne(mappedBy = "serviceProxyResourceCustomization") + private ConfigurationResourceCustomization configResourceCustomization; + + @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 getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public Date getCreated() { + return created; + } + + @LinkedResource + public Service getSourceService() { + return sourceService; + } + + public void setSourceService(Service sourceService) { + this.sourceService = sourceService; + } + + @LinkedResource + public ServiceProxyResource getServiceProxyResource() { + return serviceProxyResource; + } + + public void setServiceProxyResource(ServiceProxyResource serviceProxyResource) { + this.serviceProxyResource = serviceProxyResource; + } + + @LinkedResource + public ConfigurationResourceCustomization getConfigResourceCustomization() { + return configResourceCustomization; + } + + public void setConfigResourceCustomization(ConfigurationResourceCustomization configResourceCustomization) { + this.configResourceCustomization = configResourceCustomization; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("toscaNodeType", toscaNodeType) + .append("created", created).append("sourceService", sourceService) + .append("serviceProxyResource", serviceProxyResource) + .append("configResourceCustomization", configResourceCustomization).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ServiceProxyResourceCustomization)) { + return false; + } + ServiceProxyResourceCustomization castOther = (ServiceProxyResourceCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java new file mode 100644 index 0000000000..d063ea4809 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java @@ -0,0 +1,184 @@ +/*- + * ============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.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +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.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "service_recipe") +public class ServiceRecipe implements Serializable, Recipe { + + private static final long serialVersionUID = 768026109321305392L; + + @Id + @Column(name = "id") + private Integer id; + + @BusinessKey + @Column(name = "SERVICE_MODEL_UUID") + private String serviceModelUUID; + + @BusinessKey + @Column(name = "ACTION") + private String action; + + @Column(name = "description") + private String description; + + @BusinessKey + @Column(name = "ORCHESTRATION_URI") + private String orchestrationUri; + + @Column(name = "SERVICE_PARAM_XSD") + private String paramXsd; + + @Column(name = "RECIPE_TIMEOUT") + private Integer recipeTimeout; + + @Column(name = "SERVICE_TIMEOUT_INTERIM") + private Integer serviceTimeoutInterim; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("serviceModelUUID", serviceModelUUID) + .append("action", action).append("description", description) + .append("orchestrationUri", orchestrationUri).append("serviceParamXSD", paramXsd) + .append("recipeTimeout", recipeTimeout).append("serviceTimeoutInterim", serviceTimeoutInterim) + .append("created", created).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ServiceRecipe)) { + return false; + } + ServiceRecipe castOther = (ServiceRecipe) other; + return new EqualsBuilder().append(serviceModelUUID, castOther.serviceModelUUID).append(action, castOther.action) + .append(orchestrationUri, castOther.orchestrationUri).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(serviceModelUUID).append(action).append(orchestrationUri).toHashCode(); + } + + // This 'default' CTR is now needed for backward compatibility since a new + // CTR was added below + public ServiceRecipe() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public void setCreated(Date created) { + this.created = created; + } + + public String getServiceModelUUID() { + return serviceModelUUID; + } + + public void setServiceModelUUID(String serviceModelUUID) { + this.serviceModelUUID = serviceModelUUID; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getOrchestrationUri() { + return orchestrationUri; + } + + public void setOrchestrationUri(String orchestrationUri) { + this.orchestrationUri = orchestrationUri; + } + + public String getParamXsd() { + return paramXsd; + } + + public void setParamXsd(String paramXsd) { + this.paramXsd = paramXsd; + } + + public Integer getRecipeTimeout() { + return recipeTimeout; + } + + public void setRecipeTimeout(Integer recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + public Integer getServiceTimeoutInterim() { + return serviceTimeoutInterim; + } + + public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) { + this.serviceTimeoutInterim = serviceTimeoutInterim; + } + + public Date getCreated() { + return created; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/SubType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/SubType.java new file mode 100644 index 0000000000..bc4f07b54b --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/SubType.java @@ -0,0 +1,25 @@ +/*- + * ============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; + +public enum SubType { + SUB_INTERFACE +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookup.java index 6fd6e3e6ae..484a5a9e97 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookup.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,21 +18,58 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; 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 org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + import com.openpojo.business.annotation.BusinessKey; +@Entity +@Table(name = "temp_network_heat_template_lookup") +@IdClass(TempNetworkHeatTemplateLookupId.class) public class TempNetworkHeatTemplateLookup implements Serializable { + public static final long serialVersionUID = -1322322139926390329L; + @BusinessKey - private String networkResourceModelName = null; + @Id + @Column(name = "NETWORK_RESOURCE_MODEL_NAME") + private String networkResourceModelName; + @BusinessKey - private String heatTemplateArtifactUuid = null; - private String aicVersionMin = null; - private String aicVersionMax = null; - public static final long serialVersionUID = -1322322139926390329L; + @Id + @Column(name = "HEAT_TEMPLATE_ARTIFACT_UUID") + private String heatTemplateArtifactUuid; + + @Column(name = "AIC_VERSION_MIN") + private String aicVersionMin; + + @Column(name = "AIC_VERSION_MAX") + private String aicVersionMax; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof TempNetworkHeatTemplateLookup)) { + return false; + } + TempNetworkHeatTemplateLookup castOther = (TempNetworkHeatTemplateLookup) other; + return new EqualsBuilder().append(networkResourceModelName, castOther.networkResourceModelName) + .append(heatTemplateArtifactUuid, castOther.heatTemplateArtifactUuid).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(networkResourceModelName).append(heatTemplateArtifactUuid).toHashCode(); + } public TempNetworkHeatTemplateLookup() { super(); @@ -41,6 +78,7 @@ public class TempNetworkHeatTemplateLookup implements Serializable { public String getNetworkResourceModelName() { return this.networkResourceModelName; } + public void setNetworkResourceModelName(String networkResourceModelName) { this.networkResourceModelName = networkResourceModelName; } @@ -48,9 +86,11 @@ public class TempNetworkHeatTemplateLookup implements Serializable { public String getHeatTemplateArtifactUuid() { return this.heatTemplateArtifactUuid; } + public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; } + public String getAicVersionMin() { return this.aicVersionMin; } @@ -69,32 +109,11 @@ public class TempNetworkHeatTemplateLookup implements Serializable { @Override public String toString() { - return "NetworkResourceModelName=" + this.networkResourceModelName + "HeatTemplateArtifactUuid=" + - this.heatTemplateArtifactUuid + "aicVersionMin=" + this.aicVersionMin + "aicVersionMax=" + this.aicVersionMax; + StringBuilder sb = new StringBuilder(); + sb.append("NetworkResourceModelName=" + this.networkResourceModelName); + sb.append("HeatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid); + sb.append("aicVersionMin=" + this.aicVersionMin); + sb.append("aicVersionMax=" + this.aicVersionMax); + return sb.toString(); } - - @Override - public boolean equals (Object o) { - if (!(o instanceof TempNetworkHeatTemplateLookup)) { - return false; - } - if (this == o) { - return true; - } - TempNetworkHeatTemplateLookup tnhtl = (TempNetworkHeatTemplateLookup) o; - if (tnhtl.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid()) && tnhtl.getNetworkResourceModelName().equals(this.getNetworkResourceModelName())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result; - result = (this.networkResourceModelName != null ? this.networkResourceModelName.hashCode() : 0) + (this.heatTemplateArtifactUuid != null ? this.heatTemplateArtifactUuid.hashCode() : 0); - return result; - } - } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookupId.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookupId.java new file mode 100644 index 0000000000..2be6fe4e12 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/TempNetworkHeatTemplateLookupId.java @@ -0,0 +1,78 @@ +/*- + * ============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 org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +public class TempNetworkHeatTemplateLookupId implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3660507980620002091L; + @BusinessKey + private String networkResourceModelName; + @BusinessKey + private String heatTemplateArtifactUuid; + + @Override + public String toString() { + return new ToStringBuilder(this).append("networkResourceModelName", networkResourceModelName) + .append("heatTemplateArtifactUuid", heatTemplateArtifactUuid).toString(); + } + + public String getNetworkResourceModelName() { + return networkResourceModelName; + } + + public void setNetworkResourceModelName(String networkResourceModelName) { + this.networkResourceModelName = networkResourceModelName; + } + + public String getHeatTemplateArtifactUuid() { + return heatTemplateArtifactUuid; + } + + public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { + this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof TempNetworkHeatTemplateLookupId)) { + return false; + } + TempNetworkHeatTemplateLookupId castOther = (TempNetworkHeatTemplateLookupId) other; + return new EqualsBuilder().append(networkResourceModelName, castOther.networkResourceModelName) + .append(heatTemplateArtifactUuid, castOther.heatTemplateArtifactUuid).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(networkResourceModelName).append(heatTemplateArtifactUuid).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ToscaCsar.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ToscaCsar.java new file mode 100644 index 0000000000..567675044e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ToscaCsar.java @@ -0,0 +1,171 @@ +/*- + * ============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 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.JsonIgnore; +import com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "tosca_csar") +public class ToscaCsar implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "ARTIFACT_UUID") + private String artifactUUID; + + @Column(name = "NAME") + private String name; + + @Column(name = "ARTIFACT_CHECKSUM") + private String artifactChecksum; + + @Column(name = "URL") + private String url; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @BusinessKey + @Column(name = "Version") + private String version; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "csar") + @JsonIgnore + private List<Service> services; + + @Override + public String toString() { + return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("name", name) + .append("artifactChecksum", artifactChecksum).append("url", url).append("description", description) + .append("created", created).append("version", version).append("services", services).toString(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ToscaCsar)) { + return false; + } + ToscaCsar castOther = (ToscaCsar) other; + return new EqualsBuilder().append(artifactUUID, castOther.artifactUUID).append(version, castOther.version) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(artifactUUID).append(version).toHashCode(); + } + + public ToscaCsar() { + } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreated() { + return created; + } + + @LinkedResource + public List<Service> getServices() { + return services; + } + + public void setServices(List<Service> services) { + this.services = services; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VFCInstanceGroup.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VFCInstanceGroup.java new file mode 100644 index 0000000000..e44309e258 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VFCInstanceGroup.java @@ -0,0 +1,34 @@ +/*- + * ============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 javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +@Entity +@DiscriminatorValue(value = "VNFC") +public class VFCInstanceGroup extends InstanceGroup { + + /** + * + */ + private static final long serialVersionUID = -6254325954630189563L; +} 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 new file mode 100644 index 0000000000..47d82bff06 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModule.java @@ -0,0 +1,231 @@ +/*- + * ============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.ArrayList; +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.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +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 = "vf_module") +public class VfModule implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @Id + @BusinessKey + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "IS_BASE") + private Boolean isBase; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "VOL_HEAT_TEMPLATE_ARTIFACT_UUID") + private HeatTemplate volumeHeatTemplate; + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID") + private HeatTemplate moduleHeatTemplate; + + @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) + @JoinTable(name = "vf_module_to_heat_files", joinColumns = @JoinColumn(name = "VF_MODULE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "HEAT_FILES_ARTIFACT_UUID")) + private List<HeatFiles> heatFiles; + + @OneToMany(mappedBy = "vfModule") + private List<VfModuleCustomization> vfModuleCustomization; + + @ManyToOne + @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID") + private VnfResource vnfResources; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) + .append("modelName", modelName).append("modelVersion", modelVersion).append("description", description) + .append("isBase", isBase).append("volumeHeatTemplate", volumeHeatTemplate) + .append("moduleHeatTemplate", moduleHeatTemplate).append("created", created) + .append("heatFiles", heatFiles).append("vfModuleCustomization", vfModuleCustomization) + .append("vnfResources", vnfResources).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VfModule)) { + return false; + } + VfModule castOther = (VfModule) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public String getModelInvariantUUID() { + return modelInvariantUUID; + } + + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } + + @LinkedResource + public List<VfModuleCustomization> getVfModuleCustomization() { + if (vfModuleCustomization == null) + vfModuleCustomization = new ArrayList<>(); + + return vfModuleCustomization; + } + + public void setVfModuleCustomization(List<VfModuleCustomization> vfModuleCustomization) { + this.vfModuleCustomization = vfModuleCustomization; + } + + public String getModelName() { + return this.modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public Boolean getIsBase() { + return isBase; + } + + public void setIsBase(Boolean isBase) { + this.isBase = isBase; + } + + @LinkedResource + public List<HeatFiles> getHeatFiles() { + if (heatFiles == null) + heatFiles = new ArrayList<>(); + return heatFiles; + } + + public void setHeatFiles(List<HeatFiles> heatFiles) { + this.heatFiles = heatFiles; + } + + @LinkedResource + public VnfResource getVnfResources() { + return vnfResources; + } + + public void setVnfResources(VnfResource vnfResources) { + this.vnfResources = vnfResources; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreated() { + return created; + } + + public String getModelUUID() { + return modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getModelVersion() { + return modelVersion; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + @LinkedResource + public HeatTemplate getVolumeHeatTemplate() { + return volumeHeatTemplate; + } + + public void setVolumeHeatTemplate(HeatTemplate volumeHeatTemplate) { + this.volumeHeatTemplate = volumeHeatTemplate; + } + + @LinkedResource + public HeatTemplate getModuleHeatTemplate() { + return moduleHeatTemplate; + } + + public void setModuleHeatTemplate(HeatTemplate moduleHeatTemplate) { + this.moduleHeatTemplate = moduleHeatTemplate; + } +} 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 new file mode 100644 index 0000000000..4a9b3bbbb5 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VfModuleCustomization.java @@ -0,0 +1,199 @@ +/*- + * ============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.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; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "vf_module_customization") +public class VfModuleCustomization implements Serializable { + + public static final long serialVersionUID = -1322322139926390329L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "LABEL") + private String label; + + @Column(name = "MIN_INSTANCES") + private Integer minInstances; + + @Column(name = "MAX_INSTANCES") + private Integer maxInstances; + + @Column(name = "INITIAL_COUNT") + private Integer initialCount; + + @Column(name = "AVAILABILITY_ZONE_COUNT") + private Integer availabilityZoneCount; + + @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) + @JoinColumn(name = "VOL_ENVIRONMENT_ARTIFACT_UUID") + HeatEnvironment volumeHeatEnv; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "HEAT_ENVIRONMENT_ARTIFACT_UUID") + HeatEnvironment heatEnvironment; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "VF_MODULE_MODEL_UUID") + private VfModule vfModule; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID).append("label", label) + .append("minInstances", minInstances).append("maxInstances", maxInstances) + .append("initialCount", initialCount).append("availabilityZoneCount", availabilityZoneCount) + .append("created", created).append("volumeHeatEnv", volumeHeatEnv) + .append("heatEnvironment", heatEnvironment).append("vfModule", vfModule).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VfModuleCustomization)) { + return false; + } + VfModuleCustomization castOther = (VfModuleCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + + public VfModuleCustomization() { + super(); + } + + public String getModelCustomizationUUID() { + return this.modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + @LinkedResource + public HeatEnvironment getVolumeHeatEnv() { + return volumeHeatEnv; + } + + public void setVolumeHeatEnv(HeatEnvironment volumeHeatEnv) { + this.volumeHeatEnv = volumeHeatEnv; + } + + @LinkedResource + public HeatEnvironment getHeatEnvironment() { + return heatEnvironment; + } + + public void setHeatEnvironment(HeatEnvironment heatEnvironment) { + this.heatEnvironment = heatEnvironment; + } + + public Integer getMinInstances() { + return this.minInstances; + } + + public void setMinInstances(Integer minInstances) { + this.minInstances = minInstances; + } + + public Integer getMaxInstances() { + return this.maxInstances; + } + + public void setMaxInstances(Integer maxInstances) { + this.maxInstances = maxInstances; + } + + public Integer getInitialCount() { + return this.initialCount; + } + + public void setInitialCount(Integer initialCount) { + this.initialCount = initialCount; + } + + public Integer getAvailabilityZoneCount() { + return this.availabilityZoneCount; + } + + public void setAvailabilityZoneCount(Integer availabilityZoneCount) { + this.availabilityZoneCount = availabilityZoneCount; + } + + public Date getCreated() { + return created; + } + + public String getLabel() { + return this.label; + } + + public void setLabel(String label) { + this.label = label; + } + + @LinkedResource + public VfModule getVfModule() { + return this.vfModule; + } + + public void setVfModule(VfModule vfModule) { + this.vfModule = vfModule; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java new file mode 100644 index 0000000000..e4ac0d5816 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java @@ -0,0 +1,171 @@ +/*- + * ============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 javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "vnf_components_recipe") +public class VnfComponentsRecipe implements Serializable, Recipe { + + private static final long serialVersionUID = 768026109321305392L; + + @Id + @Column(name = "id") + private Integer id; + + @BusinessKey + @Column(name = "ACTION") + private String action; + + @Column(name = "DESCRIPTION") + private String description; + + @BusinessKey + @Column(name = "ORCHESTRATION_URI") + private String orchestrationUri; + + @Column(name = "RECIPE_TIMEOUT") + private Integer recipeTimeout; + + @BusinessKey + @Column(name = "VNF_TYPE") + private String vnfType; + + @Column(name = "VNF_COMPONENT_PARAM_XSD") + private String paramXsd; + + @Column(name = "VNF_COMPONENT_TYPE") + private String vnfComponentType; + + @BusinessKey + @Column(name = "VF_MODULE_MODEL_UUID") + private String vfModuleModelUUID; + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("action", action).append("description", description) + .append("orchestrationUri", orchestrationUri).append("recipeTimeout", recipeTimeout) + .append("vnfType", vnfType).append("paramXsd", paramXsd).append("vnfComponentType", vnfComponentType) + .append("vfModuleModelUUID", vfModuleModelUUID).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VnfComponentsRecipe)) { + return false; + } + VnfComponentsRecipe castOther = (VnfComponentsRecipe) other; + return new EqualsBuilder().append(action, castOther.action).append(orchestrationUri, castOther.orchestrationUri) + .append(vnfType, castOther.vnfType).append(vfModuleModelUUID, castOther.vfModuleModelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(action).append(orchestrationUri).append(vnfType).append(vfModuleModelUUID) + .toHashCode(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setOrchestrationUri(String orchestrationUri) { + this.orchestrationUri = orchestrationUri; + } + + public void setRecipeTimeout(Integer recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getParamXsd() { + return paramXsd; + } + + public void setParamXsd(String paramXsd) { + this.paramXsd = paramXsd; + } + + public String getVnfComponentType() { + return vnfComponentType; + } + + public void setVnfComponentType(String vnfComponentType) { + this.vnfComponentType = vnfComponentType; + } + + public String getVfModuleModelUUID() { + return vfModuleModelUUID; + } + + public void setVfModuleModelUUID(String vfModuleModelUUID) { + this.vfModuleModelUUID = vfModuleModelUUID; + } + + @Override + public String getOrchestrationUri() { + return orchestrationUri; + } + + @Override + public Integer getRecipeTimeout() { + return recipeTimeout; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java new file mode 100644 index 0000000000..aef2ac5e74 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java @@ -0,0 +1,187 @@ +/*- + * ============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.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +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.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "vnf_recipe") +public class VnfRecipe implements Serializable, Recipe { + + private static final long serialVersionUID = 768026109321305392L; + + @Id + @Column(name = "id") + private Integer id; + + @BusinessKey + @Column(name = "NF_ROLE") + private String nfRole; + + @Column(name = "VNF_PARAM_XSD") + private String paramXsd; + + @Column(name = "VF_MODULE_ID") + private String vfModuleId; + + @BusinessKey + @Column(name = "ACTION") + protected String action; + + @Column(name = "description") + private String description; + + @BusinessKey + @Column(name = "ORCHESTRATION_URI") + protected String orchestrationUri; + + @Column(name = "RECIPE_TIMEOUT") + private Integer recipeTimeout; + + @BusinessKey + @Column(name = "SERVICE_TYPE") + private String serviceType; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("vnfType", nfRole).append("paramXsd", paramXsd) + .append("vfModuleId", vfModuleId).append("action", action).append("description", description) + .append("orchestrationUri", orchestrationUri).append("recipeTimeout", recipeTimeout) + .append("serviceType", serviceType).append("created", created).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VnfRecipe)) { + return false; + } + VnfRecipe castOther = (VnfRecipe) other; + return new EqualsBuilder().append(nfRole, castOther.nfRole).append(action, castOther.action) + .append(orchestrationUri, castOther.orchestrationUri).append(serviceType, castOther.serviceType) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(nfRole).append(action).append(orchestrationUri).append(serviceType) + .toHashCode(); + } + + public String getNfRole() { + return nfRole; + } + + public void setNfRole(String nfRole) { + this.nfRole = nfRole; + } + + public String getParamXsd() { + return paramXsd; + } + + public void setParamXsd(String paramXsd) { + this.paramXsd = paramXsd; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getOrchestrationUri() { + return orchestrationUri; + } + + public void setOrchestrationUri(String orchestrationUri) { + this.orchestrationUri = orchestrationUri; + } + + public Integer getRecipeTimeout() { + return recipeTimeout; + } + + public void setRecipeTimeout(Integer recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public Date getCreated() { + return created; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java new file mode 100644 index 0000000000..764d2b7c39 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java @@ -0,0 +1,259 @@ +/*- + * ============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.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "vnf_resource") +public class VnfResource implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "MODEL_UUID") + private String modelUUID; + + @Column(name = "MODEL_INVARIANT_UUID") + private String modelInvariantUUID; + + @Column(name = "MODEL_NAME") + private String modelName; + + @Column(name = "MODEL_VERSION") + private String modelVersion; + + @Column(name = "TOSCA_NODE_TYPE") + private String toscaNodeType; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "ORCHESTRATION_MODE") + private String orchestrationMode; + + @Column(name = "AIC_VERSION_MIN") + private String aicVersionMin; + + @Column(name = "AIC_VERSION_MAX") + private String aicVersionMax; + + @Column(name = "RESOURCE_CATEGORY") + private String category; + + @Column(name = "RESOURCE_SUB_CATEGORY") + private String subCategory; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID") + private HeatTemplate heatTemplates; + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResources") + private List<VnfResourceCustomization> vnfResourceCustomizations; + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID) + .append("modelName", modelName).append("modelVersion", modelVersion) + .append("toscaNodeType", toscaNodeType).append("description", description) + .append("orchestrationMode", orchestrationMode).append("aicVersionMin", aicVersionMin) + .append("aicVersionMax", aicVersionMax).append("created", created) + .append("heatTemplates", heatTemplates).append("vnfResourceCustomizations", vnfResourceCustomizations) + .toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VnfResource)) { + return false; + } + VnfResource castOther = (VnfResource) other; + return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelUUID).toHashCode(); + } + + public String getOrchestrationMode() { + return orchestrationMode; + } + + public void setOrchestrationMode(String orchestrationMode) { + this.orchestrationMode = orchestrationMode; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreated() { + return created; + } + + public String getAicVersionMin() { + return this.aicVersionMin; + } + + public void setAicVersionMin(String aicVersionMin) { + this.aicVersionMin = aicVersionMin; + } + + public String getAicVersionMax() { + return this.aicVersionMax; + } + + public void setAicVersionMax(String aicVersionMax) { + this.aicVersionMax = aicVersionMax; + } + + /** + * @return Returns the category. + */ + public String getCategory() { + return category; + } + + /** + * @param category + * The category to set. + */ + public void setCategory(String category) { + this.category = category; + } + + /** + * @return Returns the subCategory. + */ + public String getSubCategory() { + return subCategory; + } + + /** + * @param subCategory + * The subCategory to set. + */ + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getModelInvariantUUID() { + return this.modelInvariantUUID; + } + + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getModelUUID() { + return modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getModelInvariantId() { + return this.modelInvariantUUID; + } + + public String getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + @LinkedResource + public List<VnfResourceCustomization> getVnfResourceCustomizations() { + if (vnfResourceCustomizations == null) + vnfResourceCustomizations = new ArrayList<>(); + return vnfResourceCustomizations; + } + + public void setVnfResourceCustomizations(List<VnfResourceCustomization> vnfResourceCustomizations) { + this.vnfResourceCustomizations = vnfResourceCustomizations; + } + + @LinkedResource + public HeatTemplate getHeatTemplates() { + return heatTemplates; + } + + public void setHeatTemplates(HeatTemplate heatTemplates) { + this.heatTemplates = heatTemplates; + } + + public String getModelVersion() { + return modelVersion; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } +} 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 new file mode 100644 index 0000000000..fa0fe5636e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java @@ -0,0 +1,253 @@ +/*- + * ============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.ArrayList; +import java.util.Date; +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; +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 = "vnf_resource_customization") +public class VnfResourceCustomization implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "MODEL_CUSTOMIZATION_UUID") + private String modelCustomizationUUID; + + @Column(name = "MODEL_INSTANCE_NAME") + private String modelInstanceName; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Column(name = "MIN_INSTANCES") + private Integer minInstances; + + @Column(name = "MAX_INSTANCES") + private Integer maxInstances; + + @Column(name = "AVAILABILITY_ZONE_MAX_COUNT") + private Integer availabilityZoneMaxCount; + + @Column(name = "NF_FUNCTION") + private String nfFunction; + + @Column(name = "NF_TYPE") + private String nfType; + + @Column(name = "NF_ROLE") + private String nfRole; + + @Column(name = "NF_NAMING_CODE") + private String nfNamingCode; + + @Column(name = "MULTI_STAGE_DESIGN") + private String multiStageDesign; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID") + private VnfResource vnfResources; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "vnf_res_custom_to_vf_module_custom", joinColumns = @JoinColumn(name = "VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID"), inverseJoinColumns = @JoinColumn(name = "VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID")) + private List<VfModuleCustomization> vfModuleCustomizations; + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "vnfResourceCust") + private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelInstanceName", modelInstanceName).append("created", created) + .append("minInstances", minInstances).append("maxInstances", maxInstances) + .append("availabilityZoneMaxCount", availabilityZoneMaxCount).append("nfFunction", nfFunction) + .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode) + .append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources) + .append("vfModuleCustomizations", vfModuleCustomizations) + .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VnfResourceCustomization)) { + return false; + } + VnfResourceCustomization castOther = (VnfResourceCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + } + + @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 this.modelInstanceName; + } + + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + + public Date getCreationTimestamp() { + return this.created; + } + + public Integer getMinInstances() { + return this.minInstances; + } + + public void setMinInstances(Integer minInstances) { + this.minInstances = minInstances; + } + + public Integer getMaxInstances() { + return this.maxInstances; + } + + public void setMaxInstances(Integer maxInstances) { + this.maxInstances = maxInstances; + } + + public Integer getAvailabilityZoneMaxCount() { + return this.availabilityZoneMaxCount; + } + + public void setAvailabilityZoneMaxCount(Integer availabilityZoneMaxCount) { + this.availabilityZoneMaxCount = availabilityZoneMaxCount; + } + + public String getNfFunction() { + return nfFunction; + } + + public void setNfFunction(String nfFunction) { + this.nfFunction = nfFunction; + } + + public String getNfType() { + return nfType; + } + + public void setNfType(String nfType) { + this.nfType = nfType; + } + + public String getNfRole() { + return nfRole; + } + + public void setNfRole(String nfRole) { + this.nfRole = nfRole; + } + + public String getNfNamingCode() { + return nfNamingCode; + } + + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + public String getMultiStageDesign() { + return this.multiStageDesign; + } + + public void setMultiStageDesign(String multiStageDesign) { + this.multiStageDesign = multiStageDesign; + } + + @LinkedResource + public List<VfModuleCustomization> getVfModuleCustomizations() { + if (vfModuleCustomizations == null) + vfModuleCustomizations = new ArrayList<>(); + return vfModuleCustomizations; + } + + public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) { + this.vfModuleCustomizations = vfModuleCustomizations; + } + + @LinkedResource + public VnfResource getVnfResources() { + return vnfResources; + } + + public void setVnfResources(VnfResource vnfResources) { + this.vnfResources = vnfResources; + } + + public Date getCreated() { + return created; + } + + @LinkedResource + public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() { + return vnfcInstanceGroupCustomizations; + } + + public void setVnfcInstanceGroupCustomizations( + List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) { + this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java new file mode 100644 index 0000000000..1d4cef158f --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java @@ -0,0 +1,169 @@ +/*- + * ============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 java.util.Date; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.IdClass; +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.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@IdClass(VnfcInstanceGroupCustomizationId.class) +@Table(name = "vnfc_instance_group_customization") +public class VnfcInstanceGroupCustomization implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8288218040186901676L; + + @BusinessKey + @Id + @Column(name = "VNF_RESOURCE_CUSTOMIZATION_MODEL_UUID") + private String modelCustomizationUUID; + + @BusinessKey + @Id + @Column(name = "INSTANCE_GROUP_MODEL_UUID") + private String modelUUID; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "VNF_RESOURCE_CUSTOMIZATION_MODEL_UUID", updatable = false, insertable = false) + private VnfResourceCustomization vnfResourceCust; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID", updatable = false, insertable = false) + private InstanceGroup instanceGroup; + + @Column(name = "FUNCTION") + private String function; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VnfcInstanceGroupCustomization)) { + return false; + } + VnfcInstanceGroupCustomization castOther = (VnfcInstanceGroupCustomization) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) + .append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelUUID", modelUUID).append("function", function).append("description", description) + .append("created", created).toString(); + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + } + + public Date getCreated() { + return created; + } + + public String getModelCustomizationUUID() { + return modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelUUID() { + return modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + + public String getFunction() { + return function; + } + + public void setFunction(String function) { + this.function = function; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setCreated(Date created) { + this.created = created; + } + + @LinkedResource + public VnfResourceCustomization getVnfResourceCust() { + return vnfResourceCust; + } + + public void setVnfResourceCust(VnfResourceCustomization vnfResourceCust) { + this.vnfResourceCust = vnfResourceCust; + } + + @LinkedResource + public InstanceGroup getInstanceGroup() { + return instanceGroup; + } + + public void setInstanceGroup(InstanceGroup instanceGroup) { + this.instanceGroup = instanceGroup; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomizationId.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomizationId.java new file mode 100644 index 0000000000..f22d4fe213 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomizationId.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.catalog.beans; + +import java.io.Serializable; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +public class VnfcInstanceGroupCustomizationId implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1628277798979456195L; + + @BusinessKey + private String modelCustomizationUUID; + @BusinessKey + private String modelUUID; + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + .append("modelUUID", modelUUID).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VnfcInstanceGroupCustomizationId)) { + return false; + } + VnfcInstanceGroupCustomizationId castOther = (VnfcInstanceGroupCustomizationId) other; + return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID) + .append(modelUUID, castOther.modelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).toHashCode(); + } + + public String getModelCustomizationUUID() { + return this.modelCustomizationUUID; + } + + public void setModelCustomizationUUID(String modelCustomizationUUID) { + this.modelCustomizationUUID = modelCustomizationUUID; + } + + public String getModelUUID() { + return this.modelUUID; + } + + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/NorthBoundRequest.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/NorthBoundRequest.java new file mode 100644 index 0000000000..67f23c1e43 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/NorthBoundRequest.java @@ -0,0 +1,185 @@ +/*- + * ============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.macro; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "northbound_request_ref_lookup") +public class NorthBoundRequest implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -2238991039015148725L; + + @Id + @Column(name = "id") + @GeneratedValue + private Integer id; + + @BusinessKey + @Column(name = "MACRO_ACTION") + private String macroAction; + + @BusinessKey + @Column(name = "ACTION") + private String action; + + @BusinessKey + @Column(name = "REQUEST_SCOPE") + private String requestScope; + + @BusinessKey + @Column(name = "IS_ALACARTE") + private Boolean isAlacarte; + + @BusinessKey + @Column(name = "IS_TOPLEVELFLOW") + private Boolean isToplevelflow; + + @BusinessKey + @Column(name = "MIN_API_VERSION") + private Double minApiVersion; + + @BusinessKey + @Column(name = "MAX_API_VERSION") + private Double maxApiVersion; + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "northBoundRequest") + private List<OrchestrationFlow> orchestrationFlowList; + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("action", action).append("requestScope", requestScope) + .append("isAlacarte", isAlacarte).append("isToplevelflow", isToplevelflow) + .append("minApiVersion", minApiVersion).append("maxApiVersion", maxApiVersion).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof NorthBoundRequest)) { + return false; + } + NorthBoundRequest castOther = (NorthBoundRequest) other; + return new EqualsBuilder().append(action, castOther.action).append(requestScope, castOther.requestScope) + .append(isAlacarte, castOther.isAlacarte).append(isToplevelflow, castOther.isToplevelflow) + .append(minApiVersion, castOther.minApiVersion).append(maxApiVersion, castOther.maxApiVersion) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(action).append(requestScope).append(isAlacarte).append(isToplevelflow) + .append(minApiVersion).append(maxApiVersion).toHashCode(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getMacroAction() { + return macroAction; + } + + public void setMacroAction(String macroAction) { + this.macroAction = macroAction; + } + + public String getRequestScope() { + return requestScope; + } + + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + + public Boolean getIsAlacarte() { + return isAlacarte; + } + + public void setIsAlacarte(Boolean isAlacarte) { + this.isAlacarte = isAlacarte; + } + + public Boolean getIsToplevelflow() { + return isToplevelflow; + } + + public void setIsToplevelflow(Boolean isToplevelflow) { + this.isToplevelflow = isToplevelflow; + } + + public Double getMinApiVersion() { + return minApiVersion; + } + + public void setMinApiVersion(Double minApiVersion) { + this.minApiVersion = minApiVersion; + } + + public Double getMaxApiVersion() { + return maxApiVersion; + } + + public void setMaxApiVersion(Double maxApiVersion) { + this.maxApiVersion = maxApiVersion; + } + + @LinkedResource + public List<OrchestrationFlow> getOrchestrationFlowList() { + return orchestrationFlowList; + } + + public void setOrchestrationFlowList(List<OrchestrationFlow> orchestrationFlowList) { + this.orchestrationFlowList = orchestrationFlowList; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/OrchestrationFlow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/OrchestrationFlow.java new file mode 100644 index 0000000000..058947e6b1 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/OrchestrationFlow.java @@ -0,0 +1,146 @@ +/*- + * ============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.macro; + +import java.io.Serializable; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +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.BuildingBlockDetail; + +import com.openpojo.business.annotation.BusinessKey; + +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "orchestration_flow_reference") +public class OrchestrationFlow implements Serializable { + + private static final long serialVersionUID = 2457818854397870011L; + + @Id + @Column(name = "ID") + @GeneratedValue + private Integer id; + + @BusinessKey + @Column(name = "COMPOSITE_ACTION") + private String action; + + @BusinessKey + @Column(name = "SEQ_NO") + private Integer sequenceNumber; + + @BusinessKey + @Column(name = "FLOW_NAME") + private String flowName; + + @BusinessKey + @Column(name = "FLOW_VERSION") + private Double flowVersion; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "NB_REQ_REF_LOOKUP_ID") + private NorthBoundRequest northBoundRequest; + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("action", action) + .append("sequenceNumber", sequenceNumber).append("flowName", flowName) + .append("flowVersion", flowVersion).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof OrchestrationFlow)) { + return false; + } + OrchestrationFlow castOther = (OrchestrationFlow) other; + return new EqualsBuilder().append(action, castOther.action).append(sequenceNumber, castOther.sequenceNumber) + .append(flowName, castOther.flowName).append(flowVersion, castOther.flowVersion).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(action).append(sequenceNumber).append(flowName).append(flowVersion) + .toHashCode(); + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public Integer getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(Integer sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } + + public String getFlowName() { + return flowName; + } + + public void setFlowName(String flowName) { + this.flowName = flowName; + } + + public Double getFlowVersion() { + return flowVersion; + } + + public void setFlowVersion(Double flowVersion) { + this.flowVersion = flowVersion; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @LinkedResource + public NorthBoundRequest getNorthBoundRequest() { + return northBoundRequest; + } + + public void setNorthBoundRequest(NorthBoundRequest northBoundRequest) { + this.northBoundRequest = northBoundRequest; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/RainyDayHandlerStatus.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/RainyDayHandlerStatus.java new file mode 100644 index 0000000000..f341c4cb5c --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/macro/RainyDayHandlerStatus.java @@ -0,0 +1,154 @@ +/*- + * ============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.macro; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +@Entity +@Table(name = "rainy_day_handler_macro") +public class RainyDayHandlerStatus implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "id") + @GeneratedValue + private Integer id; + + @BusinessKey + @Column(name = "FLOW_NAME") + private String flowName; + + @BusinessKey + @Column(name = "SERVICE_TYPE") + private String serviceType; + + @BusinessKey + @Column(name = "VNF_TYPE") + private String vnfType; + + @BusinessKey + @Column(name = "ERROR_CODE") + private String errorCode; + + @BusinessKey + @Column(name = "WORK_STEP") + private String workStep; + + @BusinessKey + @Column(name = "POLICY") + private String policy; + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("flowName", flowName) + .append("serviceType", serviceType).append("vnfType", vnfType).append("errorCode", errorCode) + .append("workStep", workStep).append("policy", policy).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof RainyDayHandlerStatus)) { + return false; + } + RainyDayHandlerStatus castOther = (RainyDayHandlerStatus) other; + return new EqualsBuilder().append(flowName, castOther.flowName).append(serviceType, castOther.serviceType) + .append(vnfType, castOther.vnfType).append(errorCode, castOther.errorCode) + .append(workStep, castOther.workStep).append(policy, castOther.policy).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(flowName).append(serviceType).append(vnfType).append(errorCode) + .append(workStep).append(policy).toHashCode(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFlowName() { + return flowName; + } + + public void setFlowName(String flowName) { + this.flowName = flowName; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getWorkStep() { + return workStep; + } + + public void setWorkStep(String workStep) { + this.workStep = workStep; + } + + public String getPolicy() { + return policy; + } + + public void setPolicy(String policy) { + this.policy = policy; + } +} 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 new file mode 100644 index 0000000000..d3a1c5d8d6 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -0,0 +1,307 @@ +/*- + * ============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.client; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.db.catalog.beans.BuildingBlockDetail; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; +import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; +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.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; +import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; +import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; +import org.onap.so.logging.jaxrs.filter.jersey.SpringClientFilter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpRequest; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +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; + +@Component("CatalogDbClient") +public class CatalogDbClient { + + protected Client<Service> serviceClient; + + protected Client<VfModuleCustomization> vfModuleCustomizationClient; + + protected Client<OrchestrationFlow> orchestrationClient; + + protected Client<NorthBoundRequest> northBoundRequestClient; + + protected Client<RainyDayHandlerStatus> rainyDayHandlerStatusClient; + + protected Client<BuildingBlockDetail> buildingBlockDetailClient; + + protected Client<OrchestrationStatusStateTransitionDirective> orchestrationStatusStateTransitionDirectiveClient; + + protected Client<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizationClient; + + protected Client<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationClient; + + protected Client<InstanceGroup> instanceGroupClient; + + protected Client<NetworkCollectionResourceCustomization> networkCollectionResourceCustomizationClient; + + protected Client<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationClient; + + @Value("${mso.catalog.db.spring.endpoint}") + protected String endpoint; + + @Value("${mso.db.auth}") + private String msoAdaptersAuth; + + public CatalogDbClient() { + ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()); + + ClientFactory clientFactory = Configuration.builder().setClientHttpRequestFactory(factory).setRestTemplateConfigurer(new RestTemplateConfigurer() { + + public void configure(RestTemplate restTemplate) { + restTemplate.getInterceptors().add((new SpringClientFilter())); + + restTemplate.getInterceptors().add(new ClientHttpRequestInterceptor() { + + public ClientHttpResponse intercept(HttpRequest request, byte[] body, + ClientHttpRequestExecution execution) throws IOException { + + request.getHeaders().add("Authorization", msoAdaptersAuth); + return execution.execute(request, body); + } + }); + } + }).build().buildClientFactory(); + serviceClient = clientFactory.create(Service.class); + orchestrationClient = clientFactory.create(OrchestrationFlow.class); + vfModuleCustomizationClient = clientFactory.create(VfModuleCustomization.class); + northBoundRequestClient = clientFactory.create(NorthBoundRequest.class); + rainyDayHandlerStatusClient = clientFactory.create(RainyDayHandlerStatus.class); + buildingBlockDetailClient = clientFactory.create(BuildingBlockDetail.class); + orchestrationStatusStateTransitionDirectiveClient = clientFactory + .create(OrchestrationStatusStateTransitionDirective.class); + vnfcInstanceGroupCustomizationClient = clientFactory.create(VnfcInstanceGroupCustomization.class); + collectionResourceInstanceGroupCustomizationClient = clientFactory + .create(CollectionResourceInstanceGroupCustomization.class); + instanceGroupClient = clientFactory.create(InstanceGroup.class); + networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class); + collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class); + } + + public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) { + NetworkCollectionResourceCustomization networkCollectionResourceCustomization = + this.getSingleNetworkCollectionResourceCustomization(UriBuilder.fromUri(endpoint + "/networkCollectionResourceCustomization/" + modelCustomizationUUID).build()); + 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()); + 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); + } + return buildingBlockDetail; + } + + public CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomizationByID(String modelCustomizationUUID) { + CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = + this.getSingleCollectionNetworkResourceCustomization( + UriBuilder.fromUri(endpoint + "/collectionNetworkResourceCustomization/" + modelCustomizationUUID).build()); + if (collectionNetworkResourceCustomization != null) { + collectionNetworkResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID); + } + return collectionNetworkResourceCustomization; + } + + public InstanceGroup getInstanceGroupByModelUUID(String modelUUID) { + InstanceGroup instanceGroup = this + .getSingleInstanceGroup(UriBuilder.fromUri(endpoint + "/instanceGroup/" + modelUUID).build()); + 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 List<OrchestrationFlow> getOrchestrationFlowByAction(String action) { + return this + .getMultipleOrchestrationFlows(UriBuilder.fromUri(endpoint + "/orchestrationFlow/search/findByAction") + .queryParam("COMPOSITE_ACTION", action).build()); + } + + public List<OrchestrationFlow> getAllOrchestrationFlows() { + return this.getMultipleOrchestrationFlows(UriBuilder.fromUri(endpoint + "/orchestrationFlow/").build()); + } + + protected 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 List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomizationByModelCustUUID( + String modelCustomizationUUID) { + return this.getMultipleCollectionResourceInstanceGroupCustomizations(UriBuilder + .fromUri(endpoint + "/collectionResourceInstanceGroupCustomization/search/findByModelCustomizationUUID") + .queryParam("MODEL_CUSTOMIZATION_UUID", modelCustomizationUUID).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; + } + + protected 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 VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) { + VfModuleCustomization vfModuleCust = this.getSingleVfModuleCustomization( + UriBuilder.fromUri(endpoint + "/vfModuleCustomization/" + modelCustomizationUUID).build()); + if (vfModuleCust != null) { + vfModuleCust.setModelCustomizationUUID(modelCustomizationUUID); + } + return vfModuleCust; + } + + 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()); + } + + 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) + .build()); + } + + protected CollectionNetworkResourceCustomization getSingleCollectionNetworkResourceCustomization(URI uri) { + return collectionNetworkResourceCustomizationClient.get(uri); + } + + protected InstanceGroup getSingleInstanceGroup(URI uri) { + return instanceGroupClient.get(uri); + } + + protected Service getSingleService(URI uri) { + return serviceClient.get(uri); + } + + protected VfModuleCustomization getSingleVfModuleCustomization(URI uri) { + return vfModuleCustomizationClient.get(uri); + } + + protected NorthBoundRequest getSingleNorthBoundRequest(URI uri) { + return northBoundRequestClient.get(uri); + } + + protected RainyDayHandlerStatus getSingleRainyDayHandlerStatus(URI uri) { + return rainyDayHandlerStatusClient.get(uri); + } + + public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) { + return this.getSingleService( + UriBuilder.fromUri(endpoint + "/service/search/findByModelVersionAndModelInvariantUUID") + .queryParam("MODEL_VERSION", modelVersion) + .queryParam("MODEL_INVARIANT_UUID", modelInvariantUUID).build()); + } + + //USED FOR TEST ONLY + public void setPortToEndpoint(String port) { + endpoint = endpoint + port; + } + + //USED FOR TEST ONLY + public void removePortFromEndpoint() { + endpoint = endpoint.substring(0, endpoint.lastIndexOf(':') + 1); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineAllottedResources.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineAllottedResources.java new file mode 100644 index 0000000000..c03e988e2e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineAllottedResources.java @@ -0,0 +1,64 @@ +/*- + * ============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.projections; + +import org.onap.so.db.catalog.beans.AllottedResourceCustomization; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.rest.core.config.Projection; + +@Projection(name = "InlineAllottedResources", types = { AllottedResourceCustomization.class }) +public interface InlineAllottedResources { + + String getModelCustomizationUUID(); + String getModelInstanceName(); + String getMaxInstances(); + String getMinInstances(); + String getNfNamingCode(); + String getNfRole(); + String getNfType(); + String getNfFunction(); + String getTargetNetworkRole(); + String getProvidingServiceModelInvariantUUID(); + String getProvidingServiceModelName(); + String getProvidingServiceModelUUID(); + + @Value("#{target.getAllottedResource().getDescription()}") + String getDescription(); + + @Value("#{target.getAllottedResource().getCreated()}") + String getCreated(); + + + @Value("#{target.getAllottedResource().getModelInvariantUUID()}") + String getModelInvariantUuid (); + + @Value("#{target.getAllottedResource().getModelName()}") + String getModelName (); + + @Value("#{target.getAllottedResource().getModelUUID()}") + String getModelUuid (); + + @Value("#{target.getAllottedResource().getToscaNodeType()}") + String getToscaNodeType (); + + @Value("#{target.getAllottedResource().getSubcategory()}") + String getSubcategory (); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineNetworks.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineNetworks.java new file mode 100644 index 0000000000..8311df8adf --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineNetworks.java @@ -0,0 +1,72 @@ +/*- + * ============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.projections; + + +import java.sql.Timestamp; + +import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.rest.core.config.Projection; + +@Projection(name = "InlineNetworks", types = { NetworkResourceCustomization.class }) +public interface InlineNetworks { + + String getModelCustomizationUUID(); + String getModelInstanceName(); + String getNetworkTechnology(); + String getNetworkType(); + String getNetworkScope(); + String getNetworkRole(); + + @Value("#{target.getNetworkResource().getDescription()}") + String getDescription(); + + @Value("#{target.getNetworkResource().getCreated()}") + Timestamp getCreated(); + + @Value("#{target.getNetworkResource().getModelVersion()}") + String getModelVersion(); + + @Value("#{target.getNetworkResource().getModelInvariantUUID()}") + String getModelInvariantUUID(); + + @Value("#{target.getNetworkResource().getModelName()}") + String getModelName (); + + @Value("#{target.getNetworkResource().getModelUUID()}") + String getModelUUID (); + + @Value("#{target.getNetworkResource().getNeutronNetworkType()}") + String getNeutronNetworkType (); + + @Value("#{target.getNetworkResource().getAicVersionMin()}") + String getAicVersionMin (); + + @Value("#{target.getNetworkResource().getAicVersionMax()}") + String getAicVersionMax (); + + @Value("#{target.getNetworkResource().getOrchestrationMode()}") + String getOrchestrationMode (); + + @Value("#{target.getNetworkResource().getToscaNodeType()}") + String getToscaNodeType (); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineService.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineService.java new file mode 100644 index 0000000000..c7241acd8b --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineService.java @@ -0,0 +1,52 @@ +/*- + * ============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.projections; + + +import java.util.List; +import java.util.Map; + +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.springframework.data.rest.core.config.Projection; + +@Projection(name = "InlineService", types = { Service.class }) +public interface InlineService { + + String getModelName(); + String getDescription(); + String getCreated(); + String getModelUUID(); + String getModelInvariantUUID(); + String getModelVersion(); + String getServiceType(); + String getServiceRole(); + String getEnvironmentContext(); + String getWorkloadContext(); + + List<InlineNetworks> getNetworkCustomizations(); + + List<InlineVnf> getVnfCustomizations(); + + List<InlineAllottedResources> getAllottedCustomizations(); + + Map<String, ServiceRecipe> getRecipes (); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineVfModules.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineVfModules.java new file mode 100644 index 0000000000..316a02b016 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineVfModules.java @@ -0,0 +1,59 @@ +/*- + * ============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.projections; + +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.rest.core.config.Projection; + +@Projection(name = "InlineVfModules", types = { VfModuleCustomization.class }) +public interface InlineVfModules { + + String getModelCustomizationUUID(); + + @Value("#{target.getVfModule().getModelName()}") + String getModelName (); + + @Value("#{target.getVfModule().getModelUUID()}") + String getModelUUID (); + + @Value("#{target.getVfModule().getModelInvariantUUID()}") + String getModelInvariantUUID (); + + @Value("#{target.getVfModule().getModelVersion()}") + String getModelVersion (); + + @Value("#{target.getVfModule().getDescription()}") + String getDescription(); + + @Value("#{target.getVfModule().getIsBase()}") + Boolean getIsBase(); + + String getMinInstances(); + String getMaxInstances(); + String getAvailabilityZoneCount(); + String getLabel(); + String getInitialCount(); + + @Value("#{target.getVfModule().getCreated()}") + String getCreated(); + +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineVnf.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineVnf.java new file mode 100644 index 0000000000..17e54f9b45 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/projections/InlineVnf.java @@ -0,0 +1,76 @@ +/*- + * ============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.projections; + +import java.util.List; + +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.rest.core.config.Projection; + +@Projection(name = "InlineVnf", types = { VnfResourceCustomization.class }) +public interface InlineVnf { + + String getModelInstanceName(); + + String getModelCustomizationUUID(); + + @Value("#{target.getVnfResources().getModelUUID()}") + String getModelUUID(); + + @Value("#{target.getVnfResources().getModelInvariantUUID()}") + String getModelInvariantUUID(); + + @Value("#{target.getVnfResources().getModelName()}") + String getModelName(); + + @Value("#{target.getVnfResources().getModelVersion()}") + String getModelVersion(); + + @Value("#{target.getVnfResources().getToscaNodeType()}") + String getToscaNodeType (); + + @Value("#{target.getVnfResources().getDescription()}") + String getDescription(); + + @Value("#{target.getVnfResources().getOrchestrationMode()}") + String getOrchestrationMode(); + + @Value("#{target.getVnfResources().getAicVersionMin()}") + String getAicVersionMin(); + + @Value("#{target.getVnfResources().getAicVersionMax()}") + String getAicVersionMax(); + + String getMinInstances(); + String getMaxInstances(); + String getAvailabilityZoneMaxCount(); + String getNfFunction(); + String getNfType(); + String getNfRole(); + String getNfNamingCode(); + String getMultiStageDesign(); + + @Value("#{target.getVnfResources().getCreated()}") + String getCreated(); + + List<InlineVfModules> getVfModuleCustomizations(); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/AllottedResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/AllottedResourceCustomizationRepository.java new file mode 100644 index 0000000000..57fe2df182 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/AllottedResourceCustomizationRepository.java @@ -0,0 +1,38 @@ +/*- + * ============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.AllottedResourceCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "allottedResourceCustomization", path = "allottedResourceCustomization") +public interface AllottedResourceCustomizationRepository extends JpaRepository<AllottedResourceCustomization, String> { + + @Query(value = "SELECT * FROM ALLOTTED_RESOURCE_CUSTOMIZATION WHERE PROVIDING_SERVICE_MODEL_UUID =?0", nativeQuery = true) + List<AllottedResourceCustomization> queryByProvidingServiceModelUUID(String providingServiceModelUUID); + + List<AllottedResourceCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); + AllottedResourceCustomization 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/AllottedResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/AllottedResourceRepository.java new file mode 100644 index 0000000000..9d0ac92449 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/AllottedResourceRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.AllottedResource; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "allottedResource", path = "allottedResource") +public interface AllottedResourceRepository extends JpaRepository<AllottedResource, String> { + AllottedResource findResourceByModelUUID(String modelUUID); +} 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 new file mode 100644 index 0000000000..58058da380 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java @@ -0,0 +1,31 @@ +/*- + * ============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.ArRecipe; +import org.springframework.data.jpa.repository.JpaRepository; +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); +} 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 new file mode 100644 index 0000000000..79ad9c77d1 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BuildingBlockDetailRepository.java @@ -0,0 +1,31 @@ +/*- + * ============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.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); +} 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 new file mode 100644 index 0000000000..79efe644bd --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.CollectionNetworkResourceCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "collectionNetworkResourceCustomization", path = "collectionNetworkResourceCustomization") +public interface CollectionNetworkResourceCustomizationRepository + extends JpaRepository<CollectionNetworkResourceCustomization, String> { +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceCustomizationRepository.java new file mode 100644 index 0000000000..6e33eac556 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceCustomizationRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.CollectionResourceCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "collectionResourceCustomization", path = "collectionResourceCustomization") +public interface CollectionResourceCustomizationRepository extends JpaRepository<CollectionResourceCustomization, Long> { + CollectionResourceCustomization 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/CollectionResourceInstanceGroupCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceInstanceGroupCustomizationRepository.java new file mode 100644 index 0000000000..32e09bf2af --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceInstanceGroupCustomizationRepository.java @@ -0,0 +1,34 @@ +/*- + * ============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 java.util.List; + +import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "collectionResourceInstanceGroupCustomization", path = "collectionResourceInstanceGroupCustomization") +public interface CollectionResourceInstanceGroupCustomizationRepository + extends JpaRepository<CollectionResourceInstanceGroupCustomization, String> { + + List<CollectionResourceInstanceGroupCustomization> findByModelCustomizationUUID(String modelCustomizationlUUID); +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceRepository.java new file mode 100644 index 0000000000..5d847b87fb --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CollectionResourceRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.CollectionResource; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "collectionResource", path = "collectionResource") +public interface CollectionResourceRepository extends JpaRepository<CollectionResource, String> { + CollectionResource findByModelUUID(String modelUUID); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ConfigurationResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ConfigurationResourceCustomizationRepository.java new file mode 100644 index 0000000000..cd96f05c3e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ConfigurationResourceCustomizationRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.ConfigurationResourceCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "configurationResourceCustomization", path = "configurationResourceCustomization") +public interface ConfigurationResourceCustomizationRepository + extends JpaRepository<ConfigurationResourceCustomization, String> { + +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ConfigurationResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ConfigurationResourceRepository.java new file mode 100644 index 0000000000..5a29035cdb --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ConfigurationResourceRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.ConfigurationResource; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "configurationResource", path = "configurationResource") +public interface ConfigurationResourceRepository extends JpaRepository<ConfigurationResource, Long> { + ConfigurationResource findResourceByModelUUID(String modelUUID); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ExternalServiceToInternalServiceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ExternalServiceToInternalServiceRepository.java new file mode 100644 index 0000000000..91a912920e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ExternalServiceToInternalServiceRepository.java @@ -0,0 +1,32 @@ +/*- + * ============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.ExternalServiceToInternalService; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "externalServiceToInternalService", path = "externalServiceToInternalService") +public interface ExternalServiceToInternalServiceRepository + extends JpaRepository<ExternalServiceToInternalService, Integer> { + ExternalServiceToInternalService findByServiceName(String serviceName); + ExternalServiceToInternalService findByServiceNameAndSubscriptionServiceType(String serviceName , String subscriptionServiceType); +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HeatEnvironmentRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HeatEnvironmentRepository.java new file mode 100644 index 0000000000..85d57e5b85 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HeatEnvironmentRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.HeatEnvironment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "heatEnvironment", path = "heatEnvironment") +public interface HeatEnvironmentRepository extends JpaRepository<HeatEnvironment, String> { + HeatEnvironment findByArtifactUuid(String artifactUUID); +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HeatTemplateRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HeatTemplateRepository.java new file mode 100644 index 0000000000..cb79506868 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HeatTemplateRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.HeatTemplate; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "heatTemplate", path = "heatTemplate") +public interface HeatTemplateRepository extends JpaRepository<HeatTemplate, String> { + HeatTemplate findByArtifactUuid(String artifactUUID); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/InstanceGroupRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/InstanceGroupRepository.java new file mode 100644 index 0000000000..5f5d85ae99 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/InstanceGroupRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.InstanceGroup; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "instanceGroup", path = "instanceGroup") +public interface InstanceGroupRepository extends JpaRepository<InstanceGroup, String> { + InstanceGroup findByModelUUID(String modelUUID); +}
\ 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 new file mode 100644 index 0000000000..6ad1c64196 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRecipeRepository.java @@ -0,0 +1,33 @@ +/*- + * ============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.ModelRecipe; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "modelRecipe", path = "modelRecipe") +public interface ModelRecipeRepository extends JpaRepository<ModelRecipe, Integer> { + + + public 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 new file mode 100644 index 0000000000..4ace731817 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ModelRepository.java @@ -0,0 +1,33 @@ +/*- + * ============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.Model; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "model", path = "model") +public interface ModelRepository extends JpaRepository<Model, Integer> { + + + public Model findByModelVersionIdAndModelType(String modelVersionid, String modelType); + +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkCollectionResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkCollectionResourceCustomizationRepository.java new file mode 100644 index 0000000000..1d9bf71396 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkCollectionResourceCustomizationRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.NetworkCollectionResourceCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "networkCollectionResourceCustomization", path = "networkCollectionResourceCustomization") +public interface NetworkCollectionResourceCustomizationRepository extends JpaRepository<NetworkCollectionResourceCustomization, String> { + NetworkCollectionResourceCustomization 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/NetworkInstanceGroupRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkInstanceGroupRepository.java new file mode 100644 index 0000000000..e2981ce96e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkInstanceGroupRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.NetworkInstanceGroup; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "networkInstanceGroup", path = "networkInstanceGroup") +public interface NetworkInstanceGroupRepository extends JpaRepository<NetworkInstanceGroup, String> { + NetworkInstanceGroup findByModelUUID(String modelUUID); +} 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 new file mode 100644 index 0000000000..3fb7d7aa19 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.NetworkRecipe; +import org.springframework.data.jpa.repository.JpaRepository; +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); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceCustomizationRepository.java new file mode 100644 index 0000000000..c169f3661a --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceCustomizationRepository.java @@ -0,0 +1,39 @@ +/*- + * ============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.NetworkResourceCustomization; +import org.onap.so.db.catalog.data.projections.InlineNetworks; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "networkResourceCustomization", path = "networkResourceCustomization", excerptProjection = InlineNetworks.class) +public interface NetworkResourceCustomizationRepository extends JpaRepository<NetworkResourceCustomization, String> { + List<NetworkResourceCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); + + NetworkResourceCustomization findOneByModelCustomizationUUID(String modelCustomizationUUID); + + List<NetworkResourceCustomization> findByNetworkType(String networkType); + + NetworkResourceCustomization findOneByNetworkType(String networkType); +}
\ 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 new file mode 100644 index 0000000000..842c888091 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java @@ -0,0 +1,43 @@ +/*- + * ============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.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; + +@Repository +public interface NetworkResourceRepository extends JpaRepository<NetworkResource, String> { + + /** + * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting + * @param modelName + * @return + */ + @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 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 new file mode 100644 index 0000000000..b568d6c09b --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NorthBoundRequestRepository.java @@ -0,0 +1,32 @@ +/*- + * ============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.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); +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationFlowRepository.java index d94334c98d..db9cd745db 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationFlowRepository.java @@ -18,37 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.data.repository; -import java.io.Serializable; +import java.util.List; -public class VnfRecipe extends Recipe implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; +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; - private String vnfType = null; - private String vfModuleId = null; +@RepositoryRestResource(collectionResourceRel = "orchestrationFlow", path = "orchestrationFlow") +public interface OrchestrationFlowRepository extends JpaRepository<OrchestrationFlow, Integer> { + List<OrchestrationFlow> findByAction(@Param("COMPOSITE_ACTION") String action); - public VnfRecipe() {} - - public String getVnfType() { - return vnfType; - } - public void setVnfType(String vnfType) { - this.vnfType = vnfType; - } - - public String getVfModuleId() { - return vfModuleId; - } - - public void setVfModuleId(String vfModuleId) { - this.vfModuleId = vfModuleId; - } - - @Override - public String toString () { - return super.toString() + ",vnfParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + ",vfModuleId=" + - getVfModuleId(); - } + OrchestrationFlow findOneByAction(@Param("COMPOSITE_ACTION") 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 new file mode 100644 index 0000000000..ab728f46bf --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/OrchestrationStatusStateTransitionDirectiveRepository.java @@ -0,0 +1,34 @@ +/*- + * ============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.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.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); +} 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 new file mode 100644 index 0000000000..283c9623c8 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java @@ -0,0 +1,34 @@ +/*- + * ============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.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); +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceCustomizationRepository.java new file mode 100644 index 0000000000..c90fd8965a --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceCustomizationRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.ServiceProxyResourceCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "serviceProxyResourceCustomization", path = "serviceProxyResourceCustomization") +public interface ServiceProxyResourceCustomizationRepository + extends JpaRepository<ServiceProxyResourceCustomization, String> { +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceRepository.java new file mode 100644 index 0000000000..e6ec3b04d1 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceProxyResourceRepository.java @@ -0,0 +1,29 @@ +/*- + * ============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.ServiceProxyResource; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "serviceProxyResource", path = "serviceProxyResource") +public interface ServiceProxyResourceRepository extends JpaRepository<ServiceProxyResource, Long> { + ServiceProxyResource findResourceByModelUUID(String modelUUID); +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..57578cfb07 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRecipeRepository.java @@ -0,0 +1,34 @@ +/*- + * ============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.ServiceRecipe; +import org.springframework.data.jpa.repository.JpaRepository; +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); + + public ServiceRecipe findByAction(String action); + + public 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 new file mode 100644 index 0000000000..eac432a4dd --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceRepository.java @@ -0,0 +1,98 @@ +/*- + * ============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.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; + +@RepositoryRestResource(collectionResourceRel = "service", path = "service", excerptProjection = InlineService.class) +public interface ServiceRepository extends JpaRepository<Service, String> { + List<Service> findByModelName(String modelName); + + Service findOneByModelName(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 modelName + * @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(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 modelName + * @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 findByModelNameOrderByModelVersionDesc(String modelName); + + Service findOneByModelNameAndModelVersion(String modelName, String modelVersion); + + Service findByModelNameAndModelVersion(String modelName, String modelVersion); + + Service findByServiceType(String serviceType); + + /** + * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting + * @param modelName + * @return + */ + @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 findFirstOneByModelUUIDOrderByModelVersionDesc(String modelUUID); + + /** + * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting + * @param modelName + * @return + */ + @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); + + /** + * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting + * @param modelName + * @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 LIMIT 1;", nativeQuery = true) + Service findFirstByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID); + + List<Service> findByModelUUID(String modelUUID); + + Service findOneByModelUUID(String modelUUID); + + /** + * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting + * @param modelInvariantId + * @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); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/TempNetworkHeatTemplateRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/TempNetworkHeatTemplateRepository.java new file mode 100644 index 0000000000..d506c5b585 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/TempNetworkHeatTemplateRepository.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.TempNetworkHeatTemplateLookup; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "tempNetworkHeatTemplateLookup", path = "tempNetworkHeatTemplateLookup") +public interface TempNetworkHeatTemplateRepository extends JpaRepository<TempNetworkHeatTemplateLookup, String> { + + TempNetworkHeatTemplateLookup findFirstBynetworkResourceModelName(String networkResourceModelName); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ToscaCsarRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ToscaCsarRepository.java new file mode 100644 index 0000000000..b85867776c --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ToscaCsarRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.ToscaCsar; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "toscaCsar", path = "toscaCsar") +public interface ToscaCsarRepository extends JpaRepository<ToscaCsar, String> { + +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFCInstanceGroupRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFCInstanceGroupRepository.java new file mode 100644 index 0000000000..da091827b7 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFCInstanceGroupRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.VFCInstanceGroup; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "vfcInstanceGroup", path = "vfcInstanceGroup") +public interface VFCInstanceGroupRepository extends JpaRepository<VFCInstanceGroup, String> { + VFCInstanceGroup findByModelUUID(String modelUUID); +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleCustomizationRepository.java new file mode 100644 index 0000000000..ee2d08b6f2 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleCustomizationRepository.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 org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "vfModuleCustomization", path = "vfModuleCustomization") +public interface VFModuleCustomizationRepository extends JpaRepository<VfModuleCustomization, String> { + VfModuleCustomization findByModelCustomizationUUID(String modelCustomizationUUID); + + VfModuleCustomization findByModelCustomizationUUIDAndVfModuleModelUUID(String modelCustomizationUUID, String vfModuleModelUUID); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleRepository.java new file mode 100644 index 0000000000..6b403b312e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VFModuleRepository.java @@ -0,0 +1,58 @@ +/*- + * ============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.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; + +@RepositoryRestResource(collectionResourceRel = "vfModule", path = "vfModule") +public interface VFModuleRepository extends JpaRepository<VfModule, String> { + VfModule findByModelUUID(String modelUUID); + + VfModule findByModelInvariantUUIDAndModelVersion(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 + * @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) + VfModule findFirstByModelNameOrderByModelVersionDesc(String modelName); + + VfModule findByModelInvariantUUIDAndModelUUID(String modelCustomizationUUID, String modelUUID); + + VfModule findByModelInvariantUUID(@Param("ACTION") String modelCustomizationUUID); + + /** + * This method will not work for versions greater than 255, as it is utilizing an ip address function to do the sorting + * @param modelInvariantUUID + * @return + */ + @Query(value = "SELECT * FROM vf_module WHERE MODEL_INVARIANT_UUID = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC;", nativeQuery = true) + List<VfModule> 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/VnfComponentRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfComponentRecipeRepository.java new file mode 100644 index 0000000000..822ac44be2 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfComponentRecipeRepository.java @@ -0,0 +1,39 @@ +/*- + * ============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.VnfComponentsRecipe; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "vnfComponentsRecipe", path = "vnfComponentsRecipe") +public interface VnfComponentRecipeRepository extends JpaRepository<VnfComponentsRecipe, String> { + + VnfComponentsRecipe findVnfComponentsRecipeByVfModuleModelUUIDAndVnfTypeAndAction(String vfModuleModelUUID, + String vnfType, String action); + + VnfComponentsRecipe findVnfComponentsRecipeByVnfTypeAndAction(String vnfType, String action); + + VnfComponentsRecipe findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(String modelUUID, + String vnfComponentType, String action); + + VnfComponentsRecipe findVnfComponentsRecipeByVnfComponentTypeAndAction(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 new file mode 100644 index 0000000000..0d9ac2b33d --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfCustomizationRepository.java @@ -0,0 +1,39 @@ +/*- + * ============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.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.rest.core.annotation.RepositoryRestResource; + +@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); + +}
\ 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 new file mode 100644 index 0000000000..97d6669c58 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.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 org.onap.so.db.catalog.beans.VnfRecipe; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "vnfRecipe", path = "vnfRecipe") +public interface VnfRecipeRepository extends JpaRepository<VnfRecipe, String> { + VnfRecipe findVnfRecipeByServiceTypeAndAction(String serviceType, String action); + + VnfRecipe findVnfRecipeByNfRoleAndAction(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 new file mode 100644 index 0000000000..5b0258238e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfResourceRepository.java @@ -0,0 +1,41 @@ +/*- + * ============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.VnfResource; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "vnfResource", path = "vnfResource") +public interface VnfResourceRepository extends JpaRepository<VnfResource, String> { + + VnfResource findResourceByModelNameAndModelUUID(String modelName, String modelUUID); + + VnfResource findByModelName(String modelName); + + VnfResource findByModelNameAndModelVersion(String modelName, String modelVersion); + + VnfResource findResourceByModelUUID(String modelUUID); + + VnfResource findResourceByModelInvariantUUID(String modelInvariantId); + + VnfResource findResourceByModelInvariantUUIDAndModelVersion(String relatedInstanceModelInvariantId, String relatedInstanceVersion); +}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java new file mode 100644 index 0000000000..f2fbbe6b57 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java @@ -0,0 +1,33 @@ +/*- + * ============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 java.util.List; + +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "vnfcInstanceGroupCustomization", path = "vnfcInstanceGroupCustomization") +public interface VnfcInstanceGroupCustomizationRepository + extends JpaRepository<VnfcInstanceGroupCustomization, String> { + List<VnfcInstanceGroupCustomization> findByModelCustomizationUUID(String modelCustomizationlUUID); +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java new file mode 100644 index 0000000000..fc968a4ef9 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java @@ -0,0 +1,194 @@ +/*- + * ============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.rest.beans; + +import java.io.Serializable; +import java.util.ArrayList; + +import org.onap.so.db.catalog.beans.AllottedResourceCustomization; +import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VnfResource; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; + +import com.openpojo.business.annotation.BusinessKey; + +/* + * A simple holder for Service and its associated elements: + * VnfResource, 1-n VfModule, Network TBD + */ + +public class ServiceMacroHolder implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + @BusinessKey + private Service service; + private ArrayList<VnfResource> vnfResources; + private ArrayList<NetworkResourceCustomization> networkResourceCustomizations; + private ArrayList<AllottedResourceCustomization> allottedResourceCustomizations; + private ArrayList<VnfResourceCustomization> vnfResourceCustomizations; + + + public ServiceMacroHolder() { + super(); + this.service = null; + this.vnfResources = new ArrayList<VnfResource>(); + this.networkResourceCustomizations = new ArrayList<>(); + this.allottedResourceCustomizations = new ArrayList<>(); + this.vnfResourceCustomizations = new ArrayList<>(); + } + public ServiceMacroHolder(Service service) { + this(); + this.service = service; + } + + public Service getService() { + return this.service; + } + public void setService(Service service) { + this.service = service; + } + + public void setVnfResources(ArrayList<VnfResource> vnfResources) { + this.vnfResources = vnfResources; + } + public ArrayList<VnfResource> getVnfResources() { + return this.vnfResources; + } + public void addVnfResource(VnfResource vr) { + if (vr != null) { + if (this.vnfResources != null) { + this.vnfResources.add(vr); + } else { + this.vnfResources = new ArrayList<>(); + this.vnfResources.add(vr); + } + } + } + + public void setVnfResourceCustomizations(ArrayList<VnfResourceCustomization> vnfResourceCustomizations) { + this.vnfResourceCustomizations = vnfResourceCustomizations; + } + public ArrayList<VnfResourceCustomization> getVnfResourceCustomizations() { + return this.vnfResourceCustomizations; + } + public void addVnfResourceCustomizations(VnfResourceCustomization vrc) { + if (vrc != null) { + if (this.vnfResourceCustomizations != null) { + this.vnfResourceCustomizations.add(vrc); + } else { + this.vnfResourceCustomizations = new ArrayList<>(); + this.vnfResourceCustomizations.add(vrc); + } + } + } + + public void setNetworkResourceCustomization(ArrayList<NetworkResourceCustomization> networkResourceCustomizations) { + this.networkResourceCustomizations = networkResourceCustomizations; + } + public ArrayList<NetworkResourceCustomization> getNetworkResourceCustomization() { + return this.networkResourceCustomizations; + } + public void addNetworkResourceCustomization(NetworkResourceCustomization nrc) { + if (this.networkResourceCustomizations != null) { + this.networkResourceCustomizations.add(nrc); + } else { + this.networkResourceCustomizations = new ArrayList<>(); + this.networkResourceCustomizations.add(nrc); + } + } + + public void setAllottedResourceCustomization(ArrayList<AllottedResourceCustomization> allottedResourceCustomizations) { + this.allottedResourceCustomizations = allottedResourceCustomizations; + } + public ArrayList<AllottedResourceCustomization> getAllottedResourceCustomization() { + return this.allottedResourceCustomizations; + } + public void addAllottedResourceCustomization(AllottedResourceCustomization arc) { + if (this.allottedResourceCustomizations != null) { + this.allottedResourceCustomizations.add(arc); + } else { + this.allottedResourceCustomizations = new ArrayList<>(); + this.allottedResourceCustomizations.add(arc); + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ServicePlus: "); + if (this.service != null) { + sb.append("service: " + this.service.toString()); + } else { + sb.append("service: null"); + } + if (this.vnfResourceCustomizations != null && this.vnfResourceCustomizations.size() > 0) { + int i=0; + sb.append("VnfResources: "); + for (VnfResourceCustomization vrc : this.vnfResourceCustomizations) { + sb.append(", vnfResourceCustomization[" + i++ + "]:" + vrc.toString()); + } + } else { + sb.append("none"); + } + if (this.vnfResources != null && this.vnfResources.size() > 0) { + int i=0; + sb.append("VnfResources: "); + for (VnfResource vr : this.vnfResources) { + sb.append(", vnfResource[" + i++ + "]:" + vr.toString()); + } + } else { + sb.append("none"); + } + if (this.networkResourceCustomizations != null && this.networkResourceCustomizations.size() > 0) { + int i=0; + sb.append("NetworkResourceCustomizations:"); + for (NetworkResourceCustomization nrc : this.networkResourceCustomizations) { + sb.append("NRC[" + i++ + "]: " + nrc.toString()); + } + } + if (this.allottedResourceCustomizations != null && this.allottedResourceCustomizations.size() > 0) { + int i=0; + sb.append("AllottedResourceCustomizations:"); + for (AllottedResourceCustomization arc : this.allottedResourceCustomizations) { + sb.append("ARC[" + i++ + "]: " + arc.toString()); + } + } + + return sb.toString(); + } + public ArrayList<NetworkResourceCustomization> getNetworkResourceCustomizations() { + return networkResourceCustomizations; + } + public void setNetworkResourceCustomizations(ArrayList<NetworkResourceCustomization> networkResourceCustomizations) { + this.networkResourceCustomizations = networkResourceCustomizations; + } + public ArrayList<AllottedResourceCustomization> getAllottedResourceCustomizations() { + return allottedResourceCustomizations; + } + public void setAllottedResourceCustomizations(ArrayList<AllottedResourceCustomization> allottedResourceCustomizations) { + this.allottedResourceCustomizations = allottedResourceCustomizations; + } + + + + +} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/MavenLikeVersioning.java index e42f734a64..6951c4412d 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/MavenLikeVersioning.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.utils; +package org.onap.so.db.catalog.utils; import java.io.Serializable; diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioningComparator.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/MavenLikeVersioningComparator.java index 49fd1fa6f6..85fc9b3df2 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioningComparator.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/MavenLikeVersioningComparator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.utils; +package org.onap.so.db.catalog.utils; import java.util.Comparator; diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/RecordNotFoundException.java index 33ece6679e..4168492245 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/RecordNotFoundException.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.utils; + +package org.onap.so.db.catalog.utils; /* * Exception of the ASDC controller. diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/package-info.java index b5e4348930..4f43c26b2e 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/utils/package-info.java @@ -22,5 +22,5 @@ * Utility classes for catalog DB. */ -package org.openecomp.mso.db.catalog.utils; +package org.onap.so.db.catalog.utils; diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java deleted file mode 100644 index af0ea101f4..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java +++ /dev/null @@ -1,5203 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog; - -import java.io.Closeable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hibernate.HibernateException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.db.catalog.beans.AllottedResource; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; -import org.openecomp.mso.db.catalog.beans.ArRecipe; -import org.openecomp.mso.db.catalog.beans.HeatEnvironment; -import org.openecomp.mso.db.catalog.beans.HeatFiles; -import org.openecomp.mso.db.catalog.beans.HeatNestedTemplate; -import org.openecomp.mso.db.catalog.beans.HeatTemplate; -import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; -import org.openecomp.mso.db.catalog.beans.Model; -import org.openecomp.mso.db.catalog.beans.ModelRecipe; -import org.openecomp.mso.db.catalog.beans.NetworkRecipe; -import org.openecomp.mso.db.catalog.beans.NetworkResource; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; -import org.openecomp.mso.db.catalog.beans.ServiceRecipe; -import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources; -import org.openecomp.mso.db.catalog.beans.ServiceToNetworks; -import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization; -import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup; -import org.openecomp.mso.db.catalog.beans.ToscaCsar; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; -import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles; -import org.openecomp.mso.db.catalog.beans.VnfComponent; -import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe; -import org.openecomp.mso.db.catalog.beans.VnfRecipe; -import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioningComparator; -import org.openecomp.mso.db.catalog.utils.RecordNotFoundException; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * This class encapsulates all of the objects that can be queried from a Catalog database. - * Clients must use these methods to retrieve catalog objects. The session is not - * available for clients to do their own direct queries to the database. - * - * - */ -public class CatalogDatabase implements Closeable { - - protected final AbstractSessionFactoryManager sessionFactoryCatalogDB; - - private static final String NETWORK_TYPE = "networkType"; - private static final String ACTION = "action"; - private static final String VNF_TYPE = "vnfType"; - private static final String SERVICE_TYPE = "serviceType"; - private static final String MODEL_UUID= "modelUUID"; - private static final String VNF_COMPONENT_TYPE = "vnfComponentType"; - private static final String MODEL_ID = "modelId"; - private static final String MODEL_NAME = "modelName"; - private static final String MODEL_VERSION = "version"; - private static final String TYPE = "type"; - private static final String MODEL_TYPE = "modelType"; - private static final String MODEL_VERSION_ID = "modelVersionId"; - private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUuid"; - private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUId"; - private static final String NETWORK_SERVICE = "network service"; - private static final String TEMPLATE_NAME = "template_name"; - private static final String GET_VNF_RECIPE = "getVnfRecipe"; - - protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - protected Session session = null; - - protected CatalogDatabase (AbstractSessionFactoryManager sessionFactoryCatalog) { - sessionFactoryCatalogDB = sessionFactoryCatalog; - } - - public static CatalogDatabase getInstance() { - return new CatalogDatabase(new CatalogDbSessionFactoryManager ()); - } - - private Session getSession () { - - if (session == null) { - try { - session = sessionFactoryCatalogDB.getSessionFactory ().openSession (); - session.beginTransaction (); - } catch (HibernateException he) { - LOGGER.error (MessageEnum.GENERAL_EXCEPTION_ARG, "Error creating Hibernate Session: " + he, "", "", MsoLogger.ErrorCode.DataError, "Error creating Hibernate Session: " + he); - throw he; - } - } - - return session; - } - - - /** - * Close an open Catalog Database session. - * This method should always be called when a client is finished using a - * CatalogDatabase instance. - */ - @Override - public void close () { - if (session != null) { - session.close (); - session = null; - } - } - - /** - * Commits the current transaction on this session and starts a fresh one. - */ - public void commit () { - getSession ().getTransaction ().commit (); - getSession ().beginTransaction (); - } - - /** - * Rolls back current transaction and starts a fresh one. - */ - public void rollback () { - getSession ().getTransaction ().rollback (); - getSession ().beginTransaction (); - } - - /** - * Return all Heat Templates in the Catalog DB - * - * @return A list of HeatTemplate objects - */ - @SuppressWarnings("unchecked") - public List <HeatTemplate> getAllHeatTemplates() { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get all Heat templates"); - String hql = "FROM HeatTemplate"; - Query query = getSession().createQuery(hql); - - List <HeatTemplate> result = query.list(); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatTemplates", null); - return result; - } - - /** - * Fetch a specific Heat Template by ID. - * - * @param templateId template id - * @return HeatTemplate object or null if none found - */ - @Deprecated - public HeatTemplate getHeatTemplate(int templateId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get Heat template with id " + templateId); - - HeatTemplate template = (HeatTemplate) getSession().get(HeatTemplate.class, templateId); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return template; - } - - /** - * Return the newest version of a specific Heat Template (queried by Name). - * - * @param templateName template name - * @return HeatTemplate object or null if none found - */ - public HeatTemplate getHeatTemplate(String templateName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat template with name " + templateName); - - String hql = "FROM HeatTemplate WHERE templateName = :template_name"; - Query query = getSession().createQuery (hql); - query.setParameter(TEMPLATE_NAME, templateName); - - @SuppressWarnings("unchecked") - List <HeatTemplate> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found", "CatalogDB", "getHeatTemplate", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return resultList.get(0); - } - - /** - * Return a specific version of a specific Heat Template (queried by Name). - * - * @param templateName - * @param version - * @return HeatTemplate object or null if none found - */ - public HeatTemplate getHeatTemplate(String templateName, String version) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat template with name " + templateName - + " and version " - + version); - - String hql = "FROM HeatTemplate WHERE templateName = :template_name AND version = :version"; - Query query = getSession().createQuery(hql); - query.setParameter(TEMPLATE_NAME, templateName); - query.setParameter(MODEL_VERSION, version); - - @SuppressWarnings("unchecked") - List <HeatTemplate> resultList = query.list(); - - // See if something came back. - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found.", "CatalogDB", "getHeatTemplate", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return resultList.get(0); - } - - /** - * Return a specific Heat Template by ARTIFACT_UUID). - * - * @param artifactUuid - * @return HeatTemplate object or null if none found - */ - - public HeatTemplate getHeatTemplateByArtifactUuid(String artifactUuid) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat template with artifactUuid " + artifactUuid); - - // Will this work if the id is a string? - HeatTemplate template = (HeatTemplate) getSession ().get (HeatTemplate.class, artifactUuid); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return template; - } - - /** - * Return a specific Heat Template by ARTIFACT_UUID using standard query method. unique record expected. - * - * @param artifactUuid - * @return HeatTemplate object or null if none found - */ - public HeatTemplate getHeatTemplateByArtifactUuidRegularQuery(String artifactUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat template (regular query) with artifactUuid " + artifactUuid); - - String hql = "FROM HeatTemplate WHERE artifactUuid = :artifactUuidValue"; - HashMap<String, String> variables = new HashMap<>(); - variables.put("artifactUuidValue", artifactUuid); - HeatTemplate template = (HeatTemplate) this.executeQuerySingleRow(hql, variables, true); - - if (template == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null); - } - return template; - } - - public List<HeatTemplateParam> getParametersForHeatTemplate(String heatTemplateArtifactUuid) { - LOGGER.debug ("Catalog database - getParametersForHeatTemplate with artifactUuid " + heatTemplateArtifactUuid); - - String hql = "FROM HeatTemplateParams WHERE artifactUuid = :artifactUuidValue"; - Query query = getSession().createQuery(hql); - query.setParameter ("artifactUuidValue", heatTemplateArtifactUuid); - List<HeatTemplateParam> resultList = new ArrayList<>(); - try { - resultList = query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching HeatTemplateParams for: heatTemplateArtifactUuid='" + heatTemplateArtifactUuid + "'" + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching HeatTemplateParams for artifactUuid=" + heatTemplateArtifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for artifactUuid=" + heatTemplateArtifactUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching HeatTemplateParam for: artifactUuid='" + heatTemplateArtifactUuid + "'" + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching HeatTemplate for artifactUuid=" + heatTemplateArtifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for artifactUuid=" + heatTemplateArtifactUuid); - throw e; - } - - return resultList; - - } - - /** - * Return a specific Heat Environment by ARTIFACT_UUID using standard query method. unique record expected. - * - * @param artifactUuid - * @return HeatEnvironment object or null if none found - */ - public HeatEnvironment getHeatEnvironmentByArtifactUuid(String artifactUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat Environment with artifactUuid " + artifactUuid); - - String hql = "FROM HeatEnvironment WHERE artifactUuid = :artifactUuidValue"; - Query query = getSession().createQuery(hql); - query.setParameter("artifactUuidValue", artifactUuid); - HeatEnvironment environment = null; - try { - environment = (HeatEnvironment) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row for Envt - data integrity error: artifactUuid='" + artifactUuid +"'", nure); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for heatEnvironment artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for artifactUuid==" + artifactUuid); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for envt: artifactUuid='" + artifactUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching envt for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching envt for artifactUuid=" + artifactUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: artifactUuid='" + artifactUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching envt for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching envt for artifactUuid=" + artifactUuid); - - throw e; - } - - if (environment == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatEnvironmentByArtifactUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatEnvironmentByArtifactUuid", null); - } - return environment; - } - - /** - * Fetch a Service definition by InvariantUUID - */ - public Service getServiceByInvariantUUID (String modelInvariantUUID) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with Invariant UUID " + modelInvariantUUID); - - String hql = "FROM Service WHERE modelInvariantUUID = :model_invariant_uuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("model_invariant_uuid", modelInvariantUUID); - - @SuppressWarnings("unchecked") - List <Service> resultList = query.list (); - - // See if something came back. - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByName", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByName", null); - return resultList.get (0); - } - - /** - * Fetch a Service definition - */ - public Service getService (String modelName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with name " + modelName); - - String hql = "FROM Service WHERE modelName = :MODEL_NAME"; - Query query = getSession().createQuery(hql); - query.setParameter("MODEL_NAME", modelName); - - Service service = null; - try { - service = (Service) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelName='" + modelName + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelName=" + modelName); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelName='" + modelName + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelName=" + modelName); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelName='" + modelName + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelName=" + modelName); - throw e; - } - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getService", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getService", null); - } - - return service; - } - - public Service getServiceByModelUUID (String modelUUID) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with Model UUID " + modelUUID); - - String hql = "FROM Service WHERE modelUUID = :MODEL_UUID"; - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("MODEL_UUID", modelUUID); - - - Service service = this.executeQuerySingleRow(hql, parameters, true); - - /* - try { - service = (Service) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelUUID='" + modelUUID + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelUUID=" + modelUUID, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelUUID=" + modelUUID); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelUUID='" + modelUUID + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelUUID=" + modelUUID, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelUUID=" + modelUUID); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelUUID='" + modelUUID + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelUUID=" + modelUUID, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelUUID=" + modelUUID); - throw e; - } - */ - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getServiceByModelUUID", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelUUID", null); - } - - return service; - } - - /** - * Fetch the Common Service API definition using Http Method + serviceNameVersionId - */ - public Service getService(Map<String, String> map, String httpMethod) { - - String serviceNameVersionId = map.get("serviceNameVersionId"); - Query query; - String serviceId = "not_set"; - String serviceVersion = "not_set"; - - if(serviceNameVersionId != null && serviceNameVersionId.length() > 0){ - LOGGER.debug ("Catalog database - get service modelUUID with id " + serviceNameVersionId); - - String hql = "FROM Service WHERE MODEL_UUID = :MODEL_UUID and http_method = :http_method"; - query = getSession().createQuery(hql); - query.setParameter("MODEL_UUID", serviceNameVersionId); - } else { - serviceId = map.get("serviceId"); - serviceVersion = map.get("serviceVersion"); - LOGGER.debug("Catalog database - get serviceId with id " + serviceId + " and serviceVersion with " + serviceVersion); - - String hql = "FROM Service WHERE service_id = :service_id and service_version = :service_version and http_method = :http_method"; - query = getSession().createQuery(hql); - query.setParameter("service_id", serviceId); - query.setParameter("service_version", serviceVersion); - } - - query.setParameter("http_method", httpMethod); - - long startTime = System.currentTimeMillis(); - Service service = null; - try { - service = (Service) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - data integrity error: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for service_id=" + serviceId); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for service_id=" + serviceId); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for service_id=" + serviceId); - - throw e; - } - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getService", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getService", null); - } - return service; - } - - /** - * Return the newest version of a Service (queried by Name). - * - * @param modelName - * @return Service object or null if none found - */ - public Service getServiceByModelName(String modelName){ - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with name " + modelName); - - String hql = "FROM Service WHERE modelName = :MODEL_NAME"; - Query query = getSession().createQuery(hql); - query.setParameter("MODEL_NAME", modelName); - - @SuppressWarnings("unchecked") - List <Service> resultList = query.list(); - - // See if something came back. - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null); - return resultList.get(0); - } - - public Service getServiceByVersionAndInvariantId(String modelInvariantId, String modelVersion) throws Exception { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with modelInvariantId: " + modelInvariantId + " and modelVersion: " + modelVersion); - - String hql = "FROM Service WHERE modelInvariantUUID = :MODEL_INVARIANT_UUID AND version = :VERSION_STR"; - Query query = getSession().createQuery(hql); - query.setParameter("MODEL_INVARIANT_UUID", modelInvariantId); - query.setParameter("VERSION_STR", modelVersion); - - Service result = null; - try { - result = (Service) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantId='" + modelInvariantId + "', modelVersion='" + modelVersion + "'", nure); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelInvariantId=" + modelInvariantId + " and modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantId=" + modelInvariantId); - throw new Exception("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantId='" + modelInvariantId + "', modelVersion='" + modelVersion + "'"); - } - // See if something came back. - if (result==null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByVersionAndInvariantId", null); - return null; - } - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByVersionAndInvariantId", null); - return result; - } - - /** - * Return a newest version of Service recipe that matches a given SERVICE_ID and ACTION - * - * @param serviceModelUUID - * @param action * - * @return ServiceRecipe object or null if none found - */ - @Deprecated - public ServiceRecipe getServiceRecipe (int serviceModelUUID, String action) { - - StringBuilder hql; - - if(action == null){ - hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID"); - }else { - hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID AND action = :action "); - } - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Service recipe with serviceModelUUID " + Integer.toString(serviceModelUUID) - + " and action " - + action - ); - - Query query = getSession ().createQuery (hql.toString ()); - query.setParameter ("serviceModelUUID", serviceModelUUID); - if(action != null){ - query.setParameter (ACTION, action); - } - - @SuppressWarnings("unchecked") - List <ServiceRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); - return resultList.get (0); - } - - /** - * Return a newest version of Service recipe that matches a given SERVICE_MODEL_UUID and ACTION - * - * @param serviceModelUuid - * @param action * - * @return ServiceRecipe object or null if none found - */ - public ServiceRecipe getServiceRecipeByServiceModelUuid(String serviceModelUuid, String action) { - - StringBuilder hql; - - if(action == null){ - hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid"); - }else { - hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid AND action = :action "); - } - - long startTime = System.currentTimeMillis (); - LOGGER.debug("Catalog database - get Service recipe with serviceModelUuid " + serviceModelUuid - + " and action " - + action - ); - - Query query = getSession().createQuery(hql.toString()); - query.setParameter("serviceModelUuid", serviceModelUuid); - if(action != null){ - query.setParameter(ACTION, action); - } - - @SuppressWarnings("unchecked") - List <ServiceRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); - return resultList.get(0); - } - - public List<ServiceRecipe> getServiceRecipes(String serviceModelUuid) { - - StringBuilder hql; - - hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID"); - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Service recipe with serviceModelUUID " + serviceModelUuid); - - Query query = getSession().createQuery(hql.toString()); - query.setParameter("serviceModelUUID", serviceModelUuid); - - @SuppressWarnings("unchecked") - List <ServiceRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipes", null); - return Collections.EMPTY_LIST; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null); - return resultList; - } - - - /** - * Return the VNF component data - queried by the VNFs ID and the component type. - * - * @param vnfId - * @param type - * @return VnfComponent object or null if none found - */ - @Deprecated - public VnfComponent getVnfComponent (int vnfId, String type) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get VnfComponent where vnfId="+ vnfId+ " AND componentType="+ type); - - String hql = "FROM VnfComponent WHERE vnfId = :vnf_id AND componentType = :type"; - Query query = getSession ().createQuery (hql); - query.setParameter ("vnf_id", vnfId); - query.setParameter ("type", type); - - VnfComponent result = null; - try { - result = (VnfComponent) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnf_id='" + vnfId + "', componentType='" + type + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnf_id=" + vnfId + " and componentType=" + type, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnf_id=" + vnfId); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: vnf_id='" + vnfId + "', componentType='" + type + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnf_id=" + vnfId + " and componentType=" + type, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnf_id=" + vnfId); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnf_id='" + vnfId + "', componentType='" + type + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnf_id=" + vnfId + " and componentType=" + type, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnf_id=" + vnfId); - - throw e; - } - - if (result != null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfComponent", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No VNFComponent found", "CatalogDB", "getVnfComponent", null); - } - return result; - } - - /** - * Return the newest version of a specific VNF resource (queried by Name). - * - * @param vnfType - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResource (String vnfType) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vnf resource with model_name " + vnfType); - - String hql = "FROM VnfResource WHERE modelName = :vnf_name"; - Query query = getSession().createQuery(hql); - query.setParameter("vnf_name", vnfType); - - @SuppressWarnings("unchecked") - List <VnfResource> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); - return resultList.get(0); - } - - /** - * Return the newest version of a specific VNF resource (queried by Name). - * - * @param vnfType - * @param serviceVersion - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResource (String vnfType, String serviceVersion) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource with model_name " + vnfType + " and version=" + serviceVersion); - - String hql = "FROM VnfResource WHERE modelName = :vnfName and version = :serviceVersion"; - Query query = getSession().createQuery(hql); - query.setParameter("vnfName", vnfType); - query.setParameter("serviceVersion", serviceVersion); - - VnfResource resource = null; - try { - resource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnfType='" + vnfType + "', serviceVersion='" + serviceVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfType=" + vnfType); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: vnfType='" + vnfType + "', asdc_service_model_version='" + serviceVersion + "' " + he.getMessage()); - LOGGER.debug(Arrays.toString(he.getStackTrace())); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfType=" + vnfType); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnfType='" + vnfType + "', serviceVersion='" + serviceVersion + "' " + e.getMessage()); - LOGGER.debug(Arrays.toString(e.getStackTrace())); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfType=" + vnfType); - - throw e; - } - if (resource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResource", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); - } - return resource; - } - - /** - * Return VnfResource (queried by modelCustomizationId). - * - * @param modelCustomizationId - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResourceByModelCustomizationId(String modelCustomizationId) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource with modelCustomizationId " + modelCustomizationId); - - String hql = "SELECT vr " - + "FROM VnfResource as vr JOIN vr.vnfResourceCustomizations as vrc " - + "WHERE vrc.modelCustomizationUuid = :modelCustomizationId"; - - Query query = getSession().createQuery(hql); - query.setParameter("modelCustomizationId", modelCustomizationId); - - VnfResource resource = null; - try { - resource = (VnfResource) query.uniqueResult(); - } catch(org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationId + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationId=" + modelCustomizationId); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationId='" + modelCustomizationId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationId=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationId=" + modelCustomizationId); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationId='" + modelCustomizationId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationId=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationId=" + modelCustomizationId); - - throw e; - } - if (resource == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelCustomizationId", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelCustomizationId", null); - } - return resource; - } - - - /** - * Return the newest version of a specific VNF resource Customization (queried by modelCustomizationName and modelVersionId). - * - * @return {@link VnfResourceCustomization} object or null if none found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationName (String modelCustomizationName, String modelVersionId) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " serviceModelUUID " + modelVersionId); - - String hql = "SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.modelCustomizationUuid IN " - + "(SELECT src.resourceModelCustomizationUUID FROM ServiceToResourceCustomization src " - + "WHERE src.serviceModelUUID = :modelVersionId)" - + "AND vrc.modelInstanceName = :modelCustomizationName"; - - Query query = getSession().createQuery(hql); - query.setParameter("modelCustomizationName", modelCustomizationName); - query.setParameter("modelVersionId", modelVersionId); - - @SuppressWarnings("unchecked") - List<VnfResourceCustomization> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null); - return resultList.get(0); - } - - - /** - * Return the newest version of a specific VNF resource (queried by modelInvariantId). - * - * @param modelInvariantUuid model invariant ID - * @param modelVersion model version - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResourceByModelInvariantId(String modelInvariantUuid, String modelVersion) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource with modelInvariantUuid " + modelInvariantUuid); - - String hql = "FROM VnfResource WHERE modelInvariantUuid = :modelInvariantUuid and version = :serviceVersion"; - Query query = getSession().createQuery(hql); - query.setParameter("modelInvariantUuid", modelInvariantUuid); - query.setParameter("serviceVersion", modelVersion); - - VnfResource resource = null; - try { - resource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantUuid='" + modelInvariantUuid + "', serviceVersion='" + modelVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantUuid=" + modelInvariantUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', asdc_service_model_version='" + modelVersion + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', serviceVersion='" + modelVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantUuid=" + modelInvariantUuid); - - throw e; - } - if (resource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResource", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); - } - return resource; - } - - /** - * Return the newest version of a specific VNF resource (queried by ID). - * - * @param id The vnf id - * @return VnfResource object or null if none found - */ - @Deprecated - public VnfResource getVnfResourceById (int id) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get VNF resource with id " + id); - - String hql = "FROM VnfResource WHERE id = :id"; - Query query = getSession ().createQuery (hql); - query.setParameter ("id", id); - - @SuppressWarnings("unchecked") - List <VnfResource> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResource not found", "CatalogDB", "getVnfResourceById", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceById", null); - return resultList.get (0); - } - - /** - * Return the newest version of a vfModule - 1607 - * - */ - public VfModule getVfModuleModelName(String modelName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleModelName with name " + modelName); - - String hql = "FROM VfModule WHERE modelName = :model_name"; - Query query = getSession().createQuery(hql); - query.setParameter("model_name", modelName); - - @SuppressWarnings("unchecked") - List<VfModule> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleModelName", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleModelName", null); - return resultList.get(0); - } - - public VfModule getVfModuleModelName(String modelName, String model_version) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleModelName with type='" + modelName + "' and asdc_service_model_version='" + model_version + "'"); - - String hql = "FROM VfModule WHERE Name = :model_name and version = :model_version"; - Query query = getSession().createQuery(hql); - query.setParameter("modelName", modelName); - query.setParameter("model_version", model_version); - - VfModule module = null; - try { - module = (VfModule) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: type='" + modelName + "', asdc_service_model_version='" + model_version + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for type=" + modelName); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: type='" + modelName + "', asdc_service_model_version='" + model_version + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for type=" + modelName); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: type='" + modelName + "', asdc_service_model_version='" + model_version + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for type=" + modelName); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleModelName", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleModelName", null); - } - return module; - } - - /** - * Need this for 1707 DHV. This may be a temporary solution. May - * change it to get resources using service's model name. - * - *@author cb645j - * - */ - public VfModuleCustomization getVfModuleCustomizationByModelName(String modelName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VfModuleCustomization By VfModule's ModelName: " + modelName); - - String hql = "SELECT VfModuleCustomization FROM VfModuleCustomization as vfmc LEFT OUTER JOIN VfModule as vfm on vfm.modelUUID = vfmc.vfModuleModelUuid where vfm.modelName = :model_name"; - Query query = getSession().createQuery(hql); - query.setParameter("model_name", modelName); - - @SuppressWarnings("unchecked") - List<VfModuleCustomization> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful query but Vf module NOT found", "CatalogDB", "getVfModuleCustomizationByModelName", null); - return null; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful query ", "CatalogDB", "getVfModuleCustomizationByModelName", null); - return resultList.get(0); - } - - - /** - * Return the newest version of a specific Network resource (queried by Type). - * - * @param networkType - * @return NetworkResource object or null if none found - */ - public NetworkResource getNetworkResource(String networkType) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get network resource with type " + networkType); - - String hql = "FROM NetworkResource WHERE model_name = :network_type"; - Query query = getSession().createQuery(hql); - query.setParameter("network_type", networkType); - - @SuppressWarnings("unchecked") - List <NetworkResource> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Network Resource not found", "CatalogDB", "getNetworkResource", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResource", null); - return resultList.get(0); - } - - /** - * Return a VNF recipe that matches a given VNF_TYPE, ACTION, and, if specified, SERVICE_TYPE - * - * @param vnfType - * @param action - * @param serviceType The service Name, if null or empty is provided, it won't be taken into account - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVnfRecipe(String vnfType, String action, String serviceType) { - boolean withServiceType = false; - - StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); - - // If query c - if (serviceType == null || serviceType.isEmpty()) { - hql.append("AND serviceType is NULL "); - } else { - hql.append("AND serviceType = :serviceType "); - withServiceType = true; - } - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF recipe with name " + vnfType - + " and action " - + action - + " and service type " - + serviceType); - - Query query = getSession().createQuery(hql.toString()); - query.setParameter(VNF_TYPE, vnfType); - query.setParameter(ACTION, action); - if (withServiceType) { - query.setParameter(SERVICE_TYPE, serviceType); - } - - @SuppressWarnings("unchecked") - List <VnfRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", GET_VNF_RECIPE, null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, null); - return resultList.get(0); - } - - - - /** - * Return a VNF recipe that matches a given VNF_TYPE and ACTION - * - * @param vnfType - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVnfRecipe(String vnfType, String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF recipe with name " + vnfType - + " and action " - + action); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); - query.setParameter(VNF_TYPE, vnfType); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", GET_VNF_RECIPE, null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, null); - return resultList.get(0); - } - - /** - * Return a VNF recipe that matches a given ModelName and Modelversion and ACTION - * - * @param modelName - * @param modelVersion - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVnfRecipeByNameVersion(String modelName, String modelVersion, String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF recipe with name " + modelName + " and action " + action); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action "); - query.setParameter(VNF_TYPE, modelName); - query.setParameter(MODEL_VERSION, modelVersion); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", GET_VNF_RECIPE, null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, null); - return resultList.get(0); - } - - /** - * Return a Network recipe that matches a given MODEL_UUID and ACTION - * - * @param vnfModelUuid - * @param action - * @return NetworkRecipe object or null if none found - */ - public VnfRecipe getVnfRecipeByModuleUuid (String vnfModelUuid, String action) { - LOGGER.debug ("Catalog database - get vnf recipe with vnf resource model uuid " + vnfModelUuid - + " and action " - + action - ); - VnfResource vnfResource = getVnfResourceByModelUuid(vnfModelUuid); - if(null == vnfResource){ - return null; - } - - VnfRecipe recipe = this.getVnfRecipeByNameVersion(vnfResource.getModelName(), vnfResource.getVersion(), action); - - if (recipe == null && vnfResource.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) { - recipe = getDefaultVnfRecipe(action); - } - return recipe; - } - - private VnfRecipe getDefaultVnfRecipe(String action) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get default VNF recipe with action: " + action); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); - query.setParameter(VNF_TYPE, "NS_DEFAULT"); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", GET_VNF_RECIPE, null); - return null; - } - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, null); - return resultList.get(0); - } - - /** - * Return a VNF recipe that matches a given VF_MODULE_ID and ACTION - * - * @param vfModuleId - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVnfRecipeByVfModuleId(String vnfType, String vfModuleId, String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF Recipe with vfModuleId " + vfModuleId); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vfModuleId = :vfModuleId and action = :action "); - query.setParameter(VF_MODULE_MODEL_UUID, vfModuleId); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe Entry not found", "CatalogDB", "getVnfRecipeByVfModuleId", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF Recipe Entry found", "CatalogDB", "getVnfRecipeByVfModuleId", null); - return resultList.get(0); - } - - public VfModule getVfModuleTypeByUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleTypeByUuid with uuid=" + modelCustomizationUuid); - - String hql = "FROM VfModule WHERE modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession().createQuery(hql); - query.setParameter("modelCustomizationUuid", modelCustomizationUuid); - - VfModule module = null; - try { - module = (VfModule) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleTypeByUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleTypeByUuid", null); - } - return module; - } - - @Deprecated - public VfModule getVfModuleType(String type) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleType with type " + type); - - String hql = "FROM VfModule WHERE type = :type"; - Query query = getSession().createQuery(hql); - query.setParameter("type", type); - - @SuppressWarnings("unchecked") - List<VfModule> resultList = query.list(); - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleType", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - return resultList.get (0); - } - - @Deprecated - public VfModule getVfModuleType(String type, String version) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleType with type " + type + " and model_version " + version); - - String hql = "FROM VfModule WHERE type = :type and version = :version"; - Query query = getSession().createQuery(hql); - query.setParameter ("type", type); - query.setParameter (MODEL_VERSION, version); - VfModule module = null; - try { - module = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: type='" + type + "', asdc_service_model_version='" + version + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for type==" + type); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: type='" + type + "', asdc_service_model_version='" + version + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for type=" + type); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: type='" + type + "', asdc_service_model_version='" + version + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for type=" + type); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - } - return module; - } - - public VnfResource getVnfResourceByServiceUuid(String serviceModelInvariantUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleType with serviceModelInvariantUuid " + serviceModelInvariantUuid); - - String hql = "FROM VnfResource WHERE serviceModelInvariantUuid = :serviceModelInvariantUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("serviceModelInvariantUuid", serviceModelInvariantUuid); - VnfResource vnfResource = null; - try { - vnfResource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: serviceModelInvariantUuid='" + serviceModelInvariantUuid); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceModelInvariantUuid==" + serviceModelInvariantUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - - throw e; - } - if (vnfResource == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - } - return vnfResource; - } - - public VnfResource getVnfResourceByVnfUuid(String vnfResourceModelInvariantUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleType with vnfResourceModelInvariantUuid " + vnfResourceModelInvariantUuid); - - String hql = "FROM VnfResource WHERE vnfResourceModelInvariantUuid = :vnfResourceModelInvariantUuid"; - Query query = getSession().createQuery(hql); - query.setParameter("vnfResourceModelInvariantUuid", vnfResourceModelInvariantUuid); - VnfResource vnfResource = null; - try { - vnfResource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfResourceModelInvariantUuid==" + vnfResourceModelInvariantUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid); - - throw e; - } - if (vnfResource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - } - return vnfResource; - } - - public VnfResource getVnfResourceByType(String vnfType) { - return this.getVnfResource(vnfType); - } - - public VfModule getVfModuleByModelInvariantUuid(String modelInvariantUUID) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleTypeByModelInvariantUuid with uuid " + modelInvariantUUID); - - String hql = "FROM VfModule WHERE modelInvariantUUID = :modelInvariantUUID "; - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("modelInvariantUUID", modelInvariantUUID); - List<VfModule> modules = this.executeQueryMultipleRows(hql, parameters, true); - VfModule module = null; - - if (modules != null && ! modules.isEmpty()) { - modules.sort(new MavenLikeVersioningComparator()); - Collections.reverse (modules); - module = modules.get(0); - } - - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelInvariantUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelInvariantUuid", null); - } - return module; - } - - public VfModuleCustomization getVfModuleByModelCustomizationUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleTypeByModelCustomizationUuid with uuid " + modelCustomizationUuid); - - String hql = "FROM VfModuleCustomization WHERE modelCustomizationUuid = :modelCustomizationUuid "; - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - VfModuleCustomization module = null; - try { - module = (VfModuleCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModuleModelInvariantUuid=" + modelCustomizationUuid , "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelCustomizationUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelCustomizationUuid", null); - } - return module; - } - - - public VfModule getVfModuleByModelInvariantUuidAndModelVersion(String modelInvariantUuid, String modelVersion) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelInvariantUuidAndModelVersion with modelInvariantUuid: " + modelInvariantUuid + ", modelVersion: " + modelVersion); - - String hql = "FROM VfModule WHERE modelInvariantUUID = :modelInvariantUuid and version = :modelVersion"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelInvariantUuid", modelInvariantUuid); - query.setParameter("modelVersion", modelVersion); - VfModule module = null; - try { - module = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantUuid='" + modelInvariantUuid + "', modelVersion='" +modelVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModule ModelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for ModelInvariantUuid==" + modelInvariantUuid + " modelVersion==" + modelVersion); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', modelVersion='" +modelVersion + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', modelVersion='" +modelVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion); - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelInvariantUuidAndModelVersion", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelInvariantUuidAndModelVersion", null); - } - return module; - } - - /** - * Return the VfModuleCustomization object identified by the given modelCustomizationUuid 1707 - * - * @param modelCustomizationUuid - * @return VfModuleCustomization or null if not found - */ - public VfModuleCustomization getVfModuleCustomizationByModelCustomizationId(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleCustomizationByModelCustomizationId with modelCustomizationUuid: " + modelCustomizationUuid); - - String hql = "FROM VfModuleCustomization WHERE modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - VfModuleCustomization VfModuleCustomization = null; - try { - VfModuleCustomization = (VfModuleCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModuleCustomization modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw e; - } - if (VfModuleCustomization != null) { - LOGGER.debug("Found VMC of " + VfModuleCustomization.getModelCustomizationUuid() + ", now looking for vfModule=" + VfModuleCustomization.getVfModuleModelUuid()); - VfModuleCustomization.setVfModule(this.getVfModuleByModelUuid(VfModuleCustomization.getVfModuleModelUuid())); - } - - if (VfModuleCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleCustomizationByModelCustomizationId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleCustomizationByModelCustomizationId", null); - } - return VfModuleCustomization; - } - - /** - * Return the VfModule object identified by the given modelUuid 1707 - * per Mike Z. - this may return more than one row - and even if it does, - * the heat template will be the same - so just return any of the rows. - * - * @param modelUuid - * @return VfModule or null if not found - */ - public VfModule getVfModuleByModelUuid(String modelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelUuid with modelUuid: " + modelUuid); - - String hql = "FROM VfModule WHERE modelUUID = :modelUuidValue"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelUuidValue", modelUuid); - List<VfModule> vfModules = null; - try { - vfModules = query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VfModule for: modelUuid='" + modelUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VfModule for modelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelUuid=" + modelUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VfModule for: modelUuid='" + modelUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelUuid=" + modelUuid); - throw e; - } - - if (vfModules == null || vfModules.isEmpty()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelUuid", null); - return null; - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelUuid", null); - } - return vfModules.get(0); - } - /** - * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 - * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean - * - * @param modelCustomizationUuid - * @return VnfResourceCustomization or null if not found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVnfResourceByModelCustomizatonUuid with modelCustomizationUuid: " + modelCustomizationUuid); - - String hql = "FROM VnfResourceCustomization WHERE modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - VnfResourceCustomization vnfResourceCustomization = null; - try { - vnfResourceCustomization = (VnfResourceCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw e; - } - if (vnfResourceCustomization != null) { - LOGGER.debug("Found VRC of " + vnfResourceCustomization.getModelCustomizationUuid() + ", now looking for vnfResource=" + vnfResourceCustomization.getVnfResourceModelUuid() ); - vnfResourceCustomization.setVnfResource(this.getVnfResourceByModelUuid(vnfResourceCustomization.getVnfResourceModelUuid())); - LOGGER.debug("Now looking for vfModules for " + vnfResourceCustomization.getModelCustomizationUuid()); - vnfResourceCustomization.setVfModuleCustomizations(this.getAllVfModuleCustomizations(vnfResourceCustomization.getModelCustomizationUuid())); - } - - if (vnfResourceCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationUuid", null); - } - return vnfResourceCustomization; - } - - /** - * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 - * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean - * - * @param modelVersionId - * @return VnfResourceCustomization or null if not found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelVersionId(String modelVersionId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVnfResourceCustomizationByModelVersionId with modelVersionId: " + modelVersionId); - - String hql = "FROM VnfResourceCustomization WHERE vnfResourceModelUuid = :modelVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelVersionId", modelVersionId); - VnfResourceCustomization vnfResourceCustomization = null; - try { - vnfResourceCustomization = (VnfResourceCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelVersionId='" + modelVersionId +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelVersionId==" + modelVersionId); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelVersionId=" + modelVersionId); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelVersionId=" + modelVersionId); - throw e; - } - if (vnfResourceCustomization != null) { - LOGGER.debug("Found VRC of " + vnfResourceCustomization.getModelCustomizationUuid() + ", now looking for vnfResource=" + vnfResourceCustomization.getVnfResourceModelUuid() ); - vnfResourceCustomization.setVnfResource(this.getVnfResourceByModelUuid(vnfResourceCustomization.getVnfResourceModelUuid())); - LOGGER.debug("Now looking for vfModules for " + vnfResourceCustomization.getModelCustomizationUuid()); - vnfResourceCustomization.setVfModuleCustomizations(this.getAllVfModuleCustomizations(vnfResourceCustomization.getModelCustomizationUuid())); - } - - if (vnfResourceCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceCustomizationByModelVersionId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelVersionId", null); - } - return vnfResourceCustomization; - } - - /** - * Return the VfModule object identified by the given modelCustomizationId, modelVersionId 1707 - * - * @param modelVersionId, modelCustomizationId - * @return VfModule or null if not found - */ - public VfModule getVfModuleByModelCustomizationIdAndVersion(String modelCustomizationId, String modelVersionId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelCustomizationIdAndVersion with modelVersionId: " + modelVersionId + " modelCustomizationId: " + modelCustomizationId); - -// select * from vf_module vfm where vfm.MODEL_UUID IN ( -// select vfmc.VF_MODULE_MODEL_UUID from vf_module_customization vfmc where vfmc.MODEL_CUSTOMIZATION_UUID='222bd8f2-341d-4419-aa0e-98398fa34050') -// and vfm.MODEL_UUID = 'fa1c8558-006c-4fb6-82f2-4fc0646d6b06'; - - String hql = "Select vfm FROM VfModule as vfm WHERE vfm.modelUUID IN (" - + "SELECT vfmc.vfModuleModelUuid FROM VfModuleCustomization as vfmc " - + "WHERE vfmc.modelCustomizationUuid = :modelCustomizationId) " - + "AND vfm.modelUUID = :modelVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelVersionId", modelVersionId); - query.setParameter ("modelCustomizationId", modelCustomizationId); - VfModule vfModule = null; - try { - vfModule = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelVersionId='" + modelVersionId +"' modelCustomizationId='" + modelCustomizationId + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelVersionId=" + modelVersionId + " modelCustomizationId=" + modelCustomizationId); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' modelCustomizationId='" + modelCustomizationId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelVersionId=" + modelVersionId + " modelCustomizationId=" + modelCustomizationId); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' modelCustomizationId='" + modelCustomizationId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelVersionId=" + modelVersionId + " modelCustomizationId=" + modelCustomizationId); - throw e; - } - - if (vfModule == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelCustomizationIdAndVersion", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelCustomizationIdAndVersion", null); - } - return vfModule; - } - - /** - * Return the VfModule object identified by the given modelCustomizationId, modelVersion, modelInvariantId 1707 - * - * @param modelCustomizationId, modelVersion, modelInvariantId - * @return VfModule or null if not found - */ - public VfModule getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId(String modelCustomizationId, String modelVersion, String modelInvariantId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId with modelVersionId: " + modelVersion); - - //select * from vf_module vfm left outer join vf_module_customization vfmc on vfmc.VF_MODULE_MODEL_UUID = vfm.MODEL_UUID -// where vfmc.MODEL_CUSTOMIZATION_UUID='52643a8e-7953-4e48-8eab-97165b2b3a4b' and vfm.MODEL_UUID = '' - - String hql = "Select vfm FROM VfModule as vfm LEFT OUTER JOIN VfModuleCustomization as vfmc on vfmc.vfModuleModelUuid = vfm.modelUUID" - + "WHERE vfmc.modelCustomizationUuid = :modelCustomizationId AND vfm.modelInvariantUUID = :modelInvariantId AND vfm.modelVersion = :modelVersion"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelInvariantId", modelInvariantId); - query.setParameter ("modelCustomizationId", modelCustomizationId); - query.setParameter ("modelVersion", modelVersion); - VfModule vfModule = null; - try { - vfModule = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelInvariantId='" + modelInvariantId +"' modelVersion='" + modelVersion + "' modelCustomizationId='" + modelCustomizationId +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantId=" + modelInvariantId + " modelVersion=" + modelVersion + " modelCustomizationId=" + modelCustomizationId); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelInvariantId='" + modelInvariantId + "' modelVersion='" + modelVersion + "' modelCustomizationId='" + modelCustomizationId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantId=" + modelInvariantId + " modelVersion=" + modelVersion + " modelCustomizationId=" + modelCustomizationId); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelInvariantId='" + modelInvariantId + "' modelVersion='" + modelVersion + "' modelCustomizationId='" + modelCustomizationId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantId=" + modelInvariantId + " modelVersion=" + modelVersion + " modelCustomizationId=" + modelCustomizationId); - throw e; - } - - if (vfModule == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId", null); - } - return vfModule; - } - - /** - * Return the VnfResourceCustomization object identified by the given modelCustomizationName, modelInvariantId and modelVersion 1707 - * - * @param modelInvariantId, modelVersion, modelCustomizationName - * @return VnfResourceCustomization or null if not found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelInvariantId(String modelInvariantId, String modelVersion, String modelCustomizationName) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVnfResourceCustomizationByModelInvariantId with modelInvariantId: " + modelInvariantId + ", modelVersion: " - + modelVersion + ", modelCustomizationName: " + modelCustomizationName); - - String hql = "SELECT VnfResourceCustomization FROM VnfResourceCustomization as vrc " - + "LEFT OUTER JOIN VnfResource as vr " - + "on vr.modelUuid =vrc.vnfResourceModelUuid " - + "WHERE vr.modelInvariantUuid = :modelInvariantId AND vr.modelVersion = :modelVersion AND vrc.modelInstanceName = :modelCustomizationName"; - - Query query = getSession().createQuery(hql); - query.setParameter ("modelInvariantId", modelInvariantId); - query.setParameter("modelVersion", modelVersion); - query.setParameter("modelCustomizationName", modelCustomizationName); - VnfResourceCustomization vnfResourceCustomization = null; - try { - vnfResourceCustomization = (VnfResourceCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelInvariantId='" + modelInvariantId +"' and modelVersion='" + modelVersion + "' modelCustomizationName='" + modelCustomizationName + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantId==" + modelInvariantId+"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "'"); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelInvariantId='" + modelInvariantId +"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantId=" + modelInvariantId+"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "'"); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelInvariantId='" + modelInvariantId +"' and modelVersion='" + modelVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantId=" + modelInvariantId+"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "'"); - throw e; - } - if (vnfResourceCustomization != null) { - LOGGER.debug("Found VRC of " + vnfResourceCustomization.getModelCustomizationUuid() + ", now looking for vnfResource=" + vnfResourceCustomization.getVnfResourceModelUuid() ); - vnfResourceCustomization.setVnfResource(this.getVnfResourceByModelUuid(vnfResourceCustomization.getVnfResourceModelUUID())); - LOGGER.debug("Now looking for vfModules for " + vnfResourceCustomization.getModelCustomizationUuid()); - vnfResourceCustomization.setVfModuleCustomizations(this.getAllVfModuleCustomizations(vnfResourceCustomization.getModelCustomizationUuid())); - } - - if (vnfResourceCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceCustomizationByModelInvariantId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelInvariantId", null); - } - return vnfResourceCustomization; - } - - /** - * Return list of VnfResourceCustomization objects identified by the given modelCustomizationUuid 1707 - * - * @param modelCustomizationUuid - * @return List<VfModuleCustomization> or null if not found - */ - public List<VfModuleCustomization> getVfModuleCustomizationByVnfModuleCustomizationUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleCustomizationByVnfModuleCustomizationUuid with modelCustomizationUuid: " + modelCustomizationUuid); - -// select * from vf_module_customization as vfmc where vfmc.MODEL_CUSTOMIZATION_UUID IN( -// select vrcmc.VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID from vnf_res_custom_to_vf_module_custom as vrcmc -// where vrcmc.VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID = 'd279139c-4b85-48ff-8ac4-9b83a6fc6da7') - - String hql = "SELECT vfmc FROM VfModuleCustomization as vfmc where vfmc.modelCustomizationUuid " - + "IN(select vrcmc.vfModuleCustModelCustomizationUuid from VnfResCustomToVfModuleCustom as vrcmc " - + "WHERE vrcmc.vnfResourceCustModelCustomizationUuid = :modelCustomizationUuid)"; - - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - List<VfModuleCustomization> resultList = null; - try { - resultList = query.list(); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw e; - } - - if (resultList == null) { - resultList = new ArrayList<>(); - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleCustomizationByVnfModuleCustomizationUuid", null); - return resultList; - } - - /** - * Return the newest version of a specific VNF resource Customization (queried by modelCustomizationName and modelVersionId). - * - * @return {@link VnfResourceCustomization} object or null if none found - */ - public VnfResourceCustomization getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId (String modelCustomizationName, String modelVersionId) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " modelUUID " + modelVersionId); - - String hql = "SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.vnfResourceModelUuid IN " - + "(SELECT vr.modelUuid FROM VnfResource vr " - + "WHERE vr.modelUuid = :modelVersionId)" - + "AND vrc.modelInstanceName = :modelCustomizationName"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("modelCustomizationName", modelCustomizationName); - query.setParameter ("modelVersionId", modelVersionId); - - @SuppressWarnings("unchecked") - List <VnfResourceCustomization> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId", null); - return resultList.get (0); - } - - public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) { - LOGGER.debug ("Catalog database - getAllVfModuleCustomizations with vnfResourceCustomizationMCU " + vnfResourceCustomizationMCU); - - List<VnfResCustomToVfModuleCustom> matches = this.getVRCtoVFMC(vnfResourceCustomizationMCU, null); - if (matches == null || matches.isEmpty()) { - LOGGER.debug("Found no vf modules for " + vnfResourceCustomizationMCU); - return new ArrayList<>(); - } - ArrayList<VfModuleCustomization> list = new ArrayList<>(); - for (VnfResCustomToVfModuleCustom v : matches) { - String m = v.getVfModuleCustModelCustomizationUuid(); - LOGGER.debug("VfModule to match: " + m); - VfModuleCustomization c = this.getVfModuleCustomizationByModelCustomizationId(m); - if (c != null) { - list.add(c); - } else { - LOGGER.debug("**UNABLE to find vfModule " + m); - } - } - return list; - } - - /** - * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 - * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean - * - * @param modelUuid - * @return VnfResourceCustomization or null if not found - */ - public VnfResource getVnfResourceByModelUuid(String modelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get VnfResource with modelUuid " + modelUuid); - - String hql = "FROM VnfResource WHERE modelUuid = :modelUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelUuid", modelUuid); - VnfResource vnfResource = null; - try { - vnfResource = (VnfResource) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique Vnf_Resource row - data integrity error: modelUuid='" + modelUuid); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for Vnf Resource modelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfResource modelUuid==" + modelUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: VnfResource modelUuid='" + modelUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfResource ModelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResource modelUuid=" + modelUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnfResource ModelUuid='" + modelUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfResource ModelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfResource modelUuid=" + modelUuid); - throw e; - } - if (vnfResource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelUuid", null); - } - return vnfResource; - } - - public VnfResCustomToVfModuleCustom getVnfResCustomToVfModule(String vnfId, String vfId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - getVnfResCustomToVfModule - vnfResourceCustModelCustUuid: " + vnfId + ", vfModuleCustModelCustomUuid=" + vfId); - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("vnfIdValue", vnfId); - parameters.put("vfIdValue", vfId); - VnfResCustomToVfModuleCustom vrctvmc = this.executeQuerySingleRow( - "FROM VnfResCustomToVfModuleCustom where vnfResourceCustModelCustomizationUuid = :vnfIdValue and vfModuleCustModelCustomizationUuid = :vfIdValue", parameters, true); - if (vrctvmc == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResCustomToVfModule", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResCustomToVfModule", null); - } - return vrctvmc; - } - - public List<VfModule> getVfModulesForVnfResource(VnfResource vnfResource) { - if (vnfResource == null) - return Collections.EMPTY_LIST; - String vnfResourceModelUuid = vnfResource.getModelUuid(); - - LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResource: " + vnfResource.toString()); - - return this.getVfModulesForVnfResource(vnfResourceModelUuid); - - } - - public List<VfModule> getVfModulesForVnfResource(String vnfResourceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResourceModelUuid: " + vnfResourceModelUuid); - Query query = getSession().createQuery("FROM VfModule where vnfResourceModelUUId = :vnfResourceModelUUId"); - query.setParameter("vnfResourceModelUUId", vnfResourceModelUuid); - List<VfModule> resultList = null; - try { - resultList = query.list(); - if (resultList != null) - LOGGER.debug("\tQuery found " + resultList.size() + " records."); - else - LOGGER.debug("\tQuery found no records."); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - getVfModulesForVnfResource - while searching for: vnfResourceModelUUId='" + vnfResourceModelUuid + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModulesForVnfResource - searching for vnfResourceModelUUId=" + vnfResourceModelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceModelUUId=" + vnfResourceModelUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Exception - getVfModulesForVnfResource - while searching for: vnfResourceModelUUId='" + vnfResourceModelUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModulesForVnfResource - searching for vnfResourceModelUUId=" + vnfResourceModelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceModelUUId=" + vnfResourceModelUuid); - throw e; - } - if (resultList == null) { - resultList = new ArrayList<>(); - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModulesForVnfResource", null); - return resultList; - } - - public Service getServiceByUuid (String serviceModelInvariantUuid) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get service with ModelInvariantUuid " + serviceModelInvariantUuid); - - String hql = "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("serviceModelInvariantUuid", serviceModelInvariantUuid); - - Service service = null; - try { - service = (Service) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: serviceName='" + serviceModelInvariantUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - throw e; - } - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getService", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getService", null); - } - - return service; - } - - public NetworkResource getNetworkResourceById(Integer id) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNetworkResource with id " + id); - - String hql = "FROM NetworkResource WHERE id = :id"; - Query query = getSession ().createQuery (hql); - query.setParameter ("id", id); - - NetworkResource networkResource = null; - try { - networkResource = (NetworkResource) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: NETWORK_RESOURCE.id='" + id + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for NETWORK_RESOURCE.id=" + id); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: NETWORK_RESOURCE.id='" + id + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for NETWORK_RESOURCE.id=" + id); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: NETWORK_RESOURCE.id='" + id + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for NETWORK_RESOURCE.id=" + id); - throw e; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceById", null); - return networkResource; - - } - - public NetworkResource getNetworkResourceById(String id) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNetworkResource with model_uuid " + id); - - String hql = "FROM NetworkResource WHERE modelUUID = :model_uuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("model_uuid", id); - - List<NetworkResource> networkResources = null; - try { - networkResources = query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: NETWORK_RESOURCE.id='" + id + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for NETWORK_RESOURCE.model_uuid=" + id, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for NETWORK_RESOURCE.model_uuid=" + id); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: NETWORK_RESOURCE.id='" + id + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for NETWORK_RESOURCE.model_uuid=" + id, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for NETWORK_RESOURCE.model_uuid=" + id); - throw e; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceById", null); - if (networkResources == null || networkResources.isEmpty()) - return null; - else - return networkResources.get(0); - } - - // 1707 API Spec - - public static boolean isEmptyOrNull(String str) { - if (str == null) - return true; - if ("null".equals(str)) - return true; - if ("".equals(str)) - return true; - return false; - } - - public List<ServiceToResourceCustomization> getSTR(String serviceModelUuid, String resourceModelCustomizationUuid, String modelType) { - LOGGER.debug("Catalog database: getSTR - smu=" + serviceModelUuid + ", rmcu=" + resourceModelCustomizationUuid + ", modelType = " + modelType); - - if (isEmptyOrNull(serviceModelUuid) && isEmptyOrNull(resourceModelCustomizationUuid) && isEmptyOrNull(modelType)) - return null; - - StringBuilder hql = new StringBuilder("FROM ServiceToResourceCustomization WHERE "); - boolean first = true; - if (serviceModelUuid != null && !serviceModelUuid.equals("")) { - hql.append("serviceModelUUID = :smu"); - first = false; - } - if (resourceModelCustomizationUuid != null && !resourceModelCustomizationUuid.equals("")) { - if (!first) { - hql.append(" AND "); - } - hql.append("resourceModelCustomizationUUID = :rmcu"); - first = false; - } - if (modelType != null && !modelType.equals("")) { - if (!first) { - hql.append(" AND "); - first = false; - } - hql.append("modelType = :modelType"); - first = false; - } - Query query = getSession().createQuery(hql.toString()); - if (hql.toString().contains(":smu")) - query.setParameter("smu", serviceModelUuid); - if (hql.toString().contains(":rmcu")) - query.setParameter("rmcu", resourceModelCustomizationUuid); - if (hql.toString().contains(":modelType")) - query.setParameter("modelType", modelType); - LOGGER.debug("query - " + hql.toString()); - - @SuppressWarnings("unchecked") - List<ServiceToResourceCustomization> resultList = query.list(); - if (resultList == null || resultList.isEmpty()) { - LOGGER.debug("Found no matches to the query - " + hql.toString()); - return new ArrayList<>(); - } - return resultList; - } - - public List<VnfResCustomToVfModuleCustom> getVRCtoVFMC (String vrc_mcu, String vfmc_mcu) { - LOGGER.debug("Catalog database: getVRCtoVFMC - vrc_mcu=" + vrc_mcu + ", vfmc_mcu=" + vfmc_mcu); - - if (isEmptyOrNull(vrc_mcu) && isEmptyOrNull(vfmc_mcu)) - return null; - - StringBuilder hql = new StringBuilder("FROM VnfResCustomToVfModuleCustom WHERE "); - boolean first = true; - if (vrc_mcu != null && !vrc_mcu.equals("")) { - hql.append("vnfResourceCustModelCustomizationUuid = :vrc_mcu"); - first = false; - } - if (vfmc_mcu != null && !vfmc_mcu.equals("")) { - if (!first) { - hql.append(" AND "); - } - hql.append("vfModuleCustModelCustomizationUuid = :vfmc_mcu"); - first = false; - } - Query query = getSession().createQuery(hql.toString()); - if (hql.toString().contains(":vrc_mcu")) - query.setParameter("vrc_mcu", vrc_mcu); - if (hql.toString().contains(":vfmc_mcu")) - query.setParameter("vfmc_mcu", vfmc_mcu); - @SuppressWarnings("unchecked") - List<VnfResCustomToVfModuleCustom> resultList = query.list(); - if (resultList == null || resultList.isEmpty()) { - LOGGER.debug("Found no matches to the query - " + hql.toString()); - return new ArrayList<>(); - } - return resultList; - } - - @SuppressWarnings("unchecked") - public List <TempNetworkHeatTemplateLookup> getTempNetworkHeatTemplateLookup (String networkResourceModelName) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - GetTempNetworkHeatTemplateLookup for Network Name " + networkResourceModelName); - - String hql = "FROM TempNetworkHeatTemplateLookup where networkResourceModelName = :networkResourceModelName"; - Query query = getSession ().createQuery (hql); - query.setParameter ("networkResourceModelName", networkResourceModelName); - - List <TempNetworkHeatTemplateLookup> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getTempNetworkHeatTemplateLookup", null); - return result; - } - - // 1702 API Spec - Query for all networks in a Service: - public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getServiceNetworksByServiceModelUuid - " + serviceModelUuid); - - List<ServiceToResourceCustomization> strMappings = this.getSTR(serviceModelUuid, null, "network"); - if (strMappings == null || strMappings.isEmpty()) { - LOGGER.debug("Found NO matches for NRC with ServiceModelUuid=" + serviceModelUuid); - return new ArrayList<>(); - } - LOGGER.debug("Found " + strMappings.size() + " entries in ServiceToResourceCustomizations.network with smu=" + serviceModelUuid); - - ArrayList<NetworkResourceCustomization> masterList = new ArrayList<>(); - for (ServiceToResourceCustomization stn : strMappings) { - String networkModelCustomizationUuid = stn.getResourceModelCustomizationUUID(); - LOGGER.debug("Now searching for NetworkResourceCustomization for " + networkModelCustomizationUuid); - List<NetworkResourceCustomization> resultSet = this.getAllNetworksByNetworkModelCustomizationUuid(networkModelCustomizationUuid); - masterList.addAll(resultSet); - } - LOGGER.debug("Returning " + masterList.size() + " NRC records"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByServiceModelUuid", null); - return masterList; - } - public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Could not find Service for " + serviceModelInvariantUuid); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceNameVersionId = service.getModelUUID(); - LOGGER.debug("The highest version for the Service " + serviceModelInvariantUuid + " is " + serviceNameVersionId); - - // Service.serviceNameVersionId == ServiceToNetworks.serviceModelUuid - return this.getAllNetworksByServiceModelUuid(serviceNameVersionId); - } - public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - - //TODO - //can fix this later - no time - could do a unique query here - but this should work - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("No Service found with smu=" + serviceModelInvariantUuid + " and smv=" + serviceModelVersion); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceNameVersionId = service.getModelUUID(); - - // Service.serviceNameVersionId == ServiceToNetworks.serviceModelUuid - return this.getAllNetworksByServiceModelUuid(serviceNameVersionId); - - } - public List<NetworkResourceCustomization> getAllNetworksByNetworkModelCustomizationUuid(String networkModelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllNetworksByNetworkModelCustomizationUuid - " + networkModelCustomizationUuid); - - //Query query = getSession().createQuery(hql.toString()); - //query.setParameter("networkModelCustomizationUuid", networkModelCustomizationUuid); - //LOGGER.debug("QUERY: " + hql.toString() + ", networkModelCustomizationUuid=" + networkModelCustomizationUuid); - - //@SuppressWarnings("unchecked") - //List<NetworkResourceCustomization> resultList = query.list(); - - HashMap<String, String> params = new HashMap<>(); - params.put("networkModelCustomizationUuid", networkModelCustomizationUuid); - - List<NetworkResourceCustomization> resultList = this.executeQueryMultipleRows( - "FROM NetworkResourceCustomization WHERE modelCustomizationUuid = :networkModelCustomizationUuid", params, true); - - if (resultList.isEmpty()) { - LOGGER.debug("Unable to find an NMC with nmcu=" + networkModelCustomizationUuid); - return new ArrayList<>(); - } - for (NetworkResourceCustomization nrc : resultList) { - nrc.setNetworkResource(this.getNetworkResourceById(nrc.getNetworkResourceModelUuid())); - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkModelCustomizationUuid", null); - return resultList; - } - - public List<NetworkResourceCustomization> getAllNetworksByNetworkType(String networkType) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getServiceNetworksByNetworkType - " + networkType); - - NetworkResource nr = this.getNetworkResource(networkType); - if (nr == null) { - return new ArrayList<>(); - } - String networkResourceId = nr.getModelUUID(); - - LOGGER.debug("Now searching for NRC's with networkResourceId = " + networkResourceId); - - Query query = getSession().createQuery( - "FROM NetworkResourceCustomization WHERE networkResourceModelUuid = :networkResourceId"); - query.setParameter("networkResourceId", networkResourceId); - - @SuppressWarnings("unchecked") - List<NetworkResourceCustomization> resultList = query.list(); - - if (resultList != null && ! resultList.isEmpty()) { - LOGGER.debug("Found " + resultList.size() + " results"); - for (NetworkResourceCustomization nrc : resultList) { - nrc.setNetworkType(networkType); - nrc.setNetworkResource(nr); - } - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkType", null); - - return resultList; - } - public ArrayList<VfModuleCustomization> getAllVfmcForVrc(VnfResourceCustomization vrc) { - LOGGER.debug("Catalog database: getAllVfmcForVrc - " + vrc.getModelCustomizationUuid()); - - List<VnfResCustomToVfModuleCustom> vfmcs = this.getVRCtoVFMC(vrc.getModelCustomizationUuid(), null); - if (vfmcs == null || vfmcs.isEmpty()) { - return new ArrayList<>(); - } - ArrayList<VfModuleCustomization> vfModuleCusts = new ArrayList<>(); - for (VnfResCustomToVfModuleCustom vfmc : vfmcs) { - VfModuleCustomization vfmcust = this.getVfModuleCustomizationByModelCustomizationId(vfmc.getVfModuleCustModelCustomizationUuid()); - if (vfmcust != null) { - vfModuleCusts.add(vfmcust); - } - } - return vfModuleCusts; - } - - //1702 API Spec cont'd - Query for all VnfResources in a Service: - //1707 modified for db refactoring - public List<VnfResourceCustomization> getAllVnfsByServiceModelUuid(String serviceModelUuid) { - LOGGER.debug("Catalog database: getAllVnfsByServiceModelUuid - " + serviceModelUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelUUID = :serviceModelUuid"); - query.setParameter("serviceModelUuid", serviceModelUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a service with modelUuid=" + serviceModelUuid); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - - // Step 2 - Now query to get the related VnfResourceCustomizations - - List<ServiceToResourceCustomization> strcs = this.getSTR(serviceModelUuid, null, "vnf"); - - if (strcs.isEmpty()) { - LOGGER.debug("Unable to find any related vnfs to a service with modelUuid=" + serviceModelUuid); - return new ArrayList<>(); - } - - ArrayList<VnfResourceCustomization> allVrcs = new ArrayList<>(); - for (ServiceToResourceCustomization strc : strcs) { - LOGGER.debug("Try to find VRC for mcu=" + strc.getResourceModelCustomizationUUID()); - VnfResourceCustomization vrc = this.getVnfResourceCustomizationByModelCustomizationUuid(strc.getResourceModelCustomizationUUID()); - if (vrc != null) - allVrcs.add(vrc); - } - return allVrcs; - - } - public List<VnfResourceCustomization> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return new ArrayList<>(); - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - Service service = resultList.get(0); - //now just call the method that takes the version - the service object will have the highest version - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - public List<VnfResourceCustomization> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return new ArrayList<>(); - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - Service service = resultList.get(0); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByServiceModelInvariantUuid", null); - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - - public List<VnfResourceCustomization> getAllVnfsByServiceName(String serviceName, String serviceVersion) { - LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName + ", version=" + serviceVersion); - if (serviceVersion == null || serviceVersion.equals("")) { - return this.getAllVnfsByServiceName(serviceName); - } - - Query query = getSession().createQuery( - "FROM Service WHERE modelName = :serviceName and version = :serviceVersion"); - query.setParameter("serviceName", serviceName); - query.setParameter("serviceVersion", serviceVersion); - - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return Collections.EMPTY_LIST; - } - Service service = resultList.get(0); - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - public List<VnfResourceCustomization> getAllVnfsByServiceName(String serviceName) { - LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName); - - Query query = getSession().createQuery("FROM Service WHERE modelName = :serviceName"); - query.setParameter("serviceName", serviceName); - - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return Collections.EMPTY_LIST; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - Service service = resultList.get(0); - - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - - public List<VnfResourceCustomization> getAllVnfsByVnfModelCustomizationUuid(String vnfModelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllVnfsByVnfModelCustomizationUuid - " + vnfModelCustomizationUuid); - - Query query1 = getSession().createQuery("FROM VnfResourceCustomization WHERE modelCustomizationUuid = :vrcmcu"); - query1.setParameter("vrcmcu", vnfModelCustomizationUuid); - @SuppressWarnings("unchecked") - List<VnfResourceCustomization> resultList1 = query1.list(); - - if (resultList1.isEmpty()) { - LOGGER.debug("Found no records matching " + vnfModelCustomizationUuid); - return Collections.EMPTY_LIST; - } - - for (VnfResourceCustomization vrc : resultList1) { - VnfResource vr = this.getVnfResourceByModelUuid(vrc.getVnfResourceModelUuid()); - vrc.setVnfResource(vr); - vrc.setVfModuleCustomizations(this.getAllVfmcForVrc(vrc)); - } - - LOGGER.debug("Returning " + resultList1.size() + " vnf modules"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByVnfModelCustomizationUuid", null); - return resultList1; - } - - //1702 API Spec cont'd - Query for all allotted resources in a Service - - public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelUuid - " + serviceModelUuid); - - List<ServiceToResourceCustomization> strcs = this.getSTR(serviceModelUuid, null, "allottedResource"); - if (strcs == null || strcs.isEmpty()) { - LOGGER.debug("No AR entries found for " + serviceModelUuid); - return new ArrayList<>(); - } - LOGGER.debug("Found " + strcs.size() + " entries in ServiceToResourceCustomizations with smu=" + serviceModelUuid + ", allottedResource"); - - ArrayList<AllottedResourceCustomization> masterList = new ArrayList<>(); - for (ServiceToResourceCustomization star : strcs) { - String arModelCustomizationUuid = star.getResourceModelCustomizationUUID(); - LOGGER.debug("Now searching for AllottedResourceCustomization for " + arModelCustomizationUuid); - List<AllottedResourceCustomization> resultSet = this.getAllAllottedResourcesByArModelCustomizationUuid(arModelCustomizationUuid); - masterList.addAll(resultSet); - } - LOGGER.debug("Returning " + masterList.size() + " ARC records"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllAllottedResourcesByServiceModelUuid", null); - return masterList; - } - - public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Could not find Service for " + serviceModelInvariantUuid); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceModelUuid = service.getModelUUID(); - LOGGER.debug("The highest version for the Service " + serviceModelInvariantUuid + " is " + serviceModelUuid); - - return this.getAllAllottedResourcesByServiceModelUuid(serviceModelUuid); - } - - public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("No Service found with smu=" + serviceModelInvariantUuid + " and smv=" + serviceModelVersion); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceModelUuid = service.getModelUUID(); - - return this.getAllAllottedResourcesByServiceModelUuid(serviceModelUuid); - } - - public List<AllottedResourceCustomization> getAllAllottedResourcesByArModelCustomizationUuid(String arModelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllAllottedResourcesByArModelCustomizationUuid - " + arModelCustomizationUuid); - - Query query = getSession().createQuery( - "FROM AllottedResourceCustomization WHERE modelCustomizationUuid = :arModelCustomizationUuid"); - query.setParameter("arModelCustomizationUuid", arModelCustomizationUuid); - - @SuppressWarnings("unchecked") - List<AllottedResourceCustomization> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.debug("No ARC found with arc_mcu=" + arModelCustomizationUuid); - return new ArrayList<>(); - } - // There should only be one - but we'll handle if multiple - for (AllottedResourceCustomization arc : resultList) { - AllottedResource ar = this.getAllottedResourceByModelUuid(arc.getArModelUuid()); - arc.setAllottedResource(ar); - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllAllottedResourcesByArModelCustomizationUuid", null); - return resultList; - } - - public AllottedResource getAllottedResourceByModelUuid(String arModelUuid) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Allotted Resource with modelUuid= " + arModelUuid); - - String hql = "FROM AllottedResource WHERE modelUuid = :arModelUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("arModelUuid", arModelUuid); - - @SuppressWarnings("unchecked") - List <AllottedResource> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. AllottedResource not found", "CatalogDB", "getAllottedResourceByModelUuid", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllottedResourceByModelUuid", null); - return resultList.get (0); - - } - - //1702 API Spec cont'd - Query for all resources in a Service: - public ServiceMacroHolder getAllResourcesByServiceModelUuid(String serviceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllResourcesByServiceModelUuid - " + serviceModelUuid); - - StringBuilder hql = new StringBuilder("FROM Service WHERE modelUUID = :serviceModelUuid"); - Query query = getSession().createQuery(hql.toString()); - query.setParameter("serviceModelUuid", serviceModelUuid); - LOGGER.debug("Query: " + hql.toString() + ", smu=" + serviceModelUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a Service with serviceModelUuid=" + serviceModelUuid); - return new ServiceMacroHolder(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - ServiceMacroHolder smh = new ServiceMacroHolder(service); - ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(serviceModelUuid); - smh.setNetworkResourceCustomization(nrcList); - ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(serviceModelUuid); - smh.setAllottedResourceCustomization(arcList); - ArrayList<VnfResourceCustomization> vnfList = (ArrayList<VnfResourceCustomization>) this.getAllVnfsByServiceModelUuid(serviceModelUuid); - smh.setVnfResourceCustomizations(vnfList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelUuid", null); - return smh; - } - public ServiceMacroHolder getAllResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a Service with serviceModelInvariantUuid=" + serviceModelInvariantUuid); - return new ServiceMacroHolder(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - ServiceMacroHolder smh = new ServiceMacroHolder(service); - ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(service.getModelUUID()); - smh.setNetworkResourceCustomization(nrcList); - ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(service.getModelUUID()); - smh.setAllottedResourceCustomization(arcList); - ArrayList<VnfResourceCustomization> vnfList = (ArrayList<VnfResourceCustomization>) this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - smh.setVnfResourceCustomizations(vnfList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelInvariantUuid", null); - return smh; - - } - public ServiceMacroHolder getAllResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - //TODO make this a unique query - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a Service with serviceModelInvariantUuid=" + serviceModelInvariantUuid + " and serviceModelVersion=" + serviceModelVersion); - return new ServiceMacroHolder(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - ServiceMacroHolder smh = new ServiceMacroHolder(service); - ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(service.getModelUUID()); - smh.setNetworkResourceCustomization(nrcList); - ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(service.getModelUUID()); - smh.setAllottedResourceCustomization(arcList); - ArrayList<VnfResourceCustomization> vnfList = (ArrayList<VnfResourceCustomization>) this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - smh.setVnfResourceCustomizations(vnfList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelUuid with version", null); - return smh; - } - - // 1707 New API queries - public NetworkResourceCustomization getSingleNetworkByModelCustomizationUuid(String modelCustomizationUuid) { - LOGGER.debug("Catalog database; getSingleNetworkByModelCustomizationUuid - " + modelCustomizationUuid); - List<NetworkResourceCustomization> resultList = this.getAllNetworksByNetworkModelCustomizationUuid(modelCustomizationUuid); - if (resultList == null || resultList.isEmpty()) { - return null; - } - return resultList.get(0); - } - public AllottedResourceCustomization getSingleAllottedResourceByModelCustomizationUuid(String modelCustomizationUuid) { - LOGGER.debug("Catalog database; getSingleAllottedResourceByModelCustomizationUuid - " + modelCustomizationUuid); - List<AllottedResourceCustomization> resultList = this.getAllAllottedResourcesByArModelCustomizationUuid(modelCustomizationUuid); - if (resultList == null || resultList.isEmpty()) { - return null; - } - return resultList.get(0); - } - @Deprecated - public VnfResource getSingleVnfResourceByModelCustomizationUuid(String modelCustomizationUuid) { - /* - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database; getSingleVnfResourceByModelCustomizationUuid - " + modelCustomizationUuid); - List<VnfResource> resultList = this.getAllVnfsByVnfModelCustomizationUuid(modelCustomizationUuid); - if (resultList == null || resultList.size() < 1) { - return null; - } - return resultList.get(0); - */ - return null; - } - - private void populateNetworkResourceType(List<NetworkResourceCustomization> resultList) { - HashMap<String, NetworkResource> networkResources = new HashMap<>(); - - for (NetworkResourceCustomization nrc : resultList) { - String network_id = nrc.getNetworkResourceModelUuid(); - if (network_id == null) { - nrc.setNetworkResource(null); - nrc.setNetworkType("UNKNOWN_NETWORK_ID_NULL"); - continue; - } - if (networkResources.containsKey(network_id)) { - nrc.setNetworkResource(networkResources.get(network_id)); - nrc.setNetworkType(networkResources.get(network_id).getModelName()); - } else { - NetworkResource nr = this.getNetworkResourceById(network_id); - if (nr == null) { - nrc.setNetworkType("INVALID_NETWORK_TYPE_ID_NOT_FOUND"); - } else { - nrc.setNetworkType(nr.getModelName()); - nrc.setNetworkResource(nr); - networkResources.put(network_id, nr); - } - } - } - } - - /** - * Return a VNF recipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, and ACTION - * first query VF_MODULE table by type, and then use the ID to query - * VNF_RECIPE by VF_MODULE_ID and ACTION - * - * @param vnfType - * @parm vfModuleModelName - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVfModuleRecipe (String vnfType, String vfModuleModelName, String action) { - String vfModuleType = vnfType + "::" + vfModuleModelName; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType); - - Query query = getSession ().createQuery ("FROM VfModule WHERE type = :type "); - query.setParameter (TYPE, vfModuleType); - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVfModuleRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - VfModule vfMod = resultList.get(0); - - String vfModuleId = vfMod.getModelUUID(); - - LOGGER.debug ("Catalog database - get VNF recipe with vf module id " + vfModuleId - + " and action " - + action); - - Query query1 = getSession ().createQuery ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); - query1.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfRecipe> resultList1 = query1.list (); - - if (resultList1.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVfModuleRecipe", null); - return null; - } - - resultList1.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList1); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVfModuleRecipe", null); - return resultList1.get (0); - } - - /** - * Return a VNF Module List that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, - * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION - * - * @param vfModuleType - * @parm modelCustomizationUuid - * @param asdcServiceModelVersion - * @param modelVersion - * @param action - * @return VfModule list - */ - public List<VfModule> getVfModule (String vfModuleType, String modelCustomizationUuid, String asdcServiceModelVersion, String modelVersion, String action) { - StringBuilder hql; - Query query; - if(modelCustomizationUuid != null){ - hql = new StringBuilder ("FROM VfModule WHERE modelCustomizationUuid = :modelCustomizationUuid AND version = :version"); - - LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType + ", asdcServiceModelVersion " + asdcServiceModelVersion + ", modelVersion " + modelVersion); - - query = getSession ().createQuery (hql.toString ()); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - query.setParameter (MODEL_VERSION, asdcServiceModelVersion); - }else{ - hql = new StringBuilder ("FROM VfModule WHERE type = :type AND version = :version AND modelVersion = :modelVersion"); - - LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType + ", asdcServiceModelVersion " + asdcServiceModelVersion + ", modelVersion " + modelVersion); - - query = getSession ().createQuery (hql.toString ()); - query.setParameter (TYPE, vfModuleType); - query.setParameter (MODEL_VERSION, asdcServiceModelVersion); - query.setParameter ("modelVersion", modelVersion); - } - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - return resultList; - } - - - /** - * Return a VNF COMPONENTSrecipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, - * MODEL_CUSTOMIZATION_UUID, ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION - * first query VF_MODULE table by type, and then use the ID to query - * VNF_COMPONENTS_RECIPE by VF_MODULE_ID and ACTION - * - * @param vnfType - * @parm vfModuleModelName - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipe (String vnfType, String vfModuleModelName, String modelCustomizationUuid, String asdcServiceModelVersion, String modelVersion, String action) { - String vfModuleType = vnfType + "::" + vfModuleModelName; - long startTime = System.currentTimeMillis (); - List <VfModule> resultList = getVfModule(vfModuleType, modelCustomizationUuid, asdcServiceModelVersion, modelVersion, action); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - VfModule vfMod = resultList.get(0); - - String vfModuleId = vfMod.getModelUUID(); - - LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId - + " and action " - + action); - - Query query1 = getSession ().createQuery ( - "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); - query1.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList1 = query1.list (); - - if (resultList1.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList1.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList1); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); - if (resultList1.size() > 1 && (!resultList1. get (0).getOrchestrationUri().equals(resultList1.get (1).getOrchestrationUri ()))) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Different ORCHESTRATION URIs found for same VERSION and ID. No result returned.", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - return resultList1.get (0); - } - - /** - * Return a VNF COMPONENTSrecipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, - * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION - * first query VF_MODULE table by type, and then use the ID to query - * VNF_COMPONENTS_RECIPE by VF_MODULE_ID and ACTION - * - * @param vnfType - * @parm vfModuleModelName - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipeByVfModule(List <VfModule> resultList, String action) { - long startTime = System.currentTimeMillis (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - VfModule vfMod = resultList.get(0); - - String vfModuleId = vfMod.getModelName(); - - LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId - + " and action " - + action); - - Query query1 = getSession ().createQuery ( - "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); - query1.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList1 = query1.list (); - - if (resultList1.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList1.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList1); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); - if (resultList1.size() > 1 && (!resultList1. get (0).getOrchestrationUri().equals(resultList1.get (1).getOrchestrationUri ()))) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Different ORCHESTRATION URIs found for same VERSION and ID. No result returned.", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - return resultList1.get (0); - } - - - /** - * Return all VNF Resources in the Catalog DB - * - * @return A list of VnfResource objects - */ - @SuppressWarnings("unchecked") - public List <VnfResource> getAllVnfResources () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all VNF resources"); - - String hql = "FROM VnfResource"; - Query query = getSession ().createQuery (hql); - - List <VnfResource> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfResources", null); - return result; - } - - /** - * Return VNF Resources in the Catalog DB that match a given VNF role - * - * @return A list of VnfResource objects - */ - @SuppressWarnings("unchecked") - @Deprecated // vnfRole is no longer in VnfResource - public List <VnfResource> getVnfResourcesByRole (String vnfRole) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all VNF resources for role " + vnfRole); - - String hql = "FROM VnfResource WHERE vnfRole = :vnfRole"; - Query query = getSession ().createQuery (hql); - query.setParameter ("vnfRole", vnfRole); - - List <VnfResource> resources = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourcesByRole", null); - return resources; - } - - /** - * Return VNF Resources in the Catalog DB that match a given VNF role - * - * @return A list of VnfResource objects - */ - @SuppressWarnings("unchecked") - public List<VnfResourceCustomization> getVnfResourceCustomizationsByRole(String vnfRole) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all VNF resource customizations for role " + vnfRole); - - String hql = "FROM VnfResourceCustomization WHERE nfRole = :vnfRole"; - Query query = getSession ().createQuery (hql); - query.setParameter ("vnfRole", vnfRole); - - List <VnfResourceCustomization> resources = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationsByRole", null); - return resources; - } - - /** - * Return all Network Resources in the Catalog DB - * - * @return A list of NetworkResource objects - */ - @SuppressWarnings("unchecked") - public List <NetworkResource> getAllNetworkResources () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all network resources"); - - String hql = "FROM NetworkResource"; - Query query = getSession ().createQuery (hql); - - List <NetworkResource> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworkResources", null); - return result; - } - - @SuppressWarnings("unchecked") - public List<NetworkResourceCustomization> getAllNetworkResourceCustomizations() { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all network resource customizations"); - - String hql = "FROM NetworkResourceCustomization"; - Query query = getSession ().createQuery (hql); - - List <NetworkResourceCustomization> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworkResourceCustomizations", null); - return result; - } - - /** - * Return all VF Modules in the Catalog DB - * - * @return A list of VfModule objects - */ - @SuppressWarnings("unchecked") - public List <VfModule> getAllVfModules () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all vf modules"); - - String hql = "FROM VfModule"; - Query query = getSession ().createQuery (hql); - - List <VfModule> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVfModules", null); - return result; - } - - @SuppressWarnings("unchecked") - public List <VfModuleCustomization> getAllVfModuleCustomizations () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all vf module customizations"); - - String hql = "FROM VfModuleCustomization"; - Query query = getSession ().createQuery (hql); - - List <VfModuleCustomization> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVfModuleCustomizations", null); - return result; - } - - - /** - * Return all HeatEnvironment in the Catalog DB - * - * @return A list of HeatEnvironment objects - */ - @SuppressWarnings("unchecked") - public List <HeatEnvironment> getAllHeatEnvironment () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all Heat environments"); - - String hql = "FROM HeatEnvironment"; - Query query = getSession ().createQuery (hql); - - List <HeatEnvironment> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatEnvironment", null); - return result; - } - - /** - * Fetch the Environment by Environment ID - 1510 - */ - @Deprecated // no longer in heat envt table - public HeatEnvironment getHeatEnvironment (int id) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat environment with id " + id); - - String hql = "FROM HeatEnvironment WHERE id = :idValue"; - - LOGGER.debug ("getHeatEnvironment called with id=" + id); - - Query query = getSession ().createQuery (hql); - query.setParameter ("idValue", id); - - @SuppressWarnings("unchecked") - List <HeatEnvironment> resultList = query.list (); - - // See if something came back. - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Heat environment not found", "CatalogDB", "getHeatEnvironment", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatEnvironment", null); - return resultList.get (0); - } - - /** - * Fetch the nested templates - 1510 - */ - - @Deprecated - public Map <String, Object> getNestedTemplates (int templateId) { - Map <String, Object> nestedTemplates; - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNestedTemplates called with templateId " + templateId); - - String hql = "FROM HeatNestedTemplate where parent_template_id = :parentIdValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("parentIdValue", templateId); - - @SuppressWarnings("unchecked") - List <HeatNestedTemplate> resultList = query.list (); - // If nothing comes back, there are no nested templates - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No nestedTemplate found", "CatalogDB", "getNestedTemplates", null); - LOGGER.debug ("No nestedTemplates found for templateId=" + templateId + ", " + hql); - return null; - } - // Now, for each entry in NESTED_HEAT_TEMPLATES, we need to grab the template body from HEAT_TEMPLATE - nestedTemplates = new HashMap <> (); - for (HeatNestedTemplate hnt : resultList) { - LOGGER.debug ("Querying for " + hnt); - HeatTemplate ht = this.getHeatTemplate (hnt.getChildTemplateId ()); - if (ht == null) { - LOGGER.debug ("No template found matching childTemplateId=" + hnt.getChildTemplateId ()); - continue; - } - String providerResourceFile = hnt.getProviderResourceFile (); - String heatTemplateBody = ht.getTemplateBody (); - if (providerResourceFile != null && heatTemplateBody != null) { - nestedTemplates.put (providerResourceFile, heatTemplateBody); - } else { - LOGGER.debug ("providerResourceFile or heatTemplateBody were null - do not add to HashMap!"); - } - } - // Make sure we're not returning an empty map - if so, just return null - if (nestedTemplates.isEmpty ()) { - LOGGER.debug ("nestedTemplates is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Nested template is empty", "CatalogDB", "getNestedTemplate", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedTemplate", null); - return nestedTemplates; - } - /** - * Return a Map<String, Object> for returning the child templates and their contents - * - * @param parentHeatTemplateId - * @return Map<String,Object> or null if none found - */ - public Map <String, Object> getNestedTemplates (String parentHeatTemplateId) { - Map <String, Object> nestedTemplates; - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNestedTemplates called with parentTemplateId " + parentHeatTemplateId); - - String hql = "FROM HeatNestedTemplate where parentTemplateId = :parentHeatTemplateId"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("parentHeatTemplateId", parentHeatTemplateId); - - @SuppressWarnings("unchecked") - List <HeatNestedTemplate> resultList = query.list (); - // If nothing comes back, there are no nested templates - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No nestedTemplate found", "CatalogDB", "getNestedTemplates", null); - LOGGER.debug ("No nestedTemplates found for templateId=" + parentHeatTemplateId + ", " + hql); - return null; - } - // Now, for each entry in NESTED_HEAT_TEMPLATES, we need to grab the template body from HEAT_TEMPLATE - nestedTemplates = new HashMap <> (); - for (HeatNestedTemplate hnt : resultList) { - LOGGER.debug ("Querying for " + hnt); - HeatTemplate ht = this.getHeatTemplateByArtifactUuid (hnt.getChildTemplateId ()); - if (ht == null) { - LOGGER.debug ("No template found matching childTemplateId=" + hnt.getChildTemplateId ()); - continue; - } - String providerResourceFile = hnt.getProviderResourceFile (); - String heatTemplateBody = ht.getTemplateBody (); - if (providerResourceFile != null && heatTemplateBody != null) { - nestedTemplates.put (providerResourceFile, heatTemplateBody); - } else { - LOGGER.debug ("providerResourceFile or heatTemplateBody were null - do not add to HashMap!"); - } - } - // Make sure we're not returning an empty map - if so, just return null - if (nestedTemplates.isEmpty ()) { - LOGGER.debug ("nestedTemplates is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Nested template is empty", "CatalogDB", "getNestedTemplate", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedTemplate", null); - return nestedTemplates; - } - - /* - * Fetch any files in the HEAT_FILES table 1510 - */ - @Deprecated - public Map <String, HeatFiles> getHeatFiles (int vnfResourceId) { - Map <String, HeatFiles> heatFiles; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFiles called with vnfResourceId " + vnfResourceId); - String hql = "FROM HeatFiles where vnf_resource_id = :vnfResourceIdValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("vnfResourceIdValue", vnfResourceId); - - @SuppressWarnings("unchecked") - List <HeatFiles> resultList = query.list (); - // If nothing comes back, there are no heat files - if (resultList.isEmpty ()) { - LOGGER.debug ("No heatFiles found for vnfResourceId=" + vnfResourceId); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No heat files", "CatalogDB", "getHeatFiles", null); - return null; - } - // Now, we just need to return a HashMap (key=fileName, object=fileBody) - heatFiles = new HashMap <> (); - for (HeatFiles hf : resultList) { - LOGGER.debug ("Adding " + hf.getFileName () + "->" + hf.getFileBody ()); - heatFiles.put (hf.getFileName (), hf); - } - // Make sure we're not returning an empty map - if so, just return null - if (heatFiles.isEmpty ()) { - LOGGER.debug ("heatFiles is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Heat files is empty", "CatalogDB", "getHeatFiles", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFiles", null); - return heatFiles; - } - - // New 1607 - with modularization, use new table to determine which HEAT_FILES entries to attach - @Deprecated - public Map <String, HeatFiles> getHeatFilesForVfModule(int vfModuleId) { - /* - Map <String, HeatFiles> heatFiles = null; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFilesForVfModule called with vfModuleId " + vfModuleId); - String hql = "FROM VfModuleToHeatFiles where vf_module_id = :vfModuleIdValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("vfModuleIdValue", vfModuleId); - - List<VfModuleToHeatFiles> mapList = query.list(); - if (mapList.isEmpty()) { - LOGGER.debug ("No heatFiles found for vfModuleId=" + vfModuleId); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No heatfiles found for vfModule", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - //Now the fun part - we have a list of the heat files we need to get - could clean this up with a join - heatFiles = new HashMap<String, HeatFiles>(); - for (VfModuleToHeatFiles vmthf : mapList) { - int heatFilesId = vmthf.getHeatFilesId(); - hql = "FROM HeatFiles where id = :id_value"; - query = getSession().createQuery(hql); - query.setParameter("id_value", heatFilesId); - List<HeatFiles> fileList = query.list(); - if (fileList.isEmpty()) { - // Should this throw an exception?? - LOGGER.debug("Unable to find a HEAT_FILES entry at " + heatFilesId); - String errorString = "_ERROR|" + heatFilesId; - // The receiving code needs to know to throw an exception for this - or ignore it. - heatFiles.put(errorString, null); - } else { - // Should only ever have 1 result - add it to our Map - LOGGER.debug("Retrieved " + fileList.size() + " heat file entry at " + heatFilesId); - for (HeatFiles hf : fileList) { - LOGGER.debug("Adding " + hf.getFileName() + "->" + hf.getFileBody()); - heatFiles.put(hf.getFileName(), hf); - } - } - } - if (heatFiles.isEmpty()) { - LOGGER.debug ("heatFiles is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles is empty", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFilesForVfModule", null); - return heatFiles; - */ - return null; - } - - /** - * Return a VfModuleToHeatFiles object - * - * @param vfModuleModelUuid, heatFilesArtifactUuid - * @return VfModuleToHeatFiles or null if none found - */ - public VfModuleToHeatFiles getVfModuleToHeatFilesEntry(String vfModuleModelUuid, String heatFilesArtifactUuid) { - - LOGGER.debug ("Catalog database - getVfModuleToHeatFilesEntry with vfModuleModelUuid " + vfModuleModelUuid + ", heatFilesArtifactUuid=" + heatFilesArtifactUuid); - String hql = "FROM VfModuleToHeatFiles where vfModuleModelUuid = :vfModuleModelUuidValue and heatFilesArtifactUuid = :heatFilesArtifactUuidValue"; - - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("vfModuleModelUuidValue", vfModuleModelUuid); - parameters.put("heatFilesArtifactUuidValue", heatFilesArtifactUuid); - - VfModuleToHeatFiles vmthf = null; - - try { - vmthf = this.executeQuerySingleRow(hql, parameters, true); - } catch (Exception e) { - throw e; - } - return vmthf; - } - - - /** - * Return a ServiceToResourceCustomization object - * - * @param serviceModelUuid - * @param resourceModelCustomizationUuid - * @param modelType - * @return VfModuleToHeatFiles or null if none found - */ - public ServiceToResourceCustomization getServiceToResourceCustomization(String serviceModelUuid, String resourceModelCustomizationUuid, String modelType) { - - LOGGER.debug ("Catalog database - getServiceToResourceCustomization with serviceModelUuid=" + serviceModelUuid + ", resourceModelCustomizationUuid=" + resourceModelCustomizationUuid + ", modelType=" + modelType); - String hql = "FROM ServiceToResourceCustomization where serviceModelUUID = :serviceModelUuidValue and resourceModelCustomizationUUID = :resourceModelCustomizationUuidValue and modelType = :modelTypeValue "; - - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("serviceModelUuidValue", serviceModelUuid); - parameters.put("resourceModelCustomizationUuidValue", resourceModelCustomizationUuid); - parameters.put("modelTypeValue", modelType); - - ServiceToResourceCustomization strc = null; - - try { - strc = this.executeQuerySingleRow(hql, parameters, true); - } catch (Exception e) { - throw e; - } - return strc; - } - - /** - * Return a Map<String, HeatFiles> for returning the heat files associated with a vfModule 1707 - * - * @param vfModuleModelUuid - * @return Map<String,Object> or null if none found - */ - public Map <String, HeatFiles> getHeatFilesForVfModule(String vfModuleModelUuid) { - Map <String, HeatFiles> heatFiles; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFilesForVfModule called with vfModuleModelUuid " + vfModuleModelUuid); - String hql = "FROM VfModuleToHeatFiles where vfModuleModelUuid = :vfModuleModelUuidValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("vfModuleModelUuidValue", vfModuleModelUuid); - - @SuppressWarnings("unchecked") - List<VfModuleToHeatFiles> mapList = query.list(); - if (mapList.isEmpty()) { - LOGGER.debug ("No heatFiles found for vfModuleModelUuid=" + vfModuleModelUuid); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No heatfiles found for vfModule", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - //Now the fun part - we have a list of the heat files we need to get - could clean this up with a join - heatFiles = new HashMap<>(); - for (VfModuleToHeatFiles vmthf : mapList) { - String heatFilesUuid = vmthf.getHeatFilesArtifactUuid(); - hql = "FROM HeatFiles where artifactUuid = :heatFilesUuidValue"; - query = getSession().createQuery(hql); - query.setParameter("heatFilesUuidValue", heatFilesUuid); - @SuppressWarnings("unchecked") - List<HeatFiles> fileList = query.list(); - if (fileList.isEmpty()) { - // Should this throw an exception?? - LOGGER.debug("Unable to find a HEAT_FILES entry at " + heatFilesUuid); - String errorString = "_ERROR|" + heatFilesUuid; - // The receiving code needs to know to throw an exception for this - or ignore it. - heatFiles.put(errorString, null); - } else { - // Should only ever have 1 result - add it to our Map - LOGGER.debug("Retrieved " + fileList.size() + " heat file entry at " + heatFilesUuid); - for (HeatFiles hf : fileList) { - LOGGER.debug("Adding " + hf.getFileName() + "->" + hf.getFileBody()); - heatFiles.put(hf.getFileName(), hf); - } - } - } - if (heatFiles.isEmpty()) { - LOGGER.debug ("heatFiles is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles is empty", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFilesForVfModule", null); - return heatFiles; - } - - /** - * Get the heat template object based on asdc attributes - * - * @param templateName The template name, generally the yaml filename. "example.yaml" - * @param version The version as specified by ASDC. "1.1" - * @param asdcResourceName The ASDC resource name provided in the ASDC artifact - * - * @return The HeatTemplate - */ - @Deprecated // asdcResourceName is no longer in heatTeamplate - public HeatTemplate getHeatTemplate (String templateName, String version, String asdcResourceName) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatTemplate with name " + templateName - + " and version " - + version - + " and ASDC resource name " - + asdcResourceName); - - String hql = "FROM HeatTemplate WHERE templateName = :template_name AND version = :version AND asdcResourceName = :asdcResourceName"; - Query query = getSession ().createQuery (hql); - query.setParameter (TEMPLATE_NAME, templateName); - query.setParameter (MODEL_VERSION, version); - query.setParameter ("asdcResourceName", asdcResourceName); - - @SuppressWarnings("unchecked") - List <HeatTemplate> resultList = query.list (); - - // See if something came back. - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Heat template not found", "CatalogDB", "getHeatTemplate", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return resultList.get (0); - } - - - /** - * Save the Heat Template - * - * @param heat The heat template - * @param paramSet The list of heat template parameters - */ - public void saveHeatTemplate (HeatTemplate heat, Set <HeatTemplateParam> paramSet) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat Template with name " + heat.getTemplateName() + ", artifactUUID=" + heat.getArtifactUuid()); - - heat.setParameters(null); - try { - - HeatTemplate heatTemp = this.getHeatTemplateByArtifactUuidRegularQuery(heat.getArtifactUuid()); - - if (heatTemp == null) { - this.getSession ().save (heat); - - if (paramSet != null) { - StringBuilder sb = new StringBuilder("Parameters: "); - for (HeatTemplateParam param : paramSet) { - param.setHeatTemplateArtifactUuid(heat.getArtifactUuid()); - sb.append(param.getParamName()).append(", "); - } - LOGGER.debug(sb.toString()); - heat.setParameters (paramSet); - try { - Session session = this.getSession(); - if (!(session.isConnected() && session.isOpen())) { - LOGGER.debug("Initial session is not connected or open - get another"); - session = this.getSession(); - } - session.save(heat); - } catch (HibernateException he1) { - LOGGER.debug("Hibernate Exception encountered on first attempt at save(heat) - try again..." + he1.getMessage(), he1); - try { - Session session = this.getSession(); - session.save(heat); - } catch (HibernateException he2) { - LOGGER.debug("Hibernate Exception encountered on second attempt at save(heat)" + he2.getMessage()); - LOGGER.debug(Arrays.toString(he2.getStackTrace())); - throw he2; - } catch (Exception e2) { - LOGGER.debug("General Exception encountered on second attempt at save(heat)..." + e2.getMessage(),e2); - LOGGER.debug(Arrays.toString(e2.getStackTrace())); - throw e2; - } - - } catch (Exception e1) { - LOGGER.debug("General Exception encountered on first attempt at save(heat) - try again..." + e1.getMessage(), e1); - LOGGER.debug(Arrays.toString(e1.getStackTrace())); - try { - Session session = this.getSession(); - session.save(heat); - } catch (HibernateException he2) { - LOGGER.debug("General Exception encountered on second attempt at save(heat)" + he2.getMessage(), he2); - LOGGER.debug(Arrays.toString(he2.getStackTrace())); - throw he2; - } catch (Exception e2) { - LOGGER.debug("General Exception encountered on second attempt at save(heat)..." + e2.getMessage(), e2); - LOGGER.debug(Arrays.toString(e2.getStackTrace())); - throw e2; - } - } - } - - } else { - heat.setArtifactUuid(heatTemp.getArtifactUuid()); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatTemplate", null); - } - } - - /** - * Retrieves a Heat environment from DB based on its unique key. - * - * @param name the environment artifact name - * @param version the environment resource version - * @param asdcResourceName the environment resource name - * @return the heat environment from DB or null if not found - */ - @Deprecated - public HeatEnvironment getHeatEnvironment (String name, String version, String asdcResourceName) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat environment with name " + name - + " and version " - + version - + " and ASDC resource name " - + asdcResourceName); - - String hql = "FROM HeatEnvironment WHERE name=:name AND version=:version AND asdcResourceName=:asdcResourceName"; - Query query = getSession ().createQuery (hql); - query.setParameter ("name", name); - query.setParameter (MODEL_VERSION, version); - query.setParameter ("asdcResourceName", asdcResourceName); - HeatEnvironment env = null; - try { - env = (HeatEnvironment) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: envName='" + name + "', version='" + version + "' and asdcResourceName=" + asdcResourceName, nure); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for envName=" + name + " and version=" + version + " and asdcResourceName=" + asdcResourceName, "", "", MsoLogger.ErrorCode.DataError, "non unique result for envName=" + name); - env = null; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: envName='" + name + "', asdc_service_model_version='" + version + "' and asdcResourceName=" + asdcResourceName, he); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for envName=" + name + " and version=" + version + " and asdcResourceName=" + asdcResourceName, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for envName=" + name); - env = null; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: envName='" + name + "', asdc_service_model_version='" + version + "' and asdcResourceName=" + asdcResourceName, e); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for envName=" + name + " and version=" + version + " and asdcResourceName=" + asdcResourceName, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for envName=" + name); - env = null; - } - if (env == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplate", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - } - return env; - } - - /** - * Retrieves a Heat environment from DB based on its unique key. 1707 - * - * @param artifactUuid the environment artifact name - * @param version the environment resource version - * @return the heat environment from DB or null if not found - */ - public HeatEnvironment getHeatEnvironment (String artifactUuid, String version) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat environment with uuid " + artifactUuid - + " and version " - + version); - - String hql = "FROM HeatEnvironment WHERE artifactUuid=:artifactUuid AND version=:version"; - Query query = getSession ().createQuery (hql); - query.setParameter ("artifactUuid", artifactUuid); - query.setParameter (MODEL_VERSION, version); - HeatEnvironment env = null; - try { - env = (HeatEnvironment) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: envName='" + artifactUuid + "', version='" + version); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for artifactUUID=" + artifactUuid + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "non unique result for ArtifactUUID=" + artifactUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: artifactUUID='" + artifactUuid + "', asdc_service_model_version='" + version + " " + he.getMessage() ); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for artifactUUID=" + artifactUuid + " and version=" + version , "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for artifactUUID=" + artifactUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: artifactUUID='" + artifactUuid + "', asdc_service_model_version='" + version + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for artifactUUID=" + artifactUuid + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for artifactUUID=" + artifactUuid); - throw e; - } - if (env == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplate", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - } - return env; - } - - /** - * Save the HeatEnvironment - * - * @param env The Environment - */ - public void saveHeatEnvironment (HeatEnvironment env) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat environment with name " - + env.getEnvironment() + " and ArtifactUUID " + env.getArtifactUuid()); - try { - HeatEnvironment dbEnv = getHeatEnvironment (env.getArtifactUuid(), env.getVersion ()); - if (dbEnv == null) { - - this.getSession ().save (env); - - } else { - env.setArtifactUuid(dbEnv.getArtifactUuid()); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatTemplate", null); - } - } - - /** - * Save the heatTemplate - * - * @param heat The heat template - */ - public void saveHeatTemplate (HeatTemplate heat) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat template with name " + heat.getTemplateName ()); - try { - this.getSession ().update (heat); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatTemplate", null); - } - } - - public void saveHeatFile (HeatFiles heatFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat file with name " + heatFile.getFileName ()); - try { - this.getSession ().save (heatFile); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatFile", null); - } - } - - public void saveVnfRecipe (VnfRecipe vnfRecipe) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF recipe with VNF type " + vnfRecipe.getVnfType ()); - try { - this.getSession ().save (vnfRecipe); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfRecipe", null); - } - } - - public void saveVnfComponentsRecipe (VnfComponentsRecipe vnfComponentsRecipe) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF Component recipe with VNF type " + vnfComponentsRecipe.getVnfType ()); - try { - this.getSession ().save (vnfComponentsRecipe); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfComponentsRecipe", null); - } - } - - - public void saveOrUpdateVnfResource (VnfResource vnfResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF Resource with VNF type " + vnfResource.getModelName()); - try { - - VnfResource existing = this.getVnfResourceByModelUuid(vnfResource.getModelUuid()); - if (existing == null) { - LOGGER.debug("No existing entry found - attempting to save..."); - this.getSession ().save (vnfResource); - } else { - LOGGER.debug("Existing vnf resource found!"); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfResource", null); - } - } - - public boolean saveVnfResourceCustomization (VnfResourceCustomization vnfResourceCustomization) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF Resource Customization with Name " + vnfResourceCustomization.getModelInstanceName()); - try { - LOGGER.debug(vnfResourceCustomization.toString()); - } catch (Exception e) { - LOGGER.debug("Unable to print VRC " + e.getMessage(), e); - } - try { - // Check if NetworkResourceCustomzation record already exists. If so, skip saving it. - // List<NetworkResource> networkResourceList = getAllNetworksByNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid()); - // Do any matching customization records exist? - // if(networkResourceList.size() == 0){ - - // networkResourceCustomization.setNetworkResourceModelUuid(networkResource.getModelUuid()); - // this.getSession().flush(); - // this.getSession().clear(); - - VnfResourceCustomization existing = this.getVnfResourceCustomizationByModelCustomizationUuid(vnfResourceCustomization.getModelCustomizationUuid()); - - if (existing == null) { - LOGGER.debug("No existing entry found...attempting to save..."); - this.getSession ().save (vnfResourceCustomization); - return true; - }else { - try { - LOGGER.debug("Existing VRC entry found\n" + existing.toString()); - } catch (Exception e) { - LOGGER.debug("Unable to print VRC2 " + e.getMessage(), e); - } - return false; - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfResourceCustomization", null); - } - } - - public void saveAllottedResourceCustomization (AllottedResourceCustomization resourceCustomization) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Allotted Resource with Name " + resourceCustomization.getModelInstanceName()); - try { - List<AllottedResourceCustomization> allottedResourcesList = getAllAllottedResourcesByArModelCustomizationUuid(resourceCustomization.getModelCustomizationUuid()); - - if(allottedResourcesList.isEmpty()){ - this.getSession ().save(resourceCustomization); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateAllottedResourceCustomization", null); - } - } - - public void saveAllottedResource (AllottedResource allottedResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Allotted Resource with Name " + allottedResource.getModelName()); - try { - AllottedResource existing = this.getAllottedResourceByModelUuid(allottedResource.getModelUuid()); - if (existing == null) { - this.getSession ().save (allottedResource); - } else { - LOGGER.debug("Found existing allottedResource with this modelUuid - no need to save"); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateAllottedResourceCustomization", null); - } - } - - public void saveVnfResource (VnfResource vnfResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save vnf Resource with Name " + vnfResource.getModelName()); - try { - VnfResource existing = this.getVnfResourceByModelUuid(vnfResource.getModelUuid()); - if (existing == null) { - this.getSession().save(vnfResource); - } else { - LOGGER.debug("Found existing vnfResource with this modelUuid - no need to save"); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfResourceCustomization", null); - } - } - - public void saveNetworkResource (NetworkResource networkResource) throws RecordNotFoundException { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Network Resource with Network Name " + networkResource.getModelName()); - try { - // Check if NetworkResourceCustomzation record already exists. If so, skip saving it. - // List<NetworkResource> networkResourceList = getAllNetworksByNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid()); - // Do any matching customization records exist? - if(getNetworkResourceByModelUuid(networkResource.getModelUUID()) == null){ - this.getSession ().save(networkResource); - } - - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null); - } - } - - public void saveToscaCsar (ToscaCsar toscaCsar) throws RecordNotFoundException { - - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Tosca Csar with Name " + toscaCsar.getName()); - try { - - if(getToscaCsar(toscaCsar.getArtifactChecksum()) == null){ - this.getSession ().save (toscaCsar); - } - LOGGER.debug("Temporarily disabling saveToscaCsar pending further investigation 2017-06-02"); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveToscaCsar", null); - } - } - - - /** - * Return the newest version of a specific Tosca CSAR Record resource (queried by Name). - * - * @param artifactChecksum - * @return ToscaCsar object or null if none found - */ - public ToscaCsar getToscaCsar (String artifactChecksum) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Tosca CSAR record with artifactChecksum " + artifactChecksum); - - String hql = "FROM ToscaCsar WHERE artifactChecksum = :artifactChecksum"; - Query query = getSession ().createQuery (hql); - query.setParameter ("artifactChecksum", artifactChecksum); - - @SuppressWarnings("unchecked") - List <ToscaCsar> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Tosca Csar not found", "CatalogDB", "getToscaCsar", null); - return null; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsar", null); - return resultList.get (0); - } - - /** - * Return a specific Tosca CSAR Record resource (queried by atrifact uuid). - * - * @param toscaCsarArtifactUUID the artifact uuid of the tosca csar - * @return ToscaCsar object or null if none found - */ - public ToscaCsar getToscaCsarByUUID(String toscaCsarArtifactUUID){ - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Tosca CSAR record with artifactUUID " + toscaCsarArtifactUUID); - - String hql = "FROM ToscaCsar WHERE artifactUUID = :toscaCsarArtifactUUID"; - Query query = getSession ().createQuery (hql); - query.setParameter ("toscaCsarArtifactUUID", toscaCsarArtifactUUID); - - @SuppressWarnings("unchecked") - List <ToscaCsar> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Tosca Csar not found", "CatalogDB", "getToscaCsarByUUID", null); - return null; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByUUID", null); - return resultList.get (0); - } - - /** - * Return a specific Tosca CSAR Record resource (queried by service model uuid). - * <br> - * - * @param serviceModelUUID the service model uuid - * @return ToscaCsar object or null if none found - * @since ONAP Beijing Release - */ - public ToscaCsar getToscaCsarByServiceModelUUID(String serviceModelUUID){ - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Tosca CSAR record with serviceModelUUID " + serviceModelUUID); - Service service = getServiceByModelUUID(serviceModelUUID); - if(null == service){ - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null); - return null; - } - ToscaCsar csar = getToscaCsarByUUID(service.getToscaCsarArtifactUUID()); - if(null == csar){ - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Tosca csar of the service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByServiceModelUUID", null); - return csar; - } - - public void saveTempNetworkHeatTemplateLookup (TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save TempNetworkHeatTemplateLookup with Network Model Name " + tempNetworkHeatTemplateLookup.getNetworkResourceModelName() + - " and Heat Template Artifact UUID " + tempNetworkHeatTemplateLookup.getHeatTemplateArtifactUuid()); - try { - this.getSession ().save (tempNetworkHeatTemplateLookup); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveTempNetworkHeatTemplateLookup", null); - } - } - - public void saveVfModuleToHeatFiles (VfModuleToHeatFiles vfModuleToHeatFiles) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VfModuleToHeatFiles with VF Module UUID " + vfModuleToHeatFiles.getVfModuleModelUuid() + - " and Heat Files Artifact UUID " + vfModuleToHeatFiles.getHeatFilesArtifactUuid()); - try { - - this.getSession ().save (vfModuleToHeatFiles); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVFModuleToHeatFiles", null); - } - } - - public void saveVnfResourceToVfModuleCustomization(VnfResourceCustomization vnfResourceCustomizationUUID, VfModuleCustomization vfModuleCustomizationUUID) throws RecordNotFoundException { - long startTime = System.currentTimeMillis (); - VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom(); - - if(vnfResourceCustomizationUUID != null && vfModuleCustomizationUUID != null){ - vnfResCustomToVfModuleCustom.setVnfResourceCustModelCustomizationUuid(vnfResourceCustomizationUUID.getModelCustomizationUuid()); - vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vfModuleCustomizationUUID.getModelCustomizationUuid()); - String vnfId = vnfResourceCustomizationUUID.getModelCustomizationUuid(); - String vfId = vfModuleCustomizationUUID.getModelCustomizationUuid(); - LOGGER.debug ("Catalog database - save VnfResCustomToVfModuleCustom with vnf=" + vnfId + ", vf=" + vfId); - try { - VnfResCustomToVfModuleCustom existing = this.getVnfResCustomToVfModule(vnfId, vfId); - if (existing == null) { - LOGGER.debug("No existing entry found - will now try to save"); - this.getSession ().save (vnfResCustomToVfModuleCustom); - } else { - LOGGER.debug("Existing entry already found - no save needed"); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfResourceToVfModuleCustomization", null); - } - } - } - - public void saveNetworkResourceCustomization (NetworkResourceCustomization networkResourceCustomization) throws RecordNotFoundException { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Network Resource Customization with Network Name " + networkResourceCustomization.getModelInstanceName()); - try { - // Check if NetworkResourceCustomzation record already exists. If so, skip saving it. - List<NetworkResourceCustomization> networkResourceCustomizationList = getAllNetworksByNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid()); - // Do any matching customization records exist? - if(networkResourceCustomizationList.isEmpty()){ - - // Retreive the record from the Network_Resource table associated to the Customization record based on ModelName - // ?? is it modelInstanceName with 1707? - NetworkResource networkResource = getNetworkResource(networkResourceCustomization.getModelInstanceName()); - - if(networkResource == null){ - throw new RecordNotFoundException("No record found in NETWORK_RESOURCE table for model name " + networkResourceCustomization.getModelInstanceName()); - } - - networkResourceCustomization.setNetworkResourceModelUuid(networkResource.getModelUUID()); - - this.getSession ().save(networkResourceCustomization); - } - - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null); - } - } - - @Deprecated // table is gone - mapped to ServiceToResource - public void saveServiceToNetworks (ServiceToNetworks serviceToNetworks) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save to ServiceToNetworks table with NetworkModelCustomizationUUID of " + serviceToNetworks.getNetworkModelCustomizationUuid() + " and ServiceModelUUID of " + serviceToNetworks.getServiceModelUuid()); - try { - this.getSession ().save(serviceToNetworks); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null); - } - } - - public void saveServiceToResourceCustomization(ServiceToResourceCustomization serviceToResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save to ServiceToResourceCustomization table with ServiceModelUuid of " + serviceToResource.getServiceModelUUID() + ", ResourceModelUUID of " + serviceToResource.getResourceModelCustomizationUUID() + " and model_type=" + serviceToResource.getModelType()); - ServiceToResourceCustomization strc = this.getServiceToResourceCustomization(serviceToResource.getServiceModelUUID(), serviceToResource.getResourceModelCustomizationUUID(), serviceToResource.getModelType()); - try { - if (strc != null) { - LOGGER.debug("**This ServiceToResourceCustomization record already exists - no need to save"); - } else { - this.getSession ().save(serviceToResource); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveServiceToResourceCustomization", null); - } - } - - @Deprecated // table is gone - mapped to ServiceToResourceCustomization - public void saveServiceToAllottedResources (ServiceToAllottedResources serviceToAllottedResources) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save to serviceToAllottedResources table with ARModelCustomizationUUID of " + serviceToAllottedResources.getArModelCustomizationUuid() + " and ServiceModelUUID of " + serviceToAllottedResources.getServiceModelUuid()); - try { - this.getSession ().save(serviceToAllottedResources); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveServiceToAllottedResources", null); - } - } - - public void saveService (Service service) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Service with ServiceName/Version/serviceUUID(SERVICE_NAME_VERSION_ID)" + service.getModelName()+"/"+service.getVersion()+"/"+service.getModelUUID()); - try { - Service serviceInvariantDB = null; - // Retrieve existing service record by nameVersionId - Service serviceDB = this.getServiceByModelUUID(service.getModelUUID()); - if (serviceDB == null) { - // Check to see if a record with the same modelInvariantId already exists. This tells us that a previous version exists and we can copy its recipe Record for the new service record. - serviceInvariantDB = this.getServiceByInvariantUUID(service.getModelInvariantUUID()); - // Save the new Service record - this.getSession ().save (service); - } - - if(serviceInvariantDB != null){ // existing modelInvariantId was found. - // copy the recipe record with the matching invariant id. We will duplicate this for the new service record - List<ServiceRecipe> serviceRecipes = getServiceRecipes(serviceInvariantDB.getModelUUID()); - - if(serviceRecipes != null && ! serviceRecipes.isEmpty()){ - for(ServiceRecipe serviceRecipe : serviceRecipes){ - if(serviceRecipe != null){ - // Fetch the service record that we just added. We do this so we can extract its Id column value, this will be the foreign key we use in the service recipe table. - Service newService = this.getServiceByModelUUID(service.getModelUUID()); - // Create a new ServiceRecipe record based on the existing one we just copied from the DB. - ServiceRecipe newServiceRecipe = new ServiceRecipe(); - newServiceRecipe.setAction(serviceRecipe.getAction()); - newServiceRecipe.setDescription(serviceRecipe.getDescription()); - newServiceRecipe.setOrchestrationUri(serviceRecipe.getOrchestrationUri()); - newServiceRecipe.setRecipeTimeout(serviceRecipe.getRecipeTimeout()); - newServiceRecipe.setServiceParamXSD(serviceRecipe.getServiceParamXSD()); - newServiceRecipe.setServiceModelUUID(newService.getModelUUID()); - newServiceRecipe.setVersion(serviceRecipe.getVersion()); - // Check recipe does not exist before inserting - ServiceRecipe recipe = getServiceRecipeByModelUUID(newServiceRecipe.getServiceModelUUID(), newServiceRecipe.getAction()); - // Save the new recipe record in the service_recipe table and associate it to the new service record that we just added. - if(recipe == null){ - this.getSession ().save (newServiceRecipe); - } - } - } - } - } - - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateService", null); - } - } - - public void saveOrUpdateVfModule (VfModule vfModule) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save or update VF Module with VF Model Name " + vfModule.getModelName()); - VfModule vfModuleInvariantDB = null; - try { - LOGGER.debug("heat template id = " + vfModule.getHeatTemplateArtifactUUId() + ", vol template id = "+ vfModule.getVolHeatTemplateArtifactUUId()); - LOGGER.debug(vfModule.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodule " + e.getMessage(), e); - } - try { - VfModule existing = this.getVfModuleByModelUUID(vfModule.getModelUUID()); - if (existing == null) { - // Check to see if a record with the same modelInvariantId already exists. This tells us that a previous version exists and we can copy its recipe Record for the new service record. - vfModuleInvariantDB = this.getVfModuleByModelInvariantUuid(vfModule.getModelInvariantUUID()); - LOGGER.debug("No existing entry found, attempting to save..."); - this.getSession ().save (vfModule); - } else { - try { - LOGGER.debug("Found an existing vf module!\n" + existing.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodule2 " + e.getMessage(), e); - } - } - - if(vfModuleInvariantDB != null){ // existing modelInvariantId was found. - // copy the recipe record with the matching invariant id. We will duplicate this for the new service record - List<VnfComponentsRecipe> vfRecipes = getVnfComponentRecipes(vfModuleInvariantDB.getModelUUID()); - - - if(vfRecipes != null && ! vfRecipes.isEmpty()){ - for(VnfComponentsRecipe vfRecipe : vfRecipes){ - if(vfRecipe != null){ - // Fetch the service record that we just added. We do this so we can extract its Id column value, this will be the foreign key we use in the service recipe table. - VfModule newRecipe = this.getVfModuleByModelUUID(vfModule.getModelUUID()); - // Create a new ServiceRecipe record based on the existing one we just copied from the DB. - VnfComponentsRecipe newVnfRecipe = new VnfComponentsRecipe(); - newVnfRecipe.setAction(vfRecipe.getAction()); - newVnfRecipe.setDescription(vfRecipe.getDescription()); - newVnfRecipe.setOrchestrationUri(vfRecipe.getOrchestrationUri()); - newVnfRecipe.setRecipeTimeout(vfRecipe.getRecipeTimeout()); - newVnfRecipe.setParamXSD(vfRecipe.getParamXSD()); - newVnfRecipe.setVfModuleModelUUId(newRecipe.getModelUUID()); - newVnfRecipe.setVersion(vfRecipe.getVersion()); - newVnfRecipe.setVnfComponentType(vfRecipe.getVnfComponentType()); - newVnfRecipe.setVnfType(vfRecipe.getVnfType()); - // Check recipe does not exist before inserting - // VnfComponentsRecipe recipe = getVnfComponentRecipes(newVnfRecipe.getVfModuleModelUUId()); - List<VnfComponentsRecipe> recipe = getVnfComponentRecipes(newVnfRecipe.getVfModuleModelUUId()); - // Save the new recipe record in the service_recipe table and associate it to the new service record that we just added. - // if(recipe == null){ - this.getSession ().save (newVnfRecipe); - // } - } - } - } - - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVfModule", null); - } - } - - public void saveOrUpdateVfModuleCustomization (VfModuleCustomization vfModuleCustomization) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VF Module Customization with VF Customization Model Name UUID " + vfModuleCustomization.getVfModuleModelUuid()); - try { - LOGGER.debug("env id = " + vfModuleCustomization.getHeatEnvironmentArtifactUuid() + ", vol Env=" + vfModuleCustomization.getVolEnvironmentArtifactUuid()); - LOGGER.debug(vfModuleCustomization.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodulecust " + e.getMessage(), e); - } - try { - VfModuleCustomization existing = this.getVfModuleCustomizationByModelCustomizationId(vfModuleCustomization.getModelCustomizationUuid()); - if (existing == null) { - LOGGER.debug("No existing entry found, attempting to save..."); - this.getSession ().save (vfModuleCustomization); - } else { - try { - LOGGER.debug("Found an existing vf module customization entry\n" + existing.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodulecust2 " + e.getMessage(), e); - } - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVfModuleCustomization", null); - } - } - - @Deprecated - public HeatNestedTemplate getNestedHeatTemplate(int parentTemplateId, int childTemplateId) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get nested Heat template with PerentId-Child Id " - + parentTemplateId +"-"+childTemplateId); - try { - HeatNestedTemplate nestedTemplate = new HeatNestedTemplate (); -// nestedTemplate.setParentTemplateId (parentTemplateId); -// nestedTemplate.setChildTemplateId (childTemplateId); - - return (HeatNestedTemplate)session.get (HeatNestedTemplate.class,nestedTemplate); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedHeatTemplate", null); - } - } - - // 1707 version - public HeatNestedTemplate getNestedHeatTemplate(String parentTemplateId, String childTemplateId) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get nested Heat template with PerentId=" - + parentTemplateId +", ChildId="+childTemplateId); - try { - HeatNestedTemplate nestedTemplate = new HeatNestedTemplate (); - nestedTemplate.setParentTemplateId (parentTemplateId); - nestedTemplate.setChildTemplateId (childTemplateId); - - return (HeatNestedTemplate)session.get (HeatNestedTemplate.class,nestedTemplate); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedHeatTemplate", null); - } - } - - // 1707 - public void saveNestedHeatTemplate (String parentTemplateId, HeatTemplate childTemplate, String yamlFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save nested Heat template with name " - + childTemplate.getTemplateName () + ",parentId=" + parentTemplateId + ",childId=" + childTemplate.getArtifactUuid() + ", providerResourceFile=" + yamlFile); - try { - - saveHeatTemplate(childTemplate, childTemplate.getParameters()); - if (getNestedHeatTemplate(parentTemplateId,childTemplate.getArtifactUuid()) == null) { - HeatNestedTemplate nestedTemplate = new HeatNestedTemplate (); - nestedTemplate.setParentTemplateId (parentTemplateId); - nestedTemplate.setChildTemplateId (childTemplate.getArtifactUuid ()); - nestedTemplate.setProviderResourceFile (yamlFile); - session.flush(); - session.save (nestedTemplate); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNestedHeatTemplate", null); - } - } - - @Deprecated - public HeatFiles getHeatFiles(int vnfResourceId,String fileName,String asdcResourceName, String version) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFiles with name " + fileName - + " and vnfResourceID " - + vnfResourceId -// + " and ASDC resource name " - + asdcResourceName - + " and version " - + version); - - String hql = "FROM HeatFiles WHERE fileName = :fileName AND vnfResourceId = :vnfResourceId AND asdcResourceName = :asdcResourceName AND version = :version"; - Query query = getSession ().createQuery (hql); - query.setParameter ("fileName", fileName); - query.setParameter ("vnfResourceId", vnfResourceId); - query.setParameter ("asdcResourceName", asdcResourceName); - query.setParameter (MODEL_VERSION, version); - - @SuppressWarnings("unchecked") - - HeatFiles heatFilesResult = null; - try { - heatFilesResult = (HeatFiles) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for fileName=" + fileName + " and vnfResourceId=" + vnfResourceId + " and asdcResourceName=" + asdcResourceName + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for fileName=" + fileName); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for fileName=" + fileName + " and vnfResourceId=" + vnfResourceId + " and asdcResourceName=" + asdcResourceName + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for fileName=" + fileName); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for fileName=" + fileName + " and vnfResourceId=" + vnfResourceId + " and asdcResourceName=" + asdcResourceName + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for fileName=" + fileName); - throw e; - } - - // See if something came back. - if (heatFilesResult == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles not found", "CatalogDB", "getHeatFiles", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFiles", null); - return heatFilesResult; - } - - public HeatFiles getHeatFiles(String artifactUuid) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFiles with artifactUuid " + artifactUuid); - - String hql = "FROM HeatFiles WHERE artifactUuid = :artifactUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("artifactUuid", artifactUuid); - - @SuppressWarnings("unchecked") - - HeatFiles heatFilesResult = null; - try { - heatFilesResult = (HeatFiles) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: artifactUuid='" + artifactUuid ); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for artifactUuid=" + artifactUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: artifactUuid='" + artifactUuid + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for artifactUuid=" + artifactUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: artifactUuid='" + artifactUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for artifactUuid=" + artifactUuid , "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for artifactUuid=" + artifactUuid); - throw e; - } - - // See if something came back. - if (heatFilesResult == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles not found", "CatalogDB", "getHeatFiles", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFiles", null); - return heatFilesResult; - } - - public void saveHeatFiles (HeatFiles childFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat File with name " - + childFile.getFileName()); - try { -// HeatFiles heatFiles = getHeatFiles (childFile.getVnfResourceId(), childFile.getFileName(), childFile.getAsdcResourceName (),childFile.getVersion()); - HeatFiles heatFiles = getHeatFiles (childFile.getArtifactUuid()); - if (heatFiles == null) { - - // asdc_heat_files_save - this.getSession ().save (childFile); - - } else { - /* replaced 'heatFiles' by 'childFile' - Based on following comment: - It must be childFile.setId instead of heatFiles.setId, we must return the ID if it exists in DB. - */ - childFile.setArtifactUuid(heatFiles.getArtifactUuid()); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatFiles", null); - } - } - - public void saveVfModuleToHeatFiles (String parentVfModuleId, HeatFiles childFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat File to VFmodule link " - + childFile.getFileName()); - try { - saveHeatFiles (childFile); - VfModuleToHeatFiles checkExistingEntry = this.getVfModuleToHeatFilesEntry(parentVfModuleId, childFile.getArtifactUuid()); - if (checkExistingEntry == null) { - VfModuleToHeatFiles vfModuleToHeatFile = new VfModuleToHeatFiles (); - vfModuleToHeatFile.setVfModuleModelUuid(parentVfModuleId); - vfModuleToHeatFile.setHeatFilesArtifactUuid(childFile.getArtifactUuid()); - session.flush(); - session.save (vfModuleToHeatFile); - } else { - LOGGER.debug("**Found existing VfModuleToHeatFiles entry for " + checkExistingEntry.toString()); - LOGGER.debug("No need to save..."); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVfModuleToHeatFiles", null); - } - } - - /** - * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID - * - * @param modelUUID - * @return NetworkRecipe object or null if none found - */ - public NetworkResource getNetworkResourceByModelUuid(String modelUUID) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network resource with modelUUID " + modelUUID); - - try { - String hql = "FROM NetworkResource WHERE modelUUID=:modelUUID"; - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_UUID, modelUUID); - - @SuppressWarnings("unchecked") - List <NetworkResource> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } catch (Exception e) { - LOGGER.debug("Error trying to find Network Resource with " + modelUUID +", " + e.getMessage(),e); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceByModelUuid", null); - } - return null; - } - - - /** - * Return a Network recipe that matches a given NETWORK_TYPE, ACTION, and, if specified, SERVICE_TYPE - * - * @param networkType - * @param action - * @param serviceType - * @return NetworkRecipe object or null if none found - */ - public NetworkRecipe getNetworkRecipe (String networkType, String action, String serviceType) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network recipe with network type " + networkType - + " and action " - + action - + " and service type " - + serviceType); - - try { - String hql; - if (serviceType == null) { - hql = "FROM NetworkRecipe WHERE networkType = :networkType AND action = :action AND serviceType IS NULL "; - } else { - hql = "FROM NetworkRecipe WHERE networkType = :networkType AND action = :action AND serviceType = :serviceType "; - } - Query query = getSession ().createQuery (hql); - query.setParameter (NETWORK_TYPE, networkType); - query.setParameter (ACTION, action); - if (serviceType != null) { - query.setParameter ("serviceType", serviceType); - } - - @SuppressWarnings("unchecked") - List <NetworkRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); - } - } - - /** - * Return a Network recipe that matches a given MODEL_UUID and ACTION - * - * @param networkModelUuid - * @param action - * @return NetworkRecipe object or null if none found - */ - public NetworkRecipe getNetworkRecipeByModuleUuid (String networkModelUuid, String action) { - LOGGER.debug ("Catalog database - get network recipe with network model uuid " + networkModelUuid - + " and action " - + action - ); - NetworkResource networkResource = getNetworkResourceByModelUuid(networkModelUuid); - if(null == networkResource){ - return null; - } - - NetworkRecipe recipe = getNetworkRecipeByNameVersion(networkResource.getModelName(), networkResource.getModelVersion(), action); - - if (recipe == null) { - recipe = getDefaultNetworkReceipe(action); - } - - return recipe; - } - - private NetworkRecipe getDefaultNetworkReceipe(String action) { - String modelName = "SDNC_DEFAULT"; - return getNetworkRecipe(modelName, action); - } - - /** - * Return a Network recipe that matches a given MODEL_NAME and ACTION - * - * @param modelName - * @param action - * @return NetworkRecipe object or null if none found - */ - public NetworkRecipe getNetworkRecipe (String modelName, String action) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network recipe with network model name " + modelName - + " and action " - + action - ); - - try { - String hql = "FROM NetworkRecipe WHERE modelName = :modelName AND action = :action"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_NAME, modelName); - query.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <NetworkRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); - } - } - - /** - * get network recipe by module name and version and action. - * <br> - * - * @param modelName - * @param modelVersion - * @param action - * @return - * @since ONAP Beijing Release - */ - public NetworkRecipe getNetworkRecipeByNameVersion(String modelName, String modelVersion, String action) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network recipe with network model name " + modelName - +"model version " + modelVersion + " and action " + action); - - try { - String hql = "FROM NetworkRecipe WHERE modelName = :modelName AND version=:version AND action = :action"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_NAME, modelName); - query.setParameter (MODEL_VERSION, modelVersion); - query.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <NetworkRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); - } - } - - /** - * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID - * - * @param modelCustomizationUuid - * @return NetworkRecipe object or null if none found - */ - public NetworkResource getNetworkResourceByModelCustUuid(String modelCustomizationUuid) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network resource with modelCustomizationUuid " + modelCustomizationUuid); - - try { - String hql = "select n FROM NetworkResource n, NetworkResourceCustomization c WHERE n.modelUUID=c.networkResourceModelUuid and c.modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_CUSTOMIZATION_UUID, modelCustomizationUuid); - - @SuppressWarnings("unchecked") - List <NetworkResource> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } catch (Exception e) { - LOGGER.debug("Error trying to find Network Resource with " + modelCustomizationUuid +", " + e.getMessage(),e); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceByModelCustUuid", null); - } - return null; - } - - /** - * Return a VnfComponents recipe that matches a given VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, and, if specified, - * SERVICE_TYPE - * - * @param vnfType - * @param vnfComponentType - * @param action - * @param serviceType - * @return VnfComponentsRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipe (String vnfType, - String vnfComponentType, - String action, - String serviceType) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Vnf Component recipe with network type " + vnfType - + " and component type " - + vnfComponentType - + " and action " - + action - + " and service type " - + serviceType); - - try { - String hql; - if (serviceType == null) { - hql = "FROM VnfComponentsRecipe WHERE vnfType = :vnfType AND vnfComponentType = :vnfComponentType AND action = :action AND serviceType IS NULL "; - } else { - hql = "FROM VnfComponentsRecipe WHERE vnfType = :vnfType AND vnfComponentType = :vnfComponentType AND action = :action AND serviceType = :serviceType "; - } - Query query = getSession ().createQuery (hql); - query.setParameter (VNF_TYPE, vnfType); - query.setParameter (VNF_COMPONENT_TYPE, vnfComponentType); - query.setParameter (ACTION, action); - if (serviceType != null) { - query.setParameter ("serviceType", serviceType); - } - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfComponentsRecipe", null); - } - } - - /** - * Return a VnfComponents recipe that matches a given VF_MODULE_ID, VNF_COMPONENT_TYPE, ACTION - * - * @param vfModuleModelUUId - * @param vnfComponentType - * @param action - * @return VnfComponentsRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipeByVfModuleModelUUId (String vfModuleModelUUId, - String vnfComponentType, - String action) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Vnf Component recipe with vfModuleModelUUId " + vfModuleModelUUId - + " and component type " - + vnfComponentType - + " and action " - + action); - - try { - String hql; - hql = "FROM VnfComponentsRecipe WHERE vfModuleModelUUId = :vfModuleModelUUId AND vnfComponentType = :vnfComponentType AND action = :action "; - - Query query = getSession ().createQuery (hql); - query.setParameter (VF_MODULE_MODEL_UUID, vfModuleModelUUId); - query.setParameter (VNF_COMPONENT_TYPE, vnfComponentType); - query.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfComponentsRecipeByVfModuleModelUUId", null); - } - } - - public List<VnfComponentsRecipe> getVnfComponentRecipes (String vfModuleModelUUId) { - - StringBuilder hql = null; - - hql = new StringBuilder ("FROM VnfComponentsRecipe WHERE vfModuleModelUUId = :vfModuleModelUUId"); - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Service recipe with vfModuleModelUUId " + vfModuleModelUUId); - - Query query = getSession ().createQuery (hql.toString ()); - query.setParameter ("vfModuleModelUUId", vfModuleModelUUId); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getVfModuleRecipes", null); - return Collections.EMPTY_LIST; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleRecipes", null); - return resultList; - } - - - - public void saveOrUpdateVnfComponent (VnfComponent vnfComponent) { - long startTime = System.currentTimeMillis (); - - LOGGER.debug ("Catalog database - save VnfComponent where vnfId="+ vnfComponent.getVnfId()+ " AND componentType="+ vnfComponent.getComponentType()); - - VnfComponent vnfComponentDb = this.getVnfComponent(vnfComponent.getVnfId(), vnfComponent.getComponentType()); - - try { - - this.getSession ().save (vnfComponent); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfComponent", null); - } - } - - /** - * Return a VfModule record that matches a given MODEL_NAME - * - * @param modelName - * @return VfModule object or null if none found - */ - public VfModule getVfModule (String modelName) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get vf module with model name " + modelName); - - try { - String hql; - - hql = "FROM VfModule WHERE modelName = :modelName"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_NAME, modelName); - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModule", null); - } - } - - /** - * Return a VfModule record that matches a given MODEL_NAME - * - * @param modelUUID - * @return VfModule object or null if none found - */ - public VfModule getVfModuleByModelUUID (String modelUUID) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get vf module with modelUUID " + modelUUID); - - try { - String hql; - - hql = "FROM VfModule WHERE modelUUID = :modelUUID"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_UUID, modelUUID); - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelUUID", null); - } - } - - /** - * Return a Service recipe that matches a given service ModelUUID and action - * (modelUUID) and ACTION - * - * @param modelUUID - * @param action - * @return ServiceRecipe object or null if none found - */ - public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Service recipe with modelUUID=" + modelUUID + " and action=" + action); - - try { - String hql; - // based on the new SERVICE_RECIPE schema where SERVICE_MODEL_UUID == MODEL_UUID, a JOIN with the SERVICE table is no longer needed -// hql = "SELECT new ServiceRecipe(SR.id, SR.serviceModelUUID, SR.action, SR.description, " + -// "SR.orchestrationUri, SR.serviceParamXSD, case when SR.recipeTimeout is null then 0 else SR.recipeTimeout end, " + -// "case when SR.serviceTimeoutInterim is null then 0 else SR.serviceTimeoutInterim end, SR.created) " + -// "FROM Service as S RIGHT OUTER JOIN S.recipes SR " + -// "WHERE SR.serviceModelUUID = :modelUUID AND SR.action = :action"; - hql = "FROM ServiceRecipe WHERE serviceModelUUID = :modelUUID AND action = :action"; - Query query = getSession().createQuery(hql); - query.setParameter(MODEL_UUID, modelUUID); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List<ServiceRecipe> recipeResultList = query.list(); - if (recipeResultList.isEmpty()) { - LOGGER.debug("Catalog database - recipeResultList is null"); - return null; - } - recipeResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(recipeResultList); - LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); - - return recipeResultList.get(0); - } finally { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipeByModelUUID", null); - } - } - - /** - * Return a Service recipe that matches a given SERVICE_NAME_VERSION_ID - * (MODEL_VERSION_ID) and ACTION - * - * @param modelVersionId - * @param action - * @return ServiceRecipe object or null if none found - */ - @Deprecated - public ServiceRecipe getServiceRecipe(String modelVersionId, - String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Service recipe with modeVersionId=" + modelVersionId - + " and action=" + action); - - try { - String hql; - // Note: Even with the implementation of the HQL JOIN below, the code for the two separate - // SELECTs will be retained/commented for now in the event some subsequent JOIN issue arises - // 1st query to get the Service record for the given SERVICE_NAME_VERSION_ID (MODEL_VERSION_ID) -/* hql = "FROM Service WHERE serviceNameVersionId = :serviceNameVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter(SERVICE_NAME_VERSION_ID, modelVersionId); - - @SuppressWarnings("unchecked") - List<Service> serviceResultList = query.list(); - if (serviceResultList.isEmpty()) { - LOGGER.debug("Catalog database - serviceResultList is null"); - return null; - } - Collections.sort(serviceResultList, new MavenLikeVersioningComparator()); - Collections.reverse(serviceResultList); - LOGGER.debug("Catalog database - serviceResultList contains " + serviceResultList.get(0).toString()); - - // 2nd query to get the ServiceRecipe record corresponding to the Service from the 1st query - hql = "FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID AND action = :action"; - query = getSession().createQuery(hql); - // The SERVICE table 'id' field maps to the SERVICE_RECIPE table 'SERVICE_ID' field - query.setParameter(SERVICE_ID, serviceResultList.get(0).getId()); - query.setParameter(ACTION, action); -*/ - // The following SELECT performs a JOIN across the SERVICE and SERVICE_RECIPE tables. It required a new - // CTR in the ServiceRecipe Class to populate that object (the other option was to parse the Object[] - // returned by createQuery() and manually populate the ServiceRecipe object). Two of the 'int' fields in the - // SERVICE_RECIPE DB schema (the timeouts) permit NULL values which required some additional code in the - // SELECT to generate a default of 0 (needed by the CTR) in the cases where the value is NULL. - hql = "SELECT new ServiceRecipe(SR.id, SR.serviceModelUUID, SR.action, SR.description, " + - "SR.orchestrationUri, SR.serviceParamXSD, case when SR.recipeTimeout is null then 0 else SR.recipeTimeout end, " + - "case when SR.serviceTimeoutInterim is null then 0 else SR.serviceTimeoutInterim end, SR.created) " + - "FROM Service as S RIGHT OUTER JOIN S.recipes SR " + - "WHERE SR.serviceModelUUID = S.id AND S.serviceNameVersionId = :serviceNameVersionId AND SR.action = :action"; - Query query = getSession().createQuery(hql); - query.setParameter(MODEL_UUID, modelVersionId); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List<ServiceRecipe> recipeResultList = query.list(); - if (recipeResultList.isEmpty()) { - LOGGER.debug("Catalog database - recipeResultList is null"); - return null; - } - recipeResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(recipeResultList); - LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); - - return recipeResultList.get(0); - } finally { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); - } - } - - /** - * Return a Model recipe that matches a given MODEL_TYPE, MODEL_VERSION_ID, ACTION - * Note: This method is not currently used but was retained in the event the - * architecture moves back to a MODEL/MODEL_RECIPE structure. - * - * @param modelType - * @param modelVersionId - * @param action - * @return ModelRecipe object or null if none found - */ - public ModelRecipe getModelRecipe(String modelType, - String modelVersionId, - String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Model recipe with modelType=" + modelType - + " and modeVersionId=" + modelVersionId - + " and action=" + action); - - try { - String hql; - // TBD - at some point it would be desirable to figure out how to do a HQL JOIN across - // the MODEL and MODEL_RECIPE tables in HQL instead of 2 separate queries. - // There seems to be 2 issues: formatting a hql query that executes successfully - // and then being able to generate a result that will fit into the ModelRecipe class. - - // 1st query to get the Model record for the given MODEL_TYPE and MODEL_VERSION_ID - hql = "FROM Model WHERE modelType = :modelType AND modelVersionId = :modelVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter(MODEL_TYPE, modelType); - query.setParameter(MODEL_VERSION_ID, modelVersionId); - - @SuppressWarnings("unchecked") - List<Model> modelResultList = query.list(); - if (modelResultList.isEmpty()) { - LOGGER.debug("Catalog database - modelResultList is null"); - return null; - } - modelResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(modelResultList); - LOGGER.debug("Catalog database - modelResultList contains " + modelResultList.get(0).toString()); - - // 2nd query to get the ModelRecipe record corresponding to the Model from the 1st query - hql = "FROM ModelRecipe WHERE modelId = :modelId AND action = :action"; - query = getSession().createQuery(hql); - // The MODEL table 'id' field maps to the MODEL_RECIPE table 'MODEL_ID' field - query.setParameter(MODEL_ID, modelResultList.get(0).getId()); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List<ModelRecipe> recipeResultList = query.list(); - if (recipeResultList.isEmpty()) { - LOGGER.debug("Catalog database - recipeResultList is null"); - return null; - } - recipeResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(recipeResultList); - LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); - - return recipeResultList.get(0); - } finally { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getModelRecipe", null); - } - } - - - /** - * Verify the health of the DB. - * - * @return boolean value indicate whether DB is healthy - */ - public boolean healthCheck () { - long startTime = System.currentTimeMillis (); - Session session = this.getSession (); - - // Query query = session.createQuery (" from ActiveRequests "); - Query query = session.createSQLQuery (" show tables "); - - List<?> list = query.list(); - LOGGER.debug("healthCheck CatalogDB - Successful"); - return true; - } - - public < E > E executeQuerySingleRow(String hql, HashMap<String, String> variables, boolean retry) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - executeQuery: " + hql + (retry ? ", retry=true" : ", retry=false")); - Query query = getSession().createQuery(hql); - - StringBuilder sb = new StringBuilder(); - if (variables != null) { - for(Map.Entry<String, String> entry : variables.entrySet()){ - sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); - query.setParameter(entry.getKey(), entry.getValue()); - } - } - LOGGER.debug("Variables:\n" + sb.toString()); - - E theObject = null; - try { - theObject = (E) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for " + hql, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for " + hql ); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while performing " + hql + "; he message:" + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception while performing hql=" + hql, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for hql=" + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw he; - } - } catch (Exception e) { - LOGGER.debug("Generic Exception - while performing '" + hql + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception performing " + hql, "", "", MsoLogger.ErrorCode.DataError, "Generic exception performing " + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw e; - } - } - - if (theObject == null) { - LOGGER.debug("Returning null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "executeQuerySingleRow", null); - } else { - LOGGER.debug("Returning an Object"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "executeQuerySingleRow", null); - } - return theObject; - } - - public < E > List<E> executeQueryMultipleRows(String hql, HashMap<String, String> variables, boolean retry) { - long startTime = System.currentTimeMillis (); - LOGGER.debug("Catalog database - executeQuery: " + hql + (retry ? ", retry=true" : ", retry=false")); - Query query = getSession().createQuery(hql); - - StringBuilder sb = new StringBuilder(); - if (variables != null) { - for(Map.Entry<String, String> entry : variables.entrySet()){ - sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); - query.setParameter(entry.getKey(), entry.getValue()); - } - } - LOGGER.debug("Variables:\n" + sb.toString()); - - List<E> theObjects = null; - try { - theObjects = (List<E>) query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while performing " + hql + "; he message:" + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception while performing hql=" + hql, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for hql=" + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw he; - } - } catch (Exception e) { - LOGGER.debug("Generic Exception - while performing '" + hql + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception performing " + hql, "", "", MsoLogger.ErrorCode.DataError, "Generic exception performing " + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw e; - } - } - - if (theObjects == null) { - LOGGER.debug("Returning null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "executeQuerySingleRow", null); - } else { - try { - LOGGER.debug("Returning theObjects:" + theObjects.size()); - } catch (Exception e) { - LOGGER.debug("Returning theObjects",e); - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "executeQuerySingleRow", null); - } - return theObjects; - } - - - /** - * get allotted resource recipe by module name and version and action. - * <br> - * - * @param modelName - * @param modelVersion - * @param action - * @return - * @since ONAP Beijing Release - */ - public ArRecipe getArRecipeByNameVersion(String modelName, String modelVersion, String action) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get ar recipe with ar model name " + modelName - +"model version " + modelVersion + " and action " + action); - - try { - String hql = "FROM ArRecipe WHERE modelName = :modelName AND version=:version AND action = :action"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_NAME, modelName); - query.setParameter (MODEL_VERSION, modelVersion); - query.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <ArRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); - } - } - - /** - * Return a allotted resource recipe that matches a given MODEL_UUID and ACTION - * - * @param modelName - * @param action - * @return ArRecipe object or null if none found - */ - public ArRecipe getArRecipeByModuleUuid (String ArModelUuid, String action) { - LOGGER.debug ("Catalog database - get ar recipe with ar model uuid " + ArModelUuid - + " and action " - + action - ); - AllottedResource arResource = this.getAllottedResourceByModelUuid(ArModelUuid); - if(null == arResource){ - return null; - } - - ArRecipe recipe = getArRecipeByNameVersion(arResource.getModelName(), arResource.getModelVersion(), action); - return recipe; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManager.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManager.java deleted file mode 100644 index 6646bc3109..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManager.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog; - -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import java.net.URL; - -public class CatalogDbSessionFactoryManager extends AbstractSessionFactoryManager { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - - @Override - protected URL getHibernateConfigFile() { - try { - if ("MYSQL".equals (System.getProperty ("mso.db")) || "MARIADB".equals(System.getProperty("mso.db"))) { - return this.getClass().getClassLoader().getResource("hibernate-catalog-core-mysql.cfg.xml"); - } else { - LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC", "", "", MsoLogger.ErrorCode.DataError , "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC"); - return null; - } - } catch (Exception ex) { - LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, ex.getMessage (), "", "", MsoLogger.ErrorCode.DataError , "Problem in getting DB connection type", ex); - return null; - } - } -}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java deleted file mode 100644 index a0af4b2300..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class AllottedResource extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelUuid = null; - private String modelInvariantUuid = null; - private String modelVersion = null; - private String modelName = null; - private String toscaNodeType = null; - private String subcategory = null; - private String description = null; - private Timestamp created = null; - - public AllottedResource() { - } - - public String getModelUuid() { - return this.modelUuid; - } - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; - } - public String getModelInvariantUuid() { - return this.modelInvariantUuid; - } - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - public String getModelVersion() { - return this.modelVersion; - } - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - public String getModelName() { - return this.modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - public String getToscaNodeType() { - return this.toscaNodeType; - } - public void setToscaNodeType(String toscaNodeType) { - this.toscaNodeType = toscaNodeType; - } - public String getSubcategory() { - return this.subcategory; - } - public void setSubcategory(String subcategory) { - this.subcategory = subcategory; - } - public String getDescription() { - return this.description; - } - public void setDescription(String description) { - this.description = description; - } - public Timestamp getCreated() { - return created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java deleted file mode 100644 index e5a653760b..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; -import org.openecomp.mso.db.catalog.beans.AllottedResource; - -public class AllottedResourceCustomization extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelCustomizationUuid = null; - private String arModelUuid = null; - private Timestamp created = null; - private String modelInstanceName = null; - private String providingServiceModelInvariantUuid = null; - private String targetNetworkRole = null; - private String nfFunction = null; - private String nfType = null; - private String nfRole = null; - private String nfNamingCode = null; - private Integer minInstances; - private Integer maxInstances; - private AllottedResource allottedResource = null; - private String providingServiceModelUuid = null; - private String providingServiceModelName = null; - - public AllottedResourceCustomization() { - super(); - } - - public String getModelCustomizationUuid() { - return this.modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - - public String getArModelUuid() { - return this.arModelUuid; - } - public void setArModelUuid(String arModelUuid) { - this.arModelUuid = arModelUuid; - } - - public Timestamp getCreated() { - return this.created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getModelInstanceName() { - return this.modelInstanceName; - } - public void setModelInstanceName(String modelInstanceName) { - this.modelInstanceName = modelInstanceName; - } - public AllottedResource getAllottedResource() { - return this.allottedResource; - } - public void setAllottedResource(AllottedResource ar) { - this.allottedResource = ar; - } - public String getProvidingServiceModelInvariantUuid() { - return this.providingServiceModelInvariantUuid; - } - public void setProvidingServiceModelInvariantUuid(String providingServiceModelInvariantUuid) { - this.providingServiceModelInvariantUuid = providingServiceModelInvariantUuid; - } - public String getTargetNetworkRole() { - return this.targetNetworkRole; - } - public void setTargetNetworkRole(String targetNetworkRole) { - this.targetNetworkRole = targetNetworkRole; - } - public String getNfFunction() { - return this.nfFunction; - } - public void setNfFunction(String nfFunction) { - this.nfFunction = nfFunction; - } - public String getNfType() { - return this.nfType; - } - public void setNfType(String nfType) { - this.nfType = nfType; - } - public String getNfRole() { - return this.nfRole; - } - public void setNfRole(String nfRole) { - this.nfRole = nfRole; - } - public String getNfNamingCode() { - return this.nfNamingCode; - } - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } - public Integer getMinInstances() { - return this.minInstances; - } - public void setMinInstances(Integer minInstances) { - this.minInstances = minInstances; - } - public Integer getMaxInstances() { - return this.maxInstances; - } - public void setMaxInstances(Integer maxInstances) { - this.maxInstances = maxInstances; - } - public String getProvidingServiceModelUuid() { - return this.providingServiceModelUuid; - } - public void setProvidingServiceModelUuid(String providingServiceModelUuid) { - this.providingServiceModelUuid = providingServiceModelUuid; - } - public String getProvidingServiceModelName() { - return this.providingServiceModelName; - } - public void setProvidingServiceModelName(String providingServiceModelName) { - this.providingServiceModelName = providingServiceModelName; - } - - @Override - public String toString () { - return "modelCustomizationUuid=" + this.modelCustomizationUuid + - ",modelInstanceName=" + this.modelInstanceName + - ",modelInstanceName=" + this.modelInstanceName + - ",created=" + this.created + - ",ar=" + this.allottedResource; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java deleted file mode 100644 index 8baf62018c..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class HeatEnvironment extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String artifactUuid = null; - private String name = null; - private String description = null; - private String environment = null; - private String artifactChecksum = null; - - private Timestamp created = null; - - public String getArtifactUuid() { - return this.artifactUuid; - } - public void setArtifactUuid(String artifactUuid) { - this.artifactUuid = artifactUuid; - } - - public String getName () { - return name; - } - - public void setName (String name) { - this.name = name; - } - - public String getDescription() { - return this.description; - } - public void setDescription(String description) { - this.description = description; - } - - public String getEnvironment() { - return this.environment; - } - public void setEnvironment(String environment) { - this.environment = environment; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("Artifact UUID=").append(this.artifactUuid); - sb.append (", name="); - sb.append (name); - sb.append (", version="); - sb.append (version); - sb.append(", description="); - sb.append (this.description == null ? "null" : this.description); - sb.append(", body="); - sb.append (this.environment == null ? "null" : this.environment); - if (this.created != null) { - sb.append (",creationTimestamp="); - sb.append (DateFormat.getInstance().format(this.created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java deleted file mode 100644 index 1fff17612e..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; - -import com.openpojo.business.annotation.BusinessKey; - -public class HeatNestedTemplate implements Serializable { - - @BusinessKey - private String parentTemplateId = null; - @BusinessKey - private String childTemplateId = null; - private String providerResourceFile = null; - public static final long serialVersionUID = -1322322139926390329L; - - public HeatNestedTemplate () { - super (); - } - - public void setParentTemplateId (String parentTemplateId) { - this.parentTemplateId = parentTemplateId; - } - - public String getParentTemplateId () { - return this.parentTemplateId; - } - - public void setChildTemplateId (String childTemplateId) { - this.childTemplateId = childTemplateId; - } - - public String getChildTemplateId () { - return this.childTemplateId; - } - - public void setProviderResourceFile (String providerResourceFile) { - this.providerResourceFile = providerResourceFile; - } - - public String getProviderResourceFile () { - return this.providerResourceFile; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder (); - sb.append("ParentTemplateId=").append(this.parentTemplateId); - sb.append(", ChildTemplateId=").append(this.childTemplateId); - if (this.providerResourceFile == null) { - sb.append (", providerResourceFile=null"); - } else { - sb.append(",providerResourceFile=").append(this.providerResourceFile); - } - return sb.toString (); - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof HeatNestedTemplate)) { - return false; - } - if (this == o) { - return true; - } - HeatNestedTemplate hnt = (HeatNestedTemplate) o; - if (hnt.getChildTemplateId () == this.childTemplateId && hnt.getParentTemplateId () == this.parentTemplateId) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result; - int parentTemplateIdHash = 0; - int childTemplateIdHash = 0; - if (this.parentTemplateId != null) { - parentTemplateIdHash = this.parentTemplateId.hashCode(); - } - if (this.childTemplateId != null) { - childTemplateIdHash = this.childTemplateId.hashCode(); - } - result = parentTemplateIdHash + childTemplateIdHash; - return result; - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java deleted file mode 100644 index c6386efdd6..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class HeatTemplate extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String artifactUuid = null; - private String templateName = null; - private String templateBody = null; - private int timeoutMinutes; - private Set <HeatTemplateParam> parameters; - private Set <HeatNestedTemplate> files; - private String description = null; - private String asdcUuid = null; - private String artifactChecksum = null; - - private Timestamp created = null; - - public enum TemplateStatus { - PARENT, CHILD, PARENT_COMPLETE - } - - public HeatTemplate () { - } - - public String getArtifactUuid() { - return this.artifactUuid; - } - - public void setArtifactUuid (String artifactUuid) { - this.artifactUuid = artifactUuid; - } - - public String getTemplateName () { - return templateName; - } - - public void setTemplateName (String templateName) { - this.templateName = templateName; - } - - public String getTemplateBody () { - return templateBody; - } - - public void setTemplateBody (String templateBody) { - this.templateBody = templateBody; - } - - public int getTimeoutMinutes () { - return timeoutMinutes; - } - - public void setTimeoutMinutes (int timeout) { - this.timeoutMinutes = timeout; - } - - public Set <HeatTemplateParam> getParameters () { - return parameters; - } - - public void setParameters (Set <HeatTemplateParam> parameters) { - this.parameters = parameters; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getHeatTemplate () { - return this.templateBody; - } - - public void setFiles (Set <HeatNestedTemplate> files) { - this.files = files; - } - - public Set <HeatNestedTemplate> getFiles () { - return this.files; - } - - public String getAsdcUuid() { - return asdcUuid; - } - - public void setAsdcUuid(String asdcUuidp) { - this.asdcUuid = asdcUuidp; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString () { - String body = (templateBody != null) ? "(" + templateBody.length () + " chars)" : "(Not defined)"; - StringBuilder sb = new StringBuilder (); - sb.append ("Template=") - .append (templateName) - .append (",version=") - .append (version) - .append (",body=") - .append (body) - .append (",timeout=") - .append (timeoutMinutes) - .append (",asdcUuid=") - .append (asdcUuid) - .append (",description=") - .append (description); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - - - if (parameters != null && !parameters.isEmpty ()) { - sb.append (",params=["); - for (HeatTemplateParam param : parameters) { - sb.append (param.getParamName ()); - if (param.isRequired ()) { - sb.append ("(reqd)"); - } - sb.append (","); - } - sb.replace (sb.length () - 1, sb.length (), "]"); - } - return sb.toString (); - } - - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java deleted file mode 100644 index d4e1ec536a..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java +++ /dev/null @@ -1,209 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class NetworkResource extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String orchestrationMode = null; - private String description = null; - private String neutronNetworkType = null; - private String aicVersionMin = null; - private String aicVersionMax = null; - private String modelName = null; - private String modelInvariantUUID = null; - private String modelVersion = null; - private String toscaNodeType = null; - private Timestamp created = null; - private String modelUUID = null; - private String category = null; - private String subCategory = null; - private String heatTemplateArtifactUUID = null; - - public NetworkResource() {} - - public String getOrchestrationMode() { - return orchestrationMode; - } - - public void setOrchestrationMode(String orchestrationMode) { - this.orchestrationMode = orchestrationMode; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public String getNeutronNetworkType() { - return neutronNetworkType; - } - - public void setNeutronNetworkType(String neutronNetworkType) { - this.neutronNetworkType = neutronNetworkType; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getAicVersionMin() { - return aicVersionMin; - } - - public void setAicVersionMin(String aicVersionMin) { - this.aicVersionMin = aicVersionMin; - } - - public String getAicVersionMax() { - return aicVersionMax; - } - - public void setAicVersionMax(String aicVersionMax) { - this.aicVersionMax = aicVersionMax; - } - - public String getModelName() { - return modelName; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public String getModelInvariantUUID() { - return modelInvariantUUID; - } - - public void setModelInvariantUUID(String modelInvariantUUID) { - this.modelInvariantUUID = modelInvariantUUID; - } - - public String getToscaNodeType() { - return toscaNodeType; - } - - public void setToscaNodeType(String toscaNodeType) { - this.toscaNodeType = toscaNodeType; - } - - public String getModelUUID() { - return modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } - - - /** - * @return Returns the category. - */ - public String getCategory() { - return category; - } - - - /** - * @param category The category to set. - */ - public void setCategory(String category) { - this.category = category; - } - - - /** - * @return Returns the subCategory. - */ - public String getSubCategory() { - return subCategory; - } - - - /** - * @param subCategory The subCategory to set. - */ - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getHeatTemplateArtifactUUID() { - return heatTemplateArtifactUUID; - } - - public void setHeatTemplateArtifactUUID(String heatTemplateArtifactUUID) { - this.heatTemplateArtifactUUID = heatTemplateArtifactUUID; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("NETWORK Resource:"); - sb.append("modelVersion="); - sb.append(modelVersion); - sb.append(",mode="); - sb.append(orchestrationMode); - sb.append(",neutronType="); - sb.append(neutronNetworkType); - sb.append(",aicVersionMin="); - sb.append(aicVersionMin); - sb.append(",aicVersionMax="); - sb.append(aicVersionMax); - sb.append(",modelName="); - sb.append(modelName); - sb.append(",modelInvariantUUID="); - sb.append(modelInvariantUUID); - sb.append(",toscaNodeType="); - sb.append(toscaNodeType); - sb.append(",modelUUID="); - sb.append(modelUUID); - sb.append(",heatTemplateArtifactUUID="); - sb.append(heatTemplateArtifactUUID); - - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java deleted file mode 100644 index f1d5d4f003..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java +++ /dev/null @@ -1,146 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -import java.io.Serializable; - -public class NetworkResourceCustomization implements Serializable{ - - // modelCustomizationUuid and networkResourceModelUuid form a composite primary key - @BusinessKey - private String modelCustomizationUuid = null; - @BusinessKey - private String networkResourceModelUuid = null; - public static final long serialVersionUID = -1322322139926390329L; - private String modelInstanceName = null; - private Timestamp created = null; - private String networkTechnology = null; - private String networkType = null; - private String networkScope = null; - private String networkRole = null; - - // These fields are not in the table directly - but I'm adding them here for storage in the objects we're dealing with - private NetworkResource networkResource = null; - - public NetworkResourceCustomization() { - super(); - } - - public String getModelCustomizationUuid() { - return this.modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - - public String getNetworkResourceModelUuid() { - return this.networkResourceModelUuid; - } - public void setNetworkResourceModelUuid(String networkResourceModelUuid) { - this.networkResourceModelUuid = networkResourceModelUuid; - } - - public String getModelInstanceName() { - return this.modelInstanceName; - } - public void setModelInstanceName(String modelInstanceName) { - this.modelInstanceName = modelInstanceName; - } - - public NetworkResource getNetworkResource() { - return this.networkResource; - } - public void setNetworkResource(NetworkResource networkResource) { - this.networkResource = networkResource; - } - - public String getNetworkType() { - return this.networkType; - } - public void setNetworkType(String networkType) { - this.networkType = networkType; - } - public Timestamp getCreated() { - return this.created; - } - public void setCreated(java.sql.Timestamp timestamp) { - this.created = timestamp; - } - - public String getNetworkTechnology() { - return this.networkTechnology; - } - public void setNetworkTechnology(String networkTechnology) { - this.networkTechnology = networkTechnology; - } - public String getNetworkScope() { - return this.networkScope; - } - public void setNetworkScope(String networkScope) { - this.networkScope = networkScope; - } - public void setNetworkRole(String networkRole) { - this.networkRole = networkRole; - } - public String getNetworkRole() { - return this.networkRole; - } - - @Override - public String toString() { - return "modelCustomizationUuid=" + this.modelCustomizationUuid + - "networkResourceModelUuid=" + this.networkResourceModelUuid + - "modelInstanceName=" + this.modelInstanceName + - "networkType=" + this.networkType + - "networkTechnology=" + this.networkTechnology + - "networkScope=" + this.networkScope + - "networkRole=" + this.networkRole; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof NetworkResourceCustomization)) { - return false; - } - if (this == o) { - return true; - } - NetworkResourceCustomization nrc = (NetworkResourceCustomization) o; - if (nrc.getModelCustomizationUuid().equals(this.getModelCustomizationUuid()) - && nrc.getNetworkResourceModelUuid().equals(this.getNetworkResourceModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result; - result = (this.modelCustomizationUuid != null ? this.modelCustomizationUuid.hashCode() : 0) + (this.networkResourceModelUuid != null ? this.networkResourceModelUuid.hashCode() : 0); - return result; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java deleted file mode 100644 index 3f2093b7e2..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class Recipe extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private int id; - protected String action = null; - private String description = null; - protected String orchestrationUri = null; - private int recipeTimeout; - private String serviceType = null; - private String paramXSD = null; - private Timestamp created = null; - - public Recipe () { - super (); - } - - public int getId () { - return id; - } - - public void setId (int id) { - this.id = id; - } - - public String getAction () { - return action; - } - - public void setAction (String action) { - this.action = action; - } - - public String getDescription () { - return description; - } - - public void setDescription (String description) { - this.description = description; - } - - public String getOrchestrationUri () { - return orchestrationUri; - } - - public void setOrchestrationUri (String orchestrationUri) { - this.orchestrationUri = orchestrationUri; - } - - public int getRecipeTimeout () { - return recipeTimeout; - } - - public void setRecipeTimeout (int recipeTimeout) { - this.recipeTimeout = recipeTimeout; - } - - public String getServiceType () { - return serviceType; - } - - public void setServiceType (String serviceType) { - this.serviceType = serviceType; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - /** - * @return Returns the paramXSD. - */ - public String getParamXSD() { - return paramXSD; - } - - /** - * @param paramXSD The paramXSD to set. - */ - public void setParamXSD(String paramXSD) { - this.paramXSD = paramXSD; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("RECIPE: ").append(action); - sb.append(",uri=").append(orchestrationUri); - - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java deleted file mode 100644 index 620c6bb17c..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class Service extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelName = null; - private String description = null; - private String modelUUID = null; - private String modelInvariantUUID = null; - private Timestamp created = null; - private String toscaCsarArtifactUUID = null; - private String modelVersion = null; - private String category = null; - private String serviceType = null; - private String serviceRole = null; - private String environmentContext = null; - private String workloadContext = null; - private Map<String,ServiceRecipe> recipes = new HashMap<>(); - private Set<ServiceToResourceCustomization> serviceResourceCustomizations = new HashSet<>(); - - public Service() {} - - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public Map<String, ServiceRecipe> getRecipes() { - return recipes; - } - public void setRecipes(Map<String, ServiceRecipe> recipes) { - this.recipes = recipes; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - 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 getToscaCsarArtifactUUID() { - return toscaCsarArtifactUUID; - } - - public void setToscaCsarArtifactUUID(String toscaCsarArtifactUUID) { - this.toscaCsarArtifactUUID = toscaCsarArtifactUUID; - } - - public Set<ServiceToResourceCustomization> getServiceResourceCustomizations() { - return serviceResourceCustomizations; - } - - public void setServiceResourceCustomizations(Set<ServiceToResourceCustomization> serviceResourceCustomizations) { - this.serviceResourceCustomizations = serviceResourceCustomizations; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - /** - * @return Returns the category. - */ - public String getCategory() { - return category; - } - - - /** - * @param category The category to set. - */ - public void setCategory(String category) { - this.category = category; - } - - public String getServiceType() { - return serviceType; - } - - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - public String getServiceRole() { - return serviceRole; - } - - public void setServiceRole(String serviceRole) { - this.serviceRole = serviceRole; - } - public String getEnvironmentContext() { - return this.environmentContext; - } - public void setEnvironmentContext(String environmentContext) { - this.environmentContext = environmentContext; - } - - public String getWorkloadContext() { - return this.workloadContext; - } - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("SERVICE: name=").append(modelName).append(",modelVersion=").append(modelVersion) - .append(",description=").append(description).append(",modelInvariantUUID=").append(modelInvariantUUID) - - .append(",toscaCsarArtifactUUID=").append(toscaCsarArtifactUUID).append(",serviceType=").append(serviceType) - .append(",serviceRole=").append(serviceRole).append(",envtContext=").append(this.environmentContext) - .append(",workloadContext=").append(this.workloadContext); - for (String recipeAction : recipes.keySet()) { - ServiceRecipe recipe = recipes.get(recipeAction); - sb.append("\n").append(recipe.toString()); - } - - for(ServiceToResourceCustomization serviceResourceCustomization : serviceResourceCustomizations) { - sb.append("\n").append(serviceResourceCustomization.toString()); - } - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java deleted file mode 100644 index 3fad9a4d02..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java +++ /dev/null @@ -1,171 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/* - * A simple holder for Service and its associated elements: - * VnfResource, 1-n VfModule, Network TBD - */ - -public class ServiceMacroHolder implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private Service service; - private List<VnfResource> vnfResources; - private List<NetworkResourceCustomization> networkResourceCustomization; - private List<AllottedResourceCustomization> allottedResourceCustomization; - private List<VnfResourceCustomization> vnfResourceCustomizations; - - public ServiceMacroHolder() { - super(); - this.service = null; - this.vnfResources = new ArrayList<>(); - this.networkResourceCustomization = new ArrayList<>(); - this.allottedResourceCustomization = new ArrayList<>(); - this.vnfResourceCustomizations = new ArrayList<>(); - } - public ServiceMacroHolder(Service service) { - this(); - this.service = service; - } - - public Service getService() { - return this.service; - } - public void setService(Service service) { - this.service = service; - } - - public void setVnfResources(List<VnfResource> vnfResources) { - this.vnfResources = vnfResources; - } - public List<VnfResource> getVnfResources() { - return this.vnfResources; - } - public void addVnfResource(VnfResource vr) { - if (vr != null) { - if (this.vnfResources != null) { - this.vnfResources.add(vr); - } else { - this.vnfResources = new ArrayList<>(); - this.vnfResources.add(vr); - } - } - } - - public void setVnfResourceCustomizations(List<VnfResourceCustomization> vnfResourceCustomizations) { - this.vnfResourceCustomizations = vnfResourceCustomizations; - } - public List<VnfResourceCustomization> getVnfResourceCustomizations() { - return this.vnfResourceCustomizations; - } - public void addVnfResourceCustomizations(VnfResourceCustomization vrc) { - if (vrc != null) { - if (this.vnfResourceCustomizations != null) { - this.vnfResourceCustomizations.add(vrc); - } else { - this.vnfResourceCustomizations = new ArrayList<>(); - this.vnfResourceCustomizations.add(vrc); - } - } - } - - public void setNetworkResourceCustomization(List<NetworkResourceCustomization> networkResourceCustomizations) { - this.networkResourceCustomization = networkResourceCustomizations; - } - public List<NetworkResourceCustomization> getNetworkResourceCustomization() { - return this.networkResourceCustomization; - } - public void addNetworkResourceCustomizations(NetworkResourceCustomization nrc) { - if (this.networkResourceCustomization != null) { - this.networkResourceCustomization.add(nrc); - } else { - this.networkResourceCustomization = new ArrayList<>(); - this.networkResourceCustomization.add(nrc); - } - } - - public void setAllottedResourceCustomization(List<AllottedResourceCustomization> allottedResourceCustomizations) { - this.allottedResourceCustomization = allottedResourceCustomizations; - } - public List<AllottedResourceCustomization> getAllottedResourceCustomization() { - return this.allottedResourceCustomization; - } - public void addAllottedResourceCustomization(AllottedResourceCustomization arc) { - if (this.allottedResourceCustomization != null) { - this.allottedResourceCustomization.add(arc); - } else { - this.allottedResourceCustomization = new ArrayList<>(); - this.allottedResourceCustomization.add(arc); - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ServicePlus: "); - if (this.service != null) { - sb.append("service: ").append(this.service.toString()); - } else { - sb.append("service: null"); - } - if (this.vnfResourceCustomizations != null && this.vnfResourceCustomizations.size() > 0) { - int i=0; - sb.append("vnfResourceCustomization: "); - for (VnfResourceCustomization vrc : this.vnfResourceCustomizations) { - sb.append(", vnfResourceCustomization[").append(i++).append("]:").append(vrc.toString()); - } - } else { - sb.append("none"); - } - if (this.vnfResources != null && this.vnfResources.size() > 0) { - int i=0; - sb.append("VnfResources: "); - for (VnfResource vr : this.vnfResources) { - sb.append(", vnfResource[").append(i++).append("]:").append(vr.toString()); - } - } else { - sb.append("none"); - } - if (this.networkResourceCustomization != null && this.networkResourceCustomization.size() > 0) { - int i=0; - sb.append("NetworkResourceCustomizations:"); - for (NetworkResourceCustomization nrc : this.networkResourceCustomization) { - sb.append("NRC[").append(i++).append("]: ").append(nrc.toString()); - } - } - if (this.allottedResourceCustomization != null && this.allottedResourceCustomization.size() > 0) { - int i=0; - sb.append("AllottedResourceCustomizations:"); - for (AllottedResourceCustomization arc : this.allottedResourceCustomization) { - sb.append("ARC[").append(i++).append("]: ").append(arc.toString()); - } - } - - return sb.toString(); - } - - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java deleted file mode 100644 index d0bc9b33f7..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.Date; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; -import org.openecomp.mso.logger.MsoLogger; - -public class ServiceRecipe extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private int id; - private String serviceModelUUID = null; - private String action = null; - private String description = null; - private String orchestrationUri = null; - private String serviceParamXSD = null; - private int recipeTimeout; - private Integer serviceTimeoutInterim; - private Timestamp created = null; - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - // This 'default' CTR is now needed for backward compatibility since a new CTR was added below - public ServiceRecipe() { - super(); - } - - // This CTR is needed by the HQL SELECT JOIN between the SERVICE and SERVICE_RECIPE tables - // in CatalogDatabase::getServiceRecipe() - public ServiceRecipe(int id, String serviceModelUUID, String action, - String description, String orchestrationUri, - String serviceParamXSD, int recipeTimeout, - int serviceTimeoutInterim, Date created) { - super(); - LOGGER.debug("ServiceRecipe id=" + id + ", serviceModelUUID=" + serviceModelUUID + ", action=" + action + ", description=" + description + - ", orchestrationUri=" + orchestrationUri + ", serviceParamXSD=" + serviceParamXSD + - ", recipeTimeout=" + recipeTimeout + ", serviceTimeoutInterim=" + serviceTimeoutInterim + ", created=" + created); - this.id = id; - this.serviceModelUUID = serviceModelUUID; - this.action = action; - this.description = description; - this.orchestrationUri = orchestrationUri; - this.serviceParamXSD = serviceParamXSD; - this.recipeTimeout = recipeTimeout; - this.serviceTimeoutInterim = serviceTimeoutInterim; - long date = created.getTime(); - this.created = new Timestamp(date); - } - - public int getId() { - return id; - } - public void setId(int id) { - this.id = id; - } - - public String getServiceModelUUID() { - return serviceModelUUID; - } - public void setServiceModelUUID(String serviceModelUUID) { - this.serviceModelUUID = serviceModelUUID; - } - - public String getAction() { - return action; - } - public void setAction(String action) { - this.action = action; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public String getOrchestrationUri() { - return orchestrationUri; - } - public void setOrchestrationUri(String orchestrationUri) { - this.orchestrationUri = orchestrationUri; - } - - public String getServiceParamXSD() { - return serviceParamXSD; - } - public void setServiceParamXSD(String serviceParamXSD) { - this.serviceParamXSD = serviceParamXSD; - } - - public int getRecipeTimeout() { - return recipeTimeout; - } - public void setRecipeTimeout(int recipeTimeout) { - this.recipeTimeout = recipeTimeout; - } - - public Integer getServiceTimeoutInterim() { - return serviceTimeoutInterim; - } - - public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) { - this.serviceTimeoutInterim = serviceTimeoutInterim; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("RECIPE: ").append(action); - sb.append(",uri=").append(orchestrationUri); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java deleted file mode 100644 index 2ac71f4ddf..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class ServiceToAllottedResources implements Serializable { - - @BusinessKey - private String serviceModelUuid = null; - @BusinessKey - private String arModelCustomizationUuid = null; - private Timestamp created = null; - - public static final long serialVersionUID = -1322322139926390329L; - - public ServiceToAllottedResources() { - super(); - } - - public String getServiceModelUuid() { - return this.serviceModelUuid; - } - public void setServiceModelUuid(String serviceModelUuid) { - this.serviceModelUuid = serviceModelUuid; - } - public String getArModelCustomizationUuid() { - return this.arModelCustomizationUuid; - } - public void setArModelCustomizationUuid(String arModelCustomizationUuid) { - this.arModelCustomizationUuid = arModelCustomizationUuid; - } - public Timestamp getCreated() { - return this.created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ServiceToAllottedResources)) { - return false; - } - if (this == o) { - return true; - } - ServiceToAllottedResources star = (ServiceToAllottedResources) o; - if (star.getArModelCustomizationUuid().equals(this.getArModelCustomizationUuid()) - && star.getServiceModelUuid().equals(this.getServiceModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode() { - - int code = this.arModelCustomizationUuid == null ? 0 : this.arModelCustomizationUuid.hashCode(); - code += this.serviceModelUuid == null ? 0 : this.serviceModelUuid.hashCode(); - - return code; - } - - @Override - public String toString() { - return "serviceModelUuid=" + this.serviceModelUuid + "arModelCustomizationUuid=" + this.arModelCustomizationUuid; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java deleted file mode 100644 index 3894b4f7b5..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class ServiceToNetworks implements Serializable { - - // This maps to SERVICE.SERVICE_NAME_VERSION_ID / Service.serviceNameVersionId in SERVICE/Service table - @BusinessKey - private String serviceModelUuid = null; - // This maps to NETWORK_RESOURCE_CUSTOMIZATION.MODEL_CUSTOMIZATION_UUID / NetworkResourceCustomization.ModelCustomizationUuid - @BusinessKey - private String networkModelCustomizationUuid = null; - private Timestamp created = null; - public static final long serialVersionUID = -1322322139926390329L; - - public ServiceToNetworks() { - super(); - } - - public String getServiceModelUuid() { - return this.serviceModelUuid; - } - public void setServiceModelUuid(String serviceModelUuid) { - this.serviceModelUuid = serviceModelUuid; - } - - public String getNetworkModelCustomizationUuid() { - return this.networkModelCustomizationUuid; - } - public void setNetworkModelCustomizationUuid(String networkCustomizationUuid) { - this.networkModelCustomizationUuid = networkCustomizationUuid; - } - - public Timestamp getCreated() { - return this.created; - } - public void setCreated(Timestamp timestamp) { - this.created = timestamp; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ServiceToNetworks)) { - return false; - } - if (this == o) { - return true; - } - ServiceToNetworks stn = (ServiceToNetworks) o; - if (stn.getNetworkModelCustomizationUuid().equals(this.getNetworkModelCustomizationUuid()) - && stn.getServiceModelUuid().equals(this.getServiceModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode() { - - int code = this.networkModelCustomizationUuid == null ? 0 : this.networkModelCustomizationUuid.hashCode(); - code += this.serviceModelUuid == null ? 0 : this.serviceModelUuid.hashCode(); - - return code; - } - - @Override - public String toString() { - return "ServiceToNetworks mapping: " + "serviceModelUuid=" + this.serviceModelUuid - + ",networkModelCustomizationUuid=" + networkModelCustomizationUuid; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java deleted file mode 100644 index 3babe4ad23..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.apache.commons.lang3.builder.EqualsBuilder; - -import com.openpojo.business.annotation.BusinessKey; - -public class ServiceToResourceCustomization implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - @BusinessKey - private String modelType = null; - @BusinessKey - private String serviceModelUUID = null; - private Timestamp created = null; - @BusinessKey - private String resourceModelCustomizationUUID = null; - - public ServiceToResourceCustomization() {} - - public String getServiceModelUUID() { - return serviceModelUUID; - } - - public void setServiceModelUUID(String serviceModelUUID) { - this.serviceModelUUID = serviceModelUUID; - } - - public String getModelType() { - return modelType; - } - - public void setModelType(String modelType) { - this.modelType = modelType; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getResourceModelCustomizationUUID() { - return resourceModelCustomizationUUID; - } - - public void setResourceModelCustomizationUUID(String resourceModelCustomizationUUID) { - this.resourceModelCustomizationUUID = resourceModelCustomizationUUID; - } - - - @Override - public boolean equals (final Object other) { - if (!(other instanceof ServiceToResourceCustomization)) { - return false; - } - ServiceToResourceCustomization castOther = (ServiceToResourceCustomization) other; - return new EqualsBuilder().append(modelType, castOther.modelType) - .append(serviceModelUUID, castOther.serviceModelUUID) - .append(resourceModelCustomizationUUID, castOther.resourceModelCustomizationUUID).isEquals(); - } - - @Override - public int hashCode() { - - int code = this.modelType == null ? 0 : this.modelType.hashCode(); - code += this.serviceModelUUID == null ? 0 : this.serviceModelUUID.hashCode(); - code += this.resourceModelCustomizationUUID == null ? 0 : this.resourceModelCustomizationUUID.hashCode(); - - return code; - - }@Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ServiceToResourceCustomization: modelType=").append(modelType).append(",serviceModelUUID=") - .append(serviceModelUUID).append(",resourceModelCustomizationUUID=").append(resourceModelCustomizationUUID); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java deleted file mode 100644 index 92d02d8a11..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.HashSet; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class ToscaCsar extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String artifactUUID = null; - private String name = null; - private String artifactChecksum = null; - private String url = null; - private String description = null; - private Timestamp created = null; - private Set<Service> services = new HashSet<>(); - - public ToscaCsar() { } - - public String getArtifactUUID() { - return artifactUUID; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public Set<Service> getServices() { - return services; - } - - public void setServices(Set<Service> services) { - this.services = services; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("TOSCACSAR: artifactUUID=").append(artifactUUID).append(",name=").append(name).append(",version=") - .append(version).append(",description=").append(description).append(",artifactChecksum=") - .append(artifactChecksum).append(",url=").append(url); - for (Service service : services) { - sb.append("\n").append(service.toString()); - } - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java deleted file mode 100644 index ec3bc7fefb..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class VfModule extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelInvariantUUID = null; - private String modelName = null; - private String modelVersion = null; - private String description = null; - private int isBase; - private String heatTemplateArtifactUUId = null; - private String volHeatTemplateArtifactUUId = null; - private Timestamp created = null; - private String modelUUID = null; - private String vnfResourceModelUUId = null; - - public VfModule() { - super(); - } - - public String getVnfResourceModelUUId() { - return this.vnfResourceModelUUId; - } - - public void setVnfResourceModelUUId(String vnfResourceModelUUId) { - this.vnfResourceModelUUId = vnfResourceModelUUId; - } - - public String getModelName() { - return this.modelName; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public int getIsBase() { - return this.isBase; - } - - public void setIsBase(int isBase) { - this.isBase = isBase; - } - - public boolean isBase() { - if (this.isBase == 0) { - return false; - } else { - return true; - } - } - - public String getHeatTemplateArtifactUUId() { - return this.heatTemplateArtifactUUId; - } - - public void setHeatTemplateArtifactUUId(String heatTemplateArtifactUUId) { - this.heatTemplateArtifactUUId = heatTemplateArtifactUUId; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getModelInvariantUuid() { - return this.modelInvariantUUID; - } - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUUID = modelInvariantUuid; - } - public String getModelInvariantUUID() { - return this.modelInvariantUUID; - } - public void setModelInvariantUUID(String modelInvariantUuid) { - this.modelInvariantUUID = modelInvariantUuid; - } - - public String getVolHeatTemplateArtifactUUId() { - return this.volHeatTemplateArtifactUUId; - } - - public void setVolHeatTemplateArtifactUUId(String volHeatTemplateArtifactUUId) { - this.volHeatTemplateArtifactUUId = volHeatTemplateArtifactUUId; - } - - public String getModelUUID() { - return modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - @Override - public String toString () { - StringBuilder buf = new StringBuilder(); - - buf.append("VFModule:"); - buf.append("modelName="); - buf.append(modelName); - buf.append(",modelVersion="); - buf.append(modelVersion); - buf.append(",vnfResourceModelUUId="); - buf.append(this.vnfResourceModelUUId); - buf.append(",heatTemplateArtifactUUId="); - buf.append(this.heatTemplateArtifactUUId); - buf.append(", description="); - buf.append(this.description); - buf.append(",volHeatTemplateArtifactUUId="); - buf.append(this.volHeatTemplateArtifactUUId); - buf.append(",isBase="); - buf.append(this.isBase); - buf.append(",modelInvariantUUID="); - buf.append(this.modelInvariantUUID); - buf.append(",modelUUID="); - buf.append(this.modelUUID); - - if (this.created != null) { - buf.append (",created="); - buf.append (DateFormat.getInstance().format(this.created)); - } - - return buf.toString(); - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java deleted file mode 100644 index 5b3dec4700..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class VfModuleCustomization implements Serializable { - - @BusinessKey - private String modelCustomizationUuid = null; - @BusinessKey - private String vfModuleModelUuid = null; - private String label = null; - private Integer minInstances; - private Integer maxInstances; - private Integer initialCount; - private Integer availabilityZoneCount; - private String heatEnvironmentArtifactUuid = null; - private String volEnvironmentArtifactUuid = null; - private Timestamp created = null; - private VfModule vfModule; - public static final long serialVersionUID = -1322322139926390329L; - - public VfModuleCustomization() { - super(); - } - - public String getModelCustomizationUuid() { - return this.modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - public String getVfModuleModelUuid() { - return this.vfModuleModelUuid; - } - public void setVfModuleModelUuid(String vfModuleModelUuid) { - this.vfModuleModelUuid = vfModuleModelUuid; - } - public String getHeatEnvironmentArtifactUuid() { - return this.heatEnvironmentArtifactUuid; - } - public void setHeatEnvironmentArtifactUuid(String heatEnvironmentArtifactUuid) { - this.heatEnvironmentArtifactUuid = heatEnvironmentArtifactUuid; - } - public String getVolEnvironmentArtifactUuid() { - return this.volEnvironmentArtifactUuid; - } - public void setVolEnvironmentArtifactUuid(String volEnvironmentArtifactUuid) { - this.volEnvironmentArtifactUuid = volEnvironmentArtifactUuid; - } - - public Integer getMinInstances() { - return this.minInstances; - } - public void setMinInstances(Integer minInstances) { - this.minInstances = minInstances; - } - public Integer getMaxInstances() { - return this.maxInstances; - } - public void setMaxInstances(Integer maxInstances) { - this.maxInstances = maxInstances; - } - public Integer getInitialCount() { - return this.initialCount; - } - public void setInitialCount(Integer initialCount) { - this.initialCount = initialCount; - } - public Integer getAvailabilityZoneCount() { - return this.availabilityZoneCount; - } - public void setAvailabilityZoneCount(Integer availabilityZoneCount) { - this.availabilityZoneCount = availabilityZoneCount; - } - public Timestamp getCreated() { - return created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - public String getLabel() { - return this.label; - } - public void setLabel(String label) { - this.label = label; - } - public VfModule getVfModule() { - return this.vfModule; - } - public void setVfModule(VfModule vfModule) { - this.vfModule = vfModule; - } - - @Override - public String toString() { - return "modelCustomizationUuid=" + this.modelCustomizationUuid + - "vfModuleModelUuid=" + this.vfModuleModelUuid + - "label=" + this.label + - "initalCount=" + this.initialCount + - "minInstances=" + this.minInstances + - "maxInstances=" + this.maxInstances + - "availabilityZoneCount=" + this.availabilityZoneCount + - "heatEnvironmentArtifactUuid=" + this.heatEnvironmentArtifactUuid + - "volEnvironmentArtifactUuid=" + this.volEnvironmentArtifactUuid + - "created=" + this.created; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof VfModuleCustomization)) { - return false; - } - if (this == o) { - return true; - } - VfModuleCustomization vfmc = (VfModuleCustomization) o; - if (vfmc.getModelCustomizationUuid().equals(this.getModelCustomizationUuid()) && vfmc.getVfModuleModelUuid().equals(this.getVfModuleModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result = 0; - result = (this.modelCustomizationUuid != null ? this.modelCustomizationUuid.hashCode() : 0) + (this.vfModuleModelUuid != null ? this.vfModuleModelUuid.hashCode() : 0); - return result; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java deleted file mode 100644 index 9b701df1d2..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - - - -import java.sql.Timestamp; -import java.text.DateFormat; - -import com.openpojo.business.annotation.BusinessKey; - -import java.io.Serializable; - -public class VnfComponent implements Serializable { - @BusinessKey - private int vnfId; - @BusinessKey - private String componentType = null; - private Integer heatTemplateId; - private Integer heatEnvironmentId; - public static final long serialVersionUID = -1322322139926390329L; - - private Timestamp created = null; - - public VnfComponent() {} - - public int getVnfId() { - return vnfId; - } - public void setVnfId(int id) { - this.vnfId = id; - } - - public String getComponentType() { - return componentType; - } - public void setComponentType(String ct) { - this.componentType = ct; - } - - public Integer getHeatTemplateId() { - return heatTemplateId; - } - public void setHeatTemplateId(Integer ht) { - this.heatTemplateId = ht; - } - - public Integer getHeatEnvironmentId() { - return heatEnvironmentId; - } - public void setHeatEnvironmentId(Integer he) { - this.heatEnvironmentId = he; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("VnfComponent: "); - sb.append("vnfId=").append(vnfId); - sb.append(",componentType=").append(componentType); - sb.append(",heatTemplateId=").append(heatTemplateId); - sb.append(",heatEnvironmentId=").append(heatEnvironmentId); - - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof VnfComponent)) { - return false; - } - if (this == o) { - return true; - } - VnfComponent vnfComponent = (VnfComponent) o; - if (vnfComponent.getVnfId() == this.vnfId && vnfComponent.componentType.equalsIgnoreCase(this.componentType)) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // return the hashCode of the concat string of type+vnfId - should be okay. - int result = 0; - result = (this.componentType + this.vnfId).hashCode(); - return result; - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java deleted file mode 100644 index 2240191d45..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; - -public class VnfComponentsRecipe extends Recipe implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String vnfType = null; - private String vnfComponentType = null; - private String vfModuleModelUUId = null; - - public VnfComponentsRecipe() {} - - public String getVnfType() { - return vnfType; - } - public void setVnfType(String vnfType) { - this.vnfType = vnfType; - } - - public String getVnfComponentType() { - return vnfComponentType; - } - public void setVnfComponentType(String vnfComponentType) { - this.vnfComponentType = vnfComponentType; - } - - public String getVfModuleModelUUId() { - return vfModuleModelUUId; - } - - public void setVfModuleModelUUId(String vfModuleModelUUId) { - this.vfModuleModelUUId = vfModuleModelUUId; - } - - @Override - public String toString () { - return super.toString() + ",vnfComponentParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + - ",vnfComponentType=" + getVnfComponentType() + ",vfModuleId=" + getVfModuleModelUUId(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java deleted file mode 100644 index 6b1cb0a19c..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class VnfResCustomToVfModuleCustom implements Serializable { - - @BusinessKey - private String vnfResourceCustModelCustomizationUuid = null; - @BusinessKey - private String vfModuleCustModelCustomizationUuid = null; - private Timestamp created = null; - - public static final long serialVersionUID = -1322322139926390329L; - - - public VnfResCustomToVfModuleCustom() { - super(); - } - public String getVnfResourceCustModelCustomizationUuid() { - return this.vnfResourceCustModelCustomizationUuid; - } - public void setVnfResourceCustModelCustomizationUuid(String vnfResourceCustModelCustomizationUuid) { - this.vnfResourceCustModelCustomizationUuid = vnfResourceCustModelCustomizationUuid; - } - public String getVfModuleCustModelCustomizationUuid() { - return this.vfModuleCustModelCustomizationUuid; - } - public void setVfModuleCustModelCustomizationUuid(String vfModuleCustModelCustomizationUuid) { - this.vfModuleCustModelCustomizationUuid = vfModuleCustModelCustomizationUuid; - } - public Timestamp getCreated() { - return created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString() { - return "vnfResourceCustModelCustomizationUuid=" + this.vnfResourceCustModelCustomizationUuid + - "vfModuleCustModelCustomizationUuid=" + this.vfModuleCustModelCustomizationUuid + "created=" + this.created; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof VnfResCustomToVfModuleCustom)) { - return false; - } - if (this == o) { - return true; - } - VnfResCustomToVfModuleCustom vrctvmc = (VnfResCustomToVfModuleCustom) o; - if (vrctvmc.getVnfResourceCustModelCustomizationUuid().equals(this.getVnfResourceCustModelCustomizationUuid()) && vrctvmc.getVfModuleCustModelCustomizationUuid().equals(this.getVfModuleCustModelCustomizationUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result = 0; - result = (this.vnfResourceCustModelCustomizationUuid != null ? this.vnfResourceCustModelCustomizationUuid.hashCode() : 0) + (this.vfModuleCustModelCustomizationUuid != null ? this.vfModuleCustModelCustomizationUuid.hashCode() : 0); - return result; - } - - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java deleted file mode 100644 index f8e6024e69..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java +++ /dev/null @@ -1,283 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.HashSet; -import java.util.Set; -import java.util.List; -import java.util.ArrayList; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class VnfResource extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelUuid = null; - private String modelInvariantUuid = null; - private String modelName = null; - private String toscaNodeType = null; - private String description = null; - private String orchestrationMode = null; - private String aicVersionMin = null; - private String aicVersionMax = null; - private String category = null; - private String subCategory = null; - private String heatTemplateArtifactUUId = null; - private Timestamp created = null; - private String modelVersion = null; - private Set<VnfResourceCustomization> vnfResourceCustomizations = new HashSet<>(); - private Set<VfModule> vfModules = new HashSet<>(); - private List<VfModuleCustomization> vfModuleCustomizations = new ArrayList<>(); - - public VnfResource () { } - - public String getOrchestrationMode () { - return orchestrationMode; - } - - public void setOrchestrationMode (String orchestrationMode) { - this.orchestrationMode = orchestrationMode; - } - - public String getDescription () { - return description; - } - - public void setDescription (String description) { - this.description = description; - } - - public String getTemplateId () { - return heatTemplateArtifactUUId; - } - - public void setTemplateId (String heatTemplateArtifactUUId) { - this.heatTemplateArtifactUUId = heatTemplateArtifactUUId; - } - public String getHeatTemplateArtifactUUId () { - return heatTemplateArtifactUUId; - } - - public void setHeatTemplateArtifactUUId (String heatTemplateArtifactUUId) { - this.heatTemplateArtifactUUId = heatTemplateArtifactUUId; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getAicVersionMin() { - return this.aicVersionMin; - } - - public void setAicVersionMin(String aicVersionMin) { - this.aicVersionMin = aicVersionMin; - } - - public String getAicVersionMax() { - return this.aicVersionMax; - } - - public void setAicVersionMax(String aicVersionMax) { - this.aicVersionMax = aicVersionMax; - } - - - /** - * @return Returns the category. - */ - public String getCategory() { - return category; - } - - - /** - * @param category The category to set. - */ - public void setCategory(String category) { - this.category = category; - } - - - /** - * @return Returns the subCategory. - */ - public String getSubCategory() { - return subCategory; - } - - - /** - * @param subCategory The subCategory to set. - */ - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getModelInvariantUuid() { - return this.modelInvariantUuid; - } - - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - - public String getModelName() { - return modelName; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public String getModelUuid() { - return modelUuid; - } - - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; - } - - public String getModelInvariantId() { - return this.modelInvariantUuid; - } - - public String getToscaNodeType() { - return toscaNodeType; - } - - public void setToscaNodeType(String toscaNodeType) { - this.toscaNodeType = toscaNodeType; - } - - public Set<VnfResourceCustomization> getVnfResourceCustomizations() { - return vnfResourceCustomizations; - } - - public void setVnfResourceCustomizations(Set<VnfResourceCustomization> vnfResourceCustomizations) { - this.vnfResourceCustomizations = vnfResourceCustomizations; - } - - public Set<VfModule> getVfModules() { - return vfModules; - } - - public void setVfModules(Set<VfModule> vfModules) { - this.vfModules = vfModules; - } - - public List<VfModuleCustomization> getVfModuleCustomizations() { - return this.vfModuleCustomizations == null ? new ArrayList<>() : this.vfModuleCustomizations; - } - public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) { - this.vfModuleCustomizations = vfModuleCustomizations; - } - public void addVfModuleCustomization(VfModuleCustomization vfmc) { - if (vfmc != null) { - if (this.vfModuleCustomizations != null) { - this.vfModuleCustomizations.add(vfmc); - } else { - this.vfModuleCustomizations = new ArrayList<>(); - this.vfModuleCustomizations.add(vfmc); - } - } - } - - public void addVfModule(VfModule vfm) { - if (vfm != null) { - if (this.vfModules != null) { - this.vfModules.add(vfm); - } else { - this.vfModules = new HashSet<>(); - this.vfModules.add(vfm); - } - } - } - public ArrayList<VfModule> getVfModuleList() { - if (this.vfModules == null || this.vfModules.size() < 1) { - return null; - } - ArrayList<VfModule> list = new ArrayList<>(); - list.addAll(this.vfModules); - return list; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - - sb.append("VNF="); - sb.append(",modelVersion="); - sb.append(modelVersion); - sb.append(",mode="); - sb.append(orchestrationMode); - sb.append(",heatTemplateArtifactUUId="); - sb.append(heatTemplateArtifactUUId); - sb.append(",envtId="); - sb.append(",asdcUuid="); - sb.append(",aicVersionMin="); - sb.append(this.aicVersionMin); - sb.append(",aicVersionMax="); - sb.append(this.aicVersionMax); - sb.append(",modelInvariantUuid="); - sb.append(this.modelInvariantUuid); - sb.append(",modelVersion="); - sb.append(",modelCustomizationName="); - sb.append(",modelName="); - sb.append(this.modelName); - sb.append(",serviceModelInvariantUUID="); - sb.append(",modelCustomizationUuid="); - sb.append(",toscaNodeType="); - sb.append(toscaNodeType); - - if (created != null) { - sb.append(",created="); - sb.append(DateFormat.getInstance().format(created)); - } - - for(VnfResourceCustomization vrc : vnfResourceCustomizations) { - sb.append("/n").append(vrc.toString()); - } - - for(VfModule vfm : vfModules) { - sb.append("/n").append(vfm.toString()); - } - return sb.toString(); - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java deleted file mode 100644 index e510ee867d..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class VnfResourceCustomization extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelCustomizationUuid = null; - private String modelInstanceName = null; - private Timestamp created = null; - private String vnfResourceModelUuid = null; - private String vnfResourceModelUUID = null; - private Integer minInstances; - private Integer maxInstances; - private Integer availabilityZoneMaxCount; - private VnfResource vnfResource; - private String nfFunction = null; - private String nfType = null; - private String nfRole = null; - private String nfNamingCode = null; - private String multiStageDesign = null; - private List<VfModuleCustomization> vfModuleCustomizations; - private Set<ServiceToResourceCustomization> serviceResourceCustomizations; - - public VnfResourceCustomization() { - } - - - public String getModelCustomizationUuid() { - return modelCustomizationUuid; - } - - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - - public String getModelInstanceName() { - return this.modelInstanceName; - } - public void setModelInstanceName(String modelInstanceName) { - this.modelInstanceName = modelInstanceName; - } - - public Timestamp getCreationTimestamp() { - return this.created; - } - public void setCreationTimestamp(Timestamp created) { - this.created = created; - } - - public String getVnfResourceModelUuid() { - return this.vnfResourceModelUuid == null ? this.vnfResourceModelUUID : this.vnfResourceModelUuid; - } - public void setVnfResourceModelUuid(String vnfResourceModelUuid) { - this.vnfResourceModelUuid = vnfResourceModelUuid; - } - public String getVnfResourceModelUUID() { - return this.vnfResourceModelUUID; - } - public void setVnfResourceModelUUID(String vnfResourceModelUUID) { - this.vnfResourceModelUUID = vnfResourceModelUUID; - } - public Integer getMinInstances() { - return this.minInstances; - } - public void setMinInstances(Integer minInstances) { - this.minInstances = minInstances; - } - - public Integer getMaxInstances() { - return this.maxInstances; - } - public void setMaxInstances(Integer maxInstances) { - this.maxInstances = maxInstances; - } - - public Integer getAvailabilityZoneMaxCount() { - return this.availabilityZoneMaxCount; - } - public void setAvailabilityZoneMaxCount(Integer availabilityZoneMaxCount) { - this.availabilityZoneMaxCount = availabilityZoneMaxCount; - } - - public VnfResource getVnfResource() { - return this.vnfResource; - } - public void setVnfResource(VnfResource vnfResource) { - this.vnfResource = vnfResource; - } - - public String getNfFunction() { - return nfFunction; - } - - public void setNfFunction(String nfFunction) { - this.nfFunction = nfFunction; - } - - public String getNfType() { - return nfType; - } - - public void setNfType(String nfType) { - this.nfType = nfType; - } - - public String getNfRole() { - return nfRole; - } - - public void setNfRole(String nfRole) { - this.nfRole = nfRole; - } - - public String getNfNamingCode() { - return nfNamingCode; - } - - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } - public String getMultiStageDesign() { - return this.multiStageDesign; - } - public void setMultiStageDesign(String multiStageDesign) { - this.multiStageDesign = multiStageDesign; - } - public List<VfModuleCustomization> getVfModuleCustomizations() { - return this.vfModuleCustomizations; - } - public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) { - this.vfModuleCustomizations = vfModuleCustomizations; - } - public void addVfModuleCustomization(VfModuleCustomization vfmc) { - if (vfmc != null) { - if (this.vfModuleCustomizations != null) { - this.vfModuleCustomizations.add(vfmc); - } else { - this.vfModuleCustomizations = new ArrayList<>(); - this.vfModuleCustomizations.add(vfmc); - } - } - } - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public Set<ServiceToResourceCustomization> getServiceResourceCustomizations() { - return serviceResourceCustomizations; - } - - public void setServiceResourceCustomizations( - Set<ServiceToResourceCustomization> serviceResourceCustomizations) { - this.serviceResourceCustomizations = serviceResourceCustomizations; - } - - @Override - public String toString() { - return "VnfResourceCustomization: " + "ModelCustUuid=" + this.modelCustomizationUuid + - ", ModelInstanceName=" + this.modelInstanceName + - ", vnfResourceModelUuid=" + this.vnfResourceModelUUID + - ", creationTimestamp=" + this.created + - ", minInstances=" + this.minInstances + - ", maxInstances=" + this.maxInstances + - ", availabilityZoneMaxCount=" + this.availabilityZoneMaxCount + - ", nfFunction=" + this.nfFunction + - ", nfType=" + this.nfType + - ", nfRole=" + this.nfRole + - ", nfNamingCode=" + this.nfNamingCode + - ", multiStageDesign=" + this.multiStageDesign; - } - -} diff --git a/mso-catalog-db/src/main/resources/AllottedResource.hbm.xml b/mso-catalog-db/src/main/resources/AllottedResource.hbm.xml deleted file mode 100644 index 0c61b5f614..0000000000 --- a/mso-catalog-db/src/main/resources/AllottedResource.hbm.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-<!-- Generated Mar 29, 2017 4:25:31 PM by Hibernate Tools 3.4.0.CR1 -->
-<hibernate-mapping>
- <class name="org.openecomp.mso.db.catalog.beans.AllottedResource" table="ALLOTTED_RESOURCE">
- <id name="modelUuid" type="java.lang.String" length="200">
- <column name="MODEL_UUID" />
- <generator class="assigned" />
- </id>
- <property name="modelInvariantUuid" type="java.lang.String" length="200" not-null="true">
- <column name="MODEL_INVARIANT_UUID" />
- </property>
- <property name="modelVersion" type="java.lang.String" length="20" not-null="true">
- <column name="MODEL_VERSION" />
- </property>
- <property name="modelName" type="java.lang.String" length="200" not-null="true">
- <column name="MODEL_NAME" />
- </property>
- <property name="toscaNodeType" type="java.lang.String" length="200">
- <column name="TOSCA_NODE_TYPE" />
- </property>
- <property name="subcategory" type="java.lang.String" length="200">
- <column name="SUBCATEGORY" />
- </property>
- <property name="description" type="java.lang.String" length="1200">
- <column name="DESCRIPTION" />
- </property>
- <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
- </class>
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/AllottedResourceCustomization.hbm.xml b/mso-catalog-db/src/main/resources/AllottedResourceCustomization.hbm.xml deleted file mode 100644 index 2154928a84..0000000000 --- a/mso-catalog-db/src/main/resources/AllottedResourceCustomization.hbm.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" -"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> -<!-- Generated Dec 14, 2016 10:57:53 AM by Hibernate Tools 3.4.0.CR1 --> -<hibernate-mapping> - <class name="org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization" - table="ALLOTTED_RESOURCE_CUSTOMIZATION"> - <id name="modelCustomizationUuid" type="java.lang.String"> - <column name="MODEL_CUSTOMIZATION_UUID" length="200"/> - <generator class="assigned" /> - </id> - <property name="modelInstanceName" type="java.lang.String" length="200" not-null="true"> - <column name="MODEL_INSTANCE_NAME" /> - </property> - <property name="arModelUuid" type="java.lang.String" length="200" not-null="true"> - <column name="AR_MODEL_UUID" /> - </property> - <property name="providingServiceModelInvariantUuid" type="java.lang.String" length="200"> - <column name="PROVIDING_SERVICE_MODEL_INVARIANT_UUID" /> - </property> - <property name="targetNetworkRole" type="java.lang.String" length="200"> - <column name="TARGET_NETWORK_ROLE" /> - </property> - <property name="nfFunction" type="java.lang.String" length="200"> - <column name="NF_FUNCTION" /> - </property> - <property name="nfType" type="java.lang.String" length="200"> - <column name="NF_TYPE" /> - </property> - <property name="nfRole" type="java.lang.String" length="200"> - <column name="NF_ROLE" /> - </property> - <property name="nfNamingCode" type="java.lang.String" length="200"> - <column name="NF_NAMING_CODE" /> - </property> - <property name="minInstances" type="java.lang.Integer"> - <column name="MIN_INSTANCES" /> - </property> - <property name="maxInstances" type="java.lang.Integer"> - <column name="MAX_INSTANCES" /> - </property> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - <property name="providingServiceModelUuid" type="java.lang.String" length="200"> - <column name="PROVIDING_SERVICE_MODEL_UUID" /> - </property> - <property name="providingServiceModelName" type="java.lang.String" length="200"> - <column name="PROVIDING_SERVICE_MODEL_NAME" /> - </property> - </class> -</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/ArRecipe.hbm.xml b/mso-catalog-db/src/main/resources/ArRecipe.hbm.xml deleted file mode 100644 index a840093561..0000000000 --- a/mso-catalog-db/src/main/resources/ArRecipe.hbm.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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========================================================= - */ - --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="ArRecipe" table="AR_RECIPE"> - <meta attribute="class-description"> - This class describes a AR recipe - </meta> - - <id name="id" type="int" column="id"> - <generator class="native"/> - </id> - - <properties name="uk_ar_recipe" unique="true"> - <property name="modelName" type="string" > - <column name="MODEL_NAME" not-null="true" length="20"/> - </property> - <property name="action" type="string" > - <column name="ACTION" not-null="true" length="40"/> - </property> - <property name="version" type="string"> - <column name="VERSION_STR" not-null="true" length="20"/> - </property> - - </properties> - - <property name="serviceType" type="string" length="45"> - <column name="SERVICE_TYPE" not-null="false" length="45"/> - </property> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="orchestrationUri" type="string"> - <column name="ORCHESTRATION_URI" not-null="true" length="256"/> - </property> - <property name="paramXSD" column="AR_PARAM_XSD" type="string" length="2048"/> - <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> - -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/HeatEnvironment.hbm.xml b/mso-catalog-db/src/main/resources/HeatEnvironment.hbm.xml deleted file mode 100644 index b2c94e8776..0000000000 --- a/mso-catalog-db/src/main/resources/HeatEnvironment.hbm.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" -"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> -<!-- Generated Aug 6, 2015 1:11:38 PM by Hibernate Tools 3.4.0.CR1 --> -<hibernate-mapping> - <class name="org.openecomp.mso.db.catalog.beans.HeatEnvironment" table="HEAT_ENVIRONMENT"> - <meta attribute="class-description"> - This class describes a HEAT Environment - </meta> - <id name="artifactUuid" type="string" column="ARTIFACT_UUID" length="200"> - <generator class="assigned" /> - </id> - <property name="name" type="string" > - <column name="NAME" length="100" not-null="true"/> - </property> - <property name="version" type="string" > - <column name="VERSION" length="20" not-null="true"/> - </property> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="environment" type="text"> - <column name="BODY" not-null="true"/> - </property> - <property name="created" type="timestamp" generated="insert" insert="false" update="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - <property name="artifactChecksum" type="string"> - <column name="ARTIFACT_CHECKSUM" length="200" default="'MANUAL RECORD'" not-null="false"/> - </property> - </class> -</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/HeatFiles.hbm.xml b/mso-catalog-db/src/main/resources/HeatFiles.hbm.xml deleted file mode 100644 index 5a2c4aa537..0000000000 --- a/mso-catalog-db/src/main/resources/HeatFiles.hbm.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-<!-- Generated Mar 31, 2017 3:39:01 PM by Hibernate Tools 3.4.0.CR1 -->
-<hibernate-mapping>
- <class name="org.openecomp.mso.db.catalog.beans.HeatFiles" table="HEAT_FILES">
- <id name="artifactUuid" type="java.lang.String" length="200">
- <column name="ARTIFACT_UUID" />
- <generator class="assigned" />
- </id>
- <property name="description" type="java.lang.String" length="1200">
- <column name="DESCRIPTION" />
- </property>
- <property name="fileName" type="java.lang.String" length="200" not-null="true">
- <column name="NAME" />
- </property>
- <property name="version" type="java.lang.String" length="20" not-null="true">
- <column name="VERSION" />
- </property>
- <property name="fileBody" type="text" not-null="true">
- <column name="BODY" />
- </property>
- <property name="created" type="java.sql.Timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
- <property name="artifactChecksum" type="java.lang.String" length="200" not-null="true">
- <column name="ARTIFACT_CHECKSUM"/>
- </property>
- </class>
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/HeatNestedTemplate.hbm.xml b/mso-catalog-db/src/main/resources/HeatNestedTemplate.hbm.xml deleted file mode 100644 index a2c590f563..0000000000 --- a/mso-catalog-db/src/main/resources/HeatNestedTemplate.hbm.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" > -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="HeatNestedTemplate" table="HEAT_NESTED_TEMPLATE"> - <meta attribute="class-description"> - This class describes a nested HEAT template relationship - </meta> - - <composite-id> - <key-property name="parentTemplateId" column="PARENT_HEAT_TEMPLATE_UUID" type="string" length="200"/> - <key-property name="childTemplateId" column="CHILD_HEAT_TEMPLATE_UUID" type="string" length="200"/> - </composite-id> - - <property name="providerResourceFile" column="PROVIDER_RESOURCE_FILE" type="string" length="100"/> - - </class> - -</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/HeatTemplate.hbm.xml b/mso-catalog-db/src/main/resources/HeatTemplate.hbm.xml deleted file mode 100644 index 2fb64aa20d..0000000000 --- a/mso-catalog-db/src/main/resources/HeatTemplate.hbm.xml +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="HeatTemplate" table="HEAT_TEMPLATE"> - <meta attribute="class-description"> - This class describes a HEAT template - </meta> - - <id name="artifactUuid" type="string" column="ARTIFACT_UUID" length="200"> - <generator class="assigned" /> - </id> - - <property name="templateName" type="string" > - <column name="NAME" length="200" not-null="true"/> - </property> - <property name="version" type="string" > - <column name="VERSION" length="20" not-null="true"/> - </property> - - <property name="templateBody" type="text"> - <column name="BODY" not-null="true"/> - </property> - <property name="timeoutMinutes" column="TIMEOUT_MINUTES" type="int"/> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - <property name="artifactChecksum" type="string"> - <column name="ARTIFACT_CHECKSUM" length="200" default="'MANUAL RECORD'" not-null="true"/> - </property> - <set name="parameters" inverse="true" cascade="all"> - <key column="HEAT_TEMPLATE_ARTIFACT_UUID"/> - <one-to-many class="HeatTemplateParam"/> - </set> - - - </class> - - <class name="HeatTemplateParam" table="HEAT_TEMPLATE_PARAMS"> - <meta attribute="class-description"> - This class describes an input parameter to a heat template - </meta> - - <composite-id> - <key-property name="heatTemplateArtifactUuid" column="HEAT_TEMPLATE_ARTIFACT_UUID" type="string" /> - <key-property name="paramName" column="PARAM_NAME" type="string" /> - </composite-id> - - <properties name="uk_heat_params" unique="true"> - <property name="heatTemplateArtifactUuid" type="string" insert="false" update="false"> - <column name="HEAT_TEMPLATE_ARTIFACT_UUID" not-null="true"/> - </property> - <property name="paramName" type="string" insert="false" update="false"> - <column name="PARAM_NAME" length="100" not-null="true" /> - </property> - </properties> - <property name="required" type="boolean"> - <column name="IS_REQUIRED" not-null="true"/> - </property> - <property name="paramType" column="PARAM_TYPE" type="string" length="20"/> - <property name="paramAlias" column="PARAM_ALIAS" type="string" length="45"/> - </class> - -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/ModelRecipe.hbm.xml b/mso-catalog-db/src/main/resources/ModelRecipe.hbm.xml deleted file mode 100644 index 4a0b5fbf2a..0000000000 --- a/mso-catalog-db/src/main/resources/ModelRecipe.hbm.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="Model" table="MODEL"> - <meta attribute="class-description"> - This class describes a Model that may be orchestrated - </meta> - - <id name="id" type="int" column="id"> - <generator class="native"/> - </id> - - <properties name="uk1_model" unique="true"> - <property name="modelType" type="string"> - <column name="MODEL_TYPE" not-null="true" length="20"/> - </property> - <property name="modelVersionId" type="string"> - <column name="MODEL_VERSION_ID" not-null="true" length="40"/> - </property> - </properties> - <property name="modelInvariantId" column="MODEL_INVARIANT_ID" type="string" length="40"/> - <property name="modelName" type="string"> - <column name="MODEL_NAME" not-null="true" length="40"/> - </property> - <property name="modelVersion" column="MODEL_VERSION" type="string" length="20"/> - <property name="modelCustomizationId" column="MODEL_CUSTOMIZATION_ID" type="string" length="40"/> - <property name="modelCustomizationName" column="MODEL_CUSTOMIZATION_NAME" type="string" length="40"/> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - - <map name="recipes" cascade="all"> - <key column="MODEL_ID"/> - <map-key column="action" type="string"/> - <one-to-many class="ModelRecipe"/> - </map> - </class> - - <class name="ModelRecipe" table="MODEL_RECIPE"> - <meta attribute="class-description"> - This class describes a Model recipe - </meta> - - <id name="id" type="int" column="id"> - <generator class="native"/> - </id> - - <properties name="uk1_model_recipe" unique="true"> - <property name="modelId" type="int"> - <column name="MODEL_ID" not-null="true"/> - </property> - <property name="action" type="string" > - <column name="ACTION" not-null="true" length="40"/> - </property> - </properties> - <property name="schemaVersion" column="SCHEMA_VERSION" type="string" length="20"/> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="orchestrationUri" type="string"> - <column name="ORCHESTRATION_URI" not-null="true" length="256"/> - </property> - <property name="modelParamXSD" column="MODEL_PARAM_XSD" type="string" length="2048"/> - <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml b/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml deleted file mode 100644 index 9081bb8732..0000000000 --- a/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="NetworkRecipe" table="NETWORK_RECIPE"> - <meta attribute="class-description"> - This class describes a Network recipe - </meta> - - <id name="id" type="int" column="id"> - <generator class="native"/> - </id> - - <properties name="uk_network_recipe" unique="true"> - <property name="modelName" type="string" > - <column name="MODEL_NAME" not-null="true" length="20"/> - </property> - <property name="action" type="string" > - <column name="ACTION" not-null="true" length="40"/> - </property> - <property name="version" type="string"> - <column name="VERSION_STR" not-null="true" length="20"/> - </property> - - </properties> - - <property name="serviceType" type="string" length="45"> - <column name="SERVICE_TYPE" not-null="false" length="45"/> - </property> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="orchestrationUri" type="string"> - <column name="ORCHESTRATION_URI" not-null="true" length="256"/> - </property> - <property name="paramXSD" column="NETWORK_PARAM_XSD" type="string" length="2048"/> - <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> - -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/NetworkResource.hbm.xml b/mso-catalog-db/src/main/resources/NetworkResource.hbm.xml deleted file mode 100644 index 41e049ad8d..0000000000 --- a/mso-catalog-db/src/main/resources/NetworkResource.hbm.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="NetworkResource" table="NETWORK_RESOURCE"> - <meta attribute="class-description"> - This class describes a Network Resource - </meta> - - <id name="modelUUID" column="MODEL_UUID" type="string" length="200"/> - <property name="modelName" column="MODEL_NAME" type="string" length="200" not-null="true" /> - <property name="modelInvariantUUID" column="MODEL_INVARIANT_UUID" type="string" length="200"/> - <property name="modelVersion" column="MODEL_VERSION" type="string" length="20"/> - <property name="toscaNodeType" column="TOSCA_NODE_TYPE" type="string" length="200"/> - <property name="neutronNetworkType" column="NEUTRON_NETWORK_TYPE" type="string" length="20"/> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="orchestrationMode" column="ORCHESTRATION_MODE" type="string" length="20"/> - <property name="category" column="RESOURCE_CATEGORY" type="string" length="20"/> - <property name="subCategory" column="RESOURCE_SUB_CATEGORY" type="string" length="20"/> - <property name="heatTemplateArtifactUUID" column="HEAT_TEMPLATE_ARTIFACT_UUID" type="string" length="200" not-null="true" /> - - <property name="aicVersionMin" type="string" > - <column name="AIC_VERSION_MIN" not-null="true" default="2.5" length="20" /> - </property> - <property name="aicVersionMax" type="string"> - <column name="AIC_VERSION_MAX" not-null="false" default="2.5" length="20"/> - </property> - - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - - </class> - -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/NetworkResourceCustomization.hbm.xml b/mso-catalog-db/src/main/resources/NetworkResourceCustomization.hbm.xml deleted file mode 100644 index 236da547e2..0000000000 --- a/mso-catalog-db/src/main/resources/NetworkResourceCustomization.hbm.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping> - <class name="org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization" table="NETWORK_RESOURCE_CUSTOMIZATION"> - <id name="modelCustomizationUuid" column="MODEL_CUSTOMIZATION_UUID" type="java.lang.String" length="200"/> - <property name="networkResourceModelUuid" column="NETWORK_RESOURCE_MODEL_UUID" type="java.lang.String" length="200" not-null="true"/> - <property name="modelInstanceName" type="java.lang.String" length="200" not-null="true"> - <column name="MODEL_INSTANCE_NAME" /> - </property> - <property name="networkTechnology" type="java.lang.String" length="45"> - <column name="NETWORK_TECHNOLOGY" /> - </property> - <property name="networkType" type="java.lang.String" length="45"> - <column name="NETWORK_TYPE" /> - </property> - <property name="networkScope" type="java.lang.String" length="45"> - <column name="NETWORK_SCOPE" /> - </property> - <property name="networkRole" type="java.lang.String" length="200"> - <column name="NETWORK_ROLE" /> - </property> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/Service.hbm.xml b/mso-catalog-db/src/main/resources/Service.hbm.xml deleted file mode 100644 index 2344432056..0000000000 --- a/mso-catalog-db/src/main/resources/Service.hbm.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="Service" table="SERVICE"> - <meta attribute="class-description"> - This class describes a Service that may be orchestrated - </meta> - - <id name="modelUUID" column="MODEL_UUID" type="string" length="200"/> - <property name="modelName" column="MODEL_NAME" type="string" length="200" not-null="true"/> - <property name="version" column="MODEL_VERSION" type="string" length="20" not-null="true"/> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="toscaCsarArtifactUUID" column="TOSCA_CSAR_ARTIFACT_UUID" type="string" length="200" /> - - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - <property name="modelInvariantUUID" type="string"> - <column name="MODEL_INVARIANT_UUID" default="'MANUAL_RECORD'" not-null="true" length="200"/> - </property> - <property name="category" column="SERVICE_CATEGORY" type="string" length="20"/> - <property name="serviceType" column="SERVICE_TYPE" type="string" length="20"/> - <property name="serviceRole" column="SERVICE_ROLE" type="string" length="20"/> - <property name="environmentContext" type="string" length="200"> - <column name="ENVIRONMENT_CONTEXT" default="null"/> - </property> - <property name="workloadContext" type="string" length="200"> - <column name="WORKLOAD_CONTEXT" default="null"/> - </property> - - <map name="recipes" inverse="true" cascade="all"> - <key column="SERVICE_MODEL_UUID"/> - <map-key column="action" type="string"/> - <one-to-many class="ServiceRecipe"/> - </map> - - <set name="serviceResourceCustomizations" inverse="true" cascade="all"> - <key column="SERVICE_MODEL_UUID" not-null="true" /> - <one-to-many class="ServiceToResourceCustomization" /> - </set> - </class> -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/ServiceRecipe.hbm.xml b/mso-catalog-db/src/main/resources/ServiceRecipe.hbm.xml deleted file mode 100644 index bdd54f7832..0000000000 --- a/mso-catalog-db/src/main/resources/ServiceRecipe.hbm.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
- <class name="ServiceRecipe" table="SERVICE_RECIPE">
- <meta attribute="class-description">
- This class describes a Service recipe
- </meta>
-
- <id name="id" type="int" column="id">
- <generator class="native"/>
- </id>
-
- <properties name="uk1_service_recipe" unique="true">
- <property name="serviceModelUUID" type="string" >
- <column name="SERVICE_MODEL_UUID" not-null="true" length="200" />
- </property>
- <property name="action" type="string" >
- <column name="ACTION" not-null="true" length="40" />
- </property>
- </properties>
-
- <property name="orchestrationUri" type="string" column="ORCHESTRATION_URI" not-null="true" length="256"/>
- <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
-
- <property name="action" column="ACTION" type="string" length="40" insert="false" update="false" />
- <property name="version" column="VERSION_STR" type="string" length="20"/>
- <property name="description" column="DESCRIPTION" type="string" length="1200"/>
- <property name="serviceParamXSD" column="SERVICE_PARAM_XSD" type="string" length="2048"/>
- <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/>
- <property name="serviceTimeoutInterim" column="SERVICE_TIMEOUT_INTERIM" type="java.lang.Integer"/>
- </class>
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/ServiceToAllottedResources.hbm.xml b/mso-catalog-db/src/main/resources/ServiceToAllottedResources.hbm.xml deleted file mode 100644 index dca21886be..0000000000 --- a/mso-catalog-db/src/main/resources/ServiceToAllottedResources.hbm.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" > -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="ServiceToAllottedResources" table="SERVICE_TO_ALLOTTED_RESOURCES"> - <meta attribute="class-description"> - This class describes a Service to Allotted Resource Customization relationship - </meta> - - <composite-id> - <key-property name="serviceModelUuid" type="string" > - <column name="SERVICE_MODEL_UUID" length="200" not-null="true"/> - </key-property> - <key-property name="arModelCustomizationUuid" type="string"> - <column name="AR_MODEL_CUSTOMIZATION_UUID" length="200" not-null="true"/> - </key-property> - </composite-id> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> - -</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/ServiceToNetworks.hbm.xml b/mso-catalog-db/src/main/resources/ServiceToNetworks.hbm.xml deleted file mode 100644 index 5e2caa9840..0000000000 --- a/mso-catalog-db/src/main/resources/ServiceToNetworks.hbm.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" > -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="ServiceToNetworks" table="SERVICE_TO_NETWORKS"> - <meta attribute="class-description"> - This class describes a Service to a Network Resource Customization relationship - </meta> - - <composite-id> - <key-property name="serviceModelUuid" type="string"> - <column name="SERVICE_MODEL_UUID" not-null="true" length="200"/> - </key-property> - <key-property name="networkModelCustomizationUuid" type="string"> - <column name="NETWORK_MODEL_CUSTOMIZATION_UUID" not-null="true" length="200"/> - </key-property> - </composite-id> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> - -</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml b/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml deleted file mode 100644 index cd37fc9a99..0000000000 --- a/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
- <class name="ServiceToResourceCustomization" table="SERVICE_TO_RESOURCE_CUSTOMIZATIONS">
- <meta attribute="class-description">
- This class describes a Service To Resource Customization
- </meta>
-
- <composite-id>
- <key-property name="modelType" type="string" column="MODEL_TYPE" length="20" />
- <key-property name="resourceModelCustomizationUUID" type="string" column="RESOURCE_MODEL_CUSTOMIZATION_UUID" length="200" />
- <key-property name="serviceModelUUID" type="string" column="SERVICE_MODEL_UUID" length="200" />
- </composite-id>
- <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
-
- </class>
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/TempNetworkHeatTemplateLookup.hbm.xml b/mso-catalog-db/src/main/resources/TempNetworkHeatTemplateLookup.hbm.xml deleted file mode 100644 index 3a00c89523..0000000000 --- a/mso-catalog-db/src/main/resources/TempNetworkHeatTemplateLookup.hbm.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
-<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
- <class name="TempNetworkHeatTemplateLookup" table="TEMP_NETWORK_HEAT_TEMPLATE_LOOKUP">
- <meta attribute="class-description">
- This class describes a VF Module to HEAT Files Entry
- </meta>
-
- <id name="networkResourceModelName" column="NETWORK_RESOURCE_MODEL_NAME" type="java.lang.String" length="200"/>
-
- <property name="heatTemplateArtifactUuid" column="HEAT_TEMPLATE_ARTIFACT_UUID" type="java.lang.String" length="200" not-null="true"/>
- <property name="aicVersionMin" type="string" >
- <column name="AIC_VERSION_MIN" not-null="true" length="20"/>
- </property>
- <property name="aicVersionMax" type="string" >
- <column name="AIC_VERSION_MAX" not-null="false" length="20"/>
- </property>
-
-
- </class>
-
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/ToscaCsar.hbm.xml b/mso-catalog-db/src/main/resources/ToscaCsar.hbm.xml deleted file mode 100644 index 3529620ec9..0000000000 --- a/mso-catalog-db/src/main/resources/ToscaCsar.hbm.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
- <class name="ToscaCsar" table="TOSCA_CSAR">
- <meta attribute="class-description">
- This class describes a Tosca Csar
- </meta>
-
- <id name="artifactUUID" column="ARTIFACT_UUID" type="string" length="200"/>
- <property name="name" column="NAME" type="string" length="200" not-null="true"/>
- <property name="version" column="VERSION" type="string" length="20" not-null="true"/>
- <property name="artifactChecksum" column="ARTIFACT_CHECKSUM" type="string" length="200" not-null="true"/>
- <property name="url" column="URL" type="string" length="200" not-null="true"/>
- <property name="description" column="DESCRIPTION" type="string" length="1200"/>
-
- <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
-
- <set name="services" inverse="true" cascade="all">
- <key column="TOSCA_CSAR_ARTIFACT_UUID" not-null="true" />
- <one-to-many class="Service" />
- </set>
- </class>
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VfModule.hbm.xml b/mso-catalog-db/src/main/resources/VfModule.hbm.xml deleted file mode 100644 index a08e4d1ce2..0000000000 --- a/mso-catalog-db/src/main/resources/VfModule.hbm.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" -"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> -<!-- Generated Apr 28, 2016 2:44:06 PM by Hibernate Tools 3.4.0.CR1 --> -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="VfModule" table="VF_MODULE"> - - <id name="modelUUID" type="string" column="MODEL_UUID" length="200" /> - - <property name="vnfResourceModelUUId" type="string" column="VNF_RESOURCE_MODEL_UUID" length="200" /> - <property name="modelInvariantUUID" type="string" column="MODEL_INVARIANT_UUID" length="200"/> - <property name="version" type="string" column="MODEL_VERSION" length="20" not-null="true"/> - <property name="modelName" type="string" column="MODEL_NAME" length="200" not-null="true" /> - <property name="description" type="string" column="DESCRIPTION" length="1200"/> - <property name="isBase" type="int" column="IS_BASE" not-null="true"/> - <property name="heatTemplateArtifactUUId" type="string" column="HEAT_TEMPLATE_ARTIFACT_UUID" length="200" not-null="true" /> - <property name="volHeatTemplateArtifactUUId" type="string" column="VOL_HEAT_TEMPLATE_ARTIFACT_UUID" length="200" /> - - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - - </class> -</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/VfModuleCustomization.hbm.xml b/mso-catalog-db/src/main/resources/VfModuleCustomization.hbm.xml deleted file mode 100644 index eb918501f7..0000000000 --- a/mso-catalog-db/src/main/resources/VfModuleCustomization.hbm.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
- <class name="VfModuleCustomization" table="VF_MODULE_CUSTOMIZATION">
-
- <id name="modelCustomizationUuid" type="string" column="MODEL_CUSTOMIZATION_UUID" length="200">
- </id>
-
- <property name="vfModuleModelUuid" column="VF_MODULE_MODEL_UUID" type="java.lang.String" length="200" not-null="true"/>
-
- <property name="volEnvironmentArtifactUuid" type="java.lang.String">
- <column name="VOL_ENVIRONMENT_ARTIFACT_UUID" length="200" not-null="false" />
- </property>
-
- <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
-
- <property name="heatEnvironmentArtifactUuid" type="java.lang.String">
- <column name="HEAT_ENVIRONMENT_ARTIFACT_UUID" length="200" not-null="false" />
- </property>
- <property name="minInstances" type="java.lang.Integer" >
- <column name="MIN_INSTANCES" not-null="false"/>
- </property>
- <property name="maxInstances" type="java.lang.Integer" >
- <column name="MAX_INSTANCES" not-null="false"/>
- </property>
- <property name="initialCount" type="java.lang.Integer" >
- <column name="INITIAL_COUNT" not-null="false"/>
- </property>
- <property name="availabilityZoneCount" type="java.lang.Integer" >
- <column name="AVAILABILITY_ZONE_COUNT" not-null="false"/>
- </property>
- <property name="label" type="java.lang.String" >
- <column name="LABEL" not-null="false" length="200"/>
- </property>
-
- </class>
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VfModuleToHeatFiles.hbm.xml b/mso-catalog-db/src/main/resources/VfModuleToHeatFiles.hbm.xml deleted file mode 100644 index d2c523e413..0000000000 --- a/mso-catalog-db/src/main/resources/VfModuleToHeatFiles.hbm.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" > -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="VfModuleToHeatFiles" table="VF_MODULE_TO_HEAT_FILES"> - <meta attribute="class-description"> - This class describes a VF Module to HEAT Files Entry - </meta> - - <composite-id> - <key-property name="vfModuleModelUuid" column="VF_MODULE_MODEL_UUID" type="java.lang.String" length="200"/> - <key-property name="heatFilesArtifactUuid" column="HEAT_FILES_ARTIFACT_UUID" type="java.lang.String" length="200"/> - </composite-id> - - </class> - -</hibernate-mapping>
\ No newline at end of file diff --git a/mso-catalog-db/src/main/resources/VnfComponent.hbm.xml b/mso-catalog-db/src/main/resources/VnfComponent.hbm.xml deleted file mode 100644 index c629f00960..0000000000 --- a/mso-catalog-db/src/main/resources/VnfComponent.hbm.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="VnfComponent" table="VNF_COMPONENTS"> - <meta attribute="class-description"> - VnfComponent describes a table of components for a VNF_RESOURCE - </meta> - - <composite-id> - <key-property name="vnfId" column="VNF_ID" type="int" /> - <key-property name="componentType" column="COMPONENT_TYPE" type="string" length="20"/> - </composite-id> - - <property name="heatTemplateId" column="HEAT_TEMPLATE_ID" type="int" /> - <property name="heatEnvironmentId" column="HEAT_ENVIRONMENT_ID" type="int" /> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - - </class> - -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml b/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml deleted file mode 100644 index 8bb138a313..0000000000 --- a/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="VnfComponentsRecipe" table="VNF_COMPONENTS_RECIPE"> - <meta attribute="class-description"> - This class describes a VNF Components Recipe - </meta> - - <id name="id" type="int" column="id"> - <generator class="native"/> - </id> - <properties name="uk_vnf_component_recipe" unique="true"> - <property name="vnfType" column="VNF_TYPE" type="string" length="200"/> - <property name="vfModuleModelUUId" column="VF_MODULE_MODEL_UUID" type="string" length="100" not-null="false"/> - <property name="vnfComponentType" type="string"> - <column name="VNF_COMPONENT_TYPE" not-null="true" length="45"/> - </property> - <property name="action" type="string"> - <column name="ACTION" not-null="true" length="40"/> - </property> - <property name="serviceType" column="SERVICE_TYPE" type="string" length="45"/> - <property name="version" column="VERSION" type="string" length="20"/> - </properties> - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - <property name="orchestrationUri" type="string"> - <column name="ORCHESTRATION_URI" not-null="true" length="256"/> - </property> - <property name="paramXSD" column="VNF_COMPONENT_PARAM_XSD" type="string" length="2048"/> - <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml b/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml deleted file mode 100644 index 08570708dd..0000000000 --- a/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="VnfRecipe" table="VNF_RECIPE"> - <meta attribute="class-description"> - This class describes a VNF Recipe - </meta> - - <id name="id" type="int" column="id"> - <generator class="native"/> - </id> - - <properties name="uk_vnf_recipe" unique="true"> - - <property name="vfModuleId" type="string"> - <column name="VF_MODULE_ID" not-null="false" length="100" /> - </property> - <property name="action" type="string"> - <column name="ACTION" not-null="true" length="40" /> - </property> - <property name="version" type="string"> - <column name="VERSION_STR" not-null="true" length="20" /> - </property> - - </properties> - - <property name="vnfType" type="string"> - <column name="VNF_TYPE" not-null="false" length="200" /> - </property> - - <property name="serviceType" type="string"> - <column name="SERVICE_TYPE" not-null="false" length="45" default="null"/> - </property> - - <property name="description" column="DESCRIPTION" type="string" length="1200"/> - - <property name="orchestrationUri" type="string"> - <column name="ORCHESTRATION_URI" not-null="true" length="256"/> - </property> - - <property name="paramXSD" column="VNF_PARAM_XSD" type="string" length="2048"/> - <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - </class> -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/VnfResCustomToVfModuleCustom.hbm.xml b/mso-catalog-db/src/main/resources/VnfResCustomToVfModuleCustom.hbm.xml deleted file mode 100644 index f07af814cb..0000000000 --- a/mso-catalog-db/src/main/resources/VnfResCustomToVfModuleCustom.hbm.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
-<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
- <class name="VnfResCustomToVfModuleCustom" table="VNF_RES_CUSTOM_TO_VF_MODULE_CUSTOM">
- <meta attribute="class-description">
- This class maps two UUIDs
- </meta>
-
- <composite-id>
- <key-property name="vnfResourceCustModelCustomizationUuid" column="VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID" type="java.lang.String" length="200"/>
- <key-property name="vfModuleCustModelCustomizationUuid" column="VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID" type="java.lang.String" length="200"/>
- </composite-id>
-
- <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
-
- </class>
-
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VnfResource.hbm.xml b/mso-catalog-db/src/main/resources/VnfResource.hbm.xml deleted file mode 100644 index 03d1de544c..0000000000 --- a/mso-catalog-db/src/main/resources/VnfResource.hbm.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - -<hibernate-mapping package="org.openecomp.mso.db.catalog.beans"> - <class name="VnfResource" table="VNF_RESOURCE"> - <meta attribute="class-description"> - This class describes a VNF Resource - </meta> - - <id name="modelUuid" type="string" column="MODEL_UUID" length="200"/> - <property name="modelInvariantUuid" type="string" column="MODEL_INVARIANT_UUID" length="200"/> - <property name="version" type="string" column="MODEL_VERSION" length="20" not-null="true"/> - <property name="modelName" type="string" column="MODEL_NAME" length="200"/> - <property name="toscaNodeType" type="string" column="TOSCA_NODE_TYPE" length="200"/> - <property name="description" type="string" column="DESCRIPTION" length="1200"/> - <property name="orchestrationMode" type="string" column="ORCHESTRATION_MODE" length="20" not-null="true"/> - <property name="aicVersionMin" type="string" column="AIC_VERSION_MIN" length="20"/> - <property name="aicVersionMax" type="string" column="AIC_VERSION_MAX" length="20"/> - <property name="category" type="string" column="RESOURCE_CATEGORY" length="20"/> - <property name="subCategory" type="string" column="RESOURCE_SUB_CATEGORY" length="20"/> - <property name="heatTemplateArtifactUUId" type="string" column="HEAT_TEMPLATE_ARTIFACT_UUID" length="200" /> - <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true"> - <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/> - </property> - - <set name="vnfResourceCustomizations" inverse="true" access="field" cascade="all"> - <key column="VNF_RESOURCE_MODEL_UUID" not-null="true" /> - <one-to-many class="VnfResourceCustomization" /> - </set> - - <set name="vfModules" inverse="true" cascade="all"> - <key column="VNF_RESOURCE_MODEL_UUID" not-null="true" /> - <one-to-many class="VfModule" /> - </set> - </class> -</hibernate-mapping> diff --git a/mso-catalog-db/src/main/resources/VnfResourceCustomization.hbm.xml b/mso-catalog-db/src/main/resources/VnfResourceCustomization.hbm.xml deleted file mode 100644 index 78ed9c5ff6..0000000000 --- a/mso-catalog-db/src/main/resources/VnfResourceCustomization.hbm.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
- <class name="VnfResourceCustomization" table="VNF_RESOURCE_CUSTOMIZATION">
- <meta attribute="class-description">
- This class describes a VNF Resource Customization
- </meta>
-
- <id name="modelCustomizationUuid" column="MODEL_CUSTOMIZATION_UUID" type="string" length="200"/>
-
- <property name="modelInstanceName" column="MODEL_INSTANCE_NAME" type="string" length="200" not-null="true"/>
- <property name="minInstances" column="MIN_INSTANCES" type="int" length="11"/>
- <property name="maxInstances" column="MAX_INSTANCES" type="int" length="11"/>
- <property name="availabilityZoneMaxCount" column="AVAILABILITY_ZONE_MAX_COUNT" type="int" length="11"/>
- <property name="nfFunction" column="NF_FUNCTION" type="string" length="200"/>
- <property name="nfType" column="NF_TYPE" type="string" length="200"/>
- <property name="nfRole" column="NF_ROLE" type="string" length="200"/>
- <property name="nfNamingCode" column="NF_NAMING_CODE" type="string" length="200"/>
- <property name="multiStageDesign" column="MULTI_STAGE_DESIGN" type="string" length="200"/>
- <property name="vnfResourceModelUuid" column="VNF_RESOURCE_MODEL_UUID" type="string" length="200" not-null="true" />
-
- <property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
- <column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
- </property>
-
-<!--
- <set name="vfModuleCustomizations" inverse="true" cascade="all">
- <key column="VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID" not-null="true" />
- <one-to-many class="VnfResCustomToVfModuleCustom" />
- </set>
--->
- </class>
-</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/hibernate-catalog-core-mysql.cfg.xml b/mso-catalog-db/src/main/resources/hibernate-catalog-core-mysql.cfg.xml deleted file mode 100644 index dd470a5442..0000000000 --- a/mso-catalog-db/src/main/resources/hibernate-catalog-core-mysql.cfg.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - 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========================================================= - --> - - -<!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> - -<hibernate-configuration> - <session-factory> - <!-- <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property> --> - <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> - <property name="hibernate.show_sql">false</property> - <property name="hibernate.format_sql">true</property> - <property name="connection.datasource">java:jboss/datasources/mso-catalog</property> - <property name="hibernate.c3p0.min_size">5</property> - <property name="hibernate.c3p0.max_size">50</property> - <property name="hibernate.c3p0.timeout">1800</property> - <property name="hibernate.c3p0.max_statements">50</property> - -<!-- <property name="hibernate.hbm2ddl.auto">create</property> --> - <mapping resource="AllottedResource.hbm.xml"/> - <mapping resource="AllottedResourceCustomization.hbm.xml"/> - <mapping resource="HeatEnvironment.hbm.xml"/> - <mapping resource="HeatFiles.hbm.xml"/> - <mapping resource="HeatNestedTemplate.hbm.xml"/> - <mapping resource="HeatTemplate.hbm.xml"/> - <mapping resource="ModelRecipe.hbm.xml"/> - <mapping resource="NetworkRecipe.hbm.xml"/> - <mapping resource="NetworkResource.hbm.xml"/> - <mapping resource="NetworkResourceCustomization.hbm.xml"/> - <mapping resource="Service.hbm.xml"/> - <mapping resource="ServiceRecipe.hbm.xml"/> - <mapping resource="ServiceToAllottedResources.hbm.xml"/> - <mapping resource="ServiceToNetworks.hbm.xml"/> - <mapping resource="ServiceToResourceCustomization.hbm.xml"/> - <mapping resource="TempNetworkHeatTemplateLookup.hbm.xml"/> - <mapping resource="ToscaCsar.hbm.xml"/> - <mapping resource="VfModule.hbm.xml"/> - <mapping resource="VfModuleCustomization.hbm.xml"/> - <mapping resource="VfModuleToHeatFiles.hbm.xml"/> - <mapping resource="VnfComponent.hbm.xml"/> - <mapping resource="VnfComponentsRecipe.hbm.xml"/> - <mapping resource="VnfRecipe.hbm.xml"/> - <mapping resource="VnfResCustomToVfModuleCustom.hbm.xml"/> - <mapping resource="VnfResource.hbm.xml"/> - <mapping resource="VnfResourceCustomization.hbm.xml"/> - </session-factory> -</hibernate-configuration> diff --git a/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..60f8de6c2e --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java @@ -0,0 +1,60 @@ +/*- + * ============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; +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import javax.sql.DataSource; + +@Configuration +@Profile({"test","local"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + return new MariaDB4jSpringService(); + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); + } +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java b/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java new file mode 100644 index 0000000000..6ee88e407d --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java @@ -0,0 +1,48 @@ +/*- + * ============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; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +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"}) +@EnableJpaRepositories("org.onap.so.db.catalog.data.repository") +@EntityScan("org.onap.so.db.catalog.beans") +@Profile("test") +public class TestApplication { + private static final String LOGS_DIR = "logs_dir"; + + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/catdb/"); + } + } + + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + setLogsDir(); + } +} 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 new file mode 100644 index 0000000000..7a9fc19fcb --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java @@ -0,0 +1,53 @@ +/*- + * ============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 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; +import org.onap.so.db.catalog.data.repository.BuildingBlockDetailRepository; +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 BuildingBlockDetailTest { + @Autowired + private BuildingBlockDetailRepository buildingBlockDetailRepository; + + @Test + public void BuildingBlockDetailSingleLookupValidationTest() { + String buildingBlockName = "AssignServiceInstanceBB"; + + BuildingBlockDetail buildingBlockDetail = buildingBlockDetailRepository.findOneByBuildingBlockName(buildingBlockName); + assertEquals(buildingBlockName, buildingBlockDetail.getBuildingBlockName()); + assertEquals(ResourceType.SERVICE, buildingBlockDetail.getResourceType()); + assertEquals(OrchestrationAction.ASSIGN, buildingBlockDetail.getTargetAction()); + } +} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java index c99a714b11..b5d6271f7c 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.test; +package org.onap.so.db.catalog; import static org.junit.Assert.*; @@ -29,8 +29,8 @@ import java.util.List; import org.junit.Test; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioningComparator; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; +import org.onap.so.db.catalog.utils.MavenLikeVersioningComparator; +import org.onap.so.db.catalog.utils.MavenLikeVersioning; public class MavenVersioningTest { @@ -153,7 +153,7 @@ public class MavenVersioningTest { MavenLikeVersioning test12 = new MavenLikeVersioning(); test12.setVersion("2.0"); - List<MavenLikeVersioning> list= new LinkedList<>(); + List<MavenLikeVersioning> list= new LinkedList<MavenLikeVersioning>(); list.add(test1); list.add(test2); list.add(test3); @@ -167,7 +167,7 @@ public class MavenVersioningTest { list.add(test11); list.add(test12); - list.sort(new MavenLikeVersioningComparator()); + Collections.sort(list,new MavenLikeVersioningComparator()); //Collections.reverse(list); assertTrue(list.get(0).getVersion().equals("0.02")); assertTrue(list.get(1).getVersion().equals("1.1")); 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 new file mode 100644 index 0000000000..55c5c8351b --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java @@ -0,0 +1,47 @@ +/*- + * ============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 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; +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 NetworkTest { + @Autowired + private NetworkResourceRepository networkRepo; + + @Test + public void BuildingBlockDetailSingleLookupValidationTest() { + NetworkResource latestNetwork = networkRepo.findFirstByModelNameOrderByModelVersionDesc("CONTRAIL30_GNDIRECT"); + assertEquals("10b36f65-f4e6-4be6-ae49-9596dc1c47fz",latestNetwork.getModelUUID()); + } +} 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 new file mode 100644 index 0000000000..52cac88402 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java @@ -0,0 +1,54 @@ +/*- + * ============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 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; +import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; +import org.onap.so.db.catalog.beans.ResourceType; +import org.onap.so.db.catalog.data.repository.OrchestrationStatusStateTransitionDirectiveRepository; +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 OrchestrationStatusStateTransitionDirectiveTest { + @Autowired + private OrchestrationStatusStateTransitionDirectiveRepository orchestrationStatusStateTransitionDirectiveRepository; + + @Test + public void OrchestrationStatusTransitionDBSingleLookupValidationTest() { + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = orchestrationStatusStateTransitionDirectiveRepository.findOneByResourceTypeAndOrchestrationStatusAndTargetAction(ResourceType.SERVICE, OrchestrationStatus.ASSIGNED, OrchestrationAction.ASSIGN); + assertEquals(ResourceType.SERVICE, orchestrationStatusStateTransitionDirective.getResourceType()); + assertEquals(OrchestrationStatus.ASSIGNED, orchestrationStatusStateTransitionDirective.getOrchestrationStatus()); + assertEquals(OrchestrationAction.ASSIGN, orchestrationStatusStateTransitionDirective.getTargetAction()); + assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, orchestrationStatusStateTransitionDirective.getFlowDirective()); + } +} 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 new file mode 100644 index 0000000000..0ecaa5fbba --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java @@ -0,0 +1,79 @@ +/*- + * ============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 static org.junit.Assert.assertEquals; + +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; +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 ServiceTest { + @Autowired + private ServiceRepository serviceRepo; + + @Test + public void Find_LatestService_Test() { + Service latestVersionService = serviceRepo.findFirstByModelNameOrderByModelVersionDesc("MSOTADevInfra_vSAMP10a_Service"); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002675",latestVersionService.getModelUUID()); + } + + + @Test + public void Find_LatestService_Test_2() { + Service latestVersionService = serviceRepo.findByModelNameOrderByModelVersionDesc("MSOTADevInfra_vSAMP10a_Service"); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002675",latestVersionService.getModelUUID()); + } + + + @Test + public void Find_LatestService_Test_Invariant_UUID() { + List<Service> latestVersionService = serviceRepo.findByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002675",latestVersionService.get(0).getModelUUID()); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002674",latestVersionService.get(1).getModelUUID()); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002673",latestVersionService.get(2).getModelUUID()); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002672",latestVersionService.get(3).getModelUUID()); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002671",latestVersionService.get(4).getModelUUID()); + } + + @Test + public void Find_LatestService_Test_4() { + Service latestVersionService = serviceRepo.findOneByModelUUIDOrderByModelVersionDesc("5df8b6de-2083-11e7-93ae-92361f002671"); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002671",latestVersionService.getModelUUID()); + } + + @Test + public void Find_LatestService_Test_5() { + Service latestVersionService = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002675",latestVersionService.getModelUUID()); + } +} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/TempNetworkHeatTemplateLookupTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java index b0ccfdd781..b09ec7193d 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/TempNetworkHeatTemplateLookupTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java @@ -1,50 +1,50 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
-
-/**
- */
-
-public class TempNetworkHeatTemplateLookupTest {
-
- @Test
- public final void tempNetworkHeatTemplateLookupDataTest() {
- TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup();
- tempNetworkHeatTemplateLookup.setAicVersionMax("aicVersionMax");
- assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMax().equalsIgnoreCase("aicVersionMax"));
- tempNetworkHeatTemplateLookup.setAicVersionMin("aicVersionMin");
- assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMin().equalsIgnoreCase("aicVersionMin"));
- tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid");
- assertTrue(tempNetworkHeatTemplateLookup.getHeatTemplateArtifactUuid()
- .equalsIgnoreCase("heatTemplateArtifactUuid"));
- tempNetworkHeatTemplateLookup.setNetworkResourceModelName("networkResourceModelName");
- assertTrue(tempNetworkHeatTemplateLookup.getNetworkResourceModelName()
- .equalsIgnoreCase("networkResourceModelName"));
-// assertTrue(tempNetworkHeatTemplateLookup.toString() != null);
-
- }
-
-}
+/*- + * ============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.assertTrue; + +import org.junit.Test; +import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup; + +/** + */ + +public class TempNetworkHeatTemplateLookupTest { + + @Test + public final void tempNetworkHeatTemplateLookupDataTest() { + TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup(); + tempNetworkHeatTemplateLookup.setAicVersionMax("aicVersionMax"); + assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMax().equalsIgnoreCase("aicVersionMax")); + tempNetworkHeatTemplateLookup.setAicVersionMin("aicVersionMin"); + assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMin().equalsIgnoreCase("aicVersionMin")); + tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid"); + assertTrue(tempNetworkHeatTemplateLookup.getHeatTemplateArtifactUuid() + .equalsIgnoreCase("heatTemplateArtifactUuid")); + tempNetworkHeatTemplateLookup.setNetworkResourceModelName("networkResourceModelName"); + assertTrue(tempNetworkHeatTemplateLookup.getNetworkResourceModelName() + .equalsIgnoreCase("networkResourceModelName")); +// assertTrue(tempNetworkHeatTemplateLookup.toString() != null); + + } + +} 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 new file mode 100644 index 0000000000..44e7a03855 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java @@ -0,0 +1,57 @@ +/*- + * ============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 static org.junit.Assert.assertEquals; + +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; +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 VFModuleTest { + @Autowired + private VFModuleRepository vfModuleRepo; + + @Test + public void VFModule_Versioned_LookUp() { + VfModule latestModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc("vSAMP10aDEV::PCM::module-1"); + assertEquals("066de97e-253e-11e7-93ae-92361f002675",latestModule.getModelUUID()); + } + + @Test + public void VFModule_Versioned_LookUp_LIst() { + List<VfModule> moduleList = vfModuleRepo.findByModelInvariantUUIDOrderByModelVersionDesc("64efd51a-2544-11e7-93ae-92361f002671"); + assertEquals("066de97e-253e-11e7-93ae-92361f002675",moduleList.get(0).getModelUUID()); + assertEquals("066de97e-253e-11e7-93ae-92361f002674",moduleList.get(1).getModelUUID()); + assertEquals("066de97e-253e-11e7-93ae-92361f002673",moduleList.get(2).getModelUUID()); + } +} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java index 57bf292dd8..44439ede22 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * 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. @@ -18,17 +18,23 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.beans; +package org.onap.so.db.catalog.beans; -import static org.hamcrest.CoreMatchers.isA; -import static org.mockito.Matchers.eq; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.onap.so.openpojo.rules.HasAnnotationMatcher.hasAnnotation; +import static org.onap.so.openpojo.rules.HasAnnotationPropertyWithValueMatcher.hasAnnotationPropertyWithValue; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Temporal; -import org.hamcrest.CoreMatchers; -import org.hamcrest.Matcher; import org.junit.Test; -import org.openecomp.mso.openpojo.rules.EqualsAndHashCodeTester; -import org.openecomp.mso.openpojo.rules.HasToStringRule; -import org.openecomp.mso.openpojo.rules.ToStringTester; +import org.onap.so.openpojo.rules.CustomSetterMustExistRule; +import org.onap.so.openpojo.rules.EqualsAndHashCodeTester; +import org.onap.so.openpojo.rules.HasEqualsAndHashCodeRule; +import org.onap.so.openpojo.rules.HasToStringRule; +import org.onap.so.openpojo.rules.ToStringTester; import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.PojoClassFilter; @@ -37,8 +43,13 @@ import com.openpojo.reflection.filters.FilterNonConcrete; import com.openpojo.reflection.filters.FilterPackageInfo; import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.BusinessKeyMustExistRule; import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.rule.impl.NoNestedClassRule; +import com.openpojo.validation.rule.impl.NoPrimitivesRule; +import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule; +import com.openpojo.validation.rule.impl.NoStaticExceptFinalRule; +import com.openpojo.validation.rule.impl.SerializableMustHaveSerialVersionUIDRule; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; @@ -53,20 +64,29 @@ public class BeansTest { @Test public void pojoStructure() { - test("org.openecomp.mso.db.catalog.beans"); + test("org.onap.so.db.catalog.beans"); + test("org.onap.so.db.catalog.beans.macro"); } private void test(String pojoPackage) { Validator validator = ValidatorBuilder.create() .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) + .with(new NoPrimitivesRule()) + .with(new NoNestedClassRule()) + .with(new NoStaticExceptFinalRule()) + .with(new SerializableMustHaveSerialVersionUIDRule()) .with(new HasToStringRule()) - + .with(new EqualsAndHashCodeTester()) + .with(new NoPublicFieldsExceptStaticFinalRule()) + .with(new CustomSetterMustExistRule().exclude( + allOf(hasAnnotationPropertyWithValue(Column.class, "updatable", equalTo(false)), hasAnnotation(GeneratedValue.class)), + hasAnnotation(Temporal.class))) .with(new SetterTester()) .with(new GetterTester()) .with(new ToStringTester()) - .with(new EqualsAndHashCodeTester().onlyDeclaredMethods()) + .with(new HasEqualsAndHashCodeRule()) + .build(); diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecordNotFoundExceptionTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java index dac5fb7f9e..506a6b73c9 100644 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecordNotFoundExceptionTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.db.catalog.test; +package org.onap.so.db.catalog.test; import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.utils.RecordNotFoundException; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.utils.RecordNotFoundException; import java.util.ArrayList; import java.util.List; diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManagerTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManagerTest.java deleted file mode 100644 index 42b93b1949..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManagerTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog; - -import org.junit.Test; -import org.mockito.Mock; -import org.openecomp.mso.db.catalog.CatalogDbSessionFactoryManager; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.*; - - -public class CatalogDbSessionFactoryManagerTest { - @Test - public void testgetHibernateConfigFile() { - CatalogDbSessionFactoryManager catalogDbSessionFactoryManager = new CatalogDbSessionFactoryManager(); - System.setProperty("mso.db", "MYSQL"); - assertNotNull(catalogDbSessionFactoryManager.getHibernateConfigFile()); - } - - @Test - public void testgetHibernateConfigFileNonMSODB() { - CatalogDbSessionFactoryManager catalogDbSessionFactoryManager = new CatalogDbSessionFactoryManager(); - System.setProperty("mso.db", "test"); - assertNull(catalogDbSessionFactoryManager.getHibernateConfigFile()); - } -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/AllottedResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/AllottedResourceCustomizationTest.java deleted file mode 100644 index 101cd5ed0a..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/AllottedResourceCustomizationTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog.test; - -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.AllottedResource; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.sql.Timestamp; - -public class AllottedResourceCustomizationTest { - @Test - public void test(){ - AllottedResource allottedResource = new AllottedResource(); - allottedResource.setModelUuid("ModelUuid"); - allottedResource.setCreated(new Timestamp(System.currentTimeMillis())); - allottedResource.setModelVersion("ModelVersion"); - allottedResource.setDescription("Description"); - allottedResource.setModelInvariantUuid("ModelInvariantUuid"); - allottedResource.setModelName("ModelName"); - allottedResource.setSubcategory("Subcategory"); - allottedResource.setToscaNodeType("ToscaNodeType"); - allottedResource.setVersion("Version"); - - AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization(); - allottedResourceCustomization.setCreated(new Timestamp(System.currentTimeMillis())); - allottedResourceCustomization.setAllottedResource(allottedResource); - allottedResourceCustomization.setVersion("Version"); - allottedResourceCustomization.setArModelUuid("ArModelUuid"); - allottedResourceCustomization.setMaxInstances(100); - allottedResourceCustomization.setMinInstances(1); - allottedResourceCustomization.setModelCustomizationUuid("ModelCustomizationUuid"); - allottedResourceCustomization.setModelInstanceName("ModelInstanceName"); - allottedResourceCustomization.setNfFunction("NfFunction"); - allottedResourceCustomization.setNfNamingCode("NfNamingCode"); - allottedResourceCustomization.setNfRole("NfRole"); - allottedResourceCustomization.setNfType("NfType"); - allottedResourceCustomization.setTargetNetworkRole("TargetNetworkRole"); - allottedResourceCustomization.setProvidingServiceModelUuid("ProvidingServiceModelUuid"); - allottedResourceCustomization.setProvidingServiceModelInvariantUuid("ProvidingServiceModelInvariantUuid"); - allottedResourceCustomization.setProvidingServiceModelName("ProvidingServiceModelName"); - - assertNotNull(allottedResource.getModelUuid()); - assertNotNull(allottedResource.getCreated()); - assertNotNull(allottedResource.getModelVersion()); - assertNotNull(allottedResource.getDescription()); - assertNotNull(allottedResource.getModelInvariantUuid()); - assertNotNull(allottedResource.getModelName()); - assertNotNull(allottedResource.getSubcategory()); - assertNotNull(allottedResource.getToscaNodeType()); - assertNotNull(allottedResource.getVersion()); - - assertNotNull(allottedResourceCustomization.getAllottedResource()); - assertNotNull(allottedResourceCustomization.getVersion()); - assertNotNull(allottedResourceCustomization.getCreated()); - assertNotNull(allottedResourceCustomization.getArModelUuid()); - assertNotNull(allottedResourceCustomization.getMaxInstances()); - assertNotNull(allottedResourceCustomization.getMinInstances()); - assertNotNull(allottedResourceCustomization.getModelCustomizationUuid()); - assertNotNull(allottedResourceCustomization.getModelInstanceName()); - assertNotNull(allottedResourceCustomization.getNfFunction()); - assertNotNull(allottedResourceCustomization.getNfNamingCode()); - assertNotNull(allottedResourceCustomization.getNfRole()); - assertNotNull(allottedResourceCustomization.getNfType()); - assertNotNull(allottedResourceCustomization.getTargetNetworkRole()); - assertNotNull(allottedResourceCustomization.getProvidingServiceModelUuid()); - assertNotNull(allottedResourceCustomization.getProvidingServiceModelInvariantUuid()); - assertNotNull(allottedResourceCustomization.getProvidingServiceModelName()); - } -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java deleted file mode 100644 index b98fb438dc..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java +++ /dev/null @@ -1,6155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.hibernate.HibernateException; -import org.hibernate.NonUniqueResultException; -import org.hibernate.Query; -import org.hibernate.Session; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.*; -import org.openecomp.mso.db.catalog.utils.RecordNotFoundException; - -import mockit.Mock; -import mockit.MockUp; - -public class CatalogDatabaseTest { - - CatalogDatabase cd = null; - @Rule - public ExpectedException thrown = ExpectedException.none(); - private MockUp<CatalogDatabase> mockCd = null; - private MockUp<Session> mockedSession = null; - private MockUp<Query> mockUpQuery = null; - private MockUp<Query> mockUpQuery2 = null; - private MockUp<Query> mockUpQuery3 = null; - private MockUp<Query> mockUpQuery4 = null; - @Before - public void setup(){ - cd = CatalogDatabase.getInstance(); - } - - - @After - public void tearDown() { - if (mockCd!=null) { mockCd.tearDown(); mockCd = null; } - if (mockedSession!=null) { mockedSession.tearDown(); mockedSession = null; } - if (mockUpQuery!=null) { mockUpQuery.tearDown(); mockUpQuery = null; } - if (mockUpQuery2!=null) { mockUpQuery2.tearDown(); mockUpQuery2 = null; } - if (mockUpQuery3!=null) { mockUpQuery3.tearDown(); mockUpQuery3 = null; } - if (mockUpQuery4!=null) { mockUpQuery4.tearDown(); mockUpQuery4 = null; } - } - - - - @Test - public void getAllHeatTemplatesTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - HeatTemplate heatTemplate = new HeatTemplate(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - List <HeatTemplate> list = cd.getAllHeatTemplates(); - assertEquals(list.size(), 1); - - - } - - @Test - public void getHeatTemplateByIdTest(){ - - mockedSession = new MockUp<Session>() { - @Mock - public Object get(Class cls, Serializable id) { - HeatTemplate heatTemplate = new HeatTemplate(); - heatTemplate.setAsdcUuid("123-uuid"); - return heatTemplate; - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplate(10); - assertEquals("123-uuid", ht.getAsdcUuid()); - - - } - - @Test - public void getHeatTemplateByNameEmptyListTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - HeatTemplate heatTemplate = new HeatTemplate(); - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplate("heat123"); - assertEquals(null, ht); - - - } - - @Test - public void getHeatTemplateByNameTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - HeatTemplate heatTemplate1 = new HeatTemplate(); - heatTemplate1.setAsdcUuid("123-uuid"); - heatTemplate1.setVersion("1.2"); - HeatTemplate heatTemplate2 = new HeatTemplate(); - heatTemplate2.setAsdcUuid("456-uuid"); - heatTemplate2.setVersion("1.3"); - return Arrays.asList(heatTemplate1, heatTemplate2); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplate("heat123"); - assertEquals("456-uuid", ht.getAsdcUuid()); - - - } - - @Test - public void getHeatTemplateByTemplateNameTest() { - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - HeatTemplate heatTemplate = new HeatTemplate(); - heatTemplate.setAsdcUuid("1234-uuid"); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplate("heat123","v2"); - assertEquals("1234-uuid", ht.getAsdcUuid()); - - - } - - @Test - public void getHeatTemplateByTemplateNameEmptyResultTest() { - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplate("heat123","v2"); - assertEquals(null, ht); - - - } - - @Test - public void getHeatTemplateByArtifactUuidException(){ - - mockedSession = new MockUp<Session>() { - @Mock - public Object get(Class cls, Serializable id) { - HeatTemplate heatTemplate = new HeatTemplate(); - heatTemplate.setAsdcUuid("123-uuid"); - return heatTemplate; - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplateByArtifactUuid("123"); - assertEquals("123-uuid", ht.getAsdcUuid()); - - - } - - @Test - public void getHeatTemplateByArtifactUuidTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - HeatTemplate heatTemplate = new HeatTemplate(); - heatTemplate.setAsdcUuid("123-uuid"); - return heatTemplate; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); - assertEquals("123-uuid", ht.getAsdcUuid()); - - - } - - @Test - public void getHeatTemplateByArtifactUuidNullTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); - assertNull(ht); - - - } - - @Test - public void getHeatTemplateByArtifactUuidHibernateErrorTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); - - - } - - @Test - public void getHeatTemplateByArtifactUuidNonUniqueResultTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new NonUniqueResultException(2); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); - - - } - - @Test - public void getHeatTemplateByArtifactUuidGenericExceptionTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid"); - - - } - - @Test - public void getParametersForHeatTemplateTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - HeatTemplate heatTemplate = new HeatTemplate(); - heatTemplate.setAsdcUuid("1234-uuid"); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); - assertEquals(1, htList.size()); - - - } - - @Test - public void getParametersForHeatTemplateHibernateExceptionTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); - - - - } - - @Test - public void getParametersForHeatTemplateExceptionTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3"); - - - } - - @Test - public void getHeatEnvironmentByArtifactUuidTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - HeatEnvironment heatEnvironment = new HeatEnvironment(); - heatEnvironment.setArtifactUuid("123-uuid"); - return heatEnvironment; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123"); - assertEquals("123-uuid", he.getArtifactUuid()); - - - } - - @Test - public void getHeatEnvironmentByArtifactUuidHibernateExceptionTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123"); - - - } - - @Test - public void getHeatEnvironmentByArtifactUuidExceptionTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123"); - - - } - - @Test - public void getHeatEnvironmentByArtifactUuidNonUniqueTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new org.hibernate.NonUniqueResultException(2); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123"); - assertNull(he); - - } - - @Test - public void getServiceByInvariantUUIDTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<Service> list() { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return Arrays.asList(service); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Service service = cd.getServiceByInvariantUUID("123"); - assertEquals("123-uuid", service.getModelUUID()); - - - } - - @Test - public void getServiceByInvariantUUIDEmptyResultTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<Service> list() { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Service service = cd.getServiceByInvariantUUID("123"); - assertEquals(null, service); - - - } - - @Test - public void getServiceTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return service; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Service service = cd.getService("123"); - assertEquals("123-uuid", service.getModelUUID()); - - - } - - @Test - public void getServiceNullTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Service service = cd.getService("123"); - assertNull(service); - - - } - - @Test - public void getServiceNoUniqueResultTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - Service service = cd.getService("123"); - - - } - - @Test - public void getServiceHibernateExceptionTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - Service service = cd.getService("123"); - - - } - - @Test - public void getServiceExceptionTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception("generic exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - Service service = cd.getService("123"); - - - } - - @Test - public void getServiceByModelUUIDTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return service; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - Service service = cd.getServiceByModelUUID("123"); - assertEquals("123-uuid", service.getModelUUID()); - - - } - - @Test - public void getService2Test(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return service; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HashMap<String, String> map = new HashMap<>(); - map.put("serviceNameVersionId", "v2"); - Service service = cd.getService(map, "123"); - - assertEquals("123-uuid", service.getModelUUID()); - - map.remove("serviceNameVersionId"); - service = cd.getService(map, "123"); - assertNotNull(service); - } - - @Test - public void getService2NonUniqueTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new org.hibernate.NonUniqueResultException(2); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HashMap<String, String> map = new HashMap<>(); - map.put("serviceNameVersionId", "v2"); - - thrown.expect(org.hibernate.NonUniqueResultException.class); - Service service = cd.getService(map, "123"); - } - - @Test - public void getService2HibernateExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new org.hibernate.HibernateException("test case"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HashMap<String, String> map = new HashMap<>(); - map.put("serviceNameVersionId", "v2"); - - thrown.expect(org.hibernate.HibernateException.class); - Service service = cd.getService(map, "123"); - } - - @Test - public void getService2ExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new NullPointerException(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HashMap<String, String> map = new HashMap<>(); - map.put("serviceNameVersionId", "v2"); - - thrown.expect(NullPointerException.class); - Service service = cd.getService(map, "123"); - } - - @Test - public void getService2NullTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - HashMap<String, String> map = new HashMap<>(); - map.put("serviceNameVersionId", "v2"); - - Service service = cd.getService(map, "123"); - assertNull(service); - } - - @Test - public void getServiceByModelNameTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<Service> list() throws Exception { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return Arrays.asList(service); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Service service = cd.getServiceByModelName("123"); - assertEquals("123-uuid", service.getModelUUID()); - - - } - - @Test - public void getServiceByModelNameEmptyTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<Service> list() throws Exception { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Service service = cd.getServiceByModelName("123"); - assertEquals(null, service); - - - } - - @Test - public void getServiceByVersionAndInvariantIdTest() throws Exception{ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return service; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - Service service = cd.getServiceByVersionAndInvariantId("123","tetwe"); - assertEquals("123-uuid", service.getModelUUID()); - - - } - - @Test - public void getServiceByVersionAndInvariantIdNullTest() throws Exception{ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - Service service = cd.getServiceByVersionAndInvariantId("123","tetwe"); - assertNull(service); - - - } - - @Test - public void getServiceByVersionAndInvariantIdNonUniqueResultTest() throws Exception{ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - Service service = cd.getServiceByVersionAndInvariantId("123","tetwe"); - - - } - - @Test - public void getServiceRecipeTestException() throws Exception{ - thrown.expect(Exception.class); - ServiceRecipe ht = cd.getServiceRecipe("123","tetwe"); - } - - @Test - public void getServiceRecipeByServiceModelUuidTest() { - mockUpQuery = new MockUp<Query>() { - @Mock - public List<ServiceRecipe> list() throws Exception { - ServiceRecipe serviceRecipe = new ServiceRecipe(); - serviceRecipe.setId(1); - return Arrays.asList(serviceRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe"); - assertEquals(1, serviceRecipe.getId()); - - serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123", null); - assertEquals(1, serviceRecipe.getId()); - } - - @Test - public void getServiceRecipeByServiceModelUuidEmptyTest() { - mockUpQuery = new MockUp<Query>() { - @Mock - public List<ServiceRecipe> list() throws Exception { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe"); - assertEquals(null, serviceRecipe); - - - } - - @Test - public void getServiceRecipesTestException() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<ServiceRecipe> list() { - ServiceRecipe serviceRecipe = new ServiceRecipe(); - serviceRecipe.setId(1); - return Arrays.asList(serviceRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123"); - assertEquals(1, serviceRecipes.size()); - - - } - - @Test - public void getServiceRecipesEmptyTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<ServiceRecipe> list() { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123"); - assertEquals(0, serviceRecipes.size()); - - - } - - @Test - public void getVnfComponentTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - VnfComponent vnfComponent = new VnfComponent(); - vnfComponent.setHeatTemplateId(1234); - return vnfComponent; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfComponent ht = cd.getVnfComponent(123,"vnf"); - assertEquals(new Integer(1234), ht.getHeatTemplateId()); - } - - @Test - public void getVnfComponentNullTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfComponent ht = cd.getVnfComponent(123,"vnf"); - assertNull(ht); - } - - @Test - public void getVnfComponentNonUniqueTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new org.hibernate.NonUniqueResultException(2); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(org.hibernate.NonUniqueResultException.class); - VnfComponent ht = cd.getVnfComponent(123,"vnf"); - } - - @Test - public void getVnfComponentHibernateExceptionTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new org.hibernate.HibernateException("test case"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(org.hibernate.HibernateException.class); - VnfComponent ht = cd.getVnfComponent(123,"vnf"); - } - - @Test - public void getVnfComponentExceptionTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new NullPointerException(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(NullPointerException.class); - VnfComponent ht = cd.getVnfComponent(123,"vnf"); - } - - @Test - public void getVnfResourceTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfResource> list() { - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid("123-uuid"); - return Arrays.asList(vnfResource); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfResource vnfResource = cd.getVnfResourceByType("vnf"); - assertEquals("123-uuid", vnfResource.getModelUuid()); - - - } - - @Test - public void getVnfResourceEmptyTest() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfResource> list() { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfResource vnfResource = cd.getVnfResourceByType("vnf"); - assertEquals(null, vnfResource); - - - } - - @Test - public void getVnfResourceByTypeTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid("123-uuid"); - return vnfResource; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfResource vnfResource = cd.getVnfResource("vnf","3992"); - assertEquals("123-uuid", vnfResource.getModelUuid()); - - - } - - @Test - public void getVnfResourceNURExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - VnfResource vnfResource = cd.getVnfResource("vnf","3992"); - - - } - - @Test - public void getVnfResourceHibernateExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - VnfResource vnfResource = cd.getVnfResource("vnf","3992"); - - - } - - @Test - public void getVnfResourceExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - VnfResource vnfResource = cd.getVnfResource("vnf","3992"); - - - } - - @Test - public void getVnfResourceByModelCustomizationIdTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid("123-uuid"); - return vnfResource; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); - assertEquals("123-uuid",vnfResource.getModelUuid()); - - - } - - @Test - public void getVnfResourceByModelCustomizationIdNullTest() { - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() throws Exception { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); - assertNull(vnfResource); - } - - @Test - public void getVnfResourceByModelCustomizationIdNURExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); - - - } - - @Test - public void getVnfResourceByModelCustomizationIdHibernateExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); - } - - @Test - public void getVnfResourceByModelCustomizationIdExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new NullPointerException(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NullPointerException.class); - VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992"); - } - - - @Test - public void getServiceRecipeTest2() throws Exception{ - mockUpQuery = new MockUp<Query>() { - @Mock - public List <ServiceRecipe> list() throws Exception { - ServiceRecipe serviceRecipe = new ServiceRecipe(); - serviceRecipe.setServiceModelUUID("123-uuid"); - return Arrays.asList(serviceRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - ServiceRecipe ht = cd.getServiceRecipe(1001,"3992"); - assertEquals("123-uuid", ht.getServiceModelUUID()); - - ht = cd.getServiceRecipe(1001, null); - assertEquals("123-uuid", ht.getServiceModelUUID()); - - } - - @Test - public void getServiceRecipeTest2Exception() throws Exception{ - thrown.expect(Exception.class); - ServiceRecipe ht = cd.getServiceRecipe(1001,"3992"); - } - - @Test - public void getVnfResourceCustomizationByModelCustomizationNameTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfResourceCustomization> list() throws Exception { - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setVnfResourceModelUUID("123-uuid"); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234"); - assertEquals("123-uuid", vnf.getVnfResourceModelUUID()); - - - } - - @Test - public void getVnfResourceCustomizationByModelCustomizationNameEmptyTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfResourceCustomization> list() throws Exception { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234"); - assertEquals(null, vnf); - - - } - - @Test - public void getVnfResourceByModelInvariantIdTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult(){ - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid("123-uuid"); - return vnfResource; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); - assertEquals("123-uuid", vnf.getModelUuid()); - - - } - - @Test - public void getVnfResourceByModelInvariantIdNURExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult(){ - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); - - - } - - @Test - public void getVnfResourceByModelInvariantIdHibernateExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult(){ - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); - - - } - - @Test - public void getVnfResourceByModelInvariantIdExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234"); - - - } - - @Test - public void getVnfResourceByIdTestException(){ - mockUpQuery = new MockUp<Query>() { - int id = 0; - @Mock - public Query setParameter(String name, Object val) { - id = (Integer)val; - return this.getMockInstance(); - } - - @Mock - public List<VnfResource> list() throws Exception { - if (id==0) return new ArrayList<VnfResource>(); - VnfResource vm = new VnfResource(); - vm.setModelInvariantUuid(Integer.toString(id)); - return Arrays.asList(vm); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResource vnf = cd.getVnfResourceById(19299); - assertEquals("19299", vnf.getModelInvariantUuid()); - - vnf = cd.getVnfResourceById(0); - assertNull(vnf); - } - - @Test - public void getVfModuleModelName(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VfModule> list() throws Exception { - VfModule vfModule = new VfModule(); - vfModule.setModelUUID("123-uuid"); - return Arrays.asList(vfModule); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VfModule vfModule = cd.getVfModuleModelName("vfmodule"); - assertEquals("123-uuid", vfModule.getModelUUID()); - - - } - - @Test - public void getVfModuleModelNameExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VfModule> list() throws Exception { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VfModule vfModule = cd.getVfModuleModelName("vfmodule"); - assertEquals(null, vfModule); - - - } - - @Test - public void getVfModuleModelNameTest() { - mockUpQuery = new MockUp<Query>() { - String modelVersion = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("model_version")) modelVersion = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if (modelVersion==null || modelVersion.equals("nil")) { - return null; - } - VfModule vfModule = new VfModule(); - vfModule.setModelUUID("123-uuid"); - return vfModule; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); - assertEquals("123-uuid", vfModule.getModelUUID()); - - vfModule = cd.getVfModuleModelName("tetes","nil"); - assertNull(vfModule); - } - - @Test - public void getVfModuleModelNameNURExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); - - - } - - @Test - public void getVfModuleModelNameHibernateExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); - - - } - - @Test - public void getVfModuleModelNameGenericExceptionTest() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl"); - - - } - - @Test - public void ggetVfModuleCustomizationByModelNameTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VfModuleCustomization> list() throws Exception { - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setVfModuleModelUuid("123-uuid"); - return Arrays.asList(vfModuleCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); - assertEquals("123-uuid", vfModuleCustomization.getVfModuleModelUuid()); - - - } - - @Test - public void ggetVfModuleCustomizationByModelNameEmptyTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VfModuleCustomization> list() throws Exception { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes"); - assertEquals(null, vfModuleCustomization); - - - } - - @Test - public void getNetworkResourceTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<NetworkResource> list() throws Exception { - NetworkResource networkResource = new NetworkResource(); - networkResource.setModelUUID("123-uuid"); - return Arrays.asList(networkResource); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - NetworkResource networkResource = cd.getNetworkResource("tetes"); - assertEquals("123-uuid", networkResource.getModelUUID()); - - - } - - @Test - public void getNetworkResourceTestEmptyException(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<NetworkResource> list() throws Exception { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - NetworkResource networkResource = cd.getNetworkResource("tetes"); - assertEquals(null, networkResource); - - - } - - @Test - public void getVnfRecipeTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfRecipe> list() throws Exception { - VnfRecipe vnfRecipe = new VnfRecipe(); - vnfRecipe.setVfModuleId("123-id"); - return Arrays.asList(vnfRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","ergfedrf","4993493"); - assertEquals("123-id", vnfRecipe.getVfModuleId()); - - - } - - @Test - public void getVnfRecipeEmptyTest(){ - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfRecipe> list() throws Exception { - return Collections.emptyList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","ergfedrf","4993493"); - assertEquals(null, vnfRecipe); - - - } - - @Test - public void getVnfRecipe2Test(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfRecipe> list() throws Exception { - VnfRecipe vnfRecipe = new VnfRecipe(); - vnfRecipe.setId(1); - return Arrays.asList(vnfRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","4993493"); - assertEquals(1, vnfRecipe.getId()); - - - } - - @Test - public void getVnfRecipe2EmptyTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfRecipe> list() throws Exception { - return Collections.emptyList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","4993493"); - assertEquals(null, vnfRecipe); - - - } - - @Test - public void getVnfRecipeByVfModuleIdTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfRecipe> list() throws Exception { - VnfRecipe vnfRecipe = new VnfRecipe(); - vnfRecipe.setId(1); - return Arrays.asList(vnfRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfRecipe vnfRecipe = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf"); - assertEquals(1, vnfRecipe.getId()); - - - } - - @Test - public void getVnfRecipeByVfModuleIdEmptyTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfRecipe> list() throws Exception { - return Collections.emptyList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfRecipe vnfRecipe = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf"); - assertEquals(null, vnfRecipe); - - - } - - @Test - public void getVfModuleTypeTestException(){ - mockUpQuery = new MockUp<Query>() { - String type = null; - @Mock - public Query setParameter(String name, Object val) { - type = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<VfModule> list() { - if ("nil".equals(type)) return new ArrayList<VfModule>(); - - VfModule vm = new VfModule(); - vm.setModelUUID("123-uuid"); - return Arrays.asList(vm); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vnf = cd.getVfModuleType("4993493"); - assertEquals("123-uuid", vnf.getModelUUID()); - - vnf = cd.getVfModuleType("nil"); - assertNull(vnf); - } - - @Test - public void getVnfResourceByServiceUuidTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid("123-uuid"); - return vnfResource; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); - assertEquals("123-uuid", vnfResource.getModelUuid()); - - - } - - @Test - public void getVnfResourceByServiceUuidNURExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); - - - } - - @Test - public void getVnfResourceByServiceUuidHibernateExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); - - - } - - @Test - public void getVnfResourceByServiceUuidExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493"); - - - } - - @Test - public void getVnfResourceByVnfUuidTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid("123-uuid"); - return vnfResource; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); - assertEquals("123-uuid", vnfResource.getModelUuid()); - - - } - - @Test - public void getVnfResourceByVnfUuidNURExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new NonUniqueResultException(-1); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(NonUniqueResultException.class); - VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); - - - } - - @Test - public void getVnfResourceByVnfUuidHibernateExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() { - throw new HibernateException("hibernate exception"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(HibernateException.class); - VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); - - - } - - @Test - public void getVnfResourceByVnfUuidExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - throw new Exception(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - thrown.expect(Exception.class); - VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493"); - - - } - - @Test - public void getVfModuleByModelInvariantUuidTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VfModule> list() throws Exception { - VfModule vfModule = new VfModule(); - vfModule.setModelUUID("123-uuid"); - return Arrays.asList(vfModule); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vfModule = cd.getVfModuleByModelInvariantUuid("4993493"); - assertEquals("123-uuid", vfModule.getModelUUID()); - - - } - - @Test - public void getVfModuleByModelInvariantUuidEmptyTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VfModule> list() throws Exception { - return Collections.emptyList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vfModule = cd.getVfModuleByModelInvariantUuid("4993493"); - assertEquals(null, vfModule); - - - } - - @Test - public void getVfModuleByModelCustomizationUuidTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - VfModuleCustomization vc = new VfModuleCustomization(); - vc.setModelCustomizationUuid("4993493"); - return vc; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493"); - assertEquals("4993493", vnf.getModelCustomizationUuid()); - } - - @Test - public void getVfModuleByModelCustomizationUuidNullTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493"); - assertNull(vnf); - } - - @Test - public void getVfModuleByModelCustomizationUuidNonUniqueExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new org.hibernate.NonUniqueResultException(2); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(org.hibernate.NonUniqueResultException.class); - VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493"); - } - - @Test - public void getVfModuleByModelCustomizationUuidHibernateExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new org.hibernate.HibernateException("test case"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(org.hibernate.HibernateException.class); - VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493"); - } - - @Test - public void getVfModuleByModelCustomizationUuidExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new NullPointerException(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(NullPointerException.class); - VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493"); - } - - @Test - public void getVfModuleCustomizationByModelCustomizationIdTest(){ - mockUpQuery = new MockUp<Query>() { - String modelCustomizationUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelCustomizationUuid")) modelCustomizationUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(modelCustomizationUuid)) return null; - if ("multi".equals(modelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelCustomizationUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelCustomizationUuid)) throw new NullPointerException(); - - VfModuleCustomization vm = new VfModuleCustomization(); - vm.setModelCustomizationUuid("4993493"); - return vm; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelCustomizationId("4993493"); - assertEquals("4993493", vnf.getModelCustomizationUuid()); - - vnf = cd.getVfModuleCustomizationByModelCustomizationId("nil"); - assertNull(vnf); - - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vnf = cd.getVfModuleCustomizationByModelCustomizationId("multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vnf = cd.getVfModuleCustomizationByModelCustomizationId("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vnf = cd.getVfModuleCustomizationByModelCustomizationId("npe"); - } catch (NullPointerException e) { - // noop - } - - } - - @Test - public void getVfModuleByModelUuidTestException(){ - mockUpQuery = new MockUp<Query>() { - String modelUuidValue = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelUuidValue")) modelUuidValue = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<VfModule> list() { - if ("nil".equals(modelUuidValue)) return null; - if ("multi".equals(modelUuidValue)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelUuidValue)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelUuidValue)) throw new NullPointerException(); - - VfModule vfModule = new VfModule(); - vfModule.setModelInvariantUuid(modelUuidValue); - return Arrays.asList(vfModule); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vnf = cd.getVfModuleByModelUuid("4993493"); - assertEquals("4993493", vnf.getModelInvariantUuid()); - - vnf = cd.getVfModuleByModelUuid("nil"); - assertNull(vnf); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vnf = cd.getVfModuleByModelUuid("multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vnf = cd.getVfModuleByModelUuid("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vnf = cd.getVfModuleByModelUuid("npe"); - } catch (NullPointerException e) { - // noop - } - } - - - @Test - public void getVnfResourceCustomizationByModelVersionIdTest(){ - mockUpQuery = new MockUp<Query>() { - String modelVersionId = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelVersionId")) modelVersionId = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(modelVersionId)) return null; - if ("multi".equals(modelVersionId)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelVersionId)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelVersionId)) throw new NullPointerException(); - - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setVnfResourceModelUuid(modelVersionId); - return vnfResourceCustomization; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - public VnfResource getVnfResourceByModelUuid(String modelUuid) { - return new VnfResource(); - } - - @Mock - public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) { - ArrayList<VfModuleCustomization> toRet = new ArrayList<VfModuleCustomization>(); - VfModuleCustomization vmc = new VfModuleCustomization(); - toRet.add(vmc); - return toRet; - } - - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelVersionId("4993493"); - assertEquals("4993493", vnf.getVnfResourceModelUuid()); - - vnf = cd.getVnfResourceCustomizationByModelVersionId("nil"); - assertNull(vnf); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vnf = cd.getVnfResourceCustomizationByModelVersionId("multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vnf = cd.getVnfResourceCustomizationByModelVersionId("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vnf = cd.getVnfResourceCustomizationByModelVersionId("npe"); - } catch (NullPointerException e) { - // noop - } - } - - - @Test - public void getVfModuleByModelCustomizationIdAndVersionTestException(){ - mockUpQuery = new MockUp<Query>() { - String modelVersionId = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelVersionId")) modelVersionId = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(modelVersionId)) return null; - if ("multi".equals(modelVersionId)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelVersionId)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelVersionId)) throw new NullPointerException(); - - VfModule vfModule = new VfModule(); - vfModule.setModelVersion(modelVersionId); - return vfModule; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493","test"); - assertEquals("test", vm.getModelVersion()); - - vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "nil"); - assertNull(vm); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "npe"); - } catch (NullPointerException e) { - // noop - } - } - - @Test - public void getVfModuleCustomizationByVnfModuleCustomizationUuidTest(){ - mockUpQuery = new MockUp<Query>() { - String modelCustomizationUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelCustomizationUuid")) modelCustomizationUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<VfModuleCustomization> list() { - if ("nil".equals(modelCustomizationUuid)) return null; - if ("multi".equals(modelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelCustomizationUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelCustomizationUuid)) throw new NullPointerException(); - - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setVfModuleModelUuid(modelCustomizationUuid); - return Arrays.asList(vfModuleCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - - List<VfModuleCustomization> vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493"); - assertEquals(1, vmcl.size()); - assertEquals("4993493", vmcl.get(0).getVfModuleModelUuid()); - - vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("nil"); - assertEquals(0, vmcl.size()); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("npe"); - } catch (NullPointerException e) { - // noop - } - } - - @Test - public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionIdTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfResourceCustomization> list() { - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.vnfResourceModelUuid IN (SELECT vr.modelUuid FROM VnfResource vr WHERE vr.modelUuid = :modelVersionId)AND vrc.modelInstanceName = :modelCustomizationName")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNotNull(cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("modelCustomizationName","modelVersionId")); - - VnfResourceCustomization result = cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493", "test"); - assertNotNull(result); - } - - @Test - public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId_NullReturnTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfResourceCustomization> list() { - return Arrays.asList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.vnfResourceModelUuid IN (SELECT vr.modelUuid FROM VnfResource vr WHERE vr.modelUuid = :modelVersionId)AND vrc.modelInstanceName = :modelCustomizationName")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResourceCustomization result = cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493", "test"); - assertNull(result); - } - @Test - public void getAllVfModuleCustomizationsStrTest(){ - mockUpQuery = new MockUp<Query>() { - String vrcMcu = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("vrc_mcu")) vrcMcu = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<VnfResCustomToVfModuleCustom> list() { - if ("nil".equals(vrcMcu)) return null; - if ("multi".equals(vrcMcu)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(vrcMcu)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(vrcMcu)) throw new NullPointerException(); - - VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom(); - vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vrcMcu); - return Arrays.asList(vnfResCustomToVfModuleCustom); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(vrcMcu)) return null; - if ("multi".equals(vrcMcu)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(vrcMcu)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(vrcMcu)) throw new NullPointerException(); - - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setVfModuleModelUuid(vrcMcu); - return vfModuleCustomization; - } - - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - - @Mock - public VfModule getVfModuleByModelUuid(String modelUuid) { - return new VfModule(); - } - }; - - ArrayList<VfModuleCustomization> vmcl = cd.getAllVfModuleCustomizations("4993493"); - assertNotNull(vmcl); - assertEquals(1, vmcl.size()); - assertEquals("4993493", vmcl.get(0).getVfModuleModelUuid()); - - vmcl = cd.getAllVfModuleCustomizations("nil"); - assertNotNull(vmcl); - assertEquals(0, vmcl.size()); - - } - @Test - public void getVnfResourceByModelUuidTest(){ - mockUpQuery = new MockUp<Query>() { - String modelUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelUuid")) modelUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(modelUuid)) return null; - if ("multi".equals(modelUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelUuid)) throw new NullPointerException(); - - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid(modelUuid); - return vnfResource; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResource vr = cd.getVnfResourceByModelUuid("4993493"); - assertEquals("4993493", vr.getModelUuid()); - - vr = cd.getVnfResourceByModelUuid("nil"); - assertNull(vr); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vr = cd.getVnfResourceByModelUuid("multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vr = cd.getVnfResourceByModelUuid("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vr = cd.getVnfResourceByModelUuid("npe"); - } catch (NullPointerException e) { - // noop - } - } - - @Test - public void getVnfResCustomToVfModuleTest(){ - mockUpQuery = new MockUp<Query>() { - String vfIdValue = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("vfIdValue")) vfIdValue = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(vfIdValue)) return null; - if ("multi".equals(vfIdValue)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(vfIdValue)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(vfIdValue)) throw new NullPointerException(); - - VnfResCustomToVfModuleCustom vr = new VnfResCustomToVfModuleCustom(); - vr.setVfModuleCustModelCustomizationUuid(vfIdValue); - return vr; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResCustomToVfModuleCustom vm = cd.getVnfResCustomToVfModule("4993493","test"); - assertEquals("test", vm.getVfModuleCustModelCustomizationUuid()); - - vm = vm = cd.getVnfResCustomToVfModule("4993493", "nil"); - assertNull(vm); - } - - @Test - public void getVfModulesForVnfResourceTest(){ - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUuid("48839"); - thrown.expect(Exception.class); - cd.getVfModulesForVnfResource(vnfResource); - } - @Test - public void getVfModulesForVnfResource2Test(){ - mockUpQuery = new MockUp<Query>() { - String vnfResourceModelUUId = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("vnfResourceModelUUId")) vnfResourceModelUUId = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<VfModule> list() { - if ("nil".equals(vnfResourceModelUUId)) return null; - if ("multi".equals(vnfResourceModelUUId)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(vnfResourceModelUUId)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(vnfResourceModelUUId)) throw new NullPointerException(); - - VfModule vfModule = new VfModule(); - vfModule.setVnfResourceModelUUId(vnfResourceModelUUId); - return Arrays.asList(vfModule); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - List<VfModule> vm = cd.getVfModulesForVnfResource("4993493"); - assertNotNull(vm); - assertEquals(1, vm.size()); - assertEquals("4993493", vm.get(0).getVnfResourceModelUUId()); - - vm = cd.getVfModulesForVnfResource("nil"); - assertNotNull(vm); - assertEquals(0, vm.size()); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - cd.getVfModulesForVnfResource("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - cd.getVfModulesForVnfResource("npe"); - } catch (NullPointerException e) { - // noop - } - } - - @Test - public void getServiceByUuidTest(){ - mockUpQuery = new MockUp<Query>() { - String serviceModelInvariantUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("serviceModelInvariantUuid")) serviceModelInvariantUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(serviceModelInvariantUuid)) return null; - if ("multi".equals(serviceModelInvariantUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(serviceModelInvariantUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(serviceModelInvariantUuid)) throw new NullPointerException(); - - Service service = new Service(); - service.setModelInvariantUUID(serviceModelInvariantUuid); - return service; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Service s = cd.getServiceByUuid("4993493"); - assertEquals("4993493", s.getModelInvariantUUID()); - - s = cd.getServiceByUuid("nil"); - assertNull(s); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - s = cd.getServiceByUuid("multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - s = cd.getServiceByUuid("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - s = cd.getServiceByUuid("npe"); - } catch (NullPointerException e) { - // noop - } - - - thrown.expect(Exception.class); - cd.getServiceByUuid("4993493"); - } - - @Test - public void getNetworkResourceById2Test(){ - mockUpQuery = new MockUp<Query>() { - Integer id = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("id")) id = (Integer)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if (id==null || -1 == id) return null; - if (-2 == id) throw new org.hibernate.NonUniqueResultException(2); - if (-3 == id) throw new org.hibernate.HibernateException("test case"); - if (-4 == id) throw new NullPointerException(); - - NetworkResource networkResource = new NetworkResource(); - networkResource.setModelUUID(Integer.toString(id)); - return networkResource; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - NetworkResource nr = cd.getNetworkResourceById(4993493); - assertEquals("4993493", nr.getModelUUID()); - - nr = cd.getNetworkResourceById(-1); - assertNull(nr); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - nr = cd.getNetworkResourceById(-2); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - nr = cd.getNetworkResourceById(-3); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - nr = cd.getNetworkResourceById(-4); - } catch (NullPointerException e) { - // noop - } - } - - @Test - public void getNetworkResourceByIdTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - VfModule vm = new VfModule(); - vm.setModelInvariantUuid("4993493"); - return vm; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vm = cd.getVfModuleTypeByUuid("4993493"); - assertEquals("4993493", vm.getModelInvariantUuid()); - } - - @Test - public void getNetworkResourceByIdNullTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vm = cd.getVfModuleTypeByUuid("4993493"); - assertNull(null); - } - - @Test - public void getNetworkResourceByIdNonUniqueTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new org.hibernate.NonUniqueResultException(2); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(org.hibernate.NonUniqueResultException.class); - VfModule vm = cd.getVfModuleTypeByUuid("4993493"); - } - - @Test - public void getNetworkResourceByIdHibernateExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new org.hibernate.HibernateException("test case"); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(org.hibernate.HibernateException.class); - VfModule vm = cd.getVfModuleTypeByUuid("4993493"); - } - - @Test - public void getNetworkResourceByIdExceptionTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public Object uniqueResult() { - throw new NullPointerException(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - thrown.expect(NullPointerException.class); - VfModule vm = cd.getVfModuleTypeByUuid("4993493"); - } - - @Test - public void isEmptyOrNullTest(){ - boolean is = cd.isEmptyOrNull("4993493"); - assertFalse(is); - } - @Test - public void getSTRTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<ServiceToResourceCustomization> list() { - ServiceToResourceCustomization vnfResourceCustomization = new ServiceToResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - List<ServiceToResourceCustomization> str = cd.getSTR("4993493", "test", "vnf"); - assertFalse(str.isEmpty()); - - } - @Test - public void getVRCtoVFMCTest(){ - mockUpQuery = new MockUp<Query>() { - String vrcMcu = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("vrc_mcu")) vrcMcu = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<VnfResCustomToVfModuleCustom> list() { - if ("nil".equals(vrcMcu)) return null; - if ("multi".equals(vrcMcu)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(vrcMcu)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(vrcMcu)) throw new NullPointerException(); - - VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom(); - vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vrcMcu); - return Arrays.asList(vnfResCustomToVfModuleCustom); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - List<VnfResCustomToVfModuleCustom> vrCtoVFMC = cd.getVRCtoVFMC("", "null"); - assertNull(vrCtoVFMC); - - vrCtoVFMC = cd.getVRCtoVFMC("4993493", "388492"); - assertNotNull(vrCtoVFMC); - assertEquals(1, vrCtoVFMC.size()); - assertEquals("4993493", vrCtoVFMC.get(0).getVfModuleCustModelCustomizationUuid()); - - vrCtoVFMC = cd.getVRCtoVFMC("nil", "388492"); - assertNotNull(vrCtoVFMC); - assertEquals(0, vrCtoVFMC.size()); - - } - @Test - public void getTempNetworkHeatTemplateLookupTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<TempNetworkHeatTemplateLookup> list() { - TempNetworkHeatTemplateLookup vnfResourceCustomization = new TempNetworkHeatTemplateLookup(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<TempNetworkHeatTemplateLookup> tempNetworkHeatTemplateLookup = cd.getTempNetworkHeatTemplateLookup("4993493"); - assertFalse(tempNetworkHeatTemplateLookup.isEmpty()); - } - - @Test - public void getAllNetworksByServiceModelUuidTest(){ - mockUpQuery = new MockUp<Query>() { - String smu = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("smu")) smu = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<ServiceToResourceCustomization> list() { - if ("nil".equals(smu)) return null; - if ("multi".equals(smu)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(smu)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(smu)) throw new NullPointerException(); - - ServiceToResourceCustomization src = new ServiceToResourceCustomization(); - src.setServiceModelUUID(smu); - return Arrays.asList(src); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - - @Mock - public List<NetworkResourceCustomization> getAllNetworksByNetworkModelCustomizationUuid(String networkModelCustomizationUuid) { - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - nrc.setNetworkResourceModelUuid(networkModelCustomizationUuid); - return Arrays.asList(nrc); - } - }; - - List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByServiceModelUuid("4993493"); - assertNotNull(nrcl); - assertEquals(1, nrcl.size()); - - nrcl = cd.getAllNetworksByServiceModelUuid("nil"); - assertNotNull(nrcl); - assertEquals(0, nrcl.size()); -/* - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vm = cd.getVfModuleType("type", "multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vm = cd.getVfModuleType("type", "he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vm = cd.getVfModuleType("type", "npe"); - } catch (NullPointerException e) { - // noop - } - - assertEquals(cd.getAllNetworksByServiceModelUuid("4993493").size(), 0); - */ - } - - @Test - public void getAllNetworksByServiceModelInvariantUuidTest(){ - mockUpQuery = new MockUp<Query>() { - String serviceModelInvariantUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("serviceModelInvariantUuid")) serviceModelInvariantUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<Service> list() { - if ("nil".equals(serviceModelInvariantUuid)) return new ArrayList<Service>(); - if ("multi".equals(serviceModelInvariantUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(serviceModelInvariantUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(serviceModelInvariantUuid)) throw new NullPointerException(); - - Service nrc = new Service(); - nrc.setModelInvariantUUID(serviceModelInvariantUuid); - nrc.setModelUUID(serviceModelInvariantUuid); - return Arrays.asList(nrc); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - - @Mock - public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) { - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - nrc.setNetworkResourceModelUuid(serviceModelUuid); - return Arrays.asList(nrc); - } - }; - - List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByServiceModelInvariantUuid("4993493"); - assertNotNull(nrcl); - assertEquals(1, nrcl.size()); - assertEquals("4993493", nrcl.get(0).getNetworkResourceModelUuid()); - - nrcl = cd.getAllNetworksByServiceModelInvariantUuid("nil"); - assertNotNull(nrcl); - assertEquals(0, nrcl.size()); - } - @Test - public void getAllNetworksByServiceModelInvariantUuid2Test(){ - mockUpQuery = new MockUp<Query>() { - String serviceModelInvariantUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("serviceModelInvariantUuid")) serviceModelInvariantUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<Service> list() { - if ("nil".equals(serviceModelInvariantUuid)) return new ArrayList<Service>(); - if ("multi".equals(serviceModelInvariantUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(serviceModelInvariantUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(serviceModelInvariantUuid)) throw new NullPointerException(); - - Service service = new Service(); - service.setModelInvariantUUID(serviceModelInvariantUuid); - service.setModelUUID(serviceModelInvariantUuid); - return Arrays.asList(service); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - - @Mock - public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) { - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - nrc.setModelCustomizationUuid(serviceModelUuid); - return Arrays.asList(nrc); - } - }; - - List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByServiceModelInvariantUuid("4993493","test"); - assertNotNull(nrcl); - assertEquals(1, nrcl.size()); - assertEquals("4993493", nrcl.get(0).getModelCustomizationUuid()); - - nrcl = cd.getAllNetworksByServiceModelInvariantUuid("nil","test"); - assertNotNull(nrcl); - assertEquals(0, nrcl.size()); - } - - @Test - public void getAllNetworksByNetworkModelCustomizationUuidTest(){ - mockUpQuery = new MockUp<Query>() { - String networkModelCustomizationUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("networkModelCustomizationUuid")) networkModelCustomizationUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<NetworkResourceCustomization> list() { - if ("nil".equals(networkModelCustomizationUuid)) return new ArrayList<NetworkResourceCustomization>(); - if ("multi".equals(networkModelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(networkModelCustomizationUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(networkModelCustomizationUuid)) throw new NullPointerException(); - - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - nrc.setNetworkResourceModelUuid(networkModelCustomizationUuid); - return Arrays.asList(nrc); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - - @Mock - public NetworkResource getNetworkResourceById(String id) { - NetworkResource nr = new NetworkResource (); - return nr; - } - }; - - List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByNetworkModelCustomizationUuid("4993493"); - assertNotNull(nrcl); - assertEquals(1, nrcl.size()); - assertEquals("4993493", nrcl.get(0).getNetworkResourceModelUuid()); - - nrcl = cd.getAllNetworksByNetworkModelCustomizationUuid("nil"); - assertNotNull(nrcl); - assertEquals(0, nrcl.size()); - } - - @Test - public void getAllNetworksByNetworkTypeTest(){ - mockUpQuery = new MockUp<Query>() { - String networkResourceId = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("networkResourceId")) networkResourceId = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<NetworkResourceCustomization> list() { - if ("nil".equals(networkResourceId)) return null; - if ("multi".equals(networkResourceId)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(networkResourceId)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(networkResourceId)) throw new NullPointerException(); - - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - nrc.setNetworkResourceModelUuid(networkResourceId); - return Arrays.asList(nrc); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - - @Mock - public NetworkResource getNetworkResource(String networkType) { - if ("nil".equals(networkType)) return null; - - NetworkResource nr = new NetworkResource(); - nr.setNeutronNetworkType(networkType); - return nr; - } - }; - - List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByNetworkType("4993493"); - assertNotNull(nrcl); - assertEquals(1, nrcl.size()); - assertEquals("4993493", nrcl.get(0).getNetworkType()); - - nrcl = cd.getAllNetworksByNetworkType("nil"); - assertNotNull(nrcl); - assertEquals(0, nrcl.size()); - } - @Test - public void getAllVfmcForVrcTest(){ - VnfResourceCustomization re = new VnfResourceCustomization(); - re.setModelCustomizationUuid("377483"); - thrown.expect(Exception.class); - cd.getAllVfmcForVrc(re); - } - @Test - public void getAllVnfsByServiceModelUuidTest(){ - thrown.expect(Exception.class); - cd.getAllVnfsByServiceModelUuid("4993493"); - } - @Test - public void getAllVnfsByServiceModelInvariantUuidTest(){ - thrown.expect(Exception.class); - cd.getAllVnfsByServiceModelInvariantUuid("4993493"); - } - @Test - public void getAllVnfsByServiceModelInvariantUuid2Test(){ - thrown.expect(Exception.class); - cd.getAllVnfsByServiceModelInvariantUuid("4993493","test"); - } - @Test - public void getAllVnfsByServiceNameTest(){ - thrown.expect(Exception.class); - cd.getAllVnfsByServiceName("4993493","test"); - } - @Test - public void getAllVnfsByServiceName2Test(){ - thrown.expect(Exception.class); - cd.getAllVnfsByServiceName("4993493"); - } - @Test - public void getAllVnfsByVnfModelCustomizationUuidTest(){ - thrown.expect(Exception.class); - cd.getAllVnfsByVnfModelCustomizationUuid("4993493"); - } - @Test - public void getAllAllottedResourcesByServiceModelUuidTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<ServiceToResourceCustomization> list() { - ServiceToResourceCustomization vnfResourceCustomization = new ServiceToResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - mockUpQuery2 = new MockUp<Query>() { - - @Mock - public List<AllottedResourceCustomization> list() { - AllottedResourceCustomization vnfResourceCustomization = new AllottedResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - mockUpQuery3 = new MockUp<Query>() { - - @Mock - public List<AllottedResource> list() { - AllottedResource vnfResourceCustomization = new AllottedResource(); - return Arrays.asList(vnfResourceCustomization); - } - }; - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - if(hql.contains("ServiceToResourceCustomization")){ - return mockUpQuery.getMockInstance(); - - }else if(hql.contains("AllottedResource " )){ - return mockUpQuery3.getMockInstance(); - - } else{ - return mockUpQuery2.getMockInstance(); - } - - - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - List<AllottedResourceCustomization> allAllottedResourcesByServiceModelUuid = cd.getAllAllottedResourcesByServiceModelUuid("4993493"); - assertFalse(allAllottedResourcesByServiceModelUuid.isEmpty()); - } - @Test - public void getAllAllottedResourcesByServiceModelInvariantUuidTest(){ - thrown.expect(Exception.class); - cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493"); - } - @Test - public void getAllAllottedResourcesByServiceModelInvariantUuid2Test(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<ServiceToResourceCustomization> list() { - ServiceToResourceCustomization vnfResourceCustomization = new ServiceToResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - mockUpQuery2 = new MockUp<Query>() { - - @Mock - public List<AllottedResourceCustomization> list() { - AllottedResourceCustomization vnfResourceCustomization = new AllottedResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - mockUpQuery3 = new MockUp<Query>() { - - @Mock - public List<AllottedResource> list() { - AllottedResource vnfResourceCustomization = new AllottedResource(); - return Arrays.asList(vnfResourceCustomization); - } - }; - mockUpQuery4 = new MockUp<Query>() { - - @Mock - public List<Service> list() { - Service vnfResourceCustomization = new Service(); - return Arrays.asList(vnfResourceCustomization); - } - }; - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - if(hql.contains("ServiceToResourceCustomization")){ - return mockUpQuery.getMockInstance(); - - }else if(hql.contains("AllottedResource " )){ - return mockUpQuery3.getMockInstance(); - - } else if(hql.contains(" Service ")){ - return mockUpQuery4.getMockInstance(); - }else{ - return mockUpQuery2.getMockInstance(); - } - - - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - - List<AllottedResourceCustomization> allottedResourceCustomizations = cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493", "test"); - assertFalse(allottedResourceCustomizations.isEmpty()); - } - @Test - public void getAllAllottedResourcesByArModelCustomizationUuidTest(){ - thrown.expect(Exception.class); - cd.getAllAllottedResourcesByArModelCustomizationUuid("4993493"); - } - @Test - public void getAllottedResourceByModelUuidTest(){ - thrown.expect(Exception.class); - cd.getAllottedResourceByModelUuid("4993493"); - } - @Test - public void getAllResourcesByServiceModelUuidTest(){ - thrown.expect(Exception.class); - cd.getAllResourcesByServiceModelUuid("4993493"); - } - @Test - public void getAllResourcesByServiceModelInvariantUuidTest(){ - thrown.expect(Exception.class); - cd.getAllResourcesByServiceModelInvariantUuid("4993493"); - } - - @Test - public void getAllResourcesByServiceModelInvariantUuid2Test(){ - thrown.expect(Exception.class); - cd.getAllResourcesByServiceModelInvariantUuid("4993493","test"); - } - @Test - public void getSingleNetworkByModelCustomizationUuidTest(){ - thrown.expect(Exception.class); - cd.getSingleNetworkByModelCustomizationUuid("4993493"); - } - @Test - public void getSingleAllottedResourceByModelCustomizationUuidTest(){ - thrown.expect(Exception.class); - cd.getSingleAllottedResourceByModelCustomizationUuid("4993493"); - } - @Test - public void getVfModuleRecipeTest(){ - thrown.expect(Exception.class); - cd.getVfModuleRecipe("4993493","test","get"); - } - @Test - public void getVfModuleTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VfModule> list() { - VfModule vnfResourceCustomization = new VfModule(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - List<VfModule> vfModule = cd.getVfModule("4993493", "test", "get", "v2", "vnf"); - assertFalse(vfModule.isEmpty()); - } - @Test - public void getVnfComponentsRecipeTest(){ - thrown.expect(Exception.class); - cd.getVnfComponentsRecipe("4993493","test","v2","vnf","get","3992"); - } - @Test - public void getVnfComponentsRecipeByVfModuleTest(){ - List <VfModule> resultList = new ArrayList<>(); - VfModule m = new VfModule(); - resultList.add(m); - thrown.expect(Exception.class); - cd.getVnfComponentsRecipeByVfModule(resultList,"4993493"); - } - @Test - public void getAllVnfResourcesTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfResource> list() { - VnfResource vnfResourceCustomization = new VnfResource(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM VnfResource")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<VnfResource> allVnfResources = cd.getAllVnfResources(); - assertFalse(allVnfResources.isEmpty()); - } - @Test - public void getVnfResourcesByRoleTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfResource> list() { - VnfResource vnfResourceCustomization = new VnfResource(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM VnfResource WHERE vnfRole = :vnfRole")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<VnfResource> vnfResourcesByRole = cd.getVnfResourcesByRole("4993493"); - assertFalse(vnfResourcesByRole.isEmpty()); - } - @Test - public void getVnfResourceCustomizationsByRoleTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfResourceCustomization> list() { - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM VnfResourceCustomization WHERE nfRole = :vnfRole")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<VnfResourceCustomization> vnfResourceCustomizationsByRole = cd.getVnfResourceCustomizationsByRole("4993493"); - assertFalse(vnfResourceCustomizationsByRole.isEmpty()); - } - @Test - public void getAllNetworkResourcesTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<NetworkResource> list() { - NetworkResource vnfResourceCustomization = new NetworkResource(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM NetworkResource")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<NetworkResource> allNetworkResources = cd.getAllNetworkResources(); - assertFalse(allNetworkResources.isEmpty()); - } - @Test - public void getAllNetworkResourceCustomizationsTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<NetworkResourceCustomization> list() { - NetworkResourceCustomization vnfResourceCustomization = new NetworkResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM NetworkResourceCustomization")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<NetworkResourceCustomization> allNetworkResourceCustomizations = cd.getAllNetworkResourceCustomizations(); - assertFalse(allNetworkResourceCustomizations.isEmpty()); - } - @Test - public void getAllVfModulesTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VfModule> list() { - VfModule vnfResourceCustomization = new VfModule(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM VfModule")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<VfModule> allVfModules = cd.getAllVfModules(); - assertFalse(allVfModules.isEmpty()); - } - @Test - public void getAllVfModuleCustomizationsTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VfModuleCustomization> list() { - VfModuleCustomization vnfResourceCustomization = new VfModuleCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM VfModuleCustomization")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<VfModuleCustomization> allVfModuleCustomizations = cd.getAllVfModuleCustomizations(); - assertFalse(allVfModuleCustomizations.isEmpty()); - } - @Test - public void getAllHeatEnvironmentTest(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<HeatEnvironment> list() { - HeatEnvironment vnfResourceCustomization = new HeatEnvironment(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - assertTrue(hql.contains("FROM HeatEnvironment")); - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<HeatEnvironment> allHeatEnvironment = cd.getAllHeatEnvironment(); - assertFalse(allHeatEnvironment.isEmpty()); - } - @Test - public void getHeatEnvironment2Test(){ - thrown.expect(Exception.class); - cd.getHeatEnvironment(4993493); - } - @Test - public void getNestedTemplatesTest(){ - thrown.expect(Exception.class); - cd.getNestedTemplates(4993493); - } - @Test - public void getNestedTemplates2Test(){ - thrown.expect(Exception.class); - cd.getNestedTemplates("4993493"); - } - @Test - public void getHeatFilesTest(){ - thrown.expect(Exception.class); - cd.getHeatFiles(4993493); - } - @Test - public void getVfModuleToHeatFilesEntryTest(){ - thrown.expect(Exception.class); - cd.getVfModuleToHeatFilesEntry("4993493","49959499"); - } - @Test - public void getServiceToResourceCustomization(){ - thrown.expect(Exception.class); - cd.getServiceToResourceCustomization("4993493","599349","49900"); - } - @Test - public void getHeatFilesForVfModuleTest(){ - thrown.expect(Exception.class); - cd.getHeatFilesForVfModule("4993493"); - } - @Test - public void getHeatTemplateTest(){ - thrown.expect(Exception.class); - cd.getHeatTemplate("4993493","test","heat"); - } - - @Test - public void saveHeatTemplateTest(){ - HeatTemplate heat = new HeatTemplate(); - Set <HeatTemplateParam> paramSet = new HashSet<>(); - thrown.expect(Exception.class); - cd.saveHeatTemplate(heat,paramSet); - } - @Test - public void getHeatEnvironmentTest(){ - - mockUpQuery = new MockUp<Query>() { - - @Mock - public Object uniqueResult() throws Exception { - return null; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertEquals(cd.getHeatEnvironment("4993493","test","heat"), null); - } - @Test - public void getHeatEnvironment3Test(){ - thrown.expect(Exception.class); - cd.getHeatEnvironment("4993493","test"); - } - @Test - public void saveHeatEnvironmentTest(){ - HeatEnvironment en = new HeatEnvironment(); - thrown.expect(Exception.class); - cd.saveHeatEnvironment(en); - } - @Test - public void saveHeatTemplate2Test(){ - HeatTemplate heat = new HeatTemplate(); - thrown.expect(Exception.class); - cd.saveHeatTemplate(heat); - } - @Test - public void saveHeatFileTest(){ - HeatFiles hf = new HeatFiles(); - thrown.expect(Exception.class); - cd.saveHeatFile(hf); - } - @Test - public void saveVnfRecipeTest(){ - VnfRecipe vr = new VnfRecipe(); - thrown.expect(Exception.class); - cd.saveVnfRecipe(vr); - } - @Test - public void saveVnfComponentsRecipe(){ - VnfComponentsRecipe vr = new VnfComponentsRecipe(); - thrown.expect(Exception.class); - cd.saveVnfComponentsRecipe(vr); - } - @Test - public void saveOrUpdateVnfResourceTest(){ - VnfResource vr = new VnfResource(); - thrown.expect(Exception.class); - cd.saveOrUpdateVnfResource(vr); - } - @Test - public void saveVnfResourceCustomizationTest(){ - VnfResourceCustomization vr = new VnfResourceCustomization(); - thrown.expect(Exception.class); - cd.saveVnfResourceCustomization(vr); - } - @Test - public void saveAllottedResourceCustomizationTest(){ - AllottedResourceCustomization arc = new AllottedResourceCustomization(); - thrown.expect(Exception.class); - cd.saveAllottedResourceCustomization(arc); - } - @Test - public void saveAllottedResourceTest(){ - AllottedResource ar = new AllottedResource(); - thrown.expect(Exception.class); - cd.saveAllottedResource(ar); - } - @Test - public void saveNetworkResourceTest() throws RecordNotFoundException { - NetworkResource nr = new NetworkResource(); - thrown.expect(Exception.class); - cd.saveNetworkResource(nr); - } - @Test - public void saveToscaCsarTest()throws RecordNotFoundException { - ToscaCsar ts = new ToscaCsar(); - thrown.expect(Exception.class); - cd.saveToscaCsar(ts); - } - @Test - public void getToscaCsar(){ - thrown.expect(Exception.class); - cd.getToscaCsar("4993493"); - } - @Test - public void saveTempNetworkHeatTemplateLookupTest(){ - TempNetworkHeatTemplateLookup t = new TempNetworkHeatTemplateLookup(); - thrown.expect(Exception.class); - cd.saveTempNetworkHeatTemplateLookup(t); - } - @Test - public void saveVnfResourceToVfModuleCustomizationTest() throws RecordNotFoundException { - VnfResourceCustomization v =new VnfResourceCustomization(); - VfModuleCustomization vm = new VfModuleCustomization(); - thrown.expect(Exception.class); - cd.saveVnfResourceToVfModuleCustomization(v, vm); - } - @Test - public void saveNetworkResourceCustomizationTest() throws RecordNotFoundException { - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - thrown.expect(Exception.class); - cd.saveNetworkResourceCustomization(nrc); - } - - @Test - public void saveServiceToNetworksTest(){ - AllottedResource ar = new AllottedResource(); - thrown.expect(Exception.class); - cd.saveAllottedResource(ar); - } - @Test - public void saveServiceToResourceCustomizationTest(){ - ServiceToResourceCustomization ar = new ServiceToResourceCustomization(); - thrown.expect(Exception.class); - cd.saveServiceToResourceCustomization(ar); - } - @Test - public void saveServiceTest(){ - Service ar = new Service(); - thrown.expect(Exception.class); - cd.saveService(ar); - } - @Test - public void saveOrUpdateVfModuleTest(){ - VfModule ar = new VfModule(); - thrown.expect(Exception.class); - cd.saveOrUpdateVfModule(ar); - } - @Test - public void saveOrUpdateVfModuleCustomizationTest(){ - VfModuleCustomization ar = new VfModuleCustomization(); - thrown.expect(Exception.class); - cd.saveOrUpdateVfModuleCustomization(ar); - } - - @Test - public void getNestedHeatTemplateTest(){ - thrown.expect(Exception.class); - cd.getNestedHeatTemplate(101,201); - } - @Test - public void getNestedHeatTemplate2Test(){ - thrown.expect(Exception.class); - cd.getNestedHeatTemplate("1002","1002"); - } - @Test - public void saveNestedHeatTemplateTest(){ - HeatTemplate ar = new HeatTemplate(); - thrown.expect(Exception.class); - cd.saveNestedHeatTemplate("1001",ar,"test"); - } - @Test - public void getHeatFiles2Test(){ - VfModuleCustomization ar = new VfModuleCustomization(); - thrown.expect(Exception.class); - cd.getHeatFiles(101,"test","1001","v2"); - } - @Test - public void getHeatFiles3Test(){ - VfModuleCustomization ar = new VfModuleCustomization(); - thrown.expect(Exception.class); - cd.getHeatFiles("200192"); - } - @Test - public void saveHeatFilesTest(){ - HeatFiles ar = new HeatFiles(); - thrown.expect(Exception.class); - cd.saveHeatFiles(ar); - } - @Test - public void saveVfModuleToHeatFilesTest(){ - HeatFiles ar = new HeatFiles(); - thrown.expect(Exception.class); - cd.saveVfModuleToHeatFiles("3772893",ar); - } - @Test - public void getNetworkResourceByModelUuidTest(){ - - cd.getNetworkResourceByModelUuid("3899291"); - } - @Test - public void getNetworkRecipeTest(){ - thrown.expect(Exception.class); - cd.getNetworkRecipe("test","test1","test2"); - } - @Test - public void getNetworkRecipe2Test(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<NetworkRecipe> list() { - NetworkRecipe heatTemplate = new NetworkRecipe(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - NetworkRecipe networkRecipe = cd.getNetworkRecipe("test","test1");assertNotNull(networkRecipe); - assertNotNull(networkRecipe); - - } - @Test - public void getNetworkResourceByModelCustUuidTest(){ - - cd.getNetworkResourceByModelCustUuid("test"); - } - - @Test - public void getVnfComponentsRecipeByVfModuleModelUUIdTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfComponentsRecipe> list() { - VnfComponentsRecipe heatTemplate = new VnfComponentsRecipe(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VnfComponentsRecipe vnfComponentsRecipeByVfModuleModelUUId = cd.getVnfComponentsRecipeByVfModuleModelUUId("test1", "test2", "test3"); - assertNotNull(vnfComponentsRecipeByVfModuleModelUUId); - } - @Test - public void getVnfComponentRecipesTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfComponentsRecipe> list() { - VnfComponentsRecipe heatTemplate = new VnfComponentsRecipe(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - List<VnfComponentsRecipe> test = cd.getVnfComponentRecipes("test"); - assertNotNull(test); - assertFalse(test.isEmpty()); - } - @Test - public void saveOrUpdateVnfComponentTest(){ - VnfComponent ar = new VnfComponent(); - thrown.expect(Exception.class); - cd.saveOrUpdateVnfComponent(ar); - } - - @Test - public void getVfModule2Test(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VfModule> list() { - VfModule heatTemplate = new VfModule(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - VfModule test = cd.getVfModule("test"); - assertNotNull(test); - } - @Test - public void getVfModuleByModelUUIDTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VfModule> list() { - VfModule heatTemplate = new VfModule(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule test = cd.getVfModuleByModelUUID("test"); - assertNotNull(test); - } - @Test - public void getServiceRecipeByModelUUIDTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<ServiceRecipe> list() { - ServiceRecipe heatTemplate = new ServiceRecipe(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Assert.assertNotNull(cd.getServiceRecipeByModelUUID("test1", "test2")); - } - @Test - public void getModelRecipeTest(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<Object> list() { - return new ArrayList(); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - Assert.assertNull(cd.getModelRecipe("test1", "test2", "test3")); - } - @Test - @Ignore - public void healthCheck(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - HeatTemplate heatTemplate = new HeatTemplate(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createSQLQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNotNull(cd.healthCheck()); - } - @Test - public void executeQuerySingleRow(){ - VnfComponent ar = new VnfComponent(); - HashMap<String, String> variables = new HashMap<>(); - thrown.expect(Exception.class); - cd.executeQuerySingleRow("tets",variables,false); - } - - @Test - public void executeQueryMultipleRows(){ - HashMap<String, String> variables = new HashMap<>(); - - mockUpQuery = new MockUp<Query>() { - @Mock - public List<HeatTemplate> list() { - HeatTemplate heatTemplate = new HeatTemplate(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - - List<Object> select = cd.executeQueryMultipleRows("select", variables, false); - assertFalse(select.isEmpty()); - } - - @Test - public void getArRecipeByNameVersion(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<ArRecipe> list() { - ArRecipe arRecipe = new ArRecipe(); - return Arrays.asList(arRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNotNull(cd.getArRecipeByNameVersion("select","variables","String")); - } - @Test - public void getVnfComponentsRecipe(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<VnfComponentsRecipe> list() { - VnfComponentsRecipe heatTemplate = new VnfComponentsRecipe(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNotNull(cd.getVnfComponentsRecipe("vnfType","vnfComponentType","action","serviceType")); - } - @Test - public void getNetworkRecipeByNameVersion(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<NetworkRecipe> list() { - NetworkRecipe heatTemplate = new NetworkRecipe(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNotNull(cd.getNetworkRecipeByNameVersion("modelName","modelVersion","action")); - } - @Test - public void saveOrUpdateVfModuleCustomization(){ - mockUpQuery = new MockUp<Query>() { - @Mock - public List<NetworkRecipe> list() { - NetworkRecipe heatTemplate = new NetworkRecipe(); - return Arrays.asList(heatTemplate); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setHeatEnvironmentArtifactUuid("HeatEnvironmentArtifactUuid"); - vfModuleCustomization.setVolEnvironmentArtifactUuid("VolEnvironmentArtifactUuid"); - vfModuleCustomization.setVfModuleModelUuid("VfModuleModelUuid"); - vfModuleCustomization.setModelCustomizationUuid("ModelCustomizationUuid"); - cd.saveOrUpdateVfModuleCustomization(vfModuleCustomization); - } - @Test - public void saveServiceToNetworks(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<Service> list() { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return Arrays.asList(service); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - ServiceToNetworks serviceToNetworks = new ServiceToNetworks(); - cd.saveServiceToNetworks(serviceToNetworks); - } - @Test - public void saveVfModuleToHeatFiles() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<Service> list() { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return Arrays.asList(service); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModuleToHeatFiles vfModuleToHeatFiles = new VfModuleToHeatFiles(); - - cd.saveVfModuleToHeatFiles(vfModuleToHeatFiles); - } - @Test - public void saveTempNetworkHeatTemplateLookup() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<Service> list() { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return Arrays.asList(service); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup(); - - cd.saveTempNetworkHeatTemplateLookup(tempNetworkHeatTemplateLookup); - } - @Test - public void getToscaCsarByServiceModelUUID() { - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<Service> list() { - Service service = new Service(); - service.setModelUUID("123-uuid"); - return Arrays.asList(service); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - - assertNull(cd.getToscaCsarByServiceModelUUID("uuid-123")); - cd.close(); - } - @Test - public void getVnfRecipeByNameVersion(){ - mockUpQuery = new MockUp<Query>() { - String version = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("version")) version = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<VnfRecipe> list() { - if ("nil".equals(version)) return new ArrayList<VnfRecipe>(); - - VnfRecipe vnfRecipe = new VnfRecipe(); - vnfRecipe.setVersion(version); - return Arrays.asList(vnfRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfRecipe vf = cd.getVnfRecipeByNameVersion("modelName","modelVersion","action"); - assertEquals("modelVersion", vf.getVersion()); - - vf = cd.getVnfRecipeByNameVersion("modelName","nil","action"); - assertNull(vf); - } - - @Test - public void getVnfRecipeByModuleUuid(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfRecipe> list() { - VnfRecipe vnfRecipe = new VnfRecipe(); - return Arrays.asList(vnfRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNull(cd.getVnfRecipeByModuleUuid("vnfModelUuid","action")); - } - - @Test - public void getVfModuleType(){ - mockUpQuery = new MockUp<Query>() { - String version = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("version")) version = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(version)) return null; - if ("multi".equals(version)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(version)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(version)) throw new NullPointerException(); - - VfModule vfModule = new VfModule(); - vfModule.setVersion(version); - return vfModule; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vm = cd.getVfModuleType("type","version"); - assertEquals("version", vm.getVersion()); - - vm = cd.getVfModuleType("type", "nil"); - assertNull(vm); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vm = cd.getVfModuleType("type", "multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vm = cd.getVfModuleType("type", "he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vm = cd.getVfModuleType("type", "npe"); - } catch (NullPointerException e) { - // noop - } - - } - @Test - public void getVfModuleByModelInvariantUuidAndModelVersion(){ - mockUpQuery = new MockUp<Query>() { - String version = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelVersion")) version = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(version)) return null; - if ("multi".equals(version)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(version)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(version)) throw new NullPointerException(); - - VfModule vfModule = new VfModule(); - vfModule.setVersion(version); - return vfModule; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","modelVersion"); - assertEquals("modelVersion", vm.getVersion()); - - vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","nil"); - assertNull(vm); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","npe"); - } catch (NullPointerException e) { - // noop - } - - } - - @Test - public void getVnfResourceCustomizationByModelCustomizationUuid(){ - mockUpQuery = new MockUp<Query>() { - String modelCustomizationUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelCustomizationUuid")) modelCustomizationUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(modelCustomizationUuid)) return null; - if ("multi".equals(modelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelCustomizationUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelCustomizationUuid)) throw new NullPointerException(); - - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setModelCustomizationUuid(modelCustomizationUuid); - return vnfResourceCustomization; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - - @Mock - public VnfResource getVnfResourceByModelUuid(String modelUuid) { - VnfResource vr = new VnfResource(); - return vr; - } - - @Mock - public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) { - VfModuleCustomization vmc = new VfModuleCustomization(); - ArrayList<VfModuleCustomization> toRet = new ArrayList<VfModuleCustomization>(); - toRet.add(vmc); - return toRet; - } - }; - - VnfResourceCustomization vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("modelCustomizationUuid"); - assertEquals("modelCustomizationUuid", vrc.getModelCustomizationUuid()); - - vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("nil"); - assertNull(vrc); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("npe"); - } catch (NullPointerException e) { - // noop - } - - } - - @Test - public void getVfModuleByModelCustomizationIdAndVersion(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfRecipe> list() { - VnfRecipe vnfRecipe = new VnfRecipe(); - return Arrays.asList(vnfRecipe); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNull(cd.getVfModuleByModelCustomizationIdAndVersion("modelCustomizationUuid","modelVersionId")); - } - @Test - public void getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId(){ - mockUpQuery = new MockUp<Query>() { - String modelInvariantId = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelInvariantId")) modelInvariantId = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(modelInvariantId)) return null; - if ("multi".equals(modelInvariantId)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelInvariantId)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelInvariantId)) throw new NullPointerException(); - - VfModule vfModule = new VfModule(); - vfModule.setModelInvariantUuid(modelInvariantId); - return vfModule; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VfModule vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","modelInvariantId"); - assertEquals("modelInvariantId", vm.getModelInvariantUuid()); - - vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","nil"); - assertNull(vm); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion", "npe"); - } catch (NullPointerException e) { - // noop - } - - } - - @Test - public void getVnfResourceCustomizationByModelInvariantId(){ - mockUpQuery = new MockUp<Query>() { - String modelInvariantId = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("modelInvariantId")) modelInvariantId = (String)val; - return this.getMockInstance(); - } - - @Mock - public Object uniqueResult() { - if ("nil".equals(modelInvariantId)) return null; - if ("multi".equals(modelInvariantId)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelInvariantId)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelInvariantId)) throw new NullPointerException(); - - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setVnfResourceModelUuid(modelInvariantId); - return vnfResourceCustomization; - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - public VnfResource getVnfResourceByModelUuid(String modelUuid) { - return new VnfResource(); - } - - @Mock - public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) { - return new ArrayList<VfModuleCustomization>(); - } - - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - VnfResourceCustomization vrc = cd.getVnfResourceCustomizationByModelInvariantId("modelInvariantId","modelVersion","modelCustomizationName"); - assertEquals("modelInvariantId", vrc.getVnfResourceModelUuid()); - - vrc = cd.getVnfResourceCustomizationByModelInvariantId("nil","modelVersion","modelCustomizationName"); - assertNull(vrc); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - vrc = cd.getVnfResourceCustomizationByModelInvariantId("multi","modelVersion","modelCustomizationName"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - vrc = cd.getVnfResourceCustomizationByModelInvariantId("he","modelVersion","modelCustomizationName"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - vrc = cd.getVnfResourceCustomizationByModelInvariantId("npe","modelVersion","modelCustomizationName"); - } catch (NullPointerException e) { - // noop - } - } - - @Test - public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId(){ - mockUpQuery = new MockUp<Query>() { - - @Mock - public List<VnfResourceCustomization> list() { - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - return Arrays.asList(vnfResourceCustomization); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - assertNotNull(cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("modelCustomizationName","modelVersionId")); - } - - @Test - public void getNetworkResourceById3Test() { - mockUpQuery = new MockUp<Query>() { - String modelUuid = null; - - @Mock - public Query setParameter(String name, Object val) { - if (name.equals("model_uuid")) modelUuid = (String)val; - return this.getMockInstance(); - } - - @Mock - public List<NetworkResource> list() { - if ("nil".equals(modelUuid)) return null; - if ("multi".equals(modelUuid)) throw new org.hibernate.NonUniqueResultException(2); - if ("he".equals(modelUuid)) throw new org.hibernate.HibernateException("test case"); - if ("npe".equals(modelUuid)) throw new NullPointerException(); - - NetworkResource networkResource = new NetworkResource(); - networkResource.setModelUUID(modelUuid); - return Arrays.asList(networkResource); - } - }; - - mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String hql) { - return mockUpQuery.getMockInstance(); - } - }; - - mockCd = new MockUp<CatalogDatabase>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - NetworkResource nr = cd.getNetworkResourceById("test"); - assertEquals("test", nr.getModelUUID()); - - nr = cd.getNetworkResourceById("nil"); - assertNull(nr); - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.NonUniqueResultException.class); - nr = cd.getNetworkResourceById("multi"); - } catch (org.hibernate.NonUniqueResultException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(org.hibernate.HibernateException.class); - nr = cd.getNetworkResourceById("he"); - } catch (org.hibernate.HibernateException e) { - // noop - } - - try { - thrown = ExpectedException.none(); - thrown.expect(NullPointerException.class); - nr = cd.getNetworkResourceById("npe"); - } catch (NullPointerException e) { - // noop - } - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java deleted file mode 100644 index da4e87806c..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.UUID; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.HeatFiles; - -/** - */ - -public class HeatFilesTest { - - @Test - public final void heatFilesTest() { - - HeatFiles heatFiles = new HeatFiles(); - heatFiles.setFileBody("testBody"); - heatFiles.setArtifactUuid(UUID.randomUUID().toString()); - assertTrue(heatFiles.getFileBody().equals("testBody")); - assertTrue(!heatFiles.toString().contains("8 chars")); - heatFiles.setFileBody(null); - assertTrue(!heatFiles.toString().contains("Not defined")); - heatFiles.setVersion("12"); - assertTrue(heatFiles.getVersion().equals("12")); - - heatFiles.setFileName("File"); - assertTrue(heatFiles.getFileName().equalsIgnoreCase("File")); - - heatFiles.setCreated(null); - assertTrue(heatFiles.getCreated() == null); - heatFiles.setAsdcUuid("asdc"); - - assertTrue(heatFiles.getAsdcUuid().equalsIgnoreCase("asdc")); - - heatFiles.setDescription("desc"); - assertTrue(heatFiles.getDescription().equalsIgnoreCase("desc")); - - - heatFiles.setArtifactChecksum("artifactChecksum"); - assertTrue(heatFiles.getArtifactChecksum().equalsIgnoreCase("artifactChecksum")); - File tempFile; - try { - tempFile = File.createTempFile("heatFiles", "test"); - tempFile.deleteOnExit(); - try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile), "utf-8"))) { - writer.write("something\n"); - writer.write("something2\n"); - } - heatFiles.setFileBody(tempFile.getAbsolutePath()); - assertTrue(heatFiles.getFileBody().contains("test")); - } catch (IOException e) { - e.printStackTrace(); - fail("Exception caught"); - } - - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java deleted file mode 100644 index cf79d5b0d1..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.test; - - -import static org.junit.Assert.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.HashSet; -import java.util.UUID; - -import org.junit.Test; - -import org.openecomp.mso.db.catalog.beans.HeatTemplate; -import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; - -/** - */ - -public class HeatTemplateTest { - - @Test - public final void heatTemplateTest () { - HeatTemplate heatTemplate = new HeatTemplate (); - heatTemplate.setTemplateBody ("testBody"); - heatTemplate.setArtifactUuid(UUID.randomUUID().toString()); - assertTrue (heatTemplate.getHeatTemplate ().equals ("testBody")); - assertTrue (heatTemplate.toString ().contains ("8 chars")); - heatTemplate.setTemplateBody (null); - assertTrue (heatTemplate.toString ().contains ("Not defined")); - HashSet<HeatTemplateParam> set = new HashSet<> (); - HeatTemplateParam param = new HeatTemplateParam (); - param.setParamName ("param name"); - param.setParamType ("string"); - param.setRequired (false); - param.setHeatTemplateArtifactUuid(UUID.randomUUID().toString()); - set.add (param); - HeatTemplateParam param2 = new HeatTemplateParam (); - param2.setParamName ("param 2"); - param2.setParamType ("string"); - param2.setRequired (true); - param2.setHeatTemplateArtifactUuid(UUID.randomUUID().toString()); - set.add (param2); - heatTemplate.setParameters (set); - String heatStr = heatTemplate.toString (); - assertTrue (heatStr.contains ("param name")); - assertTrue (heatStr.contains ("param 2(reqd)")); - - File tempFile; - try { - tempFile = File.createTempFile ("heatTemplate", "test"); - tempFile.deleteOnExit (); - try (Writer writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (tempFile), - "utf-8"))) { - writer.write ("something\n"); - writer.write ("something2\n"); - } - heatTemplate.setTemplateBody(tempFile.getAbsolutePath ()); - assertTrue (heatTemplate.getHeatTemplate ().contains ("test")); - } catch (IOException e) { - e.printStackTrace (); - fail ("Exception caught"); - } - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java deleted file mode 100644 index d70f267cc1..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.ModelRecipe; - -/** - */ - -public class ModelRecipeTest { - - @Test - public final void modelRecipeDataTest() { - ModelRecipe modelRecipe = new ModelRecipe(); - modelRecipe.setAction("action"); - assertTrue(modelRecipe.getAction().equalsIgnoreCase("action")); - modelRecipe.setCreated(new Timestamp(System.currentTimeMillis())); - assertTrue(modelRecipe.getCreated() != null); - modelRecipe.setDescription("description"); - assertTrue(modelRecipe.getDescription().equalsIgnoreCase("description")); - modelRecipe.setId(1); - assertTrue(modelRecipe.getId() == 1); - modelRecipe.setModelId(1); - assertTrue(modelRecipe.getModelId() == 1); - modelRecipe.setModelParamXSD("modelParamXSD"); - assertTrue(modelRecipe.getModelParamXSD().equalsIgnoreCase("modelParamXSD")); - modelRecipe.setOrchestrationUri("orchestrationUri"); - assertTrue(modelRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri")); - modelRecipe.setRecipeTimeout(1); - assertTrue(modelRecipe.getRecipeTimeout() == 1); - modelRecipe.setSchemaVersion("schemaVersion"); - assertTrue(modelRecipe.getSchemaVersion().equalsIgnoreCase("schemaVersion")); -// assertTrue(modelRecipe.toString() != null); - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java deleted file mode 100644 index dcc9810042..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.Model; - -/** - */ - -public class ModelTest { - - @Test - public final void modelDataTest() { - Model model = new Model(); - model.setId(1); - assertTrue(model.getId() == 1); - - model.setCreated(new Timestamp(System.currentTimeMillis())); - assertTrue(model.getCreated() != null); - model.setModelCustomizationId("modelCustomizationId"); - - assertTrue(model.getModelCustomizationId().equalsIgnoreCase("modelCustomizationId")); - model.setModelCustomizationName("modelCustomizationName"); - assertTrue(model.getModelCustomizationName().equalsIgnoreCase("modelCustomizationName")); - - model.setModelInvariantId("modelInvariantId"); - assertTrue(model.getModelInvariantId().equalsIgnoreCase("modelInvariantId")); - model.setModelName("modelName"); - assertTrue(model.getModelName().equalsIgnoreCase("modelName")); - - model.setModelType("modelType"); - assertTrue(model.getModelType().equalsIgnoreCase("modelType")); - model.setModelVersion("modelVersion"); - assertTrue(model.getModelVersion().equalsIgnoreCase("modelVersion")); - model.setModelVersionId("modelVersionId"); - assertTrue(model.getModelVersionId().equalsIgnoreCase("modelVersionId")); - model.setVersion("1"); - assertTrue(model.getVersion().equalsIgnoreCase("1")); - model.setRecipes(null); - - assertTrue(model.getRecipes() == null); -// assertTrue(model.toString() != null); - - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java deleted file mode 100644 index c17b50e738..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.NetworkRecipe; - -/** - */ - -public class NetworkRecipeTest { - - @Test - public final void networkRecipeDataTest() { - - NetworkRecipe networkRecipe = new NetworkRecipe(); - networkRecipe.setAction("action"); - assertTrue(networkRecipe.getAction().equalsIgnoreCase("action")); - networkRecipe.setCreated(new Timestamp(System.currentTimeMillis())); - assertTrue(networkRecipe.getCreated() != null); - networkRecipe.setDescription("description"); - assertTrue(networkRecipe.getDescription().equalsIgnoreCase("description")); - networkRecipe.setId(1); - assertTrue(networkRecipe.getId() == 1); - networkRecipe.setModelName("modelName"); - assertTrue(networkRecipe.getModelName().equalsIgnoreCase("modelName")); - networkRecipe.setParamXSD("networkParamXSD"); - assertTrue(networkRecipe.getParamXSD().equalsIgnoreCase("networkParamXSD")); - networkRecipe.setOrchestrationUri("orchestrationUri"); - assertTrue(networkRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri")); - networkRecipe.setRecipeTimeout(1); - assertTrue(networkRecipe.getRecipeTimeout() == 1); - networkRecipe.setServiceType("serviceType"); - assertTrue(networkRecipe.getServiceType().equalsIgnoreCase("serviceType")); - networkRecipe.setVersion("version"); - assertTrue(networkRecipe.getVersion().equalsIgnoreCase("version")); -// assertTrue(networkRecipe.toString() != null); - - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceCustomizationTest.java deleted file mode 100644 index 7b54854fd9..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceCustomizationTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.NetworkResource; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; - -/** - */ - -public class NetworkResourceCustomizationTest { - - @Test - public final void networkResourceCustomizationDataTest() { - NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization(); - networkResourceCustomization.setModelCustomizationUuid("modelCustomizationUuid"); - assertTrue(networkResourceCustomization.getModelCustomizationUuid().equalsIgnoreCase("modelCustomizationUuid")); - networkResourceCustomization.setModelInstanceName("modelInstanceName"); - assertTrue(networkResourceCustomization.getModelInstanceName().equalsIgnoreCase("modelInstanceName")); - networkResourceCustomization.setCreated(new Timestamp(System.currentTimeMillis())); - assertTrue(networkResourceCustomization.getCreated() != null); - networkResourceCustomization.setNetworkResource(new NetworkResource()); - assertTrue(networkResourceCustomization.getNetworkResource() != null); - networkResourceCustomization.setNetworkResourceModelUuid("networkResourceModelUuid"); - assertTrue(networkResourceCustomization.getNetworkResourceModelUuid() - .equalsIgnoreCase("networkResourceModelUuid")); - networkResourceCustomization.setNetworkRole("networkRole"); - assertTrue(networkResourceCustomization.getNetworkRole().equalsIgnoreCase("networkRole")); - networkResourceCustomization.setNetworkScope("networkScope"); - assertTrue(networkResourceCustomization.getNetworkScope().equalsIgnoreCase("networkScope")); - networkResourceCustomization.setNetworkTechnology("networkTechnology"); - assertTrue(networkResourceCustomization.getNetworkTechnology().equalsIgnoreCase("networkTechnology")); - networkResourceCustomization.setNetworkType("networkType"); - assertTrue(networkResourceCustomization.getNetworkType().equalsIgnoreCase("networkType")); -// assertTrue(networkResourceCustomization.toString() != null); - - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceTest.java deleted file mode 100644 index 11ee57b86b..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.NetworkResource; - -/** - */ - -public class NetworkResourceTest { - - @Test - public final void networkResourceDataTest() { - NetworkResource networkResource = new NetworkResource(); - networkResource.setAicVersionMax("aicVersionMax"); - assertTrue(networkResource.getAicVersionMax().equalsIgnoreCase("aicVersionMax")); - networkResource.setAicVersionMin("aicVersionMin"); - assertTrue(networkResource.getAicVersionMin().equalsIgnoreCase("aicVersionMin")); - networkResource.setCreated(new Timestamp(System.currentTimeMillis())); - assertTrue(networkResource.getCreated() != null); - networkResource.setDescription("description"); - assertTrue(networkResource.getDescription().equalsIgnoreCase("description")); - networkResource.setHeatTemplateArtifactUUID("heatTemplateArtifactUUID"); - assertTrue(networkResource.getHeatTemplateArtifactUUID().equalsIgnoreCase("heatTemplateArtifactUUID")); - networkResource.setModelInvariantUUID("modelInvariantUUID"); - assertTrue(networkResource.getModelInvariantUUID().equalsIgnoreCase("modelInvariantUUID")); - networkResource.setModelName("modelName"); - assertTrue(networkResource.getModelName().equalsIgnoreCase("modelName")); - networkResource.setModelUUID("modelUUID"); - assertTrue(networkResource.getModelUUID().equalsIgnoreCase("modelUUID")); - networkResource.setModelVersion("modelVersion"); - assertTrue(networkResource.getModelVersion().equalsIgnoreCase("modelVersion")); - networkResource.setNeutronNetworkType("neutronNetworkType"); - assertTrue(networkResource.getNeutronNetworkType().equalsIgnoreCase("neutronNetworkType")); - networkResource.setOrchestrationMode("orchestrationMode"); - assertTrue(networkResource.getOrchestrationMode().equalsIgnoreCase("orchestrationMode")); - networkResource.setToscaNodeType("toscaNodeType"); - assertTrue(networkResource.getToscaNodeType().equalsIgnoreCase("toscaNodeType")); - networkResource.setVersion("1"); - assertTrue(networkResource.getVersion().equalsIgnoreCase("1")); -// assertTrue(networkResource.toString() != null); - - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecipeTest.java deleted file mode 100644 index 49dc9b7079..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecipeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.Recipe; - -/** - */ - -public class RecipeTest { - - @Test - public final void recipeDataTest() { - Recipe recipe = new Recipe(); - recipe.setAction("action"); - assertTrue(recipe.getAction().equalsIgnoreCase("action")); - recipe.setCreated(new Timestamp(System.currentTimeMillis())); - assertTrue(recipe.getCreated() != null); - recipe.setDescription("description"); - assertTrue(recipe.getDescription().equalsIgnoreCase("description")); - recipe.setId(1); - assertTrue(recipe.getId() == 1); - recipe.setOrchestrationUri("orchestrationUri"); - assertTrue(recipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri")); - recipe.setRecipeTimeout(1); - assertTrue(recipe.getRecipeTimeout() == 1); - recipe.setServiceType("serviceType"); - assertTrue(recipe.getServiceType().equalsIgnoreCase("serviceType")); -// assertTrue(recipe.toString() != null); - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java deleted file mode 100644 index c819079a40..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; - -/** - */ - -public class ServiceMacroHolderTest { - - @Test - public final void serviceMacroHolderDataTest() { - ServiceMacroHolder serviceMacroHolder = new ServiceMacroHolder(); - assertTrue(serviceMacroHolder.getService() == null); - serviceMacroHolder.addVnfResource(new VnfResource()); - serviceMacroHolder.addVnfResourceCustomizations(new VnfResourceCustomization()); - serviceMacroHolder.addNetworkResourceCustomizations(new NetworkResourceCustomization()); - serviceMacroHolder.addAllottedResourceCustomization(new AllottedResourceCustomization()); - assertTrue(serviceMacroHolder != null); - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceRecipeTest.java deleted file mode 100644 index 4b4a5adf4a..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceRecipeTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; -import java.util.Date; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.ServiceRecipe; - -/** - */ - -public class ServiceRecipeTest { - - @Test - public final void serviceRecipeDataTest() { - - ServiceRecipe serviceRecipe = new ServiceRecipe(); - serviceRecipe.setAction("action"); - assertTrue(serviceRecipe.getAction().equalsIgnoreCase("action")); - serviceRecipe.setCreated(new Timestamp(System.currentTimeMillis())); - assertTrue(serviceRecipe.getCreated() != null); - serviceRecipe.setDescription("description"); - assertTrue(serviceRecipe.getDescription().equalsIgnoreCase("description")); - serviceRecipe.setId(1); - assertTrue(serviceRecipe.getId() == 1); - serviceRecipe.setOrchestrationUri("orchestrationUri"); - assertTrue(serviceRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri")); - serviceRecipe.setRecipeTimeout(1); - assertTrue(serviceRecipe.getRecipeTimeout() == 1); - serviceRecipe.setVersion("version"); - assertTrue(serviceRecipe.getVersion().equalsIgnoreCase("version")); - serviceRecipe.setServiceTimeoutInterim(1); - assertTrue(serviceRecipe.getServiceTimeoutInterim() == 1); - serviceRecipe.setServiceParamXSD("serviceParamXSD"); - assertTrue(serviceRecipe.getServiceParamXSD().equalsIgnoreCase("serviceParamXSD")); - assertTrue(serviceRecipe.toString() != null); - ServiceRecipe serviceRecipeWithValue = new ServiceRecipe(1, "string", "string", "string", "string", "string", 1, - 1, new Date()); - assertTrue(serviceRecipeWithValue.toString() != null); - - } - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceTest.java deleted file mode 100644 index 12c55e7a48..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.Service;
-
-/**
- */
-
-public class ServiceTest {
-
- @Test
- public final void recipeDataTest() {
- Service service = new Service();
- service.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(service.getCreated() != null);
- service.setDescription("description");
- assertTrue(service.getDescription().equalsIgnoreCase("description"));
-
- service.setModelInvariantUUID("action");
- assertTrue(service.getModelInvariantUUID().equalsIgnoreCase("action"));
-
- service.setModelName("modelName");
- assertTrue(service.getModelName().equalsIgnoreCase("modelName"));
-
- service.setModelUUID("modelUUID");
- assertTrue(service.getModelUUID().equalsIgnoreCase("modelUUID"));
- service.setModelVersion("modelVersion");
- assertTrue(service.getModelVersion().equalsIgnoreCase("modelVersion"));
- service.setServiceRole("serviceRole");
- assertTrue(service.getServiceRole().equalsIgnoreCase("serviceRole"));
- service.setToscaCsarArtifactUUID("toscaCsarArtifactUUID");
- assertTrue(service.getToscaCsarArtifactUUID().equalsIgnoreCase("toscaCsarArtifactUUID"));
-
- service.setServiceType("serviceType");
- assertTrue(service.getServiceType().equalsIgnoreCase("serviceType"));
- service.setRecipes(null);
- assertTrue(service.getRecipes() == null);
- service.setServiceResourceCustomizations(null);
- assertTrue(service.getServiceResourceCustomizations() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToAllottedResourcesTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToAllottedResourcesTest.java deleted file mode 100644 index b2aaeeed4e..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToAllottedResourcesTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
-
-/**
- */
-
-public class ServiceToAllottedResourcesTest {
-
- @Test
- public final void serviceToAllottedResourcesDataTest() {
- ServiceToAllottedResources serviceToAllottedResources = new ServiceToAllottedResources();
- serviceToAllottedResources.setArModelCustomizationUuid("arModelCustomizationUuid");
- assertTrue(
- serviceToAllottedResources.getArModelCustomizationUuid().equalsIgnoreCase("arModelCustomizationUuid"));
- serviceToAllottedResources.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(serviceToAllottedResources.getCreated() != null);
- serviceToAllottedResources.setServiceModelUuid("serviceModelUuid");
- assertTrue(serviceToAllottedResources.getServiceModelUuid().equalsIgnoreCase("serviceModelUuid"));
-// assertTrue(serviceToAllottedResources.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToResourceCustomizationTest.java deleted file mode 100644 index 337cf4b574..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToResourceCustomizationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
-
-/**
- */
-
-public class ServiceToResourceCustomizationTest {
-
- @Test
- public final void serviceToResourceCustomizationDataTest() {
- ServiceToAllottedResources serviceToResourceCustomization = new ServiceToAllottedResources();
- serviceToResourceCustomization.setArModelCustomizationUuid("arModelCustomizationUuid");
- assertTrue(
- serviceToResourceCustomization.getArModelCustomizationUuid().equalsIgnoreCase("arModelCustomizationUuid"));
- serviceToResourceCustomization.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(serviceToResourceCustomization.getCreated() != null);
- serviceToResourceCustomization.setServiceModelUuid("serviceModelUuid");
- assertTrue(serviceToResourceCustomization.getServiceModelUuid().equalsIgnoreCase("serviceModelUuid"));
-// assertTrue(serviceToResourceCustomization.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java deleted file mode 100644 index 162073cc76..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.db.catalog.test; - -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; -import org.openecomp.mso.db.catalog.beans.HeatFiles; -import org.openecomp.mso.db.catalog.beans.Model; -import org.openecomp.mso.db.catalog.beans.ModelRecipe; -import org.openecomp.mso.db.catalog.beans.NetworkResource; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; -import org.openecomp.mso.db.catalog.beans.ServiceRecipe; -import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization; -import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfComponent; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; - -public class ToStringTest { - - @Test - public void testTModelRecipeToString(){ - ModelRecipe mr = new ModelRecipe(); - mr.setCreated(new Timestamp(10001)); - mr.setModelId(102); - mr.setRecipeTimeout(100); - String str = mr.toString(); - assertTrue(str != null); - } - - @Test - public void networkResourcetoStringTest(){ - NetworkResource nr = new NetworkResource(); - nr.setCreated(new Timestamp(10000)); - String str = nr.toString(); - assertTrue(str != null); - } - - @Test - public void modelTestToString(){ - Model m = new Model(); - m.setCreated(new Timestamp(100000)); - m.setId(1001); - m.setModelCustomizationId("10012"); - String str = m.toString(); - assertTrue(str != null); - } - - @Test - public void serviceMacroHolderTest(){ - ServiceMacroHolder smh = new ServiceMacroHolder(); - Service service = new Service(); - Map<String,ServiceRecipe> recipes = new HashMap<>(); - recipes.put("test", new ServiceRecipe()); - service.setRecipes(recipes); - - Set<ServiceToResourceCustomization> serviceResourceCustomizations = new HashSet<>(); - ServiceToResourceCustomization sr = new ServiceToResourceCustomization(); - serviceResourceCustomizations.add(sr); - service.setServiceResourceCustomizations(serviceResourceCustomizations); - smh.setService(service); - - ArrayList<VnfResource> vnflist = new ArrayList<>(); - smh.setVnfResources(vnflist); - - VnfResource vr = new VnfResource(); - Set<VnfResourceCustomization> vnfResourceCustomization = new HashSet<>(); - vnfResourceCustomization.add(new VnfResourceCustomization()); - vr.setVnfResourceCustomizations(vnfResourceCustomization); - - Set<VfModule> vfModules = new HashSet<>(); - vfModules.add(new VfModule()); - vr.setVfModules(vfModules); - smh.addVnfResource(vr); - - ArrayList<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); - smh.setVnfResourceCustomizations(vnfResourceCustomizations); - - VnfResourceCustomization vrc = new VnfResourceCustomization(); - smh.addVnfResourceCustomizations(vrc); - - ArrayList<NetworkResourceCustomization> networkResourceCustomizations = new ArrayList<>(); - smh.setNetworkResourceCustomization(networkResourceCustomizations); - - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - smh.addNetworkResourceCustomizations(nrc); - - ArrayList<AllottedResourceCustomization> allottedResourceCustomizations = new ArrayList<>(); - smh.setAllottedResourceCustomization(allottedResourceCustomizations); - - AllottedResourceCustomization arc = new AllottedResourceCustomization(); - smh.addAllottedResourceCustomization(arc); - - String str = smh.toString(); - assertTrue(str != null); - } - - @Test - public void heatFilesTest(){ - HeatFiles hf = new HeatFiles(); - String str = hf.toString(); - assertTrue(str != null); - - } - - @Test - public void testVnfConponent(){ - VnfComponent vnf = new VnfComponent(); - String str = vnf.toString(); - assertTrue(str != null); - } - - @Test - public void testTempNetworkHeatTemplateLookup(){ - TempNetworkHeatTemplateLookup tn =new TempNetworkHeatTemplateLookup(); - String str = tn.toString(); - assertTrue(str != null); - } - - -} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToscaCsarTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToscaCsarTest.java deleted file mode 100644 index 9cbfaa4d2c..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToscaCsarTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-
-/**
- */
-
-public class ToscaCsarTest {
-
- @Test
- public final void toscaCsarDataTest() {
- ToscaCsar toscaCsar = new ToscaCsar();
- toscaCsar.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(toscaCsar.getCreated() != null);
- toscaCsar.setDescription("description");
- assertTrue(toscaCsar.getDescription().equalsIgnoreCase("description"));
-
- toscaCsar.setArtifactChecksum("artifactChecksum");
- assertTrue(toscaCsar.getArtifactChecksum().equalsIgnoreCase("artifactChecksum"));
-
- toscaCsar.setArtifactUUID("artifactUUID");
- assertTrue(toscaCsar.getArtifactUUID().equalsIgnoreCase("artifactUUID"));
-
- toscaCsar.setName("name");
- assertTrue(toscaCsar.getName().equalsIgnoreCase("name"));
- toscaCsar.setUrl("url");
- assertTrue(toscaCsar.getUrl().equalsIgnoreCase("url"));
-// assertTrue(toscaCsar.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleCustomizationTest.java deleted file mode 100644 index 52d15ee597..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleCustomizationTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-
-/**
- */
-
-public class VfModuleCustomizationTest {
-
- @Test
- public final void vfModuleCustomizationDataTest() {
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vfModuleCustomization.getCreated() != null);
- vfModuleCustomization.setAvailabilityZoneCount(1);
- assertTrue(vfModuleCustomization.getAvailabilityZoneCount() == 1);
- vfModuleCustomization.hashCode();
- vfModuleCustomization.setVolEnvironmentArtifactUuid("volEnvironmentArtifactUuid");
- assertTrue(
- vfModuleCustomization.getVolEnvironmentArtifactUuid().equalsIgnoreCase("volEnvironmentArtifactUuid"));
-
- vfModuleCustomization.setHeatEnvironmentArtifactUuid("heatEnvironmentArtifactUuid");
- assertTrue(
- vfModuleCustomization.getHeatEnvironmentArtifactUuid().equalsIgnoreCase("heatEnvironmentArtifactUuid"));
-
- vfModuleCustomization.setInitialCount(1);
- assertTrue(vfModuleCustomization.getInitialCount() == 1);
-
- vfModuleCustomization.setLabel("label");
- assertTrue(vfModuleCustomization.getLabel().equalsIgnoreCase("label"));
- vfModuleCustomization.setMaxInstances(2);
- assertTrue(vfModuleCustomization.getMaxInstances() == 2);
- vfModuleCustomization.setMinInstances(1);
- assertTrue(vfModuleCustomization.getMinInstances() == 1);
- vfModuleCustomization.setModelCustomizationUuid("modelCustomizationUuid");
- assertTrue(vfModuleCustomization.getModelCustomizationUuid().equalsIgnoreCase("modelCustomizationUuid"));
- vfModuleCustomization.setVfModule(new VfModule());
- assertTrue(vfModuleCustomization.getVfModule() != null);
-
-// assertTrue(vfModuleCustomization.toString() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleTest.java deleted file mode 100644 index 9409a642ec..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-
-/**
- */
-
-public class VfModuleTest {
-
- @Test
- public final void vfModuleDataTest() {
- VfModule vfModule = new VfModule();
- vfModule.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vfModule.getCreated() != null);
- vfModule.setDescription("description");
- assertTrue(vfModule.getDescription().equalsIgnoreCase("description"));
-
- vfModule.setModelInvariantUUID("action");
- assertTrue(vfModule.getModelInvariantUUID().equalsIgnoreCase("action"));
-
- vfModule.setModelName("modelName");
- assertTrue(vfModule.getModelName().equalsIgnoreCase("modelName"));
-
- vfModule.setModelUUID("modelUUID");
- assertTrue(vfModule.getModelUUID().equalsIgnoreCase("modelUUID"));
- vfModule.setModelVersion("modelVersion");
- assertTrue(vfModule.getModelVersion().equalsIgnoreCase("modelVersion"));
- vfModule.setHeatTemplateArtifactUUId("heatTemplateArtifactUUId");
- assertTrue(vfModule.getHeatTemplateArtifactUUId().equalsIgnoreCase("heatTemplateArtifactUUId"));
- vfModule.setVnfResourceModelUUId("vnfResourceModelUUId");
- assertTrue(vfModule.getVnfResourceModelUUId().equalsIgnoreCase("vnfResourceModelUUId"));
- vfModule.setIsBase(1);
- assertTrue(vfModule.isBase());
-// assertTrue(vfModule.toString() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java deleted file mode 100644 index 3f707871a6..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VnfRecipe;
-
-/**
- */
-
-public class VnfRecipeTest {
-
- @Test
- public final void vnfRecipeDataTest() {
- VnfRecipe vnfRecipe = new VnfRecipe();
- vnfRecipe.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vnfRecipe.getCreated() != null);
- vnfRecipe.setDescription("description");
- assertTrue(vnfRecipe.getDescription().equalsIgnoreCase("description"));
-
- vnfRecipe.setOrchestrationUri("orchestrationUri");
- assertTrue(vnfRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri"));
-
- vnfRecipe.setRecipeTimeout(1);
- assertTrue(vnfRecipe.getRecipeTimeout() == 1);
- vnfRecipe.setVnfType("vnfType");
- assertTrue(vnfRecipe.getVnfType().equalsIgnoreCase("vnfType"));
-
- vnfRecipe.setServiceType("serviceType");
- assertTrue(vnfRecipe.getServiceType().equalsIgnoreCase("serviceType"));
- vnfRecipe.setVersion("version");
- assertTrue(vnfRecipe.getVersion().equalsIgnoreCase("version"));
- vnfRecipe.setParamXSD("vnfParamXSD");
- assertTrue(vnfRecipe.getParamXSD().equalsIgnoreCase("vnfParamXSD"));
- vnfRecipe.setVfModuleId("vfModuleId");
- assertTrue(vnfRecipe.getVfModuleId().equalsIgnoreCase("vfModuleId"));
-// assertTrue(vnfRecipe.toString() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceCustomizationTest.java deleted file mode 100644 index 816461f203..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceCustomizationTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-
-import static org.junit.Assert.*;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-
-/**
- */
-
-public class VnfResourceCustomizationTest {
-
- @Test
- public final void vnfResourceCustomizationTest () {
- VnfResourceCustomization vrc = new VnfResourceCustomization();
- vrc.setModelCustomizationUuid("004fccad-a9d1-4b34-b50b-ccb9800a178b");
- vrc.setModelInstanceName("testName");
- vrc.setMultiStageDesign("sampleDesign");
-
- assertTrue(vrc.getModelCustomizationUuid().equals("004fccad-a9d1-4b34-b50b-ccb9800a178b"));
- assertTrue(vrc.getModelInstanceName().equals("testName"));
- assertTrue(vrc.getMultiStageDesign().equals("sampleDesign"));
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceTest.java deleted file mode 100644 index 68749e397e..0000000000 --- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/*-
- * ============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.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-
-/**
- */
-
-public class VnfResourceTest {
-
- @Test
- public final void vnfResourceDataTest() {
-
- VnfResource vnfResource = new VnfResource();
- vnfResource.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vnfResource.getCreated() != null);
- vnfResource.setDescription("description");
- assertTrue(vnfResource.getDescription().equalsIgnoreCase("description"));
-
- vnfResource.setAicVersionMax("aicVersionMax");
- assertTrue(vnfResource.getAicVersionMax().equalsIgnoreCase("aicVersionMax"));
-
- vnfResource.setAicVersionMin("aicVersionMin");
- assertTrue(vnfResource.getAicVersionMin().equalsIgnoreCase("aicVersionMin"));
- vnfResource.setHeatTemplateArtifactUUId("heatTemplateArtifactUUId");
- assertTrue(vnfResource.getHeatTemplateArtifactUUId().equalsIgnoreCase("heatTemplateArtifactUUId"));
-
- vnfResource.setModelInvariantUuid("modelInvariantUuid");
- assertTrue(vnfResource.getModelInvariantUuid().equalsIgnoreCase("modelInvariantUuid"));
- vnfResource.setModelName("modelName");
- assertTrue(vnfResource.getModelName().equalsIgnoreCase("modelName"));
- vnfResource.setModelUuid("modelUuid");
- assertTrue(vnfResource.getModelUuid().equalsIgnoreCase("modelUuid"));
- vnfResource.setModelVersion("modelVersion");
- assertTrue(vnfResource.getModelVersion().equalsIgnoreCase("modelVersion"));
- vnfResource.setOrchestrationMode("orchestrationMode");
- assertTrue(vnfResource.getOrchestrationMode().equalsIgnoreCase("orchestrationMode"));
- vnfResource.setTemplateId("heatTemplateArtifactUUId");
- assertTrue(vnfResource.getHeatTemplateArtifactUUId().equalsIgnoreCase("heatTemplateArtifactUUId"));
- vnfResource.setModelInvariantUuid("modelInvariantUuid");
- assertTrue(vnfResource.getModelInvariantUuid().equalsIgnoreCase("modelInvariantUuid"));
- Set<VnfResourceCustomization> list = new HashSet<>();
- list.add(new VnfResourceCustomization());
- vnfResource.setVnfResourceCustomizations(list);
- assertTrue(vnfResource.getVfModuleCustomizations() != null);
- Set<VfModule> vfModules = new HashSet<>();
- vfModules.add(new VfModule());
- vnfResource.setVfModules(vfModules);
- assertTrue(vnfResource.getVfModules() != null);
-// assertTrue(vnfResource.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/resources/application-test.yaml b/mso-catalog-db/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..dbff1c1d2f --- /dev/null +++ b/mso-catalog-db/src/test/resources/application-test.yaml @@ -0,0 +1,64 @@ +# TEST FILE +catalog.db.endpoint: "http://localhost:" + +ssl-enable: false +mso: + site-name: localDevEnv + logPath: logs + catalog: + db: + spring: + endpoint: "http://localhost:" + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + +spring: + datasource: + url: jdbc:mariadb://localhost:3307/ + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + initialization-mode: never + jpa: + generate-ddl: false + show-sql: true + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client + - + username: bpel + password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO' + role: BPEL-Client + - + username: mso_admin + password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' + role: ACTUATOR +mariaDB4j: + dataDir: + port: 3307 + databaseName: catalog_db + +server: + port: 8080 + tomcat: + max-threads: 50 + + +#Actuator +management: + endpoints: + enabled-by-default: false + endpoint: + info: + enabled: true + + diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql new file mode 100644 index 0000000000..604f493cf0 --- /dev/null +++ b/mso-catalog-db/src/test/resources/data.sql @@ -0,0 +1,643 @@ + +insert into heat_files(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values +('00535bdd-0878-4478-b95a-c575c742bfb0', 'nimbus-ethernet-gw', '1', 'created from csar', 'DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n', 'MANUAL RECORD', '2017-01-21 23:56:43'); + + +insert into tosca_csar(artifact_uuid, name, version, description, artifact_checksum, url, creation_timestamp) values +('0513f839-459d-46b6-aa3d-2edfef89a079', 'service-Ciservicee3756aea561a-csar.csar', '1', 'TOSCA definition package of the asset', 'YTk1MmY2MGVlNzVhYTU4YjgzYjliMjNjMmM3NzU1NDc=', '/sdc/v1/catalog/services/Ciservicee3756aea561a/1.0/artifacts/service-Ciservicee3756aea561a-csar.csar', '2017-11-27 11:38:27'); + + +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002671', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '1.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', '0513f839-459d-46b6-aa3d-2edfef89a079', 'NA', 'NA', 'Luna', 'Oxygen'); + +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002672', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '2.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', null, 'NA', 'NA', 'Luna', 'Oxygen'); + +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002673', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '2.1', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', null, 'NA', 'NA', 'Luna', 'Oxygen'); + + +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002674', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '2.1.1', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', null, 'NA', 'NA', 'Luna', 'Oxygen'); +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002675', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '2.1.2', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', null, 'NA', 'NA', 'Luna', 'Oxygen'); + + +insert into service_recipe(id, action, version_str, description, orchestration_uri, service_param_xsd, recipe_timeout, service_timeout_interim, creation_timestamp, service_model_uuid) values +('1', 'createInstance', '1', 'MSOTADevInfra aLaCarte', '/mso/async/services/CreateGenericALaCarteServiceInstance', null, '180', '0', '2017-04-14 19:18:20', '5df8b6de-2083-11e7-93ae-92361f002671'); + +insert into heat_template(artifact_uuid, name, version, description, body, timeout_minutes, artifact_checksum, creation_timestamp) values +('ff874603-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'), +('ff87482f-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'), +('aa874603-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'); + + +insert into heat_template_params(heat_template_artifact_uuid, param_name, is_required, param_type, param_alias) values +('ff874603-4222-11e7-9252-005056850d2e', 'availability_zone_0', 1, 'string', ''), +('ff874603-4222-11e7-9252-005056850d2e', 'exn_direct_net_fqdn',1, 'string', ''), +('ff874603-4222-11e7-9252-005056850d2e', 'exn_hsl_net_fqdn', 1, 'string', ''); + +insert into heat_environment(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values +('fefb1601-4222-11e7-9252-005056850d2e', 'module_nso.env', '2', 'Auto-generated HEAT Environment deployment artifact', 'parameters:\n availability_zone_0: \"alln-zone-1\"\n nso_flavor_name: \"citeis.1vCPUx2GB\"\n nso_image_name: \"RHEL-6.8-BASE-20160912\"\n nso_name_0: \"zrdm3vamp01nso001\"\n nso_oam_ip_0: \"172.18.25.175\"\n nso_oam_net_gw: \"172.18.25.1\"\n nso_oam_net_mask: \"255.255.255.0\"\n nso_sec_grp_id: \"36f48d82-f099-4437-bfbc-70d9e5d420d1\"\n nso_srv_grp_id: \"e431c477-5bd1-476a-bfa9-e4ce16b8356b\"\n oam_net_id: \"nso_oam\"\n vf_module_id: \"145cd730797234b4a40aa99335abc143\"\n vnf_id: \"730797234b4a40aa99335157b02871cd\"\n vnf_name: \"Mobisupport\"\n', 'MWI2ODY0Yjc1NDJjNWU1NjdkMTAyMjVkNzFmZDU0MzA=', '2017-11-27 08:42:58'), +('fefb1751-4333-11e7-9252-005056850d2e', 'module_nso.env', '2', 'Auto-generated HEAT Environment deployment artifact', 'parameters:\n availability_zone_0: \"alln-zone-1\"\n nso_flavor_name: \"citeis.1vCPUx2GB\"\n nso_image_name: \"RHEL-6.8-BASE-20160912\"\n nso_name_0: \"zrdm3vamp01nso001\"\n nso_oam_ip_0: \"172.18.25.175\"\n nso_oam_net_gw: \"172.18.25.1\"\n nso_oam_net_mask: \"255.255.255.0\"\n nso_sec_grp_id: \"36f48d82-f099-4437-bfbc-70d9e5d420d1\"\n nso_srv_grp_id: \"e431c477-5bd1-476a-bfa9-e4ce16b8356b\"\n oam_net_id: \"nso_oam\"\n vf_module_id: \"145cd730797234b4a40aa99335abc143\"\n vnf_id: \"730797234b4a40aa99335157b02871cd\"\n vnf_name: \"Mobisupport\"\n', 'MWI2ODY0Yjc1NDJjNWU1NjdkMTAyMjVkNzFmZDU0MzA=', '2017-11-27 08:42:58'); + +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-92361f002671', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '1.0', 'vSAMP10a', 'VF', null); + +insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values +('68dc9a92-214c-11e7-93ae-92361f002671', 'vSAMP10a 1', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002671', null); + + +insert into vf_module(model_uuid, model_invariant_uuid, model_version, model_name, description, is_base, heat_template_artifact_uuid, vol_heat_template_artifact_uuid, creation_timestamp, vnf_resource_model_uuid) values + +('20c4431c-246d-11e7-93ae-92361f002671', '78ca26d0-246d-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::base::module-0', 'vSAMP10a DEV Base', '1', 'ff874603-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'), +('066de97e-253e-11e7-93ae-92361f002671', '64efd51a-2544-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::PCM::module-1', 'vSAMP10a DEV PCM', '0', 'ff87482f-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'); + + +insert into vf_module_customization(model_customization_uuid, label, initial_count, min_instances, max_instances, availability_zone_count, heat_environment_artifact_uuid, vol_environment_artifact_uuid, creation_timestamp, vf_module_model_uuid) values +('cb82ffd8-252a-11e7-93ae-92361f002671', 'base', '1', '0', '0', '0', 'fefb1601-4222-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '20c4431c-246d-11e7-93ae-92361f002671'), +('b4ea86b4-253f-11e7-93ae-92361f002671', 'PCM', '0', '0', '0', '0', 'fefb1751-4333-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '066de97e-253e-11e7-93ae-92361f002671'); + + +insert into vnf_res_custom_to_vf_module_custom(vnf_resource_cust_model_customization_uuid, vf_module_cust_model_customization_uuid, creation_timestamp) values +('68dc9a92-214c-11e7-93ae-92361f002671', 'cb82ffd8-252a-11e7-93ae-92361f002671', '2017-05-26 15:08:24'), +('68dc9a92-214c-11e7-93ae-92361f002671', 'b4ea86b4-253f-11e7-93ae-92361f002671', '2017-05-26 15:08:24'); + +insert into allotted_resource(model_uuid, model_invariant_uuid, model_version, model_name, tosca_node_type, subcategory, description, creation_timestamp) values +('f6b7d4c6-e8a4-46e2-81bc-31cad5072842', 'b7a1b78e-6b6b-4b36-9698-8c9530da14af', '1.0', 'Tunnel_Xconn', '', '', '', '2017-05-26 15:08:24'); + +insert into allotted_resource_customization(model_customization_uuid, model_instance_name, providing_service_model_invariant_uuid, target_network_role, nf_type, nf_role, nf_function, nf_naming_code, min_instances, max_instances, ar_model_uuid, creation_timestamp) values +('367a8ba9-057a-4506-b106-fbae818597c6', 'Sec_Tunnel_Xconn 11', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'f6b7d4c6-e8a4-46e2-81bc-31cad5072842', TIMESTAMP '2017-01-20 16:14:20.0'); + + +insert into temp_network_heat_template_lookup(network_resource_model_name, heat_template_artifact_uuid, aic_version_min, aic_version_max) values +('CONTRAIL30_GNDIRECT', 'ff874603-4222-11e7-9252-005056850d2e', '3', '3'); + +insert into network_resource(model_uuid, model_name, model_invariant_uuid, description, heat_template_artifact_uuid, neutron_network_type, model_version, tosca_node_type, aic_version_min, aic_version_max, orchestration_mode, creation_timestamp) values +('10b36f65-f4e6-4be6-ae49-9596dc1c47fc', 'CONTRAIL30_GNDIRECT', 'ce4ff476-9641-4e60-b4d5-b4abbec1271d', 'Contrail 30 GNDIRECT NW', 'aa874603-4222-11e7-9252-005056850d2e', 'BASIC', '1.0', '', '3.0', '', 'HEAT', '2017-01-17 20:35:05'); +insert into network_resource(model_uuid, model_name, model_invariant_uuid, description, heat_template_artifact_uuid, neutron_network_type, model_version, tosca_node_type, aic_version_min, aic_version_max, orchestration_mode, creation_timestamp) values +('10b36f65-f4e6-4be6-ae49-9596dc1c47fy', 'CONTRAIL30_GNDIRECT', 'ce4ff476-9641-4e60-b4d5-b4abbec1271d', 'Contrail 30 GNDIRECT NW', 'aa874603-4222-11e7-9252-005056850d2e', 'BASIC', '2.0', '', '3.0', '', 'HEAT', '2017-01-17 20:35:05'); + +insert into network_resource(model_uuid, model_name, model_invariant_uuid, description, heat_template_artifact_uuid, neutron_network_type, model_version, tosca_node_type, aic_version_min, aic_version_max, orchestration_mode, creation_timestamp) values +('10b36f65-f4e6-4be6-ae49-9596dc1c47fx', 'CONTRAIL30_GNDIRECT', 'ce4ff476-9641-4e60-b4d5-b4abbec1271d', 'Contrail 30 GNDIRECT NW', 'aa874603-4222-11e7-9252-005056850d2e', 'BASIC', '3.0', '', '3.0', '', 'HEAT', '2017-01-17 20:35:05'); + +insert into network_resource(model_uuid, model_name, model_invariant_uuid, description, heat_template_artifact_uuid, neutron_network_type, model_version, tosca_node_type, aic_version_min, aic_version_max, orchestration_mode, creation_timestamp) values +('10b36f65-f4e6-4be6-ae49-9596dc1c47fz', 'CONTRAIL30_GNDIRECT', 'ce4ff476-9641-4e60-b4d5-b4abbec1271d', 'Contrail 30 GNDIRECT NW', 'aa874603-4222-11e7-9252-005056850d2e', 'BASIC', '3.1', '', '3.0', '', 'HEAT', '2017-01-17 20:35:05'); + + +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 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); + + +insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values +('68dc9a92-214c-11e7-93ae-92361f002672', 'vSAMP10a 2', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002672', null); + + + + + +insert into vf_module(model_uuid, model_invariant_uuid, model_version, model_name, description, is_base, heat_template_artifact_uuid, vol_heat_template_artifact_uuid, creation_timestamp, vnf_resource_model_uuid) values + +('20c4431c-246d-11e7-93ae-92361f002672', '78ca26d0-246d-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::base::module-0', 'vSAMP10a DEV Base', '1', 'ff874603-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'), +('066de97e-253e-11e7-93ae-92361f002672', '64efd51a-2544-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::PCM::module-1', 'vSAMP10a DEV PCM', '0', 'ff87482f-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'), +('066de97e-253e-11e7-93ae-92361f002673', '64efd51a-2544-11e7-93ae-92361f002671', '3', 'vSAMP10aDEV::PCM::module-1', 'vSAMP10a DEV PCM', '0', 'ff87482f-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:54', 'ff2ae348-214a-11e7-93ae-92361f002671'), +('066de97e-253e-11e7-93ae-92361f002674', '64efd51a-2544-11e7-93ae-92361f002671', '3.1', 'vSAMP10aDEV::PCM::module-1', 'vSAMP10a DEV PCM', '0', 'ff87482f-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'), +('066de97e-253e-11e7-93ae-92361f002675', '64efd51a-2544-11e7-93ae-92361f002671', '3.1.1', 'vSAMP10aDEV::PCM::module-1', 'vSAMP10a DEV PCM', '0', 'ff87482f-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'); + + + +insert into vf_module_customization(model_customization_uuid, label, initial_count, min_instances, max_instances, availability_zone_count, heat_environment_artifact_uuid, vol_environment_artifact_uuid, creation_timestamp, vf_module_model_uuid) values +('cb82ffd8-252a-11e7-93ae-92361f002672', 'base', '1', '0', '0', '0', 'fefb1601-4222-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '20c4431c-246d-11e7-93ae-92361f002672'), +('b4ea86b4-253f-11e7-93ae-92361f002672', 'PCM', '0', '0', '0', '0', 'fefb1751-4333-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '066de97e-253e-11e7-93ae-92361f002672'); + + +insert into vnf_res_custom_to_vf_module_custom(vnf_resource_cust_model_customization_uuid, vf_module_cust_model_customization_uuid, creation_timestamp) values +('68dc9a92-214c-11e7-93ae-92361f002672', 'cb82ffd8-252a-11e7-93ae-92361f002672', '2017-05-26 15:08:24'), +('68dc9a92-214c-11e7-93ae-92361f002672', 'b4ea86b4-253f-11e7-93ae-92361f002672', '2017-05-26 15:08:24'); + + + +insert into vf_module_to_heat_files(vf_module_model_uuid, heat_files_artifact_uuid) values +('20c4431c-246d-11e7-93ae-92361f002671', '00535bdd-0878-4478-b95a-c575c742bfb0'), +('066de97e-253e-11e7-93ae-92361f002671', '00535bdd-0878-4478-b95a-c575c742bfb0'); + + +insert into network_resource_customization_to_service(service_model_uuid, resource_model_customization_uuid) values +('5df8b6de-2083-11e7-93ae-92361f002671', '3bdbb104-476c-483e-9f8b-c095b3d308ac'), +('5df8b6de-2083-11e7-93ae-92361f002672', '3bdbb104-476c-483e-9f8b-c095b3d308ac'); + + +insert into vnf_resource_customization_to_service(service_model_uuid, resource_model_customization_uuid) values +('5df8b6de-2083-11e7-93ae-92361f002671', '68dc9a92-214c-11e7-93ae-92361f002671'), +('5df8b6de-2083-11e7-93ae-92361f002672', '68dc9a92-214c-11e7-93ae-92361f002672'); + +insert into allotted_resource_customization_to_service(service_model_uuid, resource_model_customization_uuid) values +('5df8b6de-2083-11e7-93ae-92361f002671', '367a8ba9-057a-4506-b106-fbae818597c6' ), +('5df8b6de-2083-11e7-93ae-92361f002672', '367a8ba9-057a-4506-b106-fbae818597c6'); + + + +insert into vnf_recipe(id, nf_role, action, service_type, version_str, description, orchestration_uri, vnf_param_xsd, recipe_timeout, creation_timestamp, vf_module_id) values +('61', '*', 'CREATE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/workflow/services/CreateGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), +('63', '*', 'DELETE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/deleteGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), +('65', '*', 'UPDATE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/workflow/services/updateGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), +('67', '*', 'CREATE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/CreateVfModule', '', '180', '2016-06-03 10:14:10', '*'), +('69', '*', 'DELETE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/DeleteVfModule', '', '180', '2016-06-03 10:14:10', '*'), +('71', '*', 'UPDATE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/UpdateVfModule', '', '180', '2016-06-03 10:14:10', '*'), +('77', 'VID_DEFAULT', 'createInstance', '', '1', 'VID_DEFAULT recipe to create VNF if no custom BPMN flow is found', '/mso/async/services/CreateVnfInfra', '', '180', '2016-09-14 19:18:20', ''), +('78', 'VID_DEFAULT', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete VNF if no custom BPMN flow is found', '/mso/async/services/DeleteVnfInfra', '', '180', '2016-09-14 19:18:20', ''), +('81', 'VID_DEFAULT', 'updateInstance', '', '1', 'VID_DEFAULT update', '/mso/async/services/UpdateVnfInfra', '', '180', '2017-07-28 18:19:39', ''), +('85', 'VID_DEFAULT', 'replaceInstance', '', '1', 'VID_DEFAULT replace', '/mso/async/services/ReplaceVnfInfra', '', '180', '2017-07-28 18:19:45', ''), +('10000', 'VID_DEFAULT', 'inPlaceSoftwareUpdate', '', '1', 'VID_DEFAULT inPlaceSoftwareUpdate', '/mso/async/services/VnfInPlaceUpdate', '', '180', '2017-10-25 18:19:45', ''), +('10001', 'VID_DEFAULT', 'applyUpdatedConfig', '', '1', 'VID_DEFAULT applyUpdatedConfig', '/mso/async/services/VnfConfigUpdate', '', '180', '2017-10-25 18:19:45', ''); + + +insert into vnf_components(vnf_id, component_type, heat_template_id, heat_environment_id, creation_timestamp) values +('13961', 'VOLUME', '13843', '13961', '2016-05-19 20:22:02'); + +insert into vnf_components_recipe(id, vnf_type, vnf_component_type, action, service_type, version, description, orchestration_uri, vnf_component_param_xsd, recipe_timeout, creation_timestamp, vf_module_model_uuid) values +('5', '*', 'VOLUME_GROUP', 'CREATE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/createCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), +('7', '*', 'VOLUME_GROUP', 'DELETE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/deleteCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), +('9', '*', 'VOLUME_GROUP', 'UPDATE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/updateCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), +('13', '', 'VOLUME_GROUP', 'DELETE_VF_MODULE_VOL', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/DeleteVfModuleVolume', '', '180', '2016-06-03 10:15:11', '*'), +('15', '', 'VOLUME_GROUP', 'UPDATE_VF_MODULE_VOL', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/UpdateVfModuleVolume', '', '180', '2016-06-03 10:15:11', '*'), +('16', '', 'volumeGroup', 'createInstance', '', '1', 'VID_DEFAULT recipe to create volume-group if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('17', '', 'volumeGroup', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete volume-group if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('18', '', 'volumeGroup', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update volume-group if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('19', '', 'vfModule', 'createInstance', '', '1', 'VID_DEFAULT recipe to create vf-module if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('20', '', 'vfModule', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete vf-module if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('21', '', 'vfModule', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update vf-module if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('25', '', 'vfModule', 'replaceInstance', '', '1', 'VID_DEFAULT vfModule replace', '/mso/async/services/ReplaceVfModuleInfra', '', '180', '2017-07-28 18:25:06', 'VID_DEFAULT'); + +insert into network_recipe(id, model_name, action, description, orchestration_uri, network_param_xsd, recipe_timeout, service_type, creation_timestamp, version_str) values +('1', 'CONTRAIL_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('2', 'CONTRAIL_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('3', 'CONTRAIL_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('4', 'CONTRAIL_SHARED', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('5', 'CONTRAIL_SHARED', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('6', 'CONTRAIL_SHARED', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('7', 'CONTRAIL_EXTERNAL', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('8', 'CONTRAIL_EXTERNAL', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('9', 'CONTRAIL_EXTERNAL', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('10', 'CONTRAIL30_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), +('11', 'CONTRAIL30_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), +('12', 'CONTRAIL30_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), +('13', 'NEUTRON_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-06-01 19:54:51', '1'), +('17', 'VID_DEFAULT', 'createInstance', 'VID_DEFAULT recipe to create network if no custom BPMN flow is found', '/mso/async/services/CreateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), +('18', 'VID_DEFAULT', 'updateInstance', 'VID_DEFAULT recipe to update network if no custom BPMN flow is found', '/mso/async/services/UpdateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), +('19', 'VID_DEFAULT', 'deleteInstance', 'VID_DEFAULT recipe to delete network if no custom BPMN flow is found', '/mso/async/services/DeleteNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), +('124', 'CONTRAIL30_MPSCE', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), +('126', 'CONTRAIL30_MPSCE', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), +('128', 'CONTRAIL30_MPSCE', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), +('141', 'CONTRAIL30_L2NODHCP', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), +('144', 'CONTRAIL30_L2NODHCP', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), +('147', 'CONTRAIL30_L2NODHCP', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), +('169', 'CONTRAIL30_GNDIRECT', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), +('172', 'CONTRAIL30_GNDIRECT', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), +('175', 'CONTRAIL30_GNDIRECT', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), +('176', 'NEUTRON_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-09-22 18:47:31', '1'), +('177', 'NEUTRON_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-09-22 18:47:31', '1'); + +INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, IS_ALACARTE, IS_TOPLEVELFLOW, MIN_API_VERSION, MAX_API_VERSION) VALUES +('Service-Create', 'createInstance', 'Service', true, true, '7','7'), +('Service-Delete', 'deleteInstance', 'Service', true, true, '7','7'), +('Service-Macro-Assign', 'assignInstance', 'Service', false, true, '7','7'), +('Service-Macro-Activate', 'activateInstance', 'Service', false, true, '7','7'), +('Service-Macro-Unassign', 'unassignInstance', 'Service', false, true, '7','7'), +('Service-Macro-Create', 'createInstance', 'Service', false, true, '7','7'), +('Service-Macro-Delete', 'deleteInstance', 'Service', false, true, '7','7'), +('Network-Create', 'createInstance', 'Network', true, true, '7','7'), +('Network-Delete', 'deleteInstance', 'Network', true, true, '7','7'), +('VNF-Macro-Recreate', 'replaceInstance', 'Vnf', false, false, '7','7'), +('VNF-Macro-Replace', 'internalReplace', 'Vnf', false, false, '7','7'), +('VNF-Create', 'createInstance', 'Vnf', true, true, '7', '7'), +('VNF-Delete', 'deleteInstance', 'Vnf', true, true, '7', '7'), +('VolumeGroup-Create', 'createInstance', 'VolumeGroup', true, true, '7','7'), +('VolumeGroup-Delete', 'deleteInstance', 'VolumeGroup', true, true, '7','7'), +('VFModule-Create', 'createInstance', 'VfModule', true, true, '7','7'), +('VFModule-Delete', 'deleteInstance', 'VfModule', true, true, '7','7'), +('VFModule-DeactivateAndCloudDelete', 'deactivateAndCloudDelete', 'VfModule', true, true, '7','7'), +('NetworkCollection-Macro-Create', 'createInstance', 'NetworkCollection', false, true, '7','7'), +('NetworkCollection-Macro-Delete', 'deleteInstance', 'NetworkCollection', false, true, '7','7'); + +INSERT INTO building_block_detail (BUILDING_BLOCK_NAME, RESOURCE_TYPE, TARGET_ACTION) +VALUES +('AssignServiceInstanceBB', 'SERVICE', 'ASSIGN'), +('AssignVnfBB', 'VNF', 'ASSIGN'), +('AssignVolumeGroupBB', 'VOLUME_GROUP', 'ASSIGN'), +('AssignVfModuleBB', 'VF_MODULE', 'ASSIGN'), +('AssignNetworkBB', 'NETWORK', 'ASSIGN'), +('AssignNetwork1802BB', 'NETWORK', 'ASSIGN'), +('UnassignServiceInstanceBB', 'SERVICE', 'UNASSIGN'), +('UnassignVnfBB', 'VNF', 'UNASSIGN'), +('UnassignVolumeGroupBB', 'VOLUME_GROUP', 'UNASSIGN'), +('UnassignVfModuleBB', 'VF_MODULE', 'UNASSIGN'), +('UnassignNetwork1802BB', 'NETWORK', 'UNASSIGN'), +('UnassignNetworkBB', 'NETWORK', 'UNASSIGN'), +('ActivateServiceInstanceBB', 'SERVICE', 'ACTIVATE'), +('ActivateVnfBB', 'VNF', 'ACTIVATE'), +('ActivateVolumeGroupBB', 'VOLUME_GROUP', 'ACTIVATE'), +('ActivateVfModuleBB', 'VF_MODULE', 'ACTIVATE'), +('ActivateNetworkBB', 'NETWORK', 'ACTIVATE'), +('ActivateNetworkCollectionBB', 'NETWORK', 'ACTIVATE'), +('DeactivateServiceInstanceBB', 'SERVICE', 'DEACTIVATE'), +('DeactivateVnfBB', 'VNF', 'DEACTIVATE'), +('DeactivateVolumeGroupBB', 'VOLUME_GROUP', 'DEACTIVATE'), +('DeactivateVfModuleBB', 'VF_MODULE', 'DEACTIVATE'), +('DeactivateNetworkBB', 'NETWORK', 'DEACTIVATE'), +('ChangeModelServiceInstanceBB', 'SERVICE', 'CHANGE_MODEL'), +('ChangeModelVnfBB', 'VNF', 'CHANGE_MODEL'), +('ChangeModelVfModuleBB', 'VF_MODULE', 'CHANGE_MODEL'), +('CreateVolumeGroupBB', 'VOLUME_GROUP', 'CREATE'), +('CreateVfModuleBB', 'VF_MODULE', 'CREATE'), +('CreateNetworkBB', 'NETWORK', 'CREATE'), +('CreateNetworkCollectionBB', 'NETWORK', 'CREATE'), +('DeleteVolumeGroupBB', 'VOLUME_GROUP', 'DELETE'), +('DeleteVfModuleBB', 'VF_MODULE', 'DELETE'), +('DeleteNetworkBB', 'NETWORK', 'DELETE'), +('DeleteNetworkCollectionBB', 'NETWORK', 'DELETE'), +('AssignAndActivateVpnBondingLinksBB', 'CUSTOM', 'CUSTOM'), +('AvpnAssignServiceInstanceBB', 'CUSTOM', 'CUSTOM'), +('CreateCustomerVpnBindingBB', 'CUSTOM', 'CUSTOM'), +('SniroHoming', 'CUSTOM', 'CUSTOM'), +('DeactivateAndUnassignVpnBondingLinksBB', 'CUSTOM', 'CUSTOM'), +('DeactivateNetworkCollectionBB', 'CUSTOM', 'CUSTOM'), +('AAICheckVnfInMaintBB', 'CUSTOM', 'CUSTOM'), +('AAISetVnfInMaintBB', 'CUSTOM', 'CUSTOM'), +('AAIUnsetVnfInMaintBB', 'CUSTOM', 'CUSTOM'), +('SDNOVnfHealthCheckBB', 'CUSTOM', 'CUSTOM'), +('VNF-Macro-Replace', 'CUSTOM', 'CUSTOM'), +('HomingV2', 'CUSTOM', 'CUSTOM'); + +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES +('Service-Create', '1', 'AssignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Create')), +('Service-Create', '2', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Create')), +('Service-Delete', '1', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Delete')), +('Service-Delete', '2', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Delete')), +('Service-Macro-Assign', '1', 'AssignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Assign')), +('Service-Macro-Assign', '2', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Assign')), +('Service-Macro-Assign', '3', 'AssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Assign')), +('Service-Macro-Assign', '4', 'AssignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Assign')), +('Service-Macro-Assign', '5', 'AssignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Assign')), +('Service-Macro-Activate', '1', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Activate', '2', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Activate', '3', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Activate', '4', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Activate', '5', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Activate', '6', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Activate', '7', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Activate', '8', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Activate')), +('Service-Macro-Unassign', '1', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Unassign')), +('Service-Macro-Unassign', '2', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Unassign')), +('Service-Macro-Unassign', '3', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Unassign')), +('Service-Macro-Unassign', '4', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Unassign')), +('Service-Macro-Unassign', '5', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Unassign')), +('Service-Macro-Create', '1', 'AssignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '2', 'CreateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '3', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '4', 'AssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '5', 'AssignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '6', 'AssignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '7', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '8', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '9', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '10', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '11', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '12', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '13', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '14', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Create', '15', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create')), +('Service-Macro-Delete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '5', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '6', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '7', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '8', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '9', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '10', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '11', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '12', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '13', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Service-Macro-Delete', '14', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete')), +('Network-Create', '1', 'AssignNetwork1802BB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create')), +('Network-Create', '2', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create')), +('Network-Create', '3', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create')), +('Network-Delete', '1', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Delete')), +('Network-Delete', '2', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Delete')), +('Network-Delete', '3', 'UnassignNetwork1802BB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Delete')), +('VNF-Create', '1', 'AssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Create')), +('VNF-Create', '2', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Create')), +('VNF-Delete', '1', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Delete')), +('VNF-Delete', '2', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Delete')), +('VNF-Macro-Recreate', '1', 'AAICheckVnfInMaintBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate')), +('VNF-Macro-Recreate', '2', 'AAISetVnfInMaintBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate')), +('VNF-Macro-Recreate', '3', 'VNF-Macro-Replace', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate')), +('VNF-Macro-Recreate', '4', 'SDNOVnfHealthCheckBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate')), +('VNF-Macro-Recreate', '5', 'AAIUnsetVnfInMaintBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Recreate')), +('VNF-Macro-Replace', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Replace')), +('VNF-Macro-Replace', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Replace')), +('VNF-Macro-Replace', '3', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Replace')), +('VNF-Macro-Replace', '4', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Replace')), +('VNF-Macro-Replace', '5', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Replace')), +('VNF-Macro-Replace', '6', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Macro-Replace')), +('VolumeGroup-Create', '1', 'AssignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VolumeGroup-Create')), +('VolumeGroup-Create', '2', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VolumeGroup-Create')), +('VolumeGroup-Create', '3', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VolumeGroup-Create')), +('VolumeGroup-Delete', '1', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VolumeGroup-Delete')), +('VolumeGroup-Delete', '2', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VolumeGroup-Delete')), +('VolumeGroup-Delete', '3', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VolumeGroup-Delete')), +('VFModule-Create', '1', 'AssignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Create')), +('VFModule-Create', '2', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Create')), +('VFModule-Create', '3', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Create')), +('VFModule-Delete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete')), +('VFModule-Delete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete')), +('VFModule-Delete', '3', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete')), +('VFModule-DeactivateAndCloudDelete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-DeactivateAndCloudDelete')), +('VFModule-DeactivateAndCloudDelete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-DeactivateAndCloudDelete')), +('NetworkCollection-Macro-Create', '1', 'CreateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Create')), +('NetworkCollection-Macro-Create', '2', 'AssignNetworkBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Create')), +('NetworkCollection-Macro-Create', '3', 'CreateNetworkBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Create')), +('NetworkCollection-Macro-Create', '4', 'ActivateNetworkBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Create')), +('NetworkCollection-Macro-Create', '5', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Create')), +('NetworkCollection-Macro-Delete', '1', 'DeactivateNetworkBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Delete')), +('NetworkCollection-Macro-Delete', '2', 'DeleteNetworkBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Delete')), +('NetworkCollection-Macro-Delete', '3', 'UnassignNetworkBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Delete')), +('NetworkCollection-Macro-Delete', '4', 'DeleteNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'NetworkCollection-Macro-Delete')); + +INSERT INTO orchestration_status_state_transition_directive (RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) +VALUES +('SERVICE', 'PRECREATED', 'ASSIGN', 'CONTINUE'), +('VNF', 'PRECREATED', 'ASSIGN', 'CONTINUE'), +('VOLUME_GROUP', 'PRECREATED', 'ASSIGN', 'CONTINUE'), +('VF_MODULE', 'PRECREATED', 'ASSIGN', 'CONTINUE'), +('NETWORK', 'PRECREATED', 'ASSIGN', 'CONTINUE'), +('SERVICE', 'INVENTORIED', 'ASSIGN', 'CONTINUE'), +('VNF', 'INVENTORIED', 'ASSIGN', 'CONTINUE'), +('VOLUME_GROUP', 'INVENTORIED', 'ASSIGN', 'FAIL'), +('VF_MODULE', 'INVENTORIED', 'ASSIGN', 'CONTINUE'), +('NETWORK', 'INVENTORIED', 'ASSIGN', 'CONTINUE'), +('SERVICE', 'ASSIGNED', 'ASSIGN', 'SILENT_SUCCESS'), +('VNF', 'ASSIGNED', 'ASSIGN', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'ASSIGNED', 'ASSIGN', 'SILENT_SUCCESS'), +('VF_MODULE', 'ASSIGNED', 'ASSIGN', 'SILENT_SUCCESS'), +('NETWORK', 'ASSIGNED', 'ASSIGN', 'SILENT_SUCCESS'), +('SERVICE', 'CREATED', 'ASSIGN', 'SILENT_SUCCESS'), +('VNF', 'CREATED', 'ASSIGN', 'CONTINUE'), +('VOLUME_GROUP', 'CREATED', 'ASSIGN', 'FAIL'), +('VF_MODULE', 'CREATED', 'ASSIGN', 'SILENT_SUCCESS'), +('NETWORK', 'CREATED', 'ASSIGN', 'SILENT_SUCCESS'), +('SERVICE', 'ACTIVE', 'ASSIGN', 'SILENT_SUCCESS'), +('VNF', 'ACTIVE', 'ASSIGN', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'ACTIVE', 'ASSIGN', 'SILENT_SUCCESS'), +('VF_MODULE', 'ACTIVE', 'ASSIGN', 'SILENT_SUCCESS'), +('NETWORK', 'ACTIVE', 'ASSIGN', 'SILENT_SUCCESS'), +('SERVICE', 'PENDING_CREATE', 'ASSIGN', 'FAIL'), +('VNF', 'PENDING_CREATE', 'ASSIGN', 'FAIL'), +('VOLUME_GROUP', 'PENDING_CREATE', 'ASSIGN', 'FAIL'), +('VF_MODULE', 'PENDING_CREATE', 'ASSIGN', 'CONTINUE'), +('NETWORK', 'PENDING_CREATE', 'ASSIGN', 'SILENT_SUCCESS'), +('SERVICE', 'PENDING_DELETE', 'ASSIGN', 'SILENT_SUCCESS'), +('VNF', 'PENDING_DELETE', 'ASSIGN', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'PENDING_DELETE', 'ASSIGN', 'FAIL'), +('VF_MODULE', 'PENDING_DELETE', 'ASSIGN', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_DELETE', 'ASSIGN', 'SILENT_SUCCESS'), +('SERVICE', 'PENDING_ACTIVATION', 'ASSIGN', 'FAIL'), +('VNF', 'PENDING_ACTIVATION', 'ASSIGN', 'FAIL'), +('VOLUME_GROUP', 'PENDING_ACTIVATION', 'ASSIGN', 'FAIL'), +('VF_MODULE', 'PENDING_ACTIVATION', 'ASSIGN', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_ACTIVATION', 'ASSIGN', 'FAIL'), +('SERVICE', 'PENDING', 'ASSIGN', 'FAIL'), +('VNF', 'PENDING', 'ASSIGN', 'FAIL'), +('VOLUME_GROUP', 'PENDING', 'ASSIGN', 'SILENT_SUCCESS'), +('VF_MODULE', 'PENDING', 'ASSIGN', 'FAIL'), +('NETWORK', 'PENDING', 'ASSIGN', 'FAIL'), +('SERVICE', 'PRECREATED', 'UNASSIGN', 'SILENT_SUCCESS'), +('VNF', 'PRECREATED', 'UNASSIGN', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'PRECREATED', 'UNASSIGN', 'SILENT_SUCCESS'), +('VF_MODULE', 'PRECREATED', 'UNASSIGN', 'SILENT_SUCCESS'), +('NETWORK', 'PRECREATED', 'UNASSIGN', 'SILENT_SUCCESS'), +('SERVICE', 'INVENTORIED', 'UNASSIGN', 'CONTINUE'), +('VNF', 'INVENTORIED', 'UNASSIGN', 'CONTINUE'), +('VOLUME_GROUP', 'INVENTORIED', 'UNASSIGN', 'FAIL'), +('VF_MODULE', 'INVENTORIED', 'UNASSIGN', 'CONTINUE'), +('NETWORK', 'INVENTORIED', 'UNASSIGN', 'CONTINUE'), +('SERVICE', 'ASSIGNED', 'UNASSIGN', 'CONTINUE'), +('VNF', 'ASSIGNED', 'UNASSIGN', 'CONTINUE'), +('VOLUME_GROUP', 'ASSIGNED', 'UNASSIGN', 'CONTINUE'), +('VF_MODULE', 'ASSIGNED', 'UNASSIGN', 'CONTINUE'), +('NETWORK', 'ASSIGNED', 'UNASSIGN', 'CONTINUE'), +('SERVICE', 'CREATED', 'UNASSIGN', 'CONTINUE'), +('VNF', 'CREATED', 'UNASSIGN', 'CONTINUE'), +('VOLUME_GROUP', 'CREATED', 'UNASSIGN', 'FAIL'), +('VF_MODULE', 'CREATED', 'UNASSIGN', 'FAIL'), +('NETWORK', 'CREATED', 'UNASSIGN', 'FAIL'), +('SERVICE', 'ACTIVE', 'UNASSIGN', 'FAIL'), +('VNF', 'ACTIVE', 'UNASSIGN', 'FAIL'), +('VOLUME_GROUP', 'ACTIVE', 'UNASSIGN', 'FAIL'), +('VF_MODULE', 'ACTIVE', 'UNASSIGN', 'FAIL'), +('NETWORK', 'ACTIVE', 'UNASSIGN', 'FAIL'), +('SERVICE', 'PENDING_CREATE', 'UNASSIGN', 'FAIL'), +('VNF', 'PENDING_CREATE', 'UNASSIGN', 'FAIL'), +('VOLUME_GROUP', 'PENDING_CREATE', 'UNASSIGN', 'FAIL'), +('VF_MODULE', 'PENDING_CREATE', 'UNASSIGN', 'CONTINUE'), +('NETWORK', 'PENDING_CREATE', 'UNASSIGN', 'CONTINUE'), +('SERVICE', 'PENDING_DELETE', 'UNASSIGN', 'CONTINUE'), +('VNF', 'PENDING_DELETE', 'UNASSIGN', 'CONTINUE'), +('VOLUME_GROUP', 'PENDING_DELETE', 'UNASSIGN', 'FAIL'), +('VF_MODULE', 'PENDING_DELETE', 'UNASSIGN', 'CONTINUE'), +('NETWORK', 'PENDING_DELETE', 'UNASSIGN', 'CONTINUE'), +('SERVICE', 'PENDING_ACTIVATION', 'UNASSIGN', 'FAIL'), +('VNF', 'PENDING_ACTIVATION', 'UNASSIGN', 'FAIL'), +('VOLUME_GROUP', 'PENDING_ACTIVATION', 'UNASSIGN', 'FAIL'), +('VF_MODULE', 'PENDING_ACTIVATION', 'UNASSIGN', 'CONTINUE'), +('NETWORK', 'PENDING_ACTIVATION', 'UNASSIGN', 'FAIL'), +('SERVICE', 'PENDING', 'UNASSIGN', 'FAIL'), +('VNF', 'PENDING', 'UNASSIGN', 'FAIL'), +('VOLUME_GROUP', 'PENDING', 'UNASSIGN', 'CONTINUE'), +('VF_MODULE', 'PENDING', 'UNASSIGN', 'FAIL'), +('NETWORK', 'PENDING', 'UNASSIGN', 'FAIL'), +('SERVICE', 'PRECREATED', 'ACTIVATE', 'FAIL'), +('VNF', 'PRECREATED', 'ACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PRECREATED', 'ACTIVATE', 'FAIL'), +('VF_MODULE', 'PRECREATED', 'ACTIVATE', 'FAIL'), +('NETWORK', 'PRECREATED', 'ACTIVATE', 'FAIL'), +('SERVICE', 'INVENTORIED', 'ACTIVATE', 'FAIL'), +('VNF', 'INVENTORIED', 'ACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'INVENTORIED', 'ACTIVATE', 'FAIL'), +('VF_MODULE', 'INVENTORIED', 'ACTIVATE', 'FAIL'), +('NETWORK', 'INVENTORIED', 'ACTIVATE', 'FAIL'), +('SERVICE', 'ASSIGNED', 'ACTIVATE', 'CONTINUE'), +('VNF', 'ASSIGNED', 'ACTIVATE', 'CONTINUE'), +('VOLUME_GROUP', 'ASSIGNED', 'ACTIVATE', 'FAIL'), +('VF_MODULE', 'ASSIGNED', 'ACTIVATE', 'FAIL'), +('NETWORK', 'ASSIGNED', 'ACTIVATE', 'FAIL'), +('SERVICE', 'CREATED', 'ACTIVATE', 'CONTINUE'), +('VNF', 'CREATED', 'ACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'CREATED', 'ACTIVATE', 'CONTINUE'), +('VF_MODULE', 'CREATED', 'ACTIVATE', 'CONTINUE'), +('NETWORK', 'CREATED', 'ACTIVATE', 'CONTINUE'), +('SERVICE', 'ACTIVE', 'ACTIVATE', 'SILENT_SUCCESS'), +('VNF', 'ACTIVE', 'ACTIVATE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'ACTIVE', 'ACTIVATE', 'SILENT_SUCCESS'), +('VF_MODULE', 'ACTIVE', 'ACTIVATE', 'SILENT_SUCCESS'), +('NETWORK', 'ACTIVE', 'ACTIVATE', 'SILENT_SUCCESS'), +('SERVICE', 'PENDING_CREATE', 'ACTIVATE', 'FAIL'), +('VNF', 'PENDING_CREATE', 'ACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PENDING_CREATE', 'ACTIVATE', 'FAIL'), +('VF_MODULE', 'PENDING_CREATE', 'ACTIVATE', 'FAIL'), +('NETWORK', 'PENDING_CREATE', 'ACTIVATE', 'FAIL'), +('SERVICE', 'PENDING_DELETE', 'ACTIVATE', 'CONTINUE'), +('VNF', 'PENDING_DELETE', 'ACTIVATE', 'CONTINUE'), +('VOLUME_GROUP', 'PENDING_DELETE', 'ACTIVATE', 'FAIL'), +('VF_MODULE', 'PENDING_DELETE', 'ACTIVATE', 'FAIL'), +('NETWORK', 'PENDING_DELETE', 'ACTIVATE', 'FAIL'), +('SERVICE', 'PENDING_ACTIVATION', 'ACTIVATE', 'FAIL'), +('VNF', 'PENDING_ACTIVATION', 'ACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PENDING_ACTIVATION', 'ACTIVATE', 'FAIL'), +('VF_MODULE', 'PENDING_ACTIVATION', 'ACTIVATE', 'FAIL'), +('NETWORK', 'PENDING_ACTIVATION', 'ACTIVATE', 'FAIL'), +('SERVICE', 'PENDING', 'ACTIVATE', 'FAIL'), +('VNF', 'PENDING', 'ACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PENDING', 'ACTIVATE', 'FAIL'), +('VF_MODULE', 'PENDING', 'ACTIVATE', 'FAIL'), +('NETWORK', 'PENDING', 'ACTIVATE', 'FAIL'), +('SERVICE', 'PRECREATED', 'DEACTIVATE', 'FAIL'), +('VNF', 'PRECREATED', 'DEACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PRECREATED', 'DEACTIVATE', 'FAIL'), +('VF_MODULE', 'PRECREATED', 'DEACTIVATE', 'FAIL'), +('NETWORK', 'PRECREATED', 'DEACTIVATE', 'FAIL'), +('SERVICE', 'INVENTORIED', 'DEACTIVATE', 'FAIL'), +('VNF', 'INVENTORIED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'INVENTORIED', 'DEACTIVATE', 'FAIL'), +('VF_MODULE', 'INVENTORIED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('NETWORK', 'INVENTORIED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('SERVICE', 'ASSIGNED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VNF', 'ASSIGNED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'ASSIGNED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VF_MODULE', 'ASSIGNED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('NETWORK', 'ASSIGNED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('SERVICE', 'CREATED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VNF', 'CREATED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'CREATED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VF_MODULE', 'CREATED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('NETWORK', 'CREATED', 'DEACTIVATE', 'SILENT_SUCCESS'), +('SERVICE', 'ACTIVE', 'DEACTIVATE', 'CONTINUE'), +('VNF', 'ACTIVE', 'DEACTIVATE', 'CONTINUE'), +('VOLUME_GROUP', 'ACTIVE', 'DEACTIVATE', 'CONTINUE'), +('VF_MODULE', 'ACTIVE', 'DEACTIVATE', 'CONTINUE'), +('NETWORK', 'ACTIVE', 'DEACTIVATE', 'CONTINUE'), +('SERVICE', 'PENDING_CREATE', 'DEACTIVATE', 'FAIL'), +('VNF', 'PENDING_CREATE', 'DEACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PENDING_CREATE', 'DEACTIVATE', 'FAIL'), +('VF_MODULE', 'PENDING_CREATE', 'DEACTIVATE', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_CREATE', 'DEACTIVATE', 'SILENT_SUCCESS'), +('SERVICE', 'PENDING_DELETE', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VNF', 'PENDING_DELETE', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'PENDING_DELETE', 'DEACTIVATE', 'FAIL'), +('VF_MODULE', 'PENDING_DELETE', 'DEACTIVATE', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_DELETE', 'DEACTIVATE', 'SILENT_SUCCESS'), +('SERVICE', 'PENDING_ACTIVATION', 'DEACTIVATE', 'FAIL'), +('VNF', 'PENDING_ACTIVATION', 'DEACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PENDING_ACTIVATION', 'DEACTIVATE', 'FAIL'), +('VF_MODULE', 'PENDING_ACTIVATION', 'DEACTIVATE', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_ACTIVATION', 'DEACTIVATE', 'FAIL'), +('SERVICE', 'PENDING', 'DEACTIVATE', 'FAIL'), +('VNF', 'PENDING', 'DEACTIVATE', 'FAIL'), +('VOLUME_GROUP', 'PENDING', 'DEACTIVATE', 'SILENT_SUCCESS'), +('VF_MODULE', 'PENDING', 'DEACTIVATE', 'FAIL'), +('NETWORK', 'PENDING', 'DEACTIVATE', 'FAIL'), +('SERVICE', 'PRECREATED', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'PRECREATED', 'CHANGE_MODEL', 'FAIL'), +('VF_MODULE', 'PRECREATED', 'CHANGE_MODEL', 'FAIL'), +('SERVICE', 'INVENTORIED', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'INVENTORIED', 'CHANGE_MODEL', 'FAIL'), +('VF_MODULE', 'INVENTORIED', 'CHANGE_MODEL', 'FAIL'), +('SERVICE', 'ASSIGNED', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'ASSIGNED', 'CHANGE_MODEL', 'CONTINUE'), +('VF_MODULE', 'ASSIGNED', 'CHANGE_MODEL', 'CONTINUE'), +('SERVICE', 'CREATED', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'CREATED', 'CHANGE_MODEL', 'FAIL'), +('VF_MODULE', 'CREATED', 'CHANGE_MODEL', 'FAIL'), +('SERVICE', 'ACTIVE', 'CHANGE_MODEL', 'CONTINUE'), +('VNF', 'ACTIVE', 'CHANGE_MODEL', 'CONTINUE'), +('VF_MODULE', 'ACTIVE', 'CHANGE_MODEL', 'CONTINUE'), +('SERVICE', 'PENDING_CREATE', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'PENDING_CREATE', 'CHANGE_MODEL', 'FAIL'), +('VF_MODULE', 'PENDING_CREATE', 'CHANGE_MODEL', 'FAIL'), +('SERVICE', 'PENDING_DELETE', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'PENDING_DELETE', 'CHANGE_MODEL', 'CONTINUE'), +('VF_MODULE', 'PENDING_DELETE', 'CHANGE_MODEL', 'CONTINUE'), +('SERVICE', 'PENDING_ACTIVATION', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'PENDING_ACTIVATION', 'CHANGE_MODEL', 'CONTINUE'), +('VF_MODULE', 'PENDING_ACTIVATION', 'CHANGE_MODEL', 'CONTINUE'), +('SERVICE', 'PENDING', 'CHANGE_MODEL', 'FAIL'), +('VNF', 'PENDING', 'CHANGE_MODEL', 'FAIL'), +('VF_MODULE', 'PENDING', 'CHANGE_MODEL', 'FAIL'), +('VOLUME_GROUP', 'PRECREATED', 'CREATE', 'FAIL'), +('VF_MODULE', 'PRECREATED', 'CREATE', 'FAIL'), +('NETWORK', 'PRECREATED', 'CREATE', 'FAIL'), +('VOLUME_GROUP', 'INVENTORIED', 'CREATE', 'FAIL'), +('VF_MODULE', 'INVENTORIED', 'CREATE', 'FAIL'), +('NETWORK', 'INVENTORIED', 'CREATE', 'FAIL'), +('VOLUME_GROUP', 'ASSIGNED', 'CREATE', 'CONTINUE'), +('VF_MODULE', 'ASSIGNED', 'CREATE', 'CONTINUE'), +('NETWORK', 'ASSIGNED', 'CREATE', 'CONTINUE'), +('VOLUME_GROUP', 'CREATED', 'CREATE', 'SILENT_SUCCESS'), +('VF_MODULE', 'CREATED', 'CREATE', 'SILENT_SUCCESS'), +('NETWORK', 'CREATED', 'CREATE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'ACTIVE', 'CREATE', 'SILENT_SUCCESS'), +('VF_MODULE', 'ACTIVE', 'CREATE', 'SILENT_SUCCESS'), +('NETWORK', 'ACTIVE', 'CREATE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'PENDING_CREATE', 'CREATE', 'FAIL'), +('VF_MODULE', 'PENDING_CREATE', 'CREATE', 'FAIL'), +('NETWORK', 'PENDING_CREATE', 'CREATE', 'CONTINUE'), +('VOLUME_GROUP', 'PENDING_DELETE', 'CREATE', 'FAIL'), +('VF_MODULE', 'PENDING_DELETE', 'CREATE', 'CONTINUE'), +('NETWORK', 'PENDING_DELETE', 'CREATE', 'CONTINUE'), +('VOLUME_GROUP', 'PENDING_ACTIVATION', 'CREATE', 'FAIL'), +('VF_MODULE', 'PENDING_ACTIVATION', 'CREATE', 'FAIL'), +('NETWORK', 'PENDING_ACTIVATION', 'CREATE', 'FAIL'), +('VOLUME_GROUP', 'PENDING', 'CREATE', 'CONTINUE'), +('VF_MODULE', 'PENDING', 'CREATE', 'FAIL'), +('NETWORK', 'PENDING', 'CREATE', 'FAIL'), +('VOLUME_GROUP', 'PRECREATED', 'DELETE', 'FAIL'), +('VF_MODULE', 'PRECREATED', 'DELETE', 'FAIL'), +('NETWORK', 'PRECREATED', 'DELETE', 'FAIL'), +('VOLUME_GROUP', 'INVENTORIED', 'DELETE', 'FAIL'), +('VF_MODULE', 'INVENTORIED', 'DELETE', 'SILENT_SUCCESS'), +('NETWORK', 'INVENTORIED', 'DELETE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'ASSIGNED', 'DELETE', 'SILENT_SUCCESS'), +('VF_MODULE', 'ASSIGNED', 'DELETE', 'SILENT_SUCCESS'), +('NETWORK', 'ASSIGNED', 'DELETE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'CREATED', 'DELETE', 'CONTINUE'), +('VF_MODULE', 'CREATED', 'DELETE', 'CONTINUE'), +('NETWORK', 'CREATED', 'DELETE', 'CONTINUE'), +('VOLUME_GROUP', 'ACTIVE', 'DELETE', 'FAIL'), +('VF_MODULE', 'ACTIVE', 'DELETE', 'FAIL'), +('NETWORK', 'ACTIVE', 'DELETE', 'FAIL'), +('VOLUME_GROUP', 'PENDING_CREATE', 'DELETE', 'FAIL'), +('VF_MODULE', 'PENDING_CREATE', 'DELETE', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_CREATE', 'DELETE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'PENDING_DELETE', 'DELETE', 'FAIL'), +('VF_MODULE', 'PENDING_DELETE', 'DELETE', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_DELETE', 'DELETE', 'SILENT_SUCCESS'), +('VOLUME_GROUP', 'PENDING_ACTIVATION', 'DELETE', 'FAIL'), +('VF_MODULE', 'PENDING_ACTIVATION', 'DELETE', 'SILENT_SUCCESS'), +('NETWORK', 'PENDING_ACTIVATION', 'DELETE', 'FAIL'), +('VOLUME_GROUP', 'PENDING', 'DELETE', 'SILENT_SUCCESS'), +('VF_MODULE', 'PENDING', 'DELETE', 'FAIL'), +('NETWORK', 'PENDING', 'DELETE', 'FAIL'), +('CUSTOM', 'ACTIVE', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'ASSIGNED', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'CREATED', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'INVENTORIED', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'PENDING', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'PENDING_ACTIVATION', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'PENDING_CREATE', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'PENDING_DELETE', 'CUSTOM', 'CONTINUE'), +('CUSTOM', 'PRECREATED', 'CUSTOM', 'CONTINUE'); diff --git a/mso-catalog-db/src/test/resources/logback-test.xml b/mso-catalog-db/src/test/resources/logback-test.xml index a23395fe1b..0bf39bdad1 100644 --- a/mso-catalog-db/src/test/resources/logback-test.xml +++ b/mso-catalog-db/src/test/resources/logback-test.xml @@ -37,8 +37,11 @@ <logger name="com.att.eelf.error" level="trace" additivity="false"> <appender-ref ref="STDOUT" /> - </logger> - + </logger> + + <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> <root level="info"> <appender-ref ref="STDOUT" /> </root> diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql new file mode 100644 index 0000000000..b4b9c0d28b --- /dev/null +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -0,0 +1,826 @@ + + +CREATE TABLE IF NOT EXISTS `northbound_request_ref_lookup` ( +`id` INT(11) NOT NULL AUTO_INCREMENT, +`REQUEST_SCOPE` VARCHAR(200) NOT NULL, +`MACRO_ACTION` VARCHAR(200) NOT NULL, +`ACTION` VARCHAR(200) NOT NULL, +`IS_ALACARTE` TINYINT(1) NOT NULL DEFAULT 0, +`IS_TOPLEVELFLOW` TINYINT(1) NOT NULL DEFAULT 0, +`MIN_API_VERSION` DOUBLE NOT NULL, +`MAX_API_VERSION` DOUBLE NULL, +PRIMARY KEY (`id`), +UNIQUE INDEX `UK_northbound_request_ref_lookup` (`MIN_API_VERSION` ASC, `REQUEST_SCOPE` ASC, `ACTION` ASC, `IS_ALACARTE` ASC, `MACRO_ACTION` ASC)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + +CREATE TABLE IF NOT EXISTS building_block_detail ( +id INT(11) AUTO_INCREMENT, +BUILDING_BLOCK_NAME VARCHAR(200) NOT NULL, +RESOURCE_TYPE VARCHAR(25) NOT NULL, +TARGET_ACTION VARCHAR(25) NOT NULL, +PRIMARY KEY(`id`), +UNIQUE INDEX `UK_building_block_name`(`BUILDING_BLOCK_NAME`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + +CREATE TABLE IF NOT EXISTS `orchestration_flow_reference` ( +`id` INT(11) NOT NULL AUTO_INCREMENT, +`COMPOSITE_ACTION` VARCHAR(200) NOT NULL, +`SEQ_NO` INT(11) NOT NULL, +`FLOW_NAME` VARCHAR(200) NOT NULL, +`FLOW_VERSION` DOUBLE NOT NULL, +`NB_REQ_REF_LOOKUP_ID` INT(11) NOT NULL, +PRIMARY KEY (`id`), +INDEX `fk_orchestration_flow_reference__northbound_req_ref_look_idx` (`NB_REQ_REF_LOOKUP_ID` ASC), +UNIQUE INDEX `UK_orchestration_flow_reference` (`COMPOSITE_ACTION` ASC, `FLOW_NAME` ASC, `SEQ_NO` ASC, `NB_REQ_REF_LOOKUP_ID` ASC), +CONSTRAINT `fk_orchestration_flow_reference__northbound_request_ref_look1` +FOREIGN KEY (`NB_REQ_REF_LOOKUP_ID`) REFERENCES `northbound_request_ref_lookup` (`id`) +ON DELETE CASCADE ON UPDATE CASCADE +) +ENGINE = InnoDB DEFAULT CHARACTER SET = latin1; + +create table `allotted_resource` ( + `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) default null, + `subcategory` varchar(200) default null, + `description` varchar(1200) default null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`model_uuid`) +) engine=innodb default charset=latin1; + + + + +create table `allotted_resource_customization` ( + `model_customization_uuid` varchar(200) not null, + `model_instance_name` varchar(200) not null, + `providing_service_model_uuid` varchar(200) default null, + `providing_service_model_invariant_uuid` varchar(200) default null, + `providing_service_model_name` varchar(200) default null, + `target_network_role` varchar(200) default null, + `nf_type` varchar(200) default null, + `nf_role` varchar(200) default null, + `nf_function` varchar(200) default null, + `nf_naming_code` varchar(200) default null, + `min_instances` int(11) default null, + `max_instances` int(11) default null, + `ar_model_uuid` varchar(200) not null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`model_customization_uuid`), + key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), + constraint `fk_allotted_resource_customization__allotted_resource1` foreign key (`ar_model_uuid`) references `allotted_resource` (`model_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + + +create table `heat_environment` ( + `artifact_uuid` varchar(200) not null, + `name` varchar(100) not null, + `version` varchar(20) not null, + `description` varchar(1200) default null, + `body` longtext not null, + `artifact_checksum` varchar(200) not null default 'manual record', + `creation_timestamp` datetime not null default current_timestamp, + primary key (`artifact_uuid`) +) engine=innodb default charset=latin1; + + + +create table `heat_files` ( + `artifact_uuid` varchar(200) not null, + `name` varchar(200) not null, + `version` varchar(20) not null, + `description` varchar(1200) default null, + `body` longtext not null, + `artifact_checksum` varchar(200) not null default 'manual record', + `creation_timestamp` datetime not null default current_timestamp, + primary key (`artifact_uuid`) +) engine=innodb default charset=latin1; + + + + +create table `heat_template` ( + `artifact_uuid` varchar(200) not null, + `name` varchar(200) not null, + `version` varchar(20) not null, + `description` varchar(1200) default null, + `body` longtext not null, + `timeout_minutes` int(11) default null, + `artifact_checksum` varchar(200) not null default 'manual record', + `creation_timestamp` datetime not null default current_timestamp, + primary key (`artifact_uuid`) +) engine=innodb default charset=latin1; + + + +create table `heat_nested_template` ( + `parent_heat_template_uuid` varchar(200) not null, + `child_heat_template_uuid` varchar(200) not null, + `provider_resource_file` varchar(100) default null, + primary key (`parent_heat_template_uuid`,`child_heat_template_uuid`), + key `fk_heat_nested_template__heat_template2_idx` (`child_heat_template_uuid`), + constraint `fk_heat_nested_template__child_heat_temp_uuid__heat_template1` foreign key (`child_heat_template_uuid`) references `heat_template` (`artifact_uuid`) on delete cascade on update cascade, + constraint `fk_heat_nested_template__parent_heat_temp_uuid__heat_template1` foreign key (`parent_heat_template_uuid`) references `heat_template` (`artifact_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + + +create table `heat_template_params` ( + `heat_template_artifact_uuid` varchar(200) not null, + `param_name` varchar(100) not null, + `is_required` bit(1) not null, + `param_type` varchar(20) default null, + `param_alias` varchar(45) default null, + primary key (`heat_template_artifact_uuid`,`param_name`), + constraint `fk_heat_template_params__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + +create table `network_recipe` ( + `id` int(11) not null auto_increment, + `model_name` varchar(20) not null, + `action` varchar(50) not null, + `description` varchar(1200) default null, + `orchestration_uri` varchar(256) not null, + `network_param_xsd` varchar(2048) default null, + `recipe_timeout` int(11) default null, + `service_type` varchar(45) default null, + `creation_timestamp` datetime not null default current_timestamp, + `version_str` varchar(20) not null, + primary key (`id`), + unique key `uk_rl4f296i0p8lyokxveaiwkayi` (`model_name`,`action`,`version_str`) +) engine=innodb auto_increment=178 default charset=latin1; + + + + +create table `temp_network_heat_template_lookup` ( + `network_resource_model_name` varchar(200) not null, + `heat_template_artifact_uuid` varchar(200) not null, + `aic_version_min` varchar(20) not null, + `aic_version_max` varchar(20) default null, + primary key (`network_resource_model_name`), + key `fk_temp_network_heat_template_lookup__heat_template1_idx` (`heat_template_artifact_uuid`), + constraint `fk_temp_network_heat_template_lookup__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade +) engine=innodb default charset=latin1; + + + +create table `network_resource` ( + `model_uuid` varchar(200) not null, + `model_name` varchar(200) not null, + `model_invariant_uuid` varchar(200) default null, + `description` varchar(1200) default null, + `heat_template_artifact_uuid` varchar(200) not null, + `neutron_network_type` varchar(20) default null, + `model_version` varchar(20) default null, + `tosca_node_type` varchar(200) default null, + `aic_version_min` varchar(20) not null, + `aic_version_max` varchar(20) default null, + `orchestration_mode` varchar(20) default 'heat', + `resource_category` varchar(20) default null, + `resource_sub_category` varchar(20) default null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`model_uuid`), + key `fk_network_resource__temp_network_heat_template_lookup1_idx` (`model_name`), + key `fk_network_resource__heat_template1_idx` (`heat_template_artifact_uuid`), + constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade, + constraint `fk_network_resource__temp_network_heat_template_lookup__mod_nm1` foreign key (`model_name`) references `temp_network_heat_template_lookup` (`network_resource_model_name`) on delete no action on update no action +) engine=innodb default charset=latin1; + + + + + +create table `network_resource_customization` ( + `model_customization_uuid` varchar(200) not null, + `model_instance_name` varchar(200) not null, + `network_technology` varchar(45) default null, + `network_type` varchar(45) default null, + `network_role` varchar(200) default null, + `network_scope` varchar(45) default null, + `creation_timestamp` datetime not null default current_timestamp, + `network_resource_model_uuid` varchar(200) not null, + primary key (`model_customization_uuid`), + key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), + constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + + + +create table `tosca_csar` ( + `artifact_uuid` varchar(200) not null, + `name` varchar(200) not null, + `version` varchar(20) not null, + `description` varchar(1200) default null, + `artifact_checksum` varchar(200) not null, + `url` varchar(200) not null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`artifact_uuid`) +) engine=innodb default charset=latin1; + + + + +create table `service` ( + `model_uuid` varchar(200) not null, + `model_name` varchar(200) not null, + `model_invariant_uuid` varchar(200) not null, + `model_version` varchar(20) not null, + `description` varchar(1200) default null, + `creation_timestamp` datetime not null default current_timestamp, + `tosca_csar_artifact_uuid` varchar(200) default null, + `service_type` varchar(200) default null, + `service_role` varchar(200) default null, + `environment_context` varchar(200) default null, + `workload_context` varchar(200) default null, + `service_category` varchar(200) default null, + primary key (`model_uuid`), + key `fk_service__tosca_csar1_idx` (`tosca_csar_artifact_uuid`), + constraint `fk_service__tosca_csar1` foreign key (`tosca_csar_artifact_uuid`) references `tosca_csar` (`artifact_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + +create table `service_recipe` ( + `id` int(11) not null auto_increment, + `action` varchar(50) not null, + `version_str` varchar(20) default null, + `description` varchar(1200) default null, + `orchestration_uri` varchar(256) not null, + `service_param_xsd` varchar(2048) default null, + `recipe_timeout` int(11) default null, + `service_timeout_interim` int(11) default null, + `creation_timestamp` datetime not null default current_timestamp, + `service_model_uuid` varchar(200) not null, + primary key (`id`), + unique key `uk_7fav5dkux2v8g9d2i5ymudlgc` (`service_model_uuid`,`action`), + key `fk_service_recipe__service1_idx` (`service_model_uuid`), + constraint `fk_service_recipe__service1` foreign key (`service_model_uuid`) references `service` (`model_uuid`) on delete cascade on update cascade +) engine=innodb auto_increment=86 default charset=latin1; + + + +create table `vnf_resource` ( + `orchestration_mode` varchar(20) not null default 'heat', + `description` varchar(1200) default null, + `creation_timestamp` datetime not null default current_timestamp, + `model_uuid` varchar(200) not null, + `aic_version_min` varchar(20) default null, + `aic_version_max` varchar(20) default null, + `model_invariant_uuid` varchar(200) default null, + `model_version` varchar(20) not null, + `model_name` varchar(200) default null, + `tosca_node_type` varchar(200) default null, + `resource_category` varchar(200) default null, + `resource_sub_category` varchar(200) default null, + `heat_template_artifact_uuid` varchar(200) default null, + primary key (`model_uuid`), + key `fk_vnf_resource__heat_template1` (`heat_template_artifact_uuid`), + constraint `fk_vnf_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + + +create table `vf_module` ( + `model_uuid` varchar(200) not null, + `model_invariant_uuid` varchar(200) default null, + `model_version` varchar(20) not null, + `model_name` varchar(200) not null, + `description` varchar(1200) default null, + `is_base` int(11) not null, + `heat_template_artifact_uuid` varchar(200) default null, + `vol_heat_template_artifact_uuid` varchar(200) default null, + `creation_timestamp` datetime not null default current_timestamp, + `vnf_resource_model_uuid` varchar(200) not null, + primary key (`model_uuid`,`vnf_resource_model_uuid`), + key `fk_vf_module__vnf_resource1_idx` (`vnf_resource_model_uuid`), + key `fk_vf_module__heat_template_art_uuid__heat_template1_idx` (`heat_template_artifact_uuid`), + key `fk_vf_module__vol_heat_template_art_uuid__heat_template2_idx` (`vol_heat_template_artifact_uuid`), + constraint `fk_vf_module__heat_template_art_uuid__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete cascade on update cascade, + constraint `fk_vf_module__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade, + constraint `fk_vf_module__vol_heat_template_art_uuid__heat_template2` foreign key (`vol_heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + +/*!40101 set @saved_cs_client = @@character_set_client */; +/*!40101 set character_set_client = utf8 */; +create table `vf_module_customization` ( + `model_customization_uuid` varchar(200) not null, + `label` varchar(200) default null, + `initial_count` int(11) default '0', + `min_instances` int(11) default '0', + `max_instances` int(11) default null, + `availability_zone_count` int(11) default null, + `heat_environment_artifact_uuid` varchar(200) default null, + `vol_environment_artifact_uuid` varchar(200) default null, + `creation_timestamp` datetime not null default current_timestamp, + `vf_module_model_uuid` varchar(200) not null, + primary key (`model_customization_uuid`), + key `fk_vf_module_customization__vf_module1_idx` (`vf_module_model_uuid`), + key `fk_vf_module_customization__heat_env__heat_environment1_idx` (`heat_environment_artifact_uuid`), + key `fk_vf_module_customization__vol_env__heat_environment2_idx` (`vol_environment_artifact_uuid`), + constraint `fk_vf_module_customization__heat_env__heat_environment1` foreign key (`heat_environment_artifact_uuid`) references `heat_environment` (`artifact_uuid`) on delete cascade on update cascade, + constraint `fk_vf_module_customization__vf_module1` foreign key (`vf_module_model_uuid`) references `vf_module` (`model_uuid`) on delete cascade on update cascade, + constraint `fk_vf_module_customization__vol_env__heat_environment2` foreign key (`vol_environment_artifact_uuid`) references `heat_environment` (`artifact_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; +/*!40101 set character_set_client = @saved_cs_client */; + +-- +-- table structure for table `vf_module_to_heat_files` +-- + + +/*!40101 set @saved_cs_client = @@character_set_client */; +/*!40101 set character_set_client = utf8 */; +create table `vf_module_to_heat_files` ( + `vf_module_model_uuid` varchar(200) not null, + `heat_files_artifact_uuid` varchar(200) not null, + primary key (`vf_module_model_uuid`,`heat_files_artifact_uuid`), + key `fk_vf_module_to_heat_files__heat_files__artifact_uuid1_idx` (`heat_files_artifact_uuid`), + constraint `fk_vf_module_to_heat_files__heat_files__artifact_uuid1` foreign key (`heat_files_artifact_uuid`) references `heat_files` (`artifact_uuid`) on delete cascade on update cascade, + constraint `fk_vf_module_to_heat_files__vf_module__model_uuid1` foreign key (`vf_module_model_uuid`) references `vf_module` (`model_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1 comment='il fait ce qu''il dit'; +/*!40101 set character_set_client = @saved_cs_client */; + +-- +-- table structure for table `vnf_components` +-- + + +/*!40101 set @saved_cs_client = @@character_set_client */; +/*!40101 set character_set_client = utf8 */; +create table `vnf_components` ( + `vnf_id` int(11) not null, + `component_type` varchar(20) not null, + `heat_template_id` int(11) default null, + `heat_environment_id` int(11) default null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`vnf_id`,`component_type`) +) engine=innodb default charset=latin1; +/*!40101 set character_set_client = @saved_cs_client */; + +-- +-- table structure for table `vnf_components_recipe` +-- + + + +create table `vnf_components_recipe` ( + `id` int(11) not null auto_increment, + `vnf_type` varchar(200) default null, + `vnf_component_type` varchar(45) not null, + `action` varchar(50) not null, + `service_type` varchar(45) default null, + `version` varchar(20) not null, + `description` varchar(1200) default null, + `orchestration_uri` varchar(256) not null, + `vnf_component_param_xsd` varchar(2048) default null, + `recipe_timeout` int(11) default null, + `creation_timestamp` datetime default current_timestamp, + `vf_module_model_uuid` varchar(200) default null, + primary key (`id`), + unique key `uk_4dpdwddaaclhc11wxsb7h59ma` (`vf_module_model_uuid`,`vnf_component_type`,`action`,`version`) +) engine=innodb auto_increment=26 default charset=latin1; + + + + +create table `vnf_recipe` ( + `id` int(11) not null auto_increment, + `vnf_type` varchar(200) default null, + `action` varchar(50) not null, + `service_type` varchar(45) default null, + `version_str` varchar(20) not null, + `description` varchar(1200) default null, + `orchestration_uri` varchar(256) not null, + `vnf_param_xsd` varchar(2048) default null, + `recipe_timeout` int(11) default null, + `creation_timestamp` datetime default current_timestamp, + `vf_module_id` varchar(100) default null, + primary key (`id`), + unique key `uk_f3tvqau498vrifq3cr8qnigkr` (`vf_module_id`,`action`,`version_str`) +) engine=innodb auto_increment=10006 default charset=latin1; + + + + + + + + +create table `vnf_resource_customization` ( + `model_customization_uuid` varchar(200) not null, + `model_instance_name` varchar(200) not null, + `min_instances` int(11) default null, + `max_instances` int(11) default null, + `availability_zone_max_count` int(11) default null, + `nf_type` varchar(200) default null, + `nf_role` varchar(200) default null, + `nf_function` varchar(200) default null, + `nf_naming_code` varchar(200) default null, + `creation_timestamp` datetime not null default current_timestamp, + `vnf_resource_model_uuid` varchar(200) not null, + `multi_stage_design` varchar(20) default null, + primary key (`model_customization_uuid`), + key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), + constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + + + +create table `vnf_res_custom_to_vf_module_custom` ( + `vnf_resource_cust_model_customization_uuid` varchar(200) not null, + `vf_module_cust_model_customization_uuid` varchar(200) not null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`vnf_resource_cust_model_customization_uuid`,`vf_module_cust_model_customization_uuid`), + key `fk_vnf_res_custom_to_vf_module_custom__vf_module_customizat_idx` (`vf_module_cust_model_customization_uuid`), + constraint `fk_vnf_res_custom_to_vf_module_custom__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_vnf_res_custom_to_vf_module_custom__vnf_resource_customiza1` foreign key (`vnf_resource_cust_model_customization_uuid`) references `vnf_resource_customization` (`model_customization_uuid`) on delete cascade on update cascade +) engine=innodb default charset=latin1; + + +create table if not exists external_service_to_internal_model_mapping ( +id int(11) not null, +service_name varchar(200) not null, +product_flavor varchar(200) null, +subscription_service_type varchar(200) not null, +service_model_uuid varchar(200) not null, +primary key (id), +unique index uk_external_service_to_internal_model_mapping +(service_name asc, product_flavor asc, service_model_uuid asc)); + +create table if not exists `collection_resource` ( + model_uuid varchar(200) not null, + model_name varchar(200) not null, + model_invariant_uuid varchar(200) not null, + model_version varchar(20) not null, + tosca_node_type varchar(200) not null, + description varchar(200), + creation_timestamp datetime not null default current_timestamp, + primary key (`model_uuid`) +)engine=innodb default charset=latin1; + +create table if not exists `collection_resource_customization` ( + model_customization_uuid varchar(200) not null, + model_instance_name varchar(200) not null, + role varchar(200) NULL, + object_type varchar(200) not null, + function varchar(200) NULL, + collection_resource_type varchar(200) NULL, + creation_timestamp datetime not null default current_timestamp, + cr_model_uuid varchar(200) not null, + primary key (`model_customization_uuid`) +)engine=innodb default charset=latin1; + +create table if not exists `instance_group` ( + model_uuid varchar(200) not null, + model_name varchar(200) not null, + model_invariant_uuid varchar(200) not null, + model_version varchar(20) not null, + tosca_node_type varchar(200) NULL, + role varchar(200) not null, + object_type varchar(200) not null, + creation_timestamp datetime not null default current_timestamp, + cr_model_uuid varchar(200) not null, + instance_group_type varchar(200) not null, + primary key (`model_uuid`) +)engine=innodb default charset=latin1; + +create table if not exists `collection_resource_instance_group_customization` ( + `collection_resource_customization_model_uuid` varchar(200) not null, + `instance_group_model_uuid` varchar(200) not null, + `function` varchar(200) null, + `description` varchar(1200) null, + `subinterface_network_quantity` int(11) null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`collection_resource_customization_model_uuid`, `instance_group_model_uuid`), + index `fk_collection_resource_instance_group_customization__instan_idx` (`instance_group_model_uuid` asc), + constraint `fk_collection_resource_instance_group_customization__collecti1` + foreign key (`collection_resource_customization_model_uuid`) + references `collection_resource_customization` (`model_customization_uuid`) + on delete cascade + on update cascade, + constraint `fk_collection_resource_instance_group_customization__instance1` + foreign key (`instance_group_model_uuid`) + references `instance_group` (`model_uuid`) + on delete cascade + on update cascade) +engine = innodb +default character set = latin1; + +create table if not exists `vnfc_instance_group_customization` ( + `vnf_resource_customization_model_uuid` varchar(200) not null, + `instance_group_model_uuid` varchar(200) not null, + `function` varchar(200) null, + `description` varchar(1200) null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`vnf_resource_customization_model_uuid`, `instance_group_model_uuid`), + index `fk_vnfc_instance_group_customization__instance_group1_idx` (`instance_group_model_uuid` asc), + constraint `fk_vnfc_instance_group_customization__vnf_resource_customizat1` + foreign key (`vnf_resource_customization_model_uuid`) + references `vnf_resource_customization` (`model_customization_uuid`) + on delete cascade + on update cascade, + constraint `fk_vnfc_instance_group_customization__instance_group1` + foreign key (`instance_group_model_uuid`) + references `instance_group` (`model_uuid`) + on delete cascade + on update cascade) +engine = innodb +default character set = latin1; + + create table if not exists `configuration` + ( `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, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`model_uuid`)) + engine = innodb auto_increment = 20654 + default character set = latin1; + + create table if not exists `service_proxy` ( + `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, + `description` varchar(1200) null, + `creation_timestamp` datetime not null default current_timestamp, + primary key (`model_uuid`)) + engine = innodb auto_increment = 20654 + default character set = latin1; + +create table if not exists `service_proxy_customization` ( +`model_customization_uuid` varchar(200) not null, +`model_instance_name` varchar(200) not null, +`tosca_node_type` varchar(200) not null, +`source_service_model_uuid` varchar(200) not null, +`creation_timestamp` datetime not null default current_timestamp, +`service_proxy_model_uuid` varchar(200) not null, +primary key (`model_customization_uuid`), +index `fk_service_proxy_customization__service_proxy1_idx` (`service_proxy_model_uuid` asc), +index `fk_service_proxy_customization__service1_idx` (`source_service_model_uuid` asc), +constraint`fk_spr_customization__service_proxy_resource1` +foreign key (`service_proxy_model_uuid`) references `service_proxy` (`model_uuid`) +on delete cascade on update cascade, +constraint `fk_service_proxy_resource_customization__service1` +foreign key (`source_service_model_uuid`) references `service` +(`model_uuid`) on delete cascade on update cascade) +engine = innodb +auto_increment = 20654 +default character set = latin1; + +create table if not exists `configuration_customization` ( +`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, +`creation_timestamp` datetime not null default current_timestamp, +`configuration_model_uuid` varchar(200) not null, +`service_proxy_customization_model_customization_uuid` varchar(200) null, +`configuration_customization_model_customization_uuid` varchar(200) null, +primary key (`model_customization_uuid`), +index `fk_configuration_customization__configuration_idx` (`configuration_model_uuid` asc), +index `fk_configuration_customization__service_proxy_customization_idx` +(`service_proxy_customization_model_customization_uuid` asc), +index `fk_configuration_customization__configuration_customization_idx` +(`configuration_customization_model_customization_uuid` asc), +constraint `fk_configuration_resource_customization__configuration_resour1` +foreign key (`configuration_model_uuid`) references `configuration` (`model_uuid`) +on delete cascade on update cascade, +constraint `fk_configuration_customization__service_proxy_customization1` foreign +key (`service_proxy_customization_model_customization_uuid`) references +`service_proxy_customization` (`model_customization_uuid`) +on delete cascade on update cascade, constraint +`fk_configuration_customization__configuration_customization1` foreign +key (`configuration_customization_model_customization_uuid`) references +`configuration_customization` (`model_customization_uuid`) +on delete cascade on update cascade) +engine = innodb +auto_increment =20654 +default character set = latin1; + + +create table `service_proxy_customization_to_service` ( + `service_model_uuid` varchar(200) not null, + `resource_model_customization_uuid` varchar(200) not null, + primary key (`service_model_uuid`,`resource_model_customization_uuid`) +)engine=innodb default charset=latin1; + + +create table `configuration_customization_to_service` ( + `service_model_uuid` varchar(200) not null, + `resource_model_customization_uuid` varchar(200) not null, + primary key (`service_model_uuid`,`resource_model_customization_uuid`) +)engine=innodb default charset=latin1; + + +create table if not exists `collection_resource_customization_to_service` ( + `service_model_uuid` varchar(200) not null, + `resource_model_customization_uuid` varchar(200) not null, + primary key (`service_model_uuid`,`resource_model_customization_uuid`) +)engine=innodb default charset=latin1; + + +create table `network_resource_customization_to_service` ( + `service_model_uuid` varchar(200) not null, + `resource_model_customization_uuid` varchar(200) not null, + primary key (`service_model_uuid`,`resource_model_customization_uuid`) +)engine=innodb default charset=latin1; + +create table `vnf_resource_customization_to_service` ( + `service_model_uuid` varchar(200) not null, + `resource_model_customization_uuid` varchar(200) not null, + primary key (`service_model_uuid`,`resource_model_customization_uuid`) +)engine=innodb default charset=latin1; + +create table `allotted_resource_customization_to_service` ( + `service_model_uuid` varchar(200) not null, + `resource_model_customization_uuid` varchar(200) not null, + primary key (`service_model_uuid`,`resource_model_customization_uuid`) +)engine=innodb default charset=latin1; + + + +create table ar_recipe ( + ID INT(11) not null auto_increment, + MODEL_NAME VARCHAR(200) NOT NULL, + `ACTION` VARCHAR(200) NOT NULL, + VERSION_STR VARCHAR(200) NOT NULL, + SERVICE_TYPE VARCHAR(200), + DESCRIPTION VARCHAR(200), + ORCHESTRATION_URI VARCHAR(200) NOT NULL, + AR_PARAM_XSD VARCHAR(200), + RECIPE_TIMEOUT INT(10), + CREATION_TIMESTAMP DATETIME NOT NULL default current_timestamp, + primary key (ID), + unique key `uk_ar_recipe` (`model_name`,`action`,`version_str`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +alter table collection_resource_customization +add foreign key ( cr_model_uuid) +references collection_resource(model_uuid) +on delete cascade; + +alter table vnf_resource_customization +add column +instance_group_model_uuid varchar(200); + +alter table network_resource_customization +add column +instance_group_model_uuid varchar(200); + + +alter table network_resource_customization +add foreign key ( instance_group_model_uuid) +references instance_group(model_uuid) +on delete cascade; + +alter table collection_resource_customization_to_service +add foreign key (service_model_uuid) +references service(model_uuid) +on delete cascade; + +alter table allotted_resource_customization_to_service +add foreign key (service_model_uuid) +references service(model_uuid) +on delete cascade; + + +alter table vnf_resource_customization_to_service +add foreign key (service_model_uuid) +references service(model_uuid) +on delete cascade; + + +alter table network_resource_customization_to_service +add foreign key (service_model_uuid) +references service(model_uuid) +on delete cascade; + + +alter table network_resource_customization_to_service +add foreign key (resource_model_customization_uuid) +references network_resource_customization(model_customization_uuid) +on delete cascade; + +alter table vnf_resource_customization_to_service +add foreign key (resource_model_customization_uuid) +references vnf_resource_customization(model_customization_uuid) +on delete cascade; + +alter table allotted_resource_customization_to_service +add foreign key (resource_model_customization_uuid) +references allotted_resource_customization(model_customization_uuid) +on delete cascade; + +alter table collection_resource_customization_to_service +add foreign key (resource_model_customization_uuid) +references collection_resource_customization(model_customization_uuid) +on delete cascade; + + +create table if not exists `collection_network_resource_customization` ( +`model_customization_uuid` varchar(200) not null, +`model_instance_name` varchar(200) not null, +`network_technology` varchar(45) null, +`network_type` varchar(45) null, +`network_role` varchar(200) null, +`network_scope` varchar(45) null, +`creation_timestamp` datetime not null default current_timestamp, +`network_resource_model_uuid` varchar(200) not null, `instance_group_model_uuid` varchar(200) null, +`crc_model_customization_uuid` varchar(200) not null, primary key +(`model_customization_uuid`, `crc_model_customization_uuid`), +index `fk_collection_net_resource_customization__network_resource1_idx` +(`network_resource_model_uuid` asc), index +`fk_collection_net_resource_customization__instance_group1_idx` +(`instance_group_model_uuid` asc), index +`fk_col_net_res_customization__collection_res_customization_idx` +(`crc_model_customization_uuid` asc), constraint +`fk_collection_net_resource_customization__network_resource10` foreign +key (`network_resource_model_uuid`) references +`network_resource` (`model_uuid`) on delete cascade on +update cascade, constraint +`fk_collection_net_resource_customization__instance_group10` foreign key +(`instance_group_model_uuid`) references `instance_group` +(`model_uuid`) on delete cascade on update cascade, constraint +`fk_collection_network_resource_customization__collection_reso1` foreign +key (`crc_model_customization_uuid`) references +`collection_resource_customization` +(`model_customization_uuid`) on delete cascade on update cascade) engine += innodb default character set = latin1; + +CREATE TABLE IF NOT EXISTS `northbound_request_ref_lookup` ( +`id` INT(11) NOT NULL AUTO_INCREMENT, +`REQUEST_SCOPE` VARCHAR(200) NOT NULL, +`MACRO_ACTION` VARCHAR(200) NOT NULL, +`ACTION` VARCHAR(200) NOT NULL, +`IS_ALACARTE` TINYINT(1) NOT NULL DEFAULT 0, +`IS_TOPLEVELFLOW` TINYINT(1) NOT NULL DEFAULT 1, +`MIN_API_VERSION` DOUBLE NOT NULL, +`MAX_API_VERSION` DOUBLE NULL, +PRIMARY KEY (`id`), +UNIQUE INDEX `UK_northbound_request_ref_lookup` (`MIN_API_VERSION` ASC, `REQUEST_SCOPE` ASC, `ACTION` ASC, `IS_ALACARTE` ASC, `MACRO_ACTION` ASC)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + +CREATE TABLE IF NOT EXISTS orchestration_status_state_transition_directive ( +id INT(11) AUTO_INCREMENT, +RESOURCE_TYPE VARCHAR(25) NOT NULL, +ORCHESTRATION_STATUS VARCHAR(25) NOT NULL, +TARGET_ACTION VARCHAR(25) NOT NULL, +FLOW_DIRECTIVE VARCHAR(25) NOT NULL, +PRIMARY KEY (id), +UNIQUE KEY UK_orchestration_status_state_transition_directive (RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + +create table if not exists model_recipe ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `MODEL_ID` INT(11), + `ACTION` VARCHAR(40), + `SCHEMA_VERSION` VARCHAR(40), + `DESCRIPTION` VARCHAR(40), + `ORCHESTRATION_URI` VARCHAR(20), + `MODEL_PARAM_XSD` VARCHAR(20), + `RECIPE_TIMEOUT` INT(11), + `CREATION_TIMESTAMP` datetime not null default current_timestamp, + PRIMARY KEY (`ID`), + CONSTRAINT uk1_model_recipe UNIQUE (`MODEL_ID`, `ACTION`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +create table if not exists model ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `MODEL_CUSTOMIZATION_ID` VARCHAR(40), + `MODEL_CUSTOMIZATION_NAME` VARCHAR(40), + `MODEL_INVARIANT_ID` VARCHAR(40), + `MODEL_NAME` VARCHAR(40), + `MODEL_TYPE` VARCHAR(20), + `MODEL_VERSION` VARCHAR(20), + `MODEL_VERSION_ID` VARCHAR(40), + `CREATION_TIMESTAMP` datetime not null default current_timestamp, + `RECIPE` INT(11), + PRIMARY KEY (`ID`), + CONSTRAINT uk1_model UNIQUE (`MODEL_TYPE`, `MODEL_VERSION_ID`), + FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +ALTER TABLE `vnf_recipe` +CHANGE COLUMN `VNF_TYPE` `NF_ROLE` VARCHAR(200) NULL DEFAULT NULL ;
\ No newline at end of file diff --git a/mso-catalog-db/src/test/resources/status-request.json b/mso-catalog-db/src/test/resources/status-request.json new file mode 100644 index 0000000000..b8714168eb --- /dev/null +++ b/mso-catalog-db/src/test/resources/status-request.json @@ -0,0 +1,82 @@ +{ + "requestInfo": { + "requestId": "random uuid", + "requestorId": "userid", + "sourceSystem": "VID", + "suppressRollback": false, + "seflLink":"http://getorchestrationrequest/request-id" + }, + "statusInfo": { + "result": "COMPLETED/FAILED/ManualFallout", + "statusMessage": "MESSSAGE", + "errorCode": "5000" + }, + "serviceInstance": { + "serviceInstanceId": "UUID", + "modelInfo": { + "modelInvariantId": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelInvariantUuid": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelName": "0503_Test", + "modelType": "service", + "modelUuid": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba", + "modelVersion": "1.0", + "modelVersionId": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba" + } + }, + "resourcesOrchestrated": { + "serviceInstance": { + "serviceInstanceId": "UUID", + "orchestrationStatus": "Active", + "modelInfo": { + "modelInvariantId": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelInvariantUuid": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelName": "0503_Test", + "modelType": "service", + "modelUuid": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba", + "modelVersion": "1.0", + "modelVersionId": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba" + }, + "actionsTaken": [ + "assign", + "create", + "activate" + ] + }, + "genericVnf": { + "genericVnfId": "UUID", + "orchestrationStatus": "Active", + "modelInfo": { + "modelInvariantId": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelInvariantUuid": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelName": "0503_Test", + "modelType": "service", + "modelUuid": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba", + "modelVersion": "1.0", + "modelVersionId": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba" + }, + "actionsTaken": [ + "assign", + "create", + "activate" + ] + }, + "vfModule": { + "vfModuleId": "UUID", + "orchestrationStatus": "Active", + "modelInfo": { + "modelInvariantId": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelInvariantUuid": "c8b07c20-02bc-4ecc-bd48-e27eab8617ae", + "modelName": "0503_Test", + "modelType": "service", + "modelUuid": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba", + "modelVersion": "1.0", + "modelVersionId": "b6f8ed8f-a3be-4f38-8a60-c74fcaaea8ba" + }, + "actionsTaken": [ + "assign", + "create", + "activate" + ] + } + } +}
\ No newline at end of file |