Enhancement for query 40/85940/19
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>
Sat, 20 Apr 2019 10:11:18 +0000 (15:41 +0530)
committerSeshu Kumar M <seshu.kumar.m@huawei.com>
Fri, 26 Apr 2019 06:17:58 +0000 (06:17 +0000)
Enhancemenv for query to include group and vnfccustomization.

{
    "serviceResources": {
        "modelInfo": {
            "modelName": "NSService",
            "modelUuid": "0bad8c92-7d22-49f0-b092-b64e6ca564a7",
            "modelInvariantUuid": "69161960-515b-4bf3-91f1-313b813f5e1d",
            "modelVersion": "1.0"
        },
        "serviceType": "",
        "serviceRole": "",
        "environmentContext": "General_Revenue-Bearing",
        "resourceOrder": "NF",
        "workloadContext": "Production",
        "serviceVnfs": [
            {
                "modelInfo": {
                    "modelName": "",
                    "modelUuid": "123",
                    "modelInvariantUuid": "",
                    "modelVersion": "",
                    "modelCustomizationUuid": "1234",
                    "modelInstanceName": "test"
                },
                "toscaNodeType": "",
                "nfFunction": "",
                "nfType": "",
                "nfRole": "",
                "nfNamingCode": "",
                "multiStageDesign": "",
                "resourceInput": "",
                "vfModules": [],
                "groups": [
                    {
                        "modelInfo": {
                            "modelName": "test",
                            "modelUuid": "11",
                            "modelInvariantUuid": "11",
                            "modelVersion": "2"
                        },
                        "vnfcs": [
                            {
                                "modelInfo": {
                                    "modelName": "xfs",
                                    "modelUuid": "22",
                                    "modelInvariantUuid": "2222",
                                    "modelVersion": "22222",
                                    "modelCustomizationUuid": "2222"
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "serviceNetworks": [],
        "serviceAllottedResources": []
    }
}

Issue-ID: SO-1393
Change-Id: Iee7f79337f73276f857d6d42b5b2416e4e8f4536
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
12 files changed:
adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java [new file with mode: 0644]
adapters/mso-openstack-adapters/src/test/resources/schema.sql
asdc-controller/src/test/resources/schema.sql
mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java
mso-catalog-db/src/test/resources/schema.sql

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 (file)
index 0000000..c15b0d9
--- /dev/null
@@ -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();
+    }
+}
index f786f25..e5241a4 100644 (file)
@@ -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 (file)
index 0000000..0bf82fd
--- /dev/null
@@ -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 (file)
index 0000000..95a2c25
--- /dev/null
@@ -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 (file)
index 0000000..00db6d5
--- /dev/null
@@ -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 (file)
index 0000000..1fd4f19
--- /dev/null
@@ -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;
+    }
+}
index 1cf28be..c700e78 100644 (file)
@@ -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;
index d143b52..bdd906d 100644 (file)
@@ -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;
index 4cbb5de..765740e 100644 (file)
@@ -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;
index a7a31dc..413efaf 100644 (file)
@@ -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.
 
 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;
     }
index 695e5bb..8a00ccd 100644 (file)
@@ -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;
+    }
 }
index 97afcc0..34340f1 100644 (file)
@@ -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;