aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/main/java
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2019-04-20 15:41:18 +0530
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2019-04-26 06:17:58 +0000
commit9797ba0f3aa46ee9267f6e8de1d7f871464f4b99 (patch)
tree7bd4b12d7391cbc58ba3698f75d1c1410f39b682 /adapters/mso-catalog-db-adapter/src/main/java
parent046eb620661451d3d62638d5253d3e112f565d1a (diff)
Enhancement for query
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>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/main/java')
-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
3 files changed, 228 insertions, 1 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();
+ }
+}