Merge "Templates: show correct values of sdnc-preload, volume-group name"
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / services / creationService.js
index 83710ce..15ba519 100755 (executable)
@@ -258,8 +258,18 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                         getLcpRegionParameter(), FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
                         FIELD.PARAMETER.TENANT_DISABLED ]);
                     parameterList = parameterList.concat([ getLineOfBusinessParameter() ]);
+
+
+                    if(_this.componentId === COMPONENT.VNF){
+                        parameterList[parameterList.length -1].isRequired = true;
+                    }
+
                     parameterList = parameterList.concat([ getPlatformParameter() ]);
 
+                    if(_this.componentId === COMPONENT.NETWORK){
+                        parameterList[parameterList.length -1].isRequired = false;
+                    }
+
                     break;
                 case COMPONENT.VF_MODULE:
                     parameterList = parameterList.concat([
@@ -407,7 +417,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                                                                option = {
                                                                                name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
                                                                                isDefault: false
-                                                               } 
+                                                               }; 
                                                                if ( ( UtilityService.hasContents (inputs[key][PARAMETER.DEFAULT]) ) 
                                                                                && (inputs[key][PARAMETER.DEFAULT] === constraintsArray[i][PARAMETER.VALID_VALUES][j] ) ) {
                                                                        option = {
@@ -471,7 +481,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                                                                parameter.min = constraintsArray[i][PARAMETER.IN_RANGE][0];
                                                                parameter.max = constraintsArray[i][PARAMETER.IN_RANGE][1];
                                                                parameter.type = PARAMETER.NUMBER;
-                                                               parameter.value = inputs[key][PARAMETER.DEFAULT]
+                                                               parameter.value = inputs[key][PARAMETER.DEFAULT];
                                                                parameterList.push(parameter);
                                                                parameterPushed = true;
                                                                //console.log ("pushed param for in_range");
@@ -482,7 +492,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                                                if ( constraintsArray[i][PARAMETER.GREATER_THAN] != null ) {
                                                                parameter.type = PARAMETER.NUMBER;
                                                                parameter.min = constraintsArray[i][PARAMETER.GREATER_THAN];
-                                                               parameter.value = inputs[key][PARAMETER.DEFAULT]
+                                                               parameter.value = inputs[key][PARAMETER.DEFAULT];
                                                                parameterList.push(parameter);
                                                                parameterPushed = true;
                                                                //console.log ("pushed param for greater_than");
@@ -505,7 +515,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
         var inventoryItem = DataService.getInventoryItem();
         var inventoryInfo = ComponentService.getInventoryInfo(
             _this.componentId, inventoryItem);
-       }
+       };
 
     /*
      * The "*Mso*" functions return URL and request details that can be passed
@@ -616,8 +626,6 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
 
     var getMsoRequestDetails = function(parameterList) {
         console.log("getMsoRequestDetails invoked, parameterList="); console.log(JSON.stringify(parameterList,null,4));
-        //console.log("getMsoRequestDetails invoked, DataService.getArbitraryParameters()=");
-        //console.log(JSON.stringify(DataService.getArbitraryParameters(),null,4));
 
         //VoLTE logic goes here
         if(DataService.getE2EService() === true) {
@@ -713,11 +721,9 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                 var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList);
 
                 if(lineOfBusiness) {
-                    var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", ");
-
                     requestDetails.lineOfBusiness = {
-                        lineOfBusinessName: lineOfBusinessNamesString
-                    }
+                        lineOfBusinessName: lineOfBusiness
+                    };
                 }
 
                 requestDetails.platform = {
@@ -735,12 +741,18 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
 
                     requestDetails.lineOfBusiness = {
                         lineOfBusinessName: lineOfBusinessNamesString
-                    }
+                    };
                 }
 
+                var platform = getValueFromList(FIELD.ID.PLATFORM, parameterList);
+                if(platform !== null && platform !== ""){
                 requestDetails.platform = {
-                    platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList)
+                        platformName: platform
                 };
+                }
+
+
+
                 break;
             case COMPONENT.VF_MODULE:
                 requestDetails.requestParameters.usePreload = getValueFromList(
@@ -763,20 +775,13 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
     };
 
     var buildCloudConfiguration = function (parameterList) {
-        var lcpRegion;
-        var cloudOwner;
 
         var lcpRegionOptionId = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
-
-        if (lcpRegionOptionId === FIELD.KEY.LCP_REGION_TEXT) {
-            lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
-                parameterList);
-            cloudOwner = undefined;
-        } else {
-            var cloudOwnerAndLcpCloudRegion = getCloudOwnerAndLcpCloudRegionFromOptionId(lcpRegionOptionId);
-            lcpRegion = cloudOwnerAndLcpCloudRegion.cloudRegionId;
-            cloudOwner = cloudOwnerAndLcpCloudRegion.cloudOwner;
-        }
+        var cloudOwnerAndLcpCloudRegion = DataService.getCloudOwnerAndLcpCloudRegionFromOptionId(lcpRegionOptionId);
+        var cloudOwner = cloudOwnerAndLcpCloudRegion.cloudOwner;
+        var lcpRegion = cloudOwnerAndLcpCloudRegion.cloudRegionId === FIELD.KEY.LCP_REGION_TEXT ?
+            getValueFromList(FIELD.ID.LCP_REGION_TEXT,parameterList) :
+            cloudOwnerAndLcpCloudRegion.cloudRegionId;
 
         return {
             lcpCloudRegionId: lcpRegion,
@@ -861,7 +866,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                         "modelCustomizationId": modelInfo.customizationUuid,
                         "modelCustomizationName": modelInfo.modelCustomizationName
                     }
-                }
+                };
             }
             relatedInstanceList.push({
                 relatedInstance : relatedInstance
@@ -913,13 +918,13 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                         arbitraryParameters = {
                             name: parameter.id,
                             value: parameter.value
-                        }
+                        };
                         arbitraryArray.push(arbitraryParameters);
                     }
             }
         }
         return (arbitraryArray);
-    }
+    };
 
     var getModel = function() {
         AsdcService.getModel(DataService.getModelId(), function(response) {
@@ -1143,15 +1148,6 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
         return parameter;
     };
 
-    var getCloudOwnerAndLcpCloudRegionFromOptionId = function (cloudRegionOptionId) {
-      var cloudRegionTenantList = DataService.getCloudRegionTenantList();
-      var cloudRegionTenant = _.find(cloudRegionTenantList, {"cloudRegionOptionId": cloudRegionOptionId});
-      return {
-        cloudOwner: cloudRegionTenant.cloudOwner,
-        cloudRegionId: cloudRegionTenant.cloudRegionId
-      }
-    };
-
     var getTenantList = function(cloudRegionOptionId) {
         var cloudRegionTenantList = DataService.getCloudRegionTenantList();
         var parameter = "";
@@ -1194,6 +1190,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                 return parameterList[i].value;
             }
         }
+        return null;
     };
     var updateUserParameterList = function(updatedId, parameterListControl) {
         console.log ("updateUserParameterList() updatedId=" + updatedId);
@@ -1243,7 +1240,9 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
                 parameterListControl
                     .updateList([ FIELD.PARAMETER.TENANT_DISABLED ]);
             }
-            if (list[0].value === FIELD.KEY.LCP_REGION_TEXT) {
+
+            var cloudOwnerAndLcpCloudRegion = DataService.getCloudOwnerAndLcpCloudRegionFromOptionId(list[0].value);
+            if (cloudOwnerAndLcpCloudRegion.cloudRegionId === FIELD.KEY.LCP_REGION_TEXT) {
                 parameterListControl
                     .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_VISIBLE ]);
             } else {
@@ -1311,8 +1310,8 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
         getMsoRequestDetails : getMsoRequestDetails,
         getMsoUrl : getMsoUrl,
         setInventoryInfo: setInventoryInfo
-    }
-}
+    };
+};
 
 appDS2.factory("CreationService", [ "$log", "AaiService", "AsdcService",
     "DataService","VIDCONFIGURATION", "ComponentService", "COMPONENT", "FIELD", "PARAMETER",