Identify whether the Service is of A-la-carte or macro type 80/100180/2
authorSunilB <SB00577584@techmahindra.com>
Fri, 10 Jan 2020 10:23:41 +0000 (15:53 +0530)
committerSunil Kumar Biradar <SB00577584@techmahindra.com>
Fri, 10 Jan 2020 10:38:39 +0000 (10:38 +0000)
Issue-ID: EXTAPI-367
Signed-off-by: sunilb <sb00577584@techmahindra.com>
Change-Id: I281936af78a0bbb7b08f7e96fd64015eaa4a6b5a

src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java
src/main/java/org/onap/nbi/apis/serviceorder/utils/MacroServiceUtils.java [new file with mode: 0644]
src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java

index 14b2541..2153b84 100644 (file)
@@ -24,6 +24,7 @@ import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
 import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.sdc.toscaparser.api.parameters.Input;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -145,6 +146,10 @@ public class ToscaInfosProcessor {
         String svcCharacteristicsJson = Json.pretty(definitions);
         serviceSpecificationDBManager.saveSpecificationInputSchema(svcCharacteristicsJson, serviceCatalogResponse);
 
+        Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata();
+        String instantationType = serviceMetadata.getValue("instantiationType");
+        serviceCatalogResponse.put("instantiationType", instantationType);
+
         LinkedHashMap inputSchemaRef = new LinkedHashMap();
         // use object to match examples in Specifications
         inputSchemaRef.put("valueType", "object");
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/utils/MacroServiceUtils.java b/src/main/java/org/onap/nbi/apis/serviceorder/utils/MacroServiceUtils.java
new file mode 100644 (file)
index 0000000..427ba3b
--- /dev/null
@@ -0,0 +1,33 @@
+/**\r
+ * Copyright (c) 2020 TechMahindra\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on\r
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the\r
+ * specific language governing permissions and limitations under the License.\r
+ */\r
+\r
+package org.onap.nbi.apis.serviceorder.utils;\r
+\r
+import java.util.Map;\r
+\r
+import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderItemInfo;\r
+\r
+public class MacroServiceUtils {\r
+  public static boolean isMacroService(ServiceOrderItemInfo serviceOrderItemInfo) {\r
+    Map<String, Object> sdcInfos = serviceOrderItemInfo.getCatalogResponse();\r
+    boolean macroService = false;\r
+    if (sdcInfos.get("instantiationType") != null) {\r
+      String instantiationType = ((String) sdcInfos.get("instantiationType")).toLowerCase();\r
+      if (instantiationType.equals("macro")) {\r
+        macroService = true;\r
+      }\r
+    }\r
+    return macroService;\r
+}\r
+\r
+}\r
index 843f599..d63d122 100644 (file)
@@ -31,6 +31,7 @@ import org.onap.nbi.apis.serviceorder.repositories.ExecutionTaskRepository;
 import org.onap.nbi.apis.serviceorder.service.ServiceOrderService;
 import org.onap.nbi.apis.serviceorder.utils.E2EServiceUtils;
 import org.onap.nbi.apis.serviceorder.utils.JsonEntityConverter;
+import org.onap.nbi.apis.serviceorder.utils.MacroServiceUtils;
 import org.onap.nbi.exceptions.TechnicalException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -81,12 +82,18 @@ public class SOTaskProcessor {
         ServiceOrderItem serviceOrderItem = getServiceOrderItem(executionTask, serviceOrder);
         boolean e2eService =
                 E2EServiceUtils.isE2EService(serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId()));
+        boolean macroService = MacroServiceUtils
+                .isMacroService(serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId()));
 
         if (shouldPostSo(serviceOrderItem)) {
             if (e2eService) {
                 ResponseEntity<CreateE2EServiceInstanceResponse> response =
                         postSoProcessor.postE2EServiceOrderItem(serviceOrderInfo, serviceOrderItem, serviceOrder);
                 updateE2EServiceOrderItem(response, serviceOrderItem, serviceOrder);
+            } else if (macroService) {
+              LOGGER.info("Mode type macro");
+              //TODO: Add logic to construct SO macro request body and call SO macro flow.(EXTAPI-368)
+
             } else {
 
                 ResponseEntity<CreateServiceInstanceResponse> response =