[SO] Create changes for SO-API and BPMN-INFRA to support CNF's through ASD
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / onap / so / bpmn / servicedecomposition / tasks / BBInputSetup.java
index 0c5e2d1..178612c 100644 (file)
@@ -8,6 +8,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2020 Nokia
  * ================================================================================
+ * Modifications Copyright (c) 2023 Nordix Foundation
+ * ================================================================================
  * 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
@@ -410,7 +412,7 @@ public class BBInputSetup implements JavaDelegate {
         if (modelType.equals(ModelType.network)) {
             parameter.getLookupKeyMap().put(ResourceKey.NETWORK_ID, parameter.getResourceId());
             this.populateL3Network(parameter);
-        } else if (modelType.equals(ModelType.vnf)) {
+        } else if (modelType.equals(ModelType.vnf) || modelType.equals(ModelType.cnf)) {
             parameter.getLookupKeyMap().put(ResourceKey.GENERIC_VNF_ID, parameter.getResourceId());
             this.populateGenericVnf(parameter);
         } else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule)
@@ -897,7 +899,8 @@ public class BBInputSetup implements JavaDelegate {
                 break;
             }
         }
-        if (vnf == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VNF.toString())) {
+        if ((vnf == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VNF.toString()))
+                || (parameter.getRequestDetails() != null && this.isCnf(parameter.getRequestDetails()))) {
             vnf = createGenericVnf(parameter.getLookupKeyMap(), parameter.getInstanceName(), parameter.getPlatform(),
                     parameter.getLineOfBusiness(), parameter.getResourceId(), generatedVnfType,
                     parameter.getInstanceParams(), parameter.getProductFamilyId(), parameter.getApplicationId());
@@ -914,6 +917,15 @@ public class BBInputSetup implements JavaDelegate {
         }
     }
 
+    private boolean isCnf(final RequestDetails requestDetails) {
+        logger.debug("Executing isCNF to check the model type is CNF");
+        if (requestDetails.getModelInfo() != null) {
+            return ModelType.cnf.equals(requestDetails.getModelInfo().getModelType());
+        }
+        logger.debug("Not a CNF model type:{}", requestDetails);
+        return false;
+    }
+
     protected boolean instanceGroupInList(GenericVnf vnf, String instanceGroupId) {
         for (InstanceGroup instanceGroup : vnf.getInstanceGroups()) {
             if (instanceGroup.getId() != null && instanceGroup.getId().equalsIgnoreCase(instanceGroupId)) {