Show Templates popup when deploying from "SDC Catalog"
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / ServiceModelController.js
index 6c4d290..1b64573 100755 (executable)
-/*-\r
- * ============LICENSE_START=======================================================\r
- * VID\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * Modifications Copyright (C) 2019 IBM.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * 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\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-(function () {\r
-       'use strict';\r
-\r
-       appDS2.controller("ServiceModelController", function ($scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService,\r
-                       PropertyService, UtilityService, AsdcService,$timeout) {\r
-\r
-               $scope.popup = {};\r
-               var defaultViewPerPage = 10;\r
-       //      var baseEndpoint = "vid";\r
-               var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS;\r
-               \r
-               if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) {\r
-                       pathQuery = COMPONENT.SERVICES_PATH;\r
-               }\r
-        window.addEventListener("message", receiveMessage, false);\r
-\r
-               function receiveMessage(event){\r
-            if(event.data == 'navigateTo') {\r
-                $location.path('/models/services').search({});\r
-                $scope.$apply();\r
-                $scope.rememberFilter = true;\r
-            }\r
-            if(event.data == 'navigateToInstantiationStatus') {\r
-                $location.path('/instantiationStatus').search({});\r
-                $scope.$apply();\r
-            }\r
-               }\r
-\r
-               $scope.getServiceModels = function() {\r
-                       $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC;\r
-\r
-                       $http.get(pathQuery)\r
-                       .then(function (response) {\r
-                               $scope.services = [];\r
-                               if (response.data && angular.isArray(response.data.services)) {\r
-                                       wholeData = response.data.services;\r
-                    $scope.services = $scope.filterDataWithHigherVersion(wholeData);\r
-                    $scope.viewPerPage = defaultViewPerPage;\r
-                    $scope.totalPage=$scope.services.length/$scope.viewPerPage;\r
-                    $scope.sortBy=COMPONENT.NAME;\r
-                    $scope.scrollViewPerPage=2;\r
-                    $scope.currentPage=1;\r
-                    $scope.currentPageNum=1;\r
-                    $scope.isSpinnerVisible = false;\r
-                    $scope.isProgressVisible = false;\r
-                    if (sessionStorage.getItem("searchKey")!='undefined' && ($scope.rememberFilter)) {\r
-                        var searchKey = JSON.parse(sessionStorage.getItem("searchKey"));\r
-                        $scope.searchString = searchKey.searchString || '';\r
-                        $scope.viewPerPage = searchKey.viewPerPage || defaultViewPerPage;\r
-                        $scope.totalPage = $scope.services.length / $scope.viewPerPage;\r
-                        $timeout(function () {\r
-                               // the table controller handles the current page once\r
-                                                       // data is loaded, therefore we're delying the paging\r
-                                                       // override\r
-                            $scope.currentPage = $scope.currentPageNum = searchKey.currentPage ? parseInt(searchKey.currentPage) : 1;\r
-                        }, 0);\r
-                        $scope.rememberFilter = false;\r
-                    }\r
-                               } else {\r
-                                       $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;\r
-                                       $scope.error = true;\r
-                                       $scope.isSpinnerVisible = false;\r
-                               }\r
-                               $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary';\r
-                       }, function (response) {\r
-                               console.log("Error: " + response);\r
-                       });\r
-               };\r
-\r
-               var wholeData=[];\r
-\r
-               $scope.filterDataWithHigherVersion = function(serviceData){\r
-                       var delimiter = '$$';\r
-                       var fiterDataServices = {};\r
-                       for(var i=0;i<serviceData.length;i++) {\r
-                               var index = serviceData[i].invariantUUID.trim() + delimiter + serviceData[i].name.trim();\r
-                               if(!fiterDataServices[index]) {\r
-                    var hasPreviousVersion = false;\r
-                    fiterDataServices[index] = {\r
-                        service: serviceData[i],\r
-                        hasPreviousVersion: false\r
-                    };\r
-                }\r
-                else {\r
-                    fiterDataServices[index].hasPreviousVersion = true;\r
-                    if(parseFloat(serviceData[i].version.trim())>parseFloat(fiterDataServices[index].service.version.trim())) {\r
-                        fiterDataServices[index].service = serviceData[i];\r
-                                       }\r
-                               }\r
-                       }\r
-            return Object.keys(fiterDataServices).map(function(key) {\r
-               var service = fiterDataServices[key].service;\r
-               service.hasPreviousVersion = fiterDataServices[key].hasPreviousVersion;\r
-                return  service;\r
-            });\r
-               };\r
-\r
-               $scope.init = function() {\r
-               var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();\r
-               PropertyService.setMsoMaxPollingIntervalMsec(msecs);\r
-               \r
-               var polls = PropertyService.retrieveMsoMaxPolls();\r
-               PropertyService.setMsoMaxPolls(polls);\r
-        };\r
-               \r
-               $scope.prevPage = function() {\r
-                       $scope.currentPage--;\r
-               };\r
-               \r
-               $scope.nextPage = function() {\r
-                       $scope.currentPage++;\r
-               };\r
-\r
-\r
-               \r
-               $scope.createType = COMPONENT.A_LA_CARTE;\r
-               $scope.deployService = function(service) {\r
-                       var searchKey = {\r
-                               searchString: $scope.searchString,\r
-                viewPerPage: $scope.viewPerPage,\r
-                currentPage: $scope.currentPage\r
-                       };\r
-                       sessionStorage.setItem("searchKey",JSON.stringify(searchKey));\r
-\r
-                       console.log("Instantiating SDC service " + service.uuid);\r
-\r
-                       $http.get(COMPONENT.SERVICES_PATH + service.uuid)\r
-                               .then(function (getServiceResponse) {\r
-\r
-                                       var serviceModel = getServiceResponse.data;\r
-\r
-                                       //VID-233 bug fix when models doesn't exists\r
-                                       if(typeof(serviceModel)==="string"){  //not an object\r
-                                               $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;\r
-                                               $scope.error = true;\r
-                                               $scope.isSpinnerVisible = false;\r
-                                               $scope.isProgressVisible = true;\r
-                                               return;\r
-                                       } else{ //clean error message\r
-                                               $scope.status = "";\r
-                                               $scope.error = false;\r
-                                               $scope.isSpinnerVisible = false;\r
-                                               $scope.isProgressVisible = false;\r
-                                       }\r
-\r
-                                       DataService.setServiceName(serviceModel.service.name);\r
-\r
-                                       //VOLTE services need input list generated and macro style\r
-                                       DataService.setE2EService(false);\r
-                                       if(serviceModel.service.category === 'E2E Service') {\r
-                                               DataService.setE2EService(true);\r
-                                               DataService.setHideServiceFields(false);\r
-                                               VIDCONFIGURATION.MACRO_SERVICES.push(serviceModel.service.invariantUuid);\r
-                                       }\r
-\r
-                                       DataService.setModelInfo(COMPONENT.SERVICE, {\r
-                                               "modelInvariantId": serviceModel.service.invariantUuid,\r
-                                               "modelVersion": serviceModel.service.version,\r
-                                               "serviceType" : serviceModel.service.serviceType,\r
-                                               "serviceRole": serviceModel.service.serviceRole,\r
-                                               "modelNameVersionId": serviceModel.service.uuid,\r
-                                               "modelName": serviceModel.service.name,\r
-                                               "description": serviceModel.service.description,\r
-                                               "category":serviceModel.service.category\r
-                                       });\r
-\r
-                    var shouldTakeTheAsyncInstantiationFlow = AsdcService.shouldTakeTheAsyncInstantiationFlow(serviceModel);\r
-                    DataService.setShouldIncludeInAsyncInstantiationFlow(shouldTakeTheAsyncInstantiationFlow);\r
-\r
-                    DataService.setALaCarte (true);\r
-          DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));\r
-                                       $scope.createType = COMPONENT.A_LA_CARTE;\r
-                                       var broadcastType = COMPONENT.CREATE_COMPONENT;\r
-                    if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) {\r
-                        DataService.setALaCarte(false);\r
-                        if(!shouldTakeTheAsyncInstantiationFlow){\r
-                            $scope.createType = COMPONENT.MACRO;\r
-                            var convertedAsdcModel = UtilityService.convertModel(serviceModel);\r
-\r
-                            DataService.setModelInfo(COMPONENT.SERVICE, {\r
-                                "modelInvariantId": serviceModel.service.invariantUuid,\r
-                                "modelVersion": serviceModel.service.version,\r
-                                "modelNameVersionId": serviceModel.service.uuid,\r
-                                "modelName": serviceModel.service.name,\r
-                                "description": serviceModel.service.description,\r
-                                "category": serviceModel.service.category,\r
-                                "serviceEcompNaming": serviceModel.service.serviceEcompNaming,\r
-                                "inputs": serviceModel.service.inputs,\r
-                                "serviceType": serviceModel.service.serviceType,\r
-                                "serviceRole": serviceModel.service.serviceRole,\r
-                                "displayInputs": convertedAsdcModel.completeDisplayInputs\r
-                            });\r
-                        }\r
-                    }\r
-\r
-                                       $scope.$broadcast(broadcastType, {\r
-                                           componentId : COMPONENT.SERVICE,\r
-                        modelNameVersionId: serviceModel.service.uuid,\r
-                                           callbackFunction : function(response) {\r
-                                               if (response.isSuccessful) {\r
-                                                               vidService.setModel(serviceModel);\r
-\r
-                                                               var subscriberId = FIELD.STATUS.NOT_FOUND;\r
-                                                               var serviceType = FIELD.STATUS.NOT_FOUND;\r
-\r
-                                                               var serviceInstanceId = response.instanceId;\r
-\r
-                                                               for (var i = 0; i < response.control.length; i++) {\r
-                                                                       if (response.control[i].id == COMPONENT.SUBSCRIBER_NAME) {\r
-                                                                               subscriberId = response.control[i].value;\r
-                                                                       } else if (response.control[i].id == FIELD.ID.SERVICE_TYPE) {\r
-                                                                               serviceType = response.control[i].value;\r
-                                                                       }\r
-                                                               }\r
-\r
-\r
-                                                               $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId);\r
-\r
-                                               }\r
-                                           }\r
-                                       });\r
-                               }, function (response) {\r
-                                       console.log("Error: " + response);\r
-                               });\r
-               };\r
-               \r
-               $scope.tableData=[];\r
-               var oldData=[];\r
-               $scope.loadPreviousVersionData=function(invariantUUID , name, version){\r
-                       $scope.tableData =[];\r
-                       oldData=[];\r
-                       for(var i=0;i<wholeData.length;i++){\r
-                               if(wholeData[i].invariantUUID == invariantUUID && wholeData[i].name == name && version!=wholeData[i].version){\r
-                                       oldData.push(wholeData[i]);\r
-                               }\r
-                       }\r
-                       $scope.tableData = oldData;\r
-                       $scope.createType = "Previous Version";\r
-                       var broadcastType = "createTableComponent";\r
-                       $scope.componentName = name;\r
-                       $scope.$broadcast(broadcastType, {\r
-                           componentId : COMPONENT.OLDVERSION,\r
-                           callbackFunction : function(response) {\r
-                           }\r
-                       });\r
-               };\r
-\r
-               $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) {\r
-                       $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI;\r
-                       $scope.init();\r
-                       $http.get( FIELD.ID.AAI_REFRESH_FULL_SUBSCRIBERS, {\r
-\r
-                       },{\r
-                               timeout: $scope.responseTimeoutMsec\r
-                       }).then(function(response){\r
-                               \r
-                               if (response.data.status < 200 || response.data.status > 202) {\r
-                                       $scope.showError(FIELD.ERROR.MSO);\r
-                                       return;\r
-                               }\r
-\r
-                               $scope.customer = response.data.customer; // get data from json\r
-\r
-                               $scope.customerList = [];\r
-\r
-                               $scope.serviceInstanceToCustomer = [];\r
-                               \r
-                               angular.forEach($scope.customer, function(subVal, subKey) {\r
-                                       var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] };\r
-                                       $scope.customerList.push(cust);\r
-                                       if (subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {\r
-                                                       angular.forEach(subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {\r
-                                                               $scope.serviceInstanceId = [];\r
-                                                               if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {\r
-                                                                       $scope.serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];\r
-                                                               } else {\r
-                                                                       $scope.serviceType = FIELD.STATUS.NO_SERVICE_SUBSCRIPTION_FOUND;\r
-                                                               }\r
-                                                               if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {\r
-                                                                       angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {\r
-                                                                               var foo = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], \r
-                                                                                               "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID],\r
-                                                                                               "subscriberName": subVal[FIELD.ID.SUBNAME] };\r
-                                                                               $scope.serviceInstanceToCustomer.push(foo);\r
-                                                                       });\r
-                                                               }\r
-                                                       });\r
-                                       }\r
-                               });     \r
-                               DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer);\r
-                               var serviceIdList = [];\r
-                               $http.get( FIELD.ID.AAI_GET_SERVICES, {\r
-                               },{\r
-                                       timeout: $scope.responseTimeoutMsec\r
-                               }).then(function(response) {\r
-                                       angular.forEach(response.data, function(value, key) {\r
-                                               angular.forEach(value, function(subVal, key) {\r
-                                                       var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] ,"isPermitted" : subVal[FIELD.ID.IS_PERMITTED] };\r
-                                                       serviceIdList.push(newVal);\r
-                                                       DataService.setServiceIdList(serviceIdList);\r
-                                                       \r
-                                                       $location.search({\r
-                                                               "subscriberId": subscriberId,\r
-                                                               "serviceType": serviceType,\r
-                                                               "serviceInstanceId": serviceInstanceId,\r
-                                                               "isPermitted": newVal.isPermitted.toString()\r
-                                                       });\r
-                                                       \r
-                                                       $location.path(COMPONENT.INSTANTIATE_PATH);\r
-                                               });\r
-                                       });\r
-                               });     \r
-                       })\r
-                       ["catch"]($scope.handleServerError);\r
-               };\r
-       });\r
-})();\r
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
+ * ================================================================================
+ * 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=========================================================
+ */
+
+(function () {
+       'use strict';
+
+       appDS2.controller("ServiceModelController",function ($uibModal, $scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService,
+                       PropertyService, UtilityService, AsdcService, $timeout, featureFlags) {
+
+               $scope.popup = {};
+               var defaultViewPerPage = 10;
+       //      var baseEndpoint = "vid";
+               var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS;
+               
+               if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) {
+                       pathQuery = COMPONENT.SERVICES_PATH;
+               }
+        window.addEventListener("message", receiveMessage, false);
+
+               function receiveMessage(event){
+            if(event.data == 'navigateTo') {
+                $location.path('/models/services').search({});
+                $scope.$apply();
+                $scope.rememberFilter = true;
+            }
+            if(event.data == 'navigateToInstantiationStatus') {
+                $location.path('/instantiationStatus').search({});
+                $scope.$apply();
+            }
+               }
+
+               $scope.getServiceModels = function() {
+                       $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC;
+
+                       $http.get(pathQuery)
+                       .then(function (response) {
+                               $scope.services = [];
+                               if (response.data && angular.isArray(response.data.services)) {
+                                       wholeData = response.data.services;
+                    $scope.services = $scope.filterDataWithHigherVersion(wholeData);
+                    $scope.viewPerPage = defaultViewPerPage;
+                    $scope.totalPage=$scope.services.length/$scope.viewPerPage;
+                    $scope.sortBy=COMPONENT.NAME;
+                    $scope.scrollViewPerPage=2;
+                    $scope.currentPage=1;
+                    $scope.currentPageNum=1;
+                    $scope.isSpinnerVisible = false;
+                    $scope.isProgressVisible = false;
+                                       var searchKey = sessionStorage.getItem("searchKey");
+                    if (searchKey != 'undefined' && searchKey!=null && ($scope.rememberFilter)) {
+                        var searchKey = JSON.parse(sessionStorage.getItem("searchKey"));
+                        $scope.searchString = searchKey.searchString || '';
+                        $scope.viewPerPage = searchKey.viewPerPage || defaultViewPerPage;
+                        $scope.totalPage = $scope.services.length / $scope.viewPerPage;
+                        $timeout(function () {
+                               // the table controller handles the current page once
+                                                       // data is loaded, therefore we're delying the paging
+                                                       // override
+                            $scope.currentPage = $scope.currentPageNum = searchKey.currentPage ? parseInt(searchKey.currentPage) : 1;
+                        }, 0);
+                        $scope.rememberFilter = false;
+                    }
+                               } else {
+                                       $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;
+                                       $scope.error = true;
+                                       $scope.isSpinnerVisible = false;
+                               }
+                               $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary';
+                       }, function (response) {
+                               console.log("Error: " + response);
+                       });
+               };
+
+               $scope.isShowOrchestrationType = function() {
+                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ORCHESTRATION_TYPE);
+               };
+
+               var wholeData=[];
+
+               $scope.filterDataWithHigherVersion = function(serviceData){
+                       var delimiter = '$$';
+                       var fiterDataServices = {};
+                       for(var i=0;i<serviceData.length;i++) {
+                               var index = serviceData[i].invariantUUID.trim() + delimiter + serviceData[i].name.trim();
+                               if(!fiterDataServices[index]) {
+                    var hasPreviousVersion = false;
+                    fiterDataServices[index] = {
+                        service: serviceData[i],
+                        hasPreviousVersion: false
+                    };
+                }
+                else {
+                    fiterDataServices[index].hasPreviousVersion = true;
+                    if(parseFloat(serviceData[i].version.trim())>parseFloat(fiterDataServices[index].service.version.trim())) {
+                        fiterDataServices[index].service = serviceData[i];
+                                       }
+                               }
+                       }
+            return Object.keys(fiterDataServices).map(function(key) {
+               var service = fiterDataServices[key].service;
+               service.hasPreviousVersion = fiterDataServices[key].hasPreviousVersion;
+                return  service;
+            });
+               };
+
+               $scope.init = function() {
+               var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();
+               PropertyService.setMsoMaxPollingIntervalMsec(msecs);
+               
+               var polls = PropertyService.retrieveMsoMaxPolls();
+               PropertyService.setMsoMaxPolls(polls);
+        };
+               
+               $scope.prevPage = function() {
+                       $scope.currentPage--;
+               };
+               
+               $scope.nextPage = function() {
+                       $scope.currentPage++;
+               };
+
+               $scope.showReportWindow = function() {
+
+                       const modalWindow = $uibModal.open({
+                               templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',
+                               controller: 'reportModalController',
+                               controllerAs: 'vm',
+                               resolve: {
+                                       errorMsg: function () {
+                                               return $scope.status;
+                                       }
+                               }
+                       });
+
+               };
+
+               $scope.isShowErrorReport = function() {
+                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);
+               };
+               
+               $scope.createType = COMPONENT.A_LA_CARTE;
+               $scope.deployService = function(service) {
+                       var searchKey = {
+                               searchString: $scope.searchString,
+                viewPerPage: $scope.viewPerPage,
+                currentPage: $scope.currentPage
+                       };
+                       DataService.setHasTemplate(service.hasTemplate);
+                       sessionStorage.setItem("searchKey",JSON.stringify(searchKey));
+
+                       console.log("Instantiating SDC service " + service.uuid);
+
+                       $http.get(COMPONENT.SERVICES_PATH + service.uuid)
+                               .then(function (getServiceResponse) {
+
+                                       var serviceModel = getServiceResponse.data;
+
+                                       //VID-233 bug fix when models doesn't exists
+                                       if(typeof(serviceModel)==="string"){  //not an object
+                                               $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;
+                                               $scope.error = true;
+                                               $scope.isSpinnerVisible = false;
+                                               $scope.isProgressVisible = true;
+                                               return;
+                                       } else{ //clean error message
+                                               $scope.status = "";
+                                               $scope.error = false;
+                                               $scope.isSpinnerVisible = false;
+                                               $scope.isProgressVisible = false;
+                                       }
+
+                                       DataService.setServiceName(serviceModel.service.name);
+
+                                       //VOLTE services need input list generated and macro style
+                                       DataService.setE2EService(false);
+                                       if(serviceModel.service.category === 'E2E Service') {
+                                               DataService.setE2EService(true);
+                                               DataService.setHideServiceFields(false);
+                                               VIDCONFIGURATION.MACRO_SERVICES.push(serviceModel.service.invariantUuid);
+                                       }
+
+                                       DataService.setModelInfo(COMPONENT.SERVICE, {
+                                               "modelInvariantId": serviceModel.service.invariantUuid,
+                                               "modelVersion": serviceModel.service.version,
+                                               "serviceType" : serviceModel.service.serviceType,
+                                               "serviceRole": serviceModel.service.serviceRole,
+                                               "modelNameVersionId": serviceModel.service.uuid,
+                                               "modelName": serviceModel.service.name,
+                                               "description": serviceModel.service.description,
+                                               "category":serviceModel.service.category
+                                       });
+
+                    var shouldTakeTheAsyncInstantiationFlow = AsdcService.shouldTakeTheAsyncInstantiationFlow(serviceModel);
+                    DataService.setShouldIncludeInAsyncInstantiationFlow(shouldTakeTheAsyncInstantiationFlow);
+
+                    DataService.setALaCarte (true);
+                    DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));
+                                       $scope.createType = COMPONENT.A_LA_CARTE;
+                                       var broadcastType = COMPONENT.CREATE_COMPONENT;
+                    if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) {
+                        DataService.setALaCarte(false);
+                        if(!shouldTakeTheAsyncInstantiationFlow){
+                            $scope.createType = COMPONENT.MACRO;
+                            var convertedAsdcModel = UtilityService.convertModel(serviceModel);
+
+                            DataService.setModelInfo(COMPONENT.SERVICE, {
+                                "modelInvariantId": serviceModel.service.invariantUuid,
+                                "modelVersion": serviceModel.service.version,
+                                "modelNameVersionId": serviceModel.service.uuid,
+                                "modelName": serviceModel.service.name,
+                                "description": serviceModel.service.description,
+                                "category": serviceModel.service.category,
+                                "serviceEcompNaming": serviceModel.service.serviceEcompNaming,
+                                "inputs": serviceModel.service.inputs,
+                                "serviceType": serviceModel.service.serviceType,
+                                "serviceRole": serviceModel.service.serviceRole,
+                                "displayInputs": convertedAsdcModel.completeDisplayInputs
+                            });
+                        }
+                    }
+
+                                       $scope.$broadcast(broadcastType, {
+                                           componentId : COMPONENT.SERVICE,
+                        modelNameVersionId: serviceModel.service.uuid,
+                                           callbackFunction : function(response) {
+                                               if (response.isSuccessful) {
+                                                               vidService.setModel(serviceModel);
+
+                                                               var subscriberId = FIELD.STATUS.NOT_FOUND;
+                                                               var serviceType = FIELD.STATUS.NOT_FOUND;
+
+                                                               var serviceInstanceId = response.instanceId;
+
+                                                               for (var i = 0; i < response.control.length; i++) {
+                                                                       if (response.control[i].id == COMPONENT.SUBSCRIBER_NAME) {
+                                                                               subscriberId = response.control[i].value;
+                                                                       } else if (response.control[i].id == FIELD.ID.SERVICE_TYPE) {
+                                                                               serviceType = response.control[i].value;
+                                                                       }
+                                                               }
+
+
+                                                               $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId);
+
+                                               }
+                                           }
+                                       });
+                               }, function (response) {
+                                       console.log("Error: " + response);
+                               });
+               };
+               
+               $scope.tableData=[];
+               var oldData=[];
+               $scope.loadPreviousVersionData=function(invariantUUID , name, version){
+                       $scope.tableData =[];
+                       oldData=[];
+                       for(var i=0;i<wholeData.length;i++){
+                               if(wholeData[i].invariantUUID == invariantUUID && wholeData[i].name == name && version!=wholeData[i].version){
+                                       oldData.push(wholeData[i]);
+                               }
+                       }
+                       $scope.tableData = oldData;
+                       $scope.createType = "Previous Version";
+                       var broadcastType = "createTableComponent";
+                       $scope.componentName = name;
+                       $scope.$broadcast(broadcastType, {
+                           componentId : COMPONENT.OLDVERSION,
+                           callbackFunction : function(response) {
+                           }
+                       });
+               };
+
+               $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) {
+                       $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI;
+                       $scope.init();
+                       $http.get( FIELD.ID.AAI_REFRESH_FULL_SUBSCRIBERS, {
+
+                       },{
+                               timeout: $scope.responseTimeoutMsec
+                       }).then(function(response){
+                               
+                               if (response.data.status < 200 || response.data.status > 202) {
+                                       $scope.showError(FIELD.ERROR.MSO);
+                                       return;
+                               }
+
+                               $scope.customer = response.data.customer; // get data from json
+
+                               $scope.customerList = [];
+
+                               $scope.serviceInstanceToCustomer = [];
+                               
+                               angular.forEach($scope.customer, function(subVal, subKey) {
+                                       var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] };
+                                       $scope.customerList.push(cust);
+                                       if (subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {
+                                                       angular.forEach(subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {
+                                                               $scope.serviceInstanceId = [];
+                                                               if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {
+                                                                       $scope.serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];
+                                                               } else {
+                                                                       $scope.serviceType = FIELD.STATUS.NO_SERVICE_SUBSCRIPTION_FOUND;
+                                                               }
+                                                               if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {
+                                                                       angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {
+                                                                               var foo = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], 
+                                                                                               "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID],
+                                                                                               "subscriberName": subVal[FIELD.ID.SUBNAME] };
+                                                                               $scope.serviceInstanceToCustomer.push(foo);
+                                                                       });
+                                                               }
+                                                       });
+                                       }
+                               });     
+                               DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer);
+                               var serviceIdList = [];
+                               $http.get( FIELD.ID.AAI_GET_SERVICES, {
+                               },{
+                                       timeout: $scope.responseTimeoutMsec
+                               }).then(function(response) {
+                                       angular.forEach(response.data, function(value, key) {
+                                               angular.forEach(value, function(subVal, key) {
+                                                       var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] ,"isPermitted" : subVal[FIELD.ID.IS_PERMITTED] };
+                                                       serviceIdList.push(newVal);
+                                                       DataService.setServiceIdList(serviceIdList);
+                                                       
+                                                       $location.search({
+                                                               "subscriberId": subscriberId,
+                                                               "serviceType": serviceType,
+                                                               "serviceInstanceId": serviceInstanceId,
+                                                               "isPermitted": newVal.isPermitted.toString()
+                                                       });
+                                                       
+                                                       $location.path(COMPONENT.INSTANTIATE_PATH);
+                                               });
+                                       });
+                               });     
+                       })
+                       ["catch"]($scope.handleServerError);
+               };
+       });
+})();