diff options
Diffstat (limited to 'mso-catalog-db/src')
7 files changed, 99 insertions, 34 deletions
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 index 059935fff3..1117648a7f 100644 --- 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 @@ -27,6 +27,8 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @@ -52,8 +54,12 @@ public class ConfigurationResourceCustomization implements Serializable { */ private static final long serialVersionUID = 1230671937560638856L; - @BusinessKey @Id + @BusinessKey + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @Column(name = "MODEL_CUSTOMIZATION_UUID") private String modelCustomizationUUID; @@ -77,18 +83,30 @@ public class ConfigurationResourceCustomization implements Serializable { private String serviceProxyResourceCustomizationUUID; @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID") + @JoinColumn(name = "CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_ID") private ConfigurationResourceCustomization configResourceCustomization; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "CONFIGURATION_MODEL_UUID") private ConfigurationResource configurationResource; + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "SERVICE_MODEL_UUID") + private Service service; + @PrePersist protected void onCreate() { this.created = new Date(); } + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getModelCustomizationUUID() { return modelCustomizationUUID; } @@ -141,6 +159,7 @@ public class ConfigurationResourceCustomization implements Serializable { this.serviceProxyResourceCustomizationUUID = serviceProxyResourceCustomizationUUID; } + @LinkedResource public ConfigurationResourceCustomization getConfigResourceCustomization() { return configResourceCustomization; @@ -159,14 +178,22 @@ public class ConfigurationResourceCustomization implements Serializable { this.configurationResource = configurationResource; } + public Service getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + @Override public String toString() { - return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID) + return new ToStringBuilder(this).append("id", id).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(); + .append("configurationResource", configurationResource).append("service", service).toString(); } @Override @@ -175,12 +202,12 @@ public class ConfigurationResourceCustomization implements Serializable { return false; } ConfigurationResourceCustomization castOther = (ConfigurationResourceCustomization) other; - return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals(); + return new EqualsBuilder().append(id, castOther.id).isEquals(); } @Override public int hashCode() { - return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode(); + return new HashCodeBuilder().append(id).toHashCode(); } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java index c333033ba2..ffcc8e9717 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java @@ -119,9 +119,7 @@ public class Service implements Serializable { 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")) + @OneToMany(cascade = CascadeType.ALL, mappedBy = "service") private List<ConfigurationResourceCustomization> configurationCustomizations; @OneToMany(cascade = CascadeType.ALL) 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 index 43104986ff..74c4c8cb04 100644 --- 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 @@ -26,6 +26,6 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "configurationResourceCustomization", path = "configurationResourceCustomization") public interface ConfigurationResourceCustomizationRepository - extends JpaRepository<ConfigurationResourceCustomization, String> { + extends JpaRepository<ConfigurationResourceCustomization, Integer> { } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java index 0b9d50fa1e..4108464811 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepository.java @@ -28,5 +28,5 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "vnfcInstanceGroupCustomization", path = "vnfcInstanceGroupCustomization") public interface VnfcInstanceGroupCustomizationRepository - extends JpaRepository<VnfcInstanceGroupCustomization, String> { + extends JpaRepository<VnfcInstanceGroupCustomization, Integer> { } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepositoryTest.java new file mode 100644 index 0000000000..8dcf89e829 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcInstanceGroupCustomizationRepositoryTest.java @@ -0,0 +1,46 @@ +/*- + * ============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.junit.Assert; +import org.junit.Test; +import org.onap.so.db.catalog.BaseTest; +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; +import org.onap.so.db.catalog.exceptions.NoEntityFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; + +public class VnfcInstanceGroupCustomizationRepositoryTest extends BaseTest { + @Autowired + private VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepository; + + @Test + public void findAllTest() throws Exception { + List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizationList = + vnfcInstanceGroupCustomizationRepository.findAll(); + Assert.assertFalse(CollectionUtils.isEmpty(vnfcInstanceGroupCustomizationList)); + + VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = vnfcInstanceGroupCustomizationRepository + .findById(1450).orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); + Assert.assertTrue(vnfcInstanceGroupCustomization.getFunction().equalsIgnoreCase("FUNCTION")); + } +} diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql index 54bb5fc15f..f6d04263c0 100644 --- a/mso-catalog-db/src/test/resources/data.sql +++ b/mso-catalog-db/src/test/resources/data.sql @@ -100,9 +100,11 @@ insert into vnf_resource(orchestration_mode, description, creation_timestamp, mo ('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,SERVICE_MODEL_UUID) 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,'5df8b6de-2083-11e7-93ae-92361f002672'); +insert into vnf_resource_customization(id, 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,SERVICE_MODEL_UUID) values +('1429', '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,'5df8b6de-2083-11e7-93ae-92361f002672'); +INSERT INTO vnfc_instance_group_customization (`ID`, `INSTANCE_GROUP_MODEL_UUID`, `FUNCTION`, `VNF_RESOURCE_CUSTOMIZATION_ID`) VALUES +('1450', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'FUNCTION', '1429'); diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index 5e43f8f3e2..f5e7d52ba4 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -280,6 +280,7 @@ DROP TABLE IF EXISTS `configuration_customization`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `configuration_customization` ( + `ID` int(11) NOT NULL AUTO_INCREMENT, `MODEL_CUSTOMIZATION_UUID` varchar(200) NOT NULL, `MODEL_INSTANCE_NAME` varchar(200) NOT NULL, `CONFIGURATION_TYPE` varchar(200) DEFAULT NULL, @@ -288,27 +289,18 @@ CREATE TABLE `configuration_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `CONFIGURATION_MODEL_UUID` varchar(200) NOT NULL, `SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID` varchar(200) DEFAULT NULL, - `CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID` varchar(200) DEFAULT NULL, - PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), - KEY `fk_configuration_customization__configuration_idx` (`CONFIGURATION_MODEL_UUID`), - KEY `fk_configuration_customization__service_proxy_customization_idx` (`SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID`), - KEY `fk_configuration_customization__configuration_customization_idx` (`CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID`), - 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, - CONSTRAINT `fk_configuration_resource_customization__configuration_resour1` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`) REFERENCES `configuration` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `configuration_customization_to_service` --- - -DROP TABLE IF EXISTS `configuration_customization_to_service`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -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`) + `CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_ID` int(11) DEFAULT NULL, + `SERVICE_MODEL_UUID` varchar(200), + PRIMARY KEY (`ID`), + KEY `fk_configuration_customization__configuration_idx` (`CONFIGURATION_MODEL_UUID`), + KEY `fk_configuration_customization__service_idx` (`SERVICE_MODEL_UUID`), + UNIQUE KEY `uk_configuration_customization` (`MODEL_CUSTOMIZATION_UUID` ASC, `SERVICE_MODEL_UUID` ASC), + CONSTRAINT `fk_configuration_customization__configuration1` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`) + REFERENCES `configuration` (`MODEL_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_configuration_customization__service1` FOREIGN KEY (`SERVICE_MODEL_UUID`) + REFERENCES `service` (`MODEL_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; |