aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2019-04-26 07:05:17 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-26 07:05:17 +0000
commit0164ebaeecf27e635b3b4097034780dbb8be7c74 (patch)
treef886d88622a52c94fb5a5f405344f61d8aa72547
parent2e0a34df5e0ec477065b2a6a5ef31927560d711b (diff)
parent9797ba0f3aa46ee9267f6e8de1d7f871464f4b99 (diff)
Merge "Enhancement for query"
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java98
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java12
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java119
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java74
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java65
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql1
-rw-r--r--asdc-controller/src/test/resources/schema.sql1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql1
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java31
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java14
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql1
12 files changed, 410 insertions, 9 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java
new file mode 100644
index 0000000000..c15b0d9df1
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei 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.adapters.catalogdb.catalogrest;
+
+import org.onap.so.db.catalog.beans.InstanceGroup;
+import org.onap.so.db.catalog.beans.VFCInstanceGroup;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement(name = "groups")
+public class QueryGroups extends CatalogQuery {
+
+ private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations;
+ private static final String TEMPLATE = "\n" + "\t{ \"modelInfo\" : {\n"
+ + "\t\t\"modelName\" : <MODEL_NAME>,\n" + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"
+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"
+ + "\t\t\"modelVersion\" : <MODEL_VERSION>\n" + "\t\t},\n" + "<_VNFCS_>\n" + "\t}";
+
+ public QueryGroups() {
+ super();
+ vnfcInstanceGroupCustomizations = new ArrayList<>();
+
+ }
+
+ public QueryGroups(List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
+ this.vnfcInstanceGroupCustomizations = new ArrayList<>();
+ if (vnfcInstanceGroupCustomizations != null) {
+ for (VnfcInstanceGroupCustomization g : vnfcInstanceGroupCustomizations) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(g.toString());
+ }
+ this.vnfcInstanceGroupCustomizations.add(g);
+ }
+ }
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray)
+ sb.append("{ ");
+ if (isArray)
+ sb.append("\"groups\": [");
+ Map<String, String> valueMap = new HashMap<>();
+ String sep = "";
+ boolean first = true;
+
+ for (VnfcInstanceGroupCustomization o : vnfcInstanceGroupCustomizations) {
+ if (first)
+ sb.append("\n");
+ first = false;
+
+ boolean vnfcCustomizationNull = o.getVnfcCustomizations() == null;
+ InstanceGroup instanceGroup = o.getInstanceGroup();
+
+ if (instanceGroup != null) {
+ put(valueMap, "MODEL_NAME", instanceGroup.getModelName());
+ put(valueMap, "MODEL_UUID", instanceGroup.getModelInvariantUUID());
+ put(valueMap, "MODEL_INVARIANT_ID", instanceGroup.getModelInvariantUUID());
+ put(valueMap, "MODEL_VERSION", instanceGroup.getModelUUID());
+ }
+
+ String subItem = new QueryVnfcs(vnfcCustomizationNull ? null : o.getVnfcCustomizations()).JSON2(true, true);
+ valueMap.put("_VNFCS_", subItem.replaceAll("(?m)^", "\t\t"));
+ sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
+ sep = ",\n";
+ }
+ if (!first)
+ sb.append("\n");
+ if (isArray)
+ sb.append("]");
+ if (!isEmbed && isArray)
+ sb.append("}");
+ return sb.toString();
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
index f786f25361..e5241a4e95 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
@@ -25,8 +25,12 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import javax.xml.bind.annotation.XmlRootElement;
+import org.onap.so.db.catalog.beans.InstanceGroup;
+import org.onap.so.db.catalog.beans.VFCInstanceGroup;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +49,7 @@ public class QueryServiceVnfs extends CatalogQuery {
+ "\t\"nfFunction\" : <NF_FUNCTION>,\n" + "\t\"nfType\" : <NF_TYPE>,\n"
+ "\t\"nfRole\" : <NF_ROLE>,\n" + "\t\"nfNamingCode\" : <NF_NAMING_CODE>,\n"
+ "\t\"multiStageDesign\" : <MULTI_STEP_DESIGN>,\n"
- + "\t\"resourceInput\" : <RESOURCE_INPUT>,\n" + "<_VFMODULES_>\n" + "\t}";
+ + "\t\"resourceInput\" : <RESOURCE_INPUT>,\n" + "<_VFMODULES_>,\n" + "<_GROUPS_>\n" + "\t}";
public QueryServiceVnfs() {
super();
@@ -120,6 +124,12 @@ public class QueryServiceVnfs extends CatalogQuery {
String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true);
valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t"));
+ List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations =
+ o.getVnfcInstanceGroupCustomizations();
+
+ String grpSubItem = new QueryGroups(vrNull ? null : vnfcInstanceGroupCustomizations).JSON2(true, true);
+ valueMap.put("_GROUPS_", grpSubItem.replaceAll("(?m)^", "\t\t"));
+
sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
sep = ",\n";
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java
new file mode 100644
index 0000000000..0bf82fd8b7
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei 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.adapters.catalogdb.catalogrest;
+
+import org.onap.so.db.catalog.beans.VnfcCustomization;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement(name = "vnfcs")
+public class QueryVnfcs extends CatalogQuery {
+ private List<VnfcCustomization> vnfcCustomizations;
+ private static final String TEMPLATE =
+ "\t{\n" + "\t\t\"modelInfo\" : { \n" + "\t\t\t\"modelName\" : <MODEL_NAME>,\n"
+ + "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"
+ + "\t\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"
+ + "\t\t\t\"modelVersion\" : <MODEL_VERSION>,\n"
+ + "\t\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>\n" + "\t\t}" + "\t}";
+
+ public QueryVnfcs() {
+ super();
+ vnfcCustomizations = new ArrayList();
+ }
+
+ public QueryVnfcs(List<VnfcCustomization> vnfcCustomizations) {
+ this.vnfcCustomizations = new ArrayList();
+ if (vnfcCustomizations != null) {
+ for (VnfcCustomization vnfcCustomization : vnfcCustomizations) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(vnfcCustomization.toString());
+ }
+ this.vnfcCustomizations.add(vnfcCustomization);
+ }
+ }
+ }
+
+ public List<VnfcCustomization> getVnfcCustomizations() {
+ return vnfcCustomizations;
+ }
+
+ public void setVnfcCustomizations(List<VnfcCustomization> vnfcCustomizations) {
+ this.vnfcCustomizations = vnfcCustomizations;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ boolean first = true;
+ int i = 1;
+ for (VnfcCustomization o : vnfcCustomizations) {
+ sb.append(i).append("\t");
+ if (!first) {
+ sb.append("\n");
+ }
+ first = false;
+ sb.append(o);
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray) {
+ sb.append("{");
+ }
+
+ if (isArray) {
+ sb.append("\"vnfcs\": [");
+ }
+
+ Map<String, String> valueMap = new HashMap<>();
+ String sep = "";
+ boolean first = true;
+
+ for (VnfcCustomization o : vnfcCustomizations) {
+ if (first)
+ sb.append("\n");
+ first = false;
+
+ put(valueMap, "MODEL_NAME", o.getModelName());
+ put(valueMap, "MODEL_UUID", o.getModelUUID());
+ put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantUUID());
+ put(valueMap, "MODEL_VERSION", o.getModelVersion());
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID());
+
+ sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
+ sep = ",\n";
+ }
+ if (!first)
+ sb.append("\n");
+ if (isArray)
+ sb.append("]");
+ if (!isEmbed && isArray)
+ sb.append("}");
+ return sb.toString();
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql
new file mode 100644
index 0000000000..95a2c25eb8
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql
@@ -0,0 +1,2 @@
+use catalogdb;
+ALTER TABLE vnfc_customization ADD vnfc_instance_group_customization_id INTEGER NULL; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java
new file mode 100644
index 0000000000..00db6d5938
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei 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.adapters.catalogdb.catalogrest;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.VFCInstanceGroup;
+import org.onap.so.db.catalog.beans.VnfResource;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfcCustomization;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
+import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
+import org.onap.so.jsonpath.JsonPathUtil;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class QueryGroupsTest {
+
+ @Test
+ public void convertToJson_successful() {
+ QueryGroups queryGroups = new QueryGroups(createList());
+ String jsonResult = queryGroups.JSON2(true, false);
+
+ Assertions.assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].modelInfo.modelName"))
+ .contains("test");
+ Assertions
+ .assertThat(
+ JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].vnfcs[0].modelInfo.modelName"))
+ .contains("test");
+ }
+
+ private List<VnfcInstanceGroupCustomization> createList() {
+
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+ vnfcCustomization.setModelCustomizationUUID("test");
+ vnfcCustomization.setModelVersion("test");
+ vnfcCustomization.setModelInvariantUUID("test");
+ vnfcCustomization.setModelName("test");
+
+ VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
+ vfcInstanceGroup.setModelName("test");
+ vfcInstanceGroup.setModelUUID("test");
+ vfcInstanceGroup.setModelInvariantUUID("test");
+ vfcInstanceGroup.setModelVersion("test");
+
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = new VnfcInstanceGroupCustomization();
+ vnfcInstanceGroupCustomization.setVnfcCustomizations(Arrays.asList(vnfcCustomization));
+ vnfcInstanceGroupCustomization.setInstanceGroup(vfcInstanceGroup);
+
+
+ vfcInstanceGroup.setVnfcInstanceGroupCustomizations(Arrays.asList(vnfcInstanceGroupCustomization));
+ return Arrays.asList(vnfcInstanceGroupCustomization);
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java
new file mode 100644
index 0000000000..1fd4f19e29
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei 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.adapters.catalogdb.catalogrest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.Test;
+import org.onap.so.db.catalog.beans.VnfcCustomization;
+import org.onap.so.jsonpath.JsonPathUtil;
+import java.util.ArrayList;
+import java.util.List;
+
+public class QueryVnfcsTest {
+
+ @Test
+ public void convertToJson_successful() {
+ QueryVnfcs queryVnfcs = new QueryVnfcs(createList());
+ String jsonResult = queryVnfcs.JSON2(true, false);
+ System.out.println(jsonResult);
+ assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[0].modelInfo.modelName"))
+ .contains("model1");
+ assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[1].modelInfo.modelName"))
+ .contains("model2");
+
+ }
+
+ private List<VnfcCustomization> createList() {
+ List<VnfcCustomization> customizations = new ArrayList();
+
+ VnfcCustomization c1 = new VnfcCustomization();
+ c1.setModelName("model1");
+ c1.setModelUUID("uuid1");
+ c1.setModelInvariantUUID("inv1");
+ c1.setModelVersion("v1");
+ c1.setModelCustomizationUUID("cust1");
+
+ VnfcCustomization c2 = new VnfcCustomization();
+ c2.setModelName("model2");
+ c2.setModelUUID("uuid2");
+ c2.setModelInvariantUUID("inv2");
+ c2.setModelVersion("v2");
+ c2.setModelCustomizationUUID("cust2");
+
+ customizations.add(c1);
+ customizations.add(c2);
+ return customizations;
+ }
+}
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index 1cf28be926..c700e78868 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -1135,6 +1135,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index d143b52fe1..bdd906d870 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -1137,6 +1137,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index 4cbb5de4ca..765740e864 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -1136,6 +1136,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java
index a7a31dcf89..413efaf12c 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Huawei 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.
@@ -20,23 +21,25 @@
package org.onap.so.db.catalog.beans;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.openpojo.business.annotation.BusinessKey;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
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.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
@Entity
@Table(name = "vnfc_customization")
@@ -81,6 +84,10 @@ public class VnfcCustomization implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "vnfcCustomization")
private List<CvnfcCustomization> cvnfcCustomization;
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID")
+ private VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization;
+
@Override
public boolean equals(final Object other) {
if (!(other instanceof VnfcCustomization)) {
@@ -190,6 +197,14 @@ public class VnfcCustomization implements Serializable {
this.cvnfcCustomization = cvnfcCustomization;
}
+ public VnfcInstanceGroupCustomization getVnfcInstanceGroupCustomization() {
+ return vnfcInstanceGroupCustomization;
+ }
+
+ public void setVnfcInstanceGroupCustomization(VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization) {
+ this.vnfcInstanceGroupCustomization = vnfcInstanceGroupCustomization;
+ }
+
public String getResourceInput() {
return resourceInput;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java
index 695e5bbbb9..8a00ccd261 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Huawei 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.
@@ -22,6 +23,7 @@ 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;
@@ -32,6 +34,7 @@ import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
@@ -66,6 +69,9 @@ public class VnfcInstanceGroupCustomization implements Serializable {
@JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID")
private InstanceGroup instanceGroup;
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "vnfcInstanceGroupCustomization")
+ private List<VnfcCustomization> vnfcCustomizations;
+
@Column(name = "FUNCTION")
private String function;
@@ -150,4 +156,12 @@ public class VnfcInstanceGroupCustomization implements Serializable {
public void setInstanceGroup(InstanceGroup instanceGroup) {
this.instanceGroup = instanceGroup;
}
+
+ public List<VnfcCustomization> getVnfcCustomizations() {
+ return vnfcCustomizations;
+ }
+
+ public void setVnfcCustomizations(List<VnfcCustomization> vnfcCustomizations) {
+ this.vnfcCustomizations = vnfcCustomizations;
+ }
}
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index 97afcc04be..34340f1357 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -1134,6 +1134,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;