diff options
author | Amichai Hemli <ah0398@intl.att.com> | 2019-03-18 09:41:23 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-18 09:41:23 +0000 |
commit | 756a9c041981e05a3f5bd740ebc0d3fc22579003 (patch) | |
tree | 394c81ce7b2dc76b2e10492ae2364bde6bd23d1a /vid-app-common/src | |
parent | d43580130f866f23be4d8269e285d120dd6c5867 (diff) | |
parent | d45c5c75ae99f40403fcd24530a5604dd0e9c6a0 (diff) |
Merge "Remove vendor from CloudOwner"
Diffstat (limited to 'vid-app-common/src')
5 files changed, 2089 insertions, 2079 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js index 819be9374..956ae1db5 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js @@ -127,6 +127,10 @@ var vfModuleActionModalController = function(COMPONENT, $scope, $uibModal, Creat $uibModalInstance.close({requestParams : requestParams, msoType: COMPONENT.MSO_DEACTIVATE_AND_CLOUD_DELETE}); }; + $scope.removeVendorFromCloudOwner = function(cloudOwner) { + return AaiService.removeVendorFromCloudOwner(cloudOwner) + }; + $scope.cancel = function() { $uibModalInstance.dismiss('cancel'); }; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html index 620754307..eb67e6ed9 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html @@ -64,7 +64,7 @@ <option ng-repeat="option in lcpRegionList" value="{{option.cloudRegionId}}" data-ng-if="option.isPermitted && isFeatureFlagCloudOwner"> - {{option.cloudRegionId}} ({{option.cloudOwner.trim().toUpperCase().replace("ATT-", "")}}) + {{option.cloudRegionId}} ({{removeVendorFromCloudOwner(option.cloudOwner).toUpperCase()}}) </option> </select> </div> diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js index bd8bd9baa..030faf524 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js @@ -1,778 +1,784 @@ -/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T 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=========================================================
- */
-
-"use strict";
-
-var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD, $q, featureFlags) {
-
- function getServiceInstance(serviceInstanceIdentifier, findBy) {
- serviceInstanceIdentifier.trim();
-
- return $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + serviceInstanceIdentifier + "/" + findBy + "?r=" + Math.random(), {}, {
- timeout: PropertyService.getServerResponseTimeoutMsec()
- });
- }
-
- function getPnfByName(pnfName) {
- var deferred = $q.defer();
- var url = COMPONENT.AAI_GET_PNF_BY_NAME+ encodeURIComponent(pnfName) ;
- var config = { timeout: PropertyService.getServerResponseTimeoutMsec() };
-
- $http.get(url, config)
- .success(function (response) {
- deferred.resolve({data: response});
- })
- .error(function(data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
- }
- function getGlobalCustomerIdFromServiceInstanceResponse(response) {
- var globalCustomerId = "";
- if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) {
- var customerIndex = 5;
- var customerIdIndex = 6;
- var itemIndex = 0;
-
- var item = response.data[FIELD.ID.RESULT_DATA][itemIndex];
- var url = item[FIELD.ID.RESOURCE_LINK];
- var urlParts = url.split("/");
- if (urlParts[customerIndex] === FIELD.ID.CUSTOMER) {
- globalCustomerId = urlParts[customerIdIndex];
- }
- }
- return globalCustomerId;
- }
-
- function searchServiceInstances(query) {
- return $http.get( COMPONENT.SEARCH_SERVICE_INSTANCES + query, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function (response) {
- var displayData = response.data[FIELD.ID.SERVICE_INSTANCES];
- if (!displayData || !displayData.length) {
- displayData = [{
- globalCustomerId : null,
- subscriberName : null,
- serviceType : FIELD.PROMPT.NO_SERVICE_SUB,
- serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE
- }];
- }
- return {displayData: displayData};
- });
- };
-
- function getJoinedQueryString(queries) {
- return queries.filter(function (val) {return val;}).join("&");
- }
-
- return {
- getSubscriberName : function(globalCustomerId,
- successCallbackFunction) {
- $log
- .debug("AaiService:getSubscriberName: globalCustomerId: "
- + globalCustomerId);
- $http.get(
- COMPONENT.AAI_SUB_DETAILS_PATH
- + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- var result = {};
- if (response.data) {
- result.subscriberName = response.data[FIELD.ID.SUBNAME];
- result.serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS];
- }
- successCallbackFunction(result);
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
-
- runNamedQuery : function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
-
- var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- return $http.get(url, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- successCallback(response);
- } else {
- errorCallback(response);
- }
- }, function(response) {
- errorCallback(response);
- });
- },
-
-
- getVNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
-
- var url = COMPONENT.AAI_GET_VNF_INFO +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- $http.get(url, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- successCallback(response);
- } else {
- errorCallback(response);
- }
- }, function(response) {
- errorCallback(response);
- });
- },
-
- getPNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
-
- var url = COMPONENT.AAI_GET_PNF_INSTANCE +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- $http.get(url, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- successCallback(response);
- } else {
- errorCallback(response);
- }
- }, function(response) {
- errorCallback(response);
- });
- },
-
- getCRInformationByInstanceId : function (serviceInstanceId) {
-
- var deferred = $q.defer();
-
- var url = COMPONENT.AAI_GET_CR_INSTANCE +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- $http.get(url, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- deferred.resolve(response);
- } else {
- deferred.resolve(response);
- }
- }, function(response) {
- deferred.resolve(response);
- });
- return deferred.promise;
- },
-
- searchServiceInstances: searchServiceInstances,
-
- getModelVersionId: function (subscriberId, instanceId) {
- var globalCustomerIdQuery = COMPONENT.SELECTED_SUBSCRIBER_SUB_PATH + subscriberId;
- var serviceInstanceQuery = COMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH + instanceId;
-
- var query = "?" + getJoinedQueryString([globalCustomerIdQuery, serviceInstanceQuery]);
-
- var deferred = $q.defer();
-
- searchServiceInstances(query).then(function (response) {
- var displayData = response.displayData;
- if (displayData[0] && displayData[0].aaiModelVersionId) {
- deferred.resolve(displayData[0].aaiModelVersionId);
- } else {
- deferred.reject(FIELD.ERROR.MODEL_VERSION_ID_MISSING);
- }
- }).catch(function (err) {
- deferred.reject(err);
- });
-
- return deferred.promise;
- },
-
- getSubDetails : function(selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) {
- var subscriber;
- var displayData;
- $http.get( COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- displayData = [];
- subscriber = response.data;
- var subscriberName = subscriber[FIELD.ID.SUBNAME];
- if (subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {
- angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {
- var serviceInstanceId = [];
- var serviceType = "";
- if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {
- serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];
- } else {
- serviceType = FIELD.PROMPT.NO_SERVICE_SUB;
- }
- if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {
- angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {
- // put them together, i guess
- var inst = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID],
- "aaiModelInvariantId": instValue[FIELD.ID.MODEL_INVAR_ID],
- "aaiModelVersionId": instValue[FIELD.ID.MODEL_VERSION_ID],
- "serviceInstanceName": instValue[FIELD.ID.SERVICE_INSTANCE_NAME]
- };
- if (selectedServiceInstance != null) {
- if ((instValue[FIELD.ID.SERVICE_INSTANCE_ID] == selectedServiceInstance ) || (instValue[FIELD.ID.SERVICE_INSTANCE_NAME] == selectedServiceInstance)) {
- serviceInstanceId.push(inst);
- }
- } else {
- serviceInstanceId.push(inst);
- }
- });
- } else {
- serviceInstanceId = [ FIELD.PROMPT.NO_SERVICE_INSTANCE ];
- }
- angular.forEach(serviceInstanceId, function(subVal, subKey) {
- displayData.push({
- globalCustomerId : selectedSubscriber,
- subscriberName : subscriberName,
- serviceType : serviceType,
- serviceInstanceId : subVal.serviceInstanceId,
- aaiModelInvariantId : subVal.aaiModelInvariantId,
- aaiModelVersionId
- : subVal.aaiModelVersionId,
- serviceInstanceName : subVal.serviceInstanceName,
- isPermitted: serviceSubscription[FIELD.ID.IS_PERMITTED]
- });
- });
- });
- } else {
- displayData.push({
- globalCustomerId : selectedSubscriber,
- subscriberName : subscriberName,
- serviceType : FIELD.PROMPT.NO_SERVICE_SUB,
- serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE
- });
- }
- successCallback(displayData, subscriberName);
- }, function(response) {
- errorCallback(response);});
- },
-
- getSubList : function(successCallback, errorCallback ) {
-
- $http.get( FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- var customerList = [];
- if (response.data.customer != null) {
- angular.forEach(response.data.customer, function(subVal, subKey) {
- var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME],
- "isPermitted": subVal[FIELD.ID.IS_PERMITTED], };
- customerList.push(cust);
- });
- successCallback(customerList);
- } else {
- errorCallback(response);
- }
- },function(response) {
- errorCallback(response);
- });
- },
-
- getServiceInstance : getServiceInstance,
- getPnfByName : getPnfByName,
-
- getGlobalCustomerIdByInstanceIdentifier : function(serviceInstanceIdentifier, findBy) {
- serviceInstanceIdentifier.trim();
-
- return getServiceInstance(serviceInstanceIdentifier, findBy)
- .then(function (response) {
- return getGlobalCustomerIdFromServiceInstanceResponse(response);
- });
- },
-
- getMultipleValueParamQueryString: function(values, paramSubPath) {
- if (values.length) {
- return paramSubPath + values.filter(function (val) {return val;}).join("&" + paramSubPath);
- }
- },
-
- getJoinedQueryString: getJoinedQueryString,
-
- getServices2 : function(successCallback, errorCallback ) {
-
- $http.get( FIELD.ID.AAI_GET_SERVICES, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- var customerList = [];
- if (response.data != null) {
- var serviceIdList = [];
- 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);
- });
- });
- successCallback(serviceIdList);
- } else {
- errorCallback(response);
- }
- },function(response) {
- errorCallback(response);
- });
- },
-
- getPortMirroringData: function (ids) {
- var defer = $q.defer();
-
- var url = COMPONENT.AAI_GET_PORT_MIRRORING_CONFIGS_DATA + '?configurationIds=' + ids.join(',');
- $http.get(url).then(function (res) {
- defer.resolve(res);
- }).catch(function (err) {
- $log.error(err);
- defer.resolve({});
- });
-
- return defer.promise;
-
- },
-
- getPortMirroringSourcePorts : function (ids) {
- var defer = $q.defer();
- var url = COMPONENT.AAI_GET_PORT_MIRRORING_SOURCE_PORTS +'?configurationIds=' + ids.join(',');
- $http.get(url).then(function(res){
- defer.resolve(res);
- }).catch(function(err) {
- $log.error(err);
- defer.resolve({});
- });
- return defer.promise;
- },
-
- getVlansByNetworksMapping : function (globalCustomerId, serviceType, serviceInstanceId, sdcModelUuid) {
- var defer = $q.defer();
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)) {
- var url = COMPONENT.AAI_GET_PROVIDER_NETWORKS_ASSOCIATIONS + '?'
- + 'globalCustomerId=' + globalCustomerId
- + '&serviceType=' + serviceType
- + '&serviceInstanceId=' + serviceInstanceId
- + '&sdcModelUuid=' + sdcModelUuid
- ;
-
- $http.get(url).then(function(res){
- defer.resolve(res.data);
- }).catch(function(err) {
- $log.error(err);
- defer.resolve({});
- });
-
- } else {
- defer.resolve({});
- }
- return defer.promise;
- },
-
- getSubscriptionServiceTypeList : function(globalCustomerId,
- successCallbackFunction) {
- $log
- .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: "
- + globalCustomerId);
- if ( UtilityService.hasContents(globalCustomerId) ) {
- $http.get(
- COMPONENT.AAI_SUB_DETAILS_PATH
- + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data && response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]) {
- var serviceTypes = [];
- var serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION];
-
- for (var i = 0; i < serviceSubscriptions.length; i++) {
- serviceTypes.push({
- "name":serviceSubscriptions[i][FIELD.ID.SERVICETYPE],
- "isPermitted": serviceSubscriptions[i][FIELD.ID.IS_PERMITTED],
- "id": i
- });}
- successCallbackFunction(serviceTypes);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- }
- },
- getLcpCloudRegionTenantList : function(globalCustomerId, serviceType,
- successCallbackFunction) {
- $log
- .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: "
- + globalCustomerId);
- var url = COMPONENT.AAI_GET_TENANTS
- + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- var lcpCloudRegionTenants = [];
- var aaiLcpCloudRegionTenants = response.data;
-
- for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) {
- lcpCloudRegionTenants.push({
- "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID],
- "cloudOwner": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_OWNER],
- "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME],
- "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID],
- "isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED]});
- }
-
- successCallbackFunction(lcpCloudRegionTenants);
- }).catch(function(error) {
- (UtilityService.runHttpErrorHandler(error.data, error.status));
- })
- },
- getSubscribers : function(successCallbackFunction) {
- $log
- .debug("AaiService:getSubscribers");
- var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response.data.customer);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
- getProvOptionsFromSystemProp : function(successCallbackFunction) {
- $log
- .debug("AaiService:getProvOptionsFromSystemProp");
- var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH;
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
- getLoggedInUserID : function(successCallbackFunction, catchCallbackFunction) {
- $log
- .debug("AaiService:getLoggedInUserID");
- var url = COMPONENT.GET_USER_ID;
-
- $http.get(url,
- {
- transformResponse: [function (data) {
- return data;
- }],
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"] (function(response, status) {
- if (catchCallbackFunction) {
- catchCallbackFunction();
- }
- UtilityService.runHttpErrorHandler(response, status);
- })
- },
- getServices : function(successCallbackFunction) {
- $log
- .debug("AaiService:getServices");
- var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout: PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function (response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
-
- getAicZones: function (successCallbackFunction) {
- $log
- .debug("getAicZones:getAicZones");
- var url = COMPONENT.AAI_GET_AIC_ZONES +COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);},
- getAicZoneForPNF: function (globalCustomerId,serviceType,serviceInstanceId,successCallbackFunction) {
- $log
- .debug("getAicZones:getAicZones");
- var url = COMPONENT.AAI_GET_AIC_ZONE_FOR_PNF
- .replace('@serviceInstanceId', serviceInstanceId)
- .replace('@globalCustomerId', globalCustomerId)
- .replace('@serviceType', serviceType);
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- successCallbackFunction(response.data);
- })["catch"]
- (UtilityService.runHttpErrorHandler);},
-
- getServiceModels : function(globalCustomerId,serviceType,successCallbackFunction) {
- $log
- .debug("AaiService:getServices");
- var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH+globalCustomerId+ COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
- getServiceModelsByServiceType : function(namedQueryId,globalCustomerId,serviceType,successCallbackFunction) {
- $log
- .debug("AaiService:getServiceModelsByServiceType");
- var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE+COMPONENT.FORWARD_SLASH+namedQueryId+COMPONENT.FORWARD_SLASH+globalCustomerId+COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
-
- getVnfsByCustomerIdAndServiceType: function(globalSubscriberId, serviceType){
- var deferred = $q.defer();
-
- if (UtilityService.hasContents(globalSubscriberId) &&
- UtilityService.hasContents(serviceType) ) {
-
- $http.get(COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + globalSubscriberId + COMPONENT.FORWARD_SLASH
- + serviceType )
- .success(function (response) {
- if(response) {
- deferred.resolve({data: response});
- } else {
- deferred.resolve({data: []});
- }
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
- }
-
- return deferred.promise;
- },
-
- getVnfVersionsByInvariantId: function(modelInvariantId){
- var deferred = $q.defer();
-
- if (UtilityService.hasContents(modelInvariantId)) {
- var body = {"versions": modelInvariantId};
- $http.post(( COMPONENT.AAI_GET_VERSION_BY_INVARIANT_ID),body)
-
- .success(function (response) {
- if(response) {
- deferred.resolve({data: response});
- } else {
- deferred.resolve({data: []});
- }
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
- }
-
- return deferred.promise;
- },
-
-
-
- getSubscriberServiceTypes: function(subscriberUuid) {
- var deferred = $q.defer();
- $log.debug("AaiService:getSubscriberServiceTypes: subscriberUuid: " + subscriberUuid);
-
- if (UtilityService.hasContents(subscriberUuid)) {
- $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + subscriberUuid + COMPONENT.ASSIGN + Math.random())
- .success(function (response) {
- if(response && [FIELD.ID.SERVICE_SUBSCRIPTIONS]) {
- deferred.resolve({data: response[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]});
- } else {
- deferred.resolve({data: []});
- }
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
- }
-
- return deferred.promise;
- },
- getVnfInstancesList: function(globalSubscriberId, serviceType, modelVersionId ,modelInvariantId, cloudRegionId) {
- var deferred = $q.defer();
- $http.get([COMPONENT.AAI_GET_VNF_INSTANCES_LIST,
- globalSubscriberId,
- serviceType,
- modelVersionId,
- modelInvariantId,
- cloudRegionId]
- .join(COMPONENT.FORWARD_SLASH))
- .success(function (response) {
- deferred.resolve(response);
- }).error(function (data, status) {
- deferred.reject({message: data, status: status});
- });
- return deferred.promise;
- },
- getPnfInstancesList: function (globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegionId, equipVendor, equipModel) {
- var deferred = $q.defer();
- $http.get([COMPONENT.AAI_GET_PNF_INSTANCES_LIST,
- globalCustomerId, serviceType,
- modelVersionId, modelInvariantId,
- cloudRegionId,
- equipVendor, equipModel
- ].join(COMPONENT.FORWARD_SLASH))
- .success(function (response) {
- deferred.resolve(response);
- }).error(function (data, status) {
- deferred.reject({message: data, status: status});
- });
- return deferred.promise;
- },
- getByUri: function(uri) {
- var deferred = $q.defer();
-
- $http.get(COMPONENT.AAI_GET_BY_URI + uri)
- .success(function (response) {
- deferred.resolve({data: []});
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
- },
- getConfiguration: function(configurationId) {
- var deferred = $q.defer();
-
- $http.get(COMPONENT.AAI_GET_CONFIGURATION + configurationId)
- .success(function (response) {
- deferred.resolve({data: []});
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
- },
-
- getInstanceGroupsByVNFInstanceId: function (vnf_instance_id, successCallback, errorCallback) {
- var url = COMPONENT.AAI_GET_INSTANCE_GROUPS_BY_VNF_INSTANCE_ID_PATH + "/" + vnf_instance_id;
-
- $http.get(url, {}, {
- timeout: PropertyService.getServerResponseTimeoutMsec()
- }).then(function (response) {
- successCallback(response);
- }, function (response) {
- errorCallback(response);
- });
- },
-
- postPOMBAverificationRequest: function (url, data, config) {
- $http.post(url, data, config)
- .success(function (data, status, headers, config) {
- //If at some point in the future the result should be handled - this should be the entry point.
- log.debug("POMBA was called successfully with data: " + data);
- })
- .error(function (data, status, header, config) {
- log.debug("Error: " +
- "Data: " + data +
- "status: " + status +
- "headers: " + header +
- "config: " + config);
- });
- },
-
- getHomingData: function(vnfInstanceId, vfModuleId) {
- var url = COMPONENT.AAI_GET_HOMING_DATA.replace('@vnfInstanceId', vnfInstanceId)
- .replace('@vfModuleId', vfModuleId);
-
- var deferred = $q.defer();
-
- $http.get(url)
- .success(function (response) {
- deferred.resolve({data: response});
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
-
- }
- };
-};
-
-appDS2.factory("AaiService", ["$http", "$log", "PropertyService",
- "UtilityService", "COMPONENT", "FIELD", "$q", "featureFlags", AaiService]);
+/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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========================================================= + */ + +"use strict"; + +var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD, $q, featureFlags) { + + function getServiceInstance(serviceInstanceIdentifier, findBy) { + serviceInstanceIdentifier.trim(); + + return $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + serviceInstanceIdentifier + "/" + findBy + "?r=" + Math.random(), {}, { + timeout: PropertyService.getServerResponseTimeoutMsec() + }); + } + + function getPnfByName(pnfName) { + var deferred = $q.defer(); + var url = COMPONENT.AAI_GET_PNF_BY_NAME+ encodeURIComponent(pnfName) ; + var config = { timeout: PropertyService.getServerResponseTimeoutMsec() }; + + $http.get(url, config) + .success(function (response) { + deferred.resolve({data: response}); + }) + .error(function(data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + } + function getGlobalCustomerIdFromServiceInstanceResponse(response) { + var globalCustomerId = ""; + if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) { + var customerIndex = 5; + var customerIdIndex = 6; + var itemIndex = 0; + + var item = response.data[FIELD.ID.RESULT_DATA][itemIndex]; + var url = item[FIELD.ID.RESOURCE_LINK]; + var urlParts = url.split("/"); + if (urlParts[customerIndex] === FIELD.ID.CUSTOMER) { + globalCustomerId = urlParts[customerIdIndex]; + } + } + return globalCustomerId; + } + + function searchServiceInstances(query) { + return $http.get( COMPONENT.SEARCH_SERVICE_INSTANCES + query, {}, { + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function (response) { + var displayData = response.data[FIELD.ID.SERVICE_INSTANCES]; + if (!displayData || !displayData.length) { + displayData = [{ + globalCustomerId : null, + subscriberName : null, + serviceType : FIELD.PROMPT.NO_SERVICE_SUB, + serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE + }]; + } + return {displayData: displayData}; + }); + }; + + function getJoinedQueryString(queries) { + return queries.filter(function (val) {return val;}).join("&"); + } + + return { + getSubscriberName : function(globalCustomerId, + successCallbackFunction) { + $log + .debug("AaiService:getSubscriberName: globalCustomerId: " + + globalCustomerId); + $http.get( + COMPONENT.AAI_SUB_DETAILS_PATH + + globalCustomerId + COMPONENT.ASSIGN + Math.random(), + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + var result = {}; + if (response.data) { + result.subscriberName = response.data[FIELD.ID.SUBNAME]; + result.serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]; + } + successCallbackFunction(result); + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + + runNamedQuery : function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { + + var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH + + COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); + return $http.get(url, {}, { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data != null) { + successCallback(response); + } else { + errorCallback(response); + } + }, function(response) { + errorCallback(response); + }); + }, + + + getVNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { + + var url = COMPONENT.AAI_GET_VNF_INFO + + COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); + $http.get(url, {}, { + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data != null) { + successCallback(response); + } else { + errorCallback(response); + } + }, function(response) { + errorCallback(response); + }); + }, + + getPNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { + + var url = COMPONENT.AAI_GET_PNF_INSTANCE + + COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); + $http.get(url, {}, { + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data != null) { + successCallback(response); + } else { + errorCallback(response); + } + }, function(response) { + errorCallback(response); + }); + }, + + getCRInformationByInstanceId : function (serviceInstanceId) { + + var deferred = $q.defer(); + + var url = COMPONENT.AAI_GET_CR_INSTANCE + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); + $http.get(url, {}, { + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data != null) { + deferred.resolve(response); + } else { + deferred.resolve(response); + } + }, function(response) { + deferred.resolve(response); + }); + return deferred.promise; + }, + + searchServiceInstances: searchServiceInstances, + + getModelVersionId: function (subscriberId, instanceId) { + var globalCustomerIdQuery = COMPONENT.SELECTED_SUBSCRIBER_SUB_PATH + subscriberId; + var serviceInstanceQuery = COMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH + instanceId; + + var query = "?" + getJoinedQueryString([globalCustomerIdQuery, serviceInstanceQuery]); + + var deferred = $q.defer(); + + searchServiceInstances(query).then(function (response) { + var displayData = response.displayData; + if (displayData[0] && displayData[0].aaiModelVersionId) { + deferred.resolve(displayData[0].aaiModelVersionId); + } else { + deferred.reject(FIELD.ERROR.MODEL_VERSION_ID_MISSING); + } + }).catch(function (err) { + deferred.reject(err); + }); + + return deferred.promise; + }, + + getSubDetails : function(selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) { + var subscriber; + var displayData; + $http.get( COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, {}, { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + displayData = []; + subscriber = response.data; + var subscriberName = subscriber[FIELD.ID.SUBNAME]; + if (subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) { + angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) { + var serviceInstanceId = []; + var serviceType = ""; + if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) { + serviceType = serviceSubscription[FIELD.ID.SERVICETYPE]; + } else { + serviceType = FIELD.PROMPT.NO_SERVICE_SUB; + } + if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) { + angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) { + // put them together, i guess + var inst = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], + "aaiModelInvariantId": instValue[FIELD.ID.MODEL_INVAR_ID], + "aaiModelVersionId": instValue[FIELD.ID.MODEL_VERSION_ID], + "serviceInstanceName": instValue[FIELD.ID.SERVICE_INSTANCE_NAME] + }; + if (selectedServiceInstance != null) { + if ((instValue[FIELD.ID.SERVICE_INSTANCE_ID] == selectedServiceInstance ) || (instValue[FIELD.ID.SERVICE_INSTANCE_NAME] == selectedServiceInstance)) { + serviceInstanceId.push(inst); + } + } else { + serviceInstanceId.push(inst); + } + }); + } else { + serviceInstanceId = [ FIELD.PROMPT.NO_SERVICE_INSTANCE ]; + } + angular.forEach(serviceInstanceId, function(subVal, subKey) { + displayData.push({ + globalCustomerId : selectedSubscriber, + subscriberName : subscriberName, + serviceType : serviceType, + serviceInstanceId : subVal.serviceInstanceId, + aaiModelInvariantId : subVal.aaiModelInvariantId, + aaiModelVersionId + : subVal.aaiModelVersionId, + serviceInstanceName : subVal.serviceInstanceName, + isPermitted: serviceSubscription[FIELD.ID.IS_PERMITTED] + }); + }); + }); + } else { + displayData.push({ + globalCustomerId : selectedSubscriber, + subscriberName : subscriberName, + serviceType : FIELD.PROMPT.NO_SERVICE_SUB, + serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE + }); + } + successCallback(displayData, subscriberName); + }, function(response) { + errorCallback(response);}); + }, + + getSubList : function(successCallback, errorCallback ) { + + $http.get( FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, {}, { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + var customerList = []; + if (response.data.customer != null) { + angular.forEach(response.data.customer, function(subVal, subKey) { + var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME], + "isPermitted": subVal[FIELD.ID.IS_PERMITTED], }; + customerList.push(cust); + }); + successCallback(customerList); + } else { + errorCallback(response); + } + },function(response) { + errorCallback(response); + }); + }, + + getServiceInstance : getServiceInstance, + getPnfByName : getPnfByName, + + getGlobalCustomerIdByInstanceIdentifier : function(serviceInstanceIdentifier, findBy) { + serviceInstanceIdentifier.trim(); + + return getServiceInstance(serviceInstanceIdentifier, findBy) + .then(function (response) { + return getGlobalCustomerIdFromServiceInstanceResponse(response); + }); + }, + + getMultipleValueParamQueryString: function(values, paramSubPath) { + if (values.length) { + return paramSubPath + values.filter(function (val) {return val;}).join("&" + paramSubPath); + } + }, + + getJoinedQueryString: getJoinedQueryString, + + getServices2 : function(successCallback, errorCallback ) { + + $http.get( FIELD.ID.AAI_GET_SERVICES, {}, { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + var customerList = []; + if (response.data != null) { + var serviceIdList = []; + 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); + }); + }); + successCallback(serviceIdList); + } else { + errorCallback(response); + } + },function(response) { + errorCallback(response); + }); + }, + + getPortMirroringData: function (ids) { + var defer = $q.defer(); + + var url = COMPONENT.AAI_GET_PORT_MIRRORING_CONFIGS_DATA + '?configurationIds=' + ids.join(','); + $http.get(url).then(function (res) { + defer.resolve(res); + }).catch(function (err) { + $log.error(err); + defer.resolve({}); + }); + + return defer.promise; + + }, + + getPortMirroringSourcePorts : function (ids) { + var defer = $q.defer(); + var url = COMPONENT.AAI_GET_PORT_MIRRORING_SOURCE_PORTS +'?configurationIds=' + ids.join(','); + $http.get(url).then(function(res){ + defer.resolve(res); + }).catch(function(err) { + $log.error(err); + defer.resolve({}); + }); + return defer.promise; + }, + + getVlansByNetworksMapping : function (globalCustomerId, serviceType, serviceInstanceId, sdcModelUuid) { + var defer = $q.defer(); + if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)) { + var url = COMPONENT.AAI_GET_PROVIDER_NETWORKS_ASSOCIATIONS + '?' + + 'globalCustomerId=' + globalCustomerId + + '&serviceType=' + serviceType + + '&serviceInstanceId=' + serviceInstanceId + + '&sdcModelUuid=' + sdcModelUuid + ; + + $http.get(url).then(function(res){ + defer.resolve(res.data); + }).catch(function(err) { + $log.error(err); + defer.resolve({}); + }); + + } else { + defer.resolve({}); + } + return defer.promise; + }, + + getSubscriptionServiceTypeList : function(globalCustomerId, + successCallbackFunction) { + $log + .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: " + + globalCustomerId); + if ( UtilityService.hasContents(globalCustomerId) ) { + $http.get( + COMPONENT.AAI_SUB_DETAILS_PATH + + globalCustomerId + COMPONENT.ASSIGN + Math.random(), + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data && response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]) { + var serviceTypes = []; + var serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]; + + for (var i = 0; i < serviceSubscriptions.length; i++) { + serviceTypes.push({ + "name":serviceSubscriptions[i][FIELD.ID.SERVICETYPE], + "isPermitted": serviceSubscriptions[i][FIELD.ID.IS_PERMITTED], + "id": i + });} + successCallbackFunction(serviceTypes); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + } + }, + getLcpCloudRegionTenantList : function(globalCustomerId, serviceType, + successCallbackFunction) { + $log + .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: " + + globalCustomerId); + var url = COMPONENT.AAI_GET_TENANTS + + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + var lcpCloudRegionTenants = []; + var aaiLcpCloudRegionTenants = response.data; + + for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) { + lcpCloudRegionTenants.push({ + "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID], + "cloudOwner": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_OWNER], + "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME], + "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID], + "isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED]}); + } + + successCallbackFunction(lcpCloudRegionTenants); + }).catch(function(error) { + (UtilityService.runHttpErrorHandler(error.data, error.status)); + }) + }, + getSubscribers : function(successCallbackFunction) { + $log + .debug("AaiService:getSubscribers"); + var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response.data.customer); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getProvOptionsFromSystemProp : function(successCallbackFunction) { + $log + .debug("AaiService:getProvOptionsFromSystemProp"); + var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH; + + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getLoggedInUserID : function(successCallbackFunction, catchCallbackFunction) { + $log + .debug("AaiService:getLoggedInUserID"); + var url = COMPONENT.GET_USER_ID; + + $http.get(url, + { + transformResponse: [function (data) { + return data; + }], + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] (function(response, status) { + if (catchCallbackFunction) { + catchCallbackFunction(); + } + UtilityService.runHttpErrorHandler(response, status); + }) + }, + getServices : function(successCallbackFunction) { + $log + .debug("AaiService:getServices"); + var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }).then(function (response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + + getAicZones: function (successCallbackFunction) { + $log + .debug("getAicZones:getAicZones"); + var url = COMPONENT.AAI_GET_AIC_ZONES +COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler);}, + getAicZoneForPNF: function (globalCustomerId,serviceType,serviceInstanceId,successCallbackFunction) { + $log + .debug("getAicZones:getAicZones"); + var url = COMPONENT.AAI_GET_AIC_ZONE_FOR_PNF + .replace('@serviceInstanceId', serviceInstanceId) + .replace('@globalCustomerId', globalCustomerId) + .replace('@serviceType', serviceType); + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + successCallbackFunction(response.data); + })["catch"] + (UtilityService.runHttpErrorHandler);}, + + getServiceModels : function(globalCustomerId,serviceType,successCallbackFunction) { + $log + .debug("AaiService:getServices"); + var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH+globalCustomerId+ COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getServiceModelsByServiceType : function(namedQueryId,globalCustomerId,serviceType,successCallbackFunction) { + $log + .debug("AaiService:getServiceModelsByServiceType"); + var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE+COMPONENT.FORWARD_SLASH+namedQueryId+COMPONENT.FORWARD_SLASH+globalCustomerId+COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random(); + + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + + getVnfsByCustomerIdAndServiceType: function(globalSubscriberId, serviceType){ + var deferred = $q.defer(); + + if (UtilityService.hasContents(globalSubscriberId) && + UtilityService.hasContents(serviceType) ) { + + $http.get(COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + globalSubscriberId + COMPONENT.FORWARD_SLASH + + serviceType ) + .success(function (response) { + if(response) { + deferred.resolve({data: response}); + } else { + deferred.resolve({data: []}); + } + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + } + + return deferred.promise; + }, + + getVnfVersionsByInvariantId: function(modelInvariantId){ + var deferred = $q.defer(); + + if (UtilityService.hasContents(modelInvariantId)) { + var body = {"versions": modelInvariantId}; + $http.post(( COMPONENT.AAI_GET_VERSION_BY_INVARIANT_ID),body) + + .success(function (response) { + if(response) { + deferred.resolve({data: response}); + } else { + deferred.resolve({data: []}); + } + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + } + + return deferred.promise; + }, + + + + getSubscriberServiceTypes: function(subscriberUuid) { + var deferred = $q.defer(); + $log.debug("AaiService:getSubscriberServiceTypes: subscriberUuid: " + subscriberUuid); + + if (UtilityService.hasContents(subscriberUuid)) { + $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + subscriberUuid + COMPONENT.ASSIGN + Math.random()) + .success(function (response) { + if(response && [FIELD.ID.SERVICE_SUBSCRIPTIONS]) { + deferred.resolve({data: response[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]}); + } else { + deferred.resolve({data: []}); + } + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + } + + return deferred.promise; + }, + getVnfInstancesList: function(globalSubscriberId, serviceType, modelVersionId ,modelInvariantId, cloudRegionId) { + var deferred = $q.defer(); + $http.get([COMPONENT.AAI_GET_VNF_INSTANCES_LIST, + globalSubscriberId, + serviceType, + modelVersionId, + modelInvariantId, + cloudRegionId] + .join(COMPONENT.FORWARD_SLASH)) + .success(function (response) { + deferred.resolve(response); + }).error(function (data, status) { + deferred.reject({message: data, status: status}); + }); + return deferred.promise; + }, + getPnfInstancesList: function (globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegionId, equipVendor, equipModel) { + var deferred = $q.defer(); + $http.get([COMPONENT.AAI_GET_PNF_INSTANCES_LIST, + globalCustomerId, serviceType, + modelVersionId, modelInvariantId, + cloudRegionId, + equipVendor, equipModel + ].join(COMPONENT.FORWARD_SLASH)) + .success(function (response) { + deferred.resolve(response); + }).error(function (data, status) { + deferred.reject({message: data, status: status}); + }); + return deferred.promise; + }, + getByUri: function(uri) { + var deferred = $q.defer(); + + $http.get(COMPONENT.AAI_GET_BY_URI + uri) + .success(function (response) { + deferred.resolve({data: []}); + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + }, + getConfiguration: function(configurationId) { + var deferred = $q.defer(); + + $http.get(COMPONENT.AAI_GET_CONFIGURATION + configurationId) + .success(function (response) { + deferred.resolve({data: []}); + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + }, + + getInstanceGroupsByVNFInstanceId: function (vnf_instance_id, successCallback, errorCallback) { + var url = COMPONENT.AAI_GET_INSTANCE_GROUPS_BY_VNF_INSTANCE_ID_PATH + "/" + vnf_instance_id; + + $http.get(url, {}, { + timeout: PropertyService.getServerResponseTimeoutMsec() + }).then(function (response) { + successCallback(response); + }, function (response) { + errorCallback(response); + }); + }, + + postPOMBAverificationRequest: function (url, data, config) { + $http.post(url, data, config) + .success(function (data, status, headers, config) { + //If at some point in the future the result should be handled - this should be the entry point. + log.debug("POMBA was called successfully with data: " + data); + }) + .error(function (data, status, header, config) { + log.debug("Error: " + + "Data: " + data + + "status: " + status + + "headers: " + header + + "config: " + config); + }); + }, + + getHomingData: function(vnfInstanceId, vfModuleId) { + var url = COMPONENT.AAI_GET_HOMING_DATA.replace('@vnfInstanceId', vnfInstanceId) + .replace('@vfModuleId', vfModuleId); + + var deferred = $q.defer(); + + $http.get(url) + .success(function (response) { + deferred.resolve({data: response}); + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + + }, + + removeVendorFromCloudOwner: function(cloudOwner) { + // Handle the case where cloud owner is formatted + // like "{vendor}-{cloud-name}" + return cloudOwner.trim().replace(/^[^-]*-/, ''); + } + }; +}; + +appDS2.factory("AaiService", ["$http", "$log", "PropertyService", + "UtilityService", "COMPONENT", "FIELD", "$q", "featureFlags", AaiService]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js index 739a17912..d5fd32001 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js @@ -1,1299 +1,1299 @@ -/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T 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=========================================================
- */
-
-"use strict";
-
-/*
- * "CreationService" isolates the "component-specific" logic required by the
- * "CreationDialog" controller.
- *
- * "Components" are defined as the 5 element types managed by the dialogs: A)
- * Service B) VNF C) VF Module D) Volume Group and E) Network.
- *
- */
-
-var CreationService = function($log, AaiService, AsdcService, DataService,VIDCONFIGURATION,
- ComponentService, COMPONENT, FIELD, PARAMETER, UtilityService, OwningEntityService,featureFlags) {
-
- var _this = this;
- var getAsyncOperationList = function() {
- if (DataService.getLoggedInUserId() == null) {
- getLoggedInUserID();
- } else {
- UtilityService.startNextAsyncOperation();
- }
- switch (_this.componentId) {
- case COMPONENT.SERVICE:
- return [ getSubscribers, getServices, getAicZones, getOwningEntityProperties ];
- case COMPONENT.NETWORK:
- return [ getLcpCloudRegionTenantList, getOwningEntityProperties ];
- case COMPONENT.VNF:
- return [ getLcpCloudRegionTenantList, getOwningEntityProperties ];
- case COMPONENT.VF_MODULE:
- return [ getLcpCloudRegionTenantList ];
- case COMPONENT.VOLUME_GROUP:
- return [ getLcpCloudRegionTenantList ];
- }
- };
-
- /*
- * "getSummaryList" and "getUserProvidedList" return parameters that should
- * be displayed in the summary and user provided sections, respectively. The
- * functions are expected to return lists that are in the format needed by
- * the parameter-block directive.
- */
-
- var getSummaryList = function() {
-
- /*
- * These placeholders should be removed and their usage in
- * "getSummaryList" should be replaced by appropriate code as the
- * requirements and interfaces firm up.
- */
-
- var PLACEHOLDER_RESOURCE_DESCRIPTION = "Resource Description (PLACEHOLDER)";
- var PLACEHOLDER_SERVICE_CATEGORY = "Service Category (PLACEHOLDER)";
- var PLACEHOLDER_VF_MODULE_DESCRIPTION = "VF Module Description (PLACEHOLDER)";
- var PLACEHOLDER_VF_MODULE_LABEL = "VF Module Label (PLACEHOLDER)";
- var PLACEHOLDER_VF_MODULE_TYPE = "VF Module Type (PLACEHOLDER)";
-
- _this.parameterList = new Array();
-
- /*
- * Common fields displayed at the top of all create instance screens.
- */
- if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]==null
- || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==undefined
- || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==''){
- addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
- }
-
- switch (_this.componentId) {
- case COMPONENT.SERVICE:
- if ( !DataService.getALaCarte() ) {
- // for macro instantiation need to add the resource names under the node template list
- // this field is called modelCustomizationName in the asdc client code
- var p;
- var rlist = DataService.getResources();
- var res;
- if ( rlist != null ) {
- for (var i = 0; i < rlist.length; i++) {
- res = rlist[i];
-
- p = FIELD.NAME.RESOURCE_NAME.concat(" " + (i+1));
- addToList(p, res.name );
- p = FIELD.NAME.RESOURCE_DESCRIPTION.concat(" " + (i+1));
- addToList(p, res.description );
- }
- }
- }
- if(DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=null && DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=''){
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getModelInfo(_this.componentId)["createSubscriberName"]);
- }
- if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=null && DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=''){
- addToList(FIELD.NAME.SERVICE_TYPE, DataService
- .getModelInfo(_this.componentId)["serviceTypeName"]);
- addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
- }
- addToList(FIELD.NAME.SERVICE_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.SERVICE_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.SERVICE_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.SERVICE_DESCRIPTION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.DESCRIPTION]);
- addToList(FIELD.NAME.SERVICE_CATEGORY, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CATEGORY]);
- if (DataService.getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE] != "null") {
- addToList(FIELD.NAME.SERVICE_TYPE, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE]);
- addToList(FIELD.NAME.SERVICE_ROLE, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_ROLE]);
- }
-
- break;
- case COMPONENT.VF_MODULE:
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getSubscriberName());
- addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
- .getServiceInstanceName());
- addToList(FIELD.NAME.MODEL_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
- addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.MODEL_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.MODEL_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
- break;
- case COMPONENT.VNF:
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getSubscriberName());
- addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
- .getServiceInstanceName());
- addToList(FIELD.NAME.MODEL_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
- addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.MODEL_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.MODEL_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_CUSTOMIZATION_NAME]);
- addToList(FIELD.NAME.MODEL_VNF_TYPE, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_TYPE]);
- addToList(FIELD.NAME.MODEL_VNF_ROLE, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_ROLE]);
- addToList(FIELD.NAME.MODEL_VNF_FUNCTION, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_FUNCTION]);
- addToList(FIELD.NAME.MODEL_VNF_CODE, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_CODE]);
- break;
- case COMPONENT.NETWORK:
- case COMPONENT.VOLUME_GROUP:
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getSubscriberName());
- addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
- .getServiceInstanceName());
- addToList(FIELD.NAME.MODEL_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
- addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.MODEL_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.MODEL_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
- break;
- }
-
- return _this.parameterList;
- };
-
- var getUserProvidedList = function() {
- var parameterList = [];
- var isUserProvidedNaming = false;
- if ( ((DataService.getModelInfo(_this.componentId).serviceEcompNaming != null)
- && (DataService.getModelInfo(_this.componentId).serviceEcompNaming === "false")) || DataService.getE2EService() ) {
- isUserProvidedNaming = true;
- }
-
- var isInTop = DataService.getHideServiceFields() || false;
- if (_this.componentId === COMPONENT.SERVICE) {
- if ( DataService.getALaCarte() ) {
- parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
- if(!isInTop){
- parameterList = parameterList.concat([ getSubscribersParameter(),
- FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
- }
- }
- else {
- // macro
-
- if(!isInTop){
- if (isUserProvidedNaming) {
- parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
-
- }
- parameterList = parameterList.concat([ getSubscribersParameter() ]);
- parameterList = parameterList.concat([ getServiceId(),
- FIELD.PARAMETER.SERVICE_TYPE,
- FIELD.PARAMETER.LCP_REGION,
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED
- ]);
- if(!DataService.getE2EService()) {
- parameterList = parameterList.concat([getAicZonesParameter()]);
- }
-
- }else{
- parameterList = parameterList.concat([ getServiceId(),
- FIELD.PARAMETER.LCP_REGION,
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED ]);
- }
- }
-
- if(!DataService.getE2EService()) {
- parameterList = parameterList.concat([getProjectParameter()]);
- parameterList = parameterList.concat([getOwningEntityParameter()]);
- }
-
- //if service model has a pnf, add a PNF ID parameter
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PNP_INSTANTIATION) && DataService.getPnf()) {
- parameterList = parameterList.concat([ FIELD.PARAMETER.PNF_ID ]);
- }
- }
- else {
- parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
- switch (_this.componentId) {
- case COMPONENT.NETWORK:
- case COMPONENT.VNF:
- parameterList = parameterList.concat([ getServiceId(),
- getLcpRegionParameter(), FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED ]);
- parameterList = parameterList.concat([ getLineOfBusinessParameter() ]);
- parameterList = parameterList.concat([ getPlatformParameter() ]);
-
- break;
- case COMPONENT.VF_MODULE:
- parameterList = parameterList.concat([
- getLcpRegionParameter(),
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED
- ]);
-
- var availableVolumeGroupList = DataService.getAvailableVolumeGroupList();
-
- if (availableVolumeGroupList && availableVolumeGroupList.length > 0) {
- var availableVolumeGroupNames = [FIELD.STATUS.NONE];
-
- for (var i = 0; i < availableVolumeGroupList.length; i++) {
- availableVolumeGroupNames.push(availableVolumeGroupList[i].instance.name);
- }
-
- parameterList.push(addOptionList(
- FIELD.PARAMETER.AVAILABLE_VOLUME_GROUP,
- availableVolumeGroupNames));
- }
- break;
- case COMPONENT.VOLUME_GROUP:
- parameterList = parameterList.concat([ getLcpRegionParameter(),
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED ]);
- }
- }
- parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK);
- if(_this.componentId === COMPONENT.VF_MODULE ){
- parameterList.push({name: FIELD.NAME.SDN_C_PRELOAD,
- id: FIELD.ID.SDN_C_PRELOAD,
- type: "checkbox",
- isEnabled: true,
- isRequired: false,
- hideFieldAndLabel: true
- }
- );
- parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- type: "checkbox",
- isEnabled: true,
- isRequired: false,
- value:false
- }
- );
-
- parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.SUPPLEMENTORY_DATA_FILE,
- type: "file",
- isRequired: false,
- isVisiblity: false
- }
- );
- }
-
- if( VIDCONFIGURATION.UPLOAD_SUPPLEMENTARY_STATUS_CHECK_ENABLED && _this.componentId === COMPONENT.VOLUME_GROUP){
- parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- type: "checkbox",
- isEnabled: true,
- isRequired: false
- }
- );
-
- parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.SUPPLEMENTORY_DATA_FILE,
- type: "file",
- isRequired: false,
- isVisiblity: false
- }
- );
- }
-
- addArbitraryParameters(parameterList);
-
- return parameterList;
- };
-
- var addArbitraryParameters = function(parameterList) {
- if ( DataService.getModelInfo(_this.componentId).displayInputs != null ) {
- var inputs = DataService.getModelInfo(_this.componentId).displayInputs;
- for ( var key in inputs) {
- var parameter = {
- id : key,
- type : PARAMETER.STRING,
- name : ComponentService.getFieldDisplayName(key),
- value : inputs[key][PARAMETER.DEFAULT],
- isRequired : inputs[key][PARAMETER.REQUIRED],
- description : inputs[key][PARAMETER.DESCRIPTION]
- };
- if ( DataService.getALaCarte() ) {
- parameter.name = ComponentService.getFieldDisplayName(inputs[key][PARAMETER.DISPLAY_NAME]);
- }
- switch (inputs[key][PARAMETER.TYPE]) {
- case PARAMETER.INTEGER:
- parameter.type = PARAMETER.NUMBER;
- break;
- case PARAMETER.BOOLEAN:
- parameter.type = PARAMETER.BOOLEAN;
- break;
- case PARAMETER.RANGE:
- break;
- case PARAMETER.LIST:
- parameter.type = PARAMETER.LIST;
- break;
- case PARAMETER.MAP:
- parameter.type = PARAMETER.MAP;
- break;
- }
-
- if ( UtilityService.hasContents(inputs[key][PARAMETER.CONSTRAINTS])
- && ( inputs[key][PARAMETER.CONSTRAINTS].length > 0 ) ) {
- var constraintsArray = inputs[key][PARAMETER.CONSTRAINTS];
- //console.log ("Calling addConstraintParameters for input name=" + key);
- addConstraintParameters (parameterList, constraintsArray, key, inputs, parameter);
- }
- else {
-
- parameterList.push(parameter);
- }
- }
- DataService.setArbitraryParameters (parameterList);
- }
- };
-
- var addConstraintParameters = function(parameterList, constraintsArray, key, inputs, parameter) {
- // If there are constraints and the operator is "valid_values",
- // use a select parameter type.
- var i = constraintsArray.length;
- var parameterPushed = false;
- if ( i > 0 ) {
- while ( (i--) && (!parameterPushed) ) {
- var keys = Object.keys(constraintsArray[i]);
- //var keys_len = keys.length;
- for ( var operator in keys ) {
- //console.log ("keys[operator]=" + keys[operator]);
- switch (keys[operator]) {
- case PARAMETER.VALID_VALUES:
- var j = constraintsArray[i][PARAMETER.VALID_VALUES].length;
- if ( j > 0 ) {
- var oList = [];
- var option;
- while (j--) {
- 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 = {
- name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
- isDefault: true
- }
- }
- oList.push(option);
- }
- parameter.type = PARAMETER.SELECT;
- parameter.optionList = oList;
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for valid values");
- }
- break;
-
- case PARAMETER.EQUAL:
- if ( constraintsArray[i][PARAMETER.EQUAL] != null ) {
- //override parameter type
- parameter.type = PARAMETER.STRING;
- parameter.isReadOnly = true;
- parameter.value = constraintsArray[i][PARAMETER.EQUAL];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for equal");
- }
- break;
-
- case PARAMETER.LENGTH:
- if ( constraintsArray[i][PARAMETER.LENGTH] != null ) {
- parameter.minLength = constraintsArray[i][PARAMETER.LENGTH];
- parameter.maxLength = constraintsArray[i][PARAMETER.LENGTH];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for length: ");
- //console.log (JSON.stringify (parameter, null, 4));
- }
- break;
- case PARAMETER.MAX_LENGTH:
- if ( constraintsArray[i][PARAMETER.MAX_LENGTH] != null ) {
- parameter.maxLength = constraintsArray[i][PARAMETER.MAX_LENGTH];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for max length: ");
- //console.log (JSON.stringify (parameter, null, 4));
- }
- break;
- case PARAMETER.MIN_LENGTH:
- if ( constraintsArray[i][PARAMETER.MIN_LENGTH] != null ) {
- parameter.minLength = constraintsArray[i][PARAMETER.MIN_LENGTH];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for min length: ");
- //console.log (JSON.stringify (parameter, null, 4));
- }
- break;
- case PARAMETER.IN_RANGE:
- if ( constraintsArray[i][PARAMETER.IN_RANGE] != null ) {
- if (constraintsArray[i][PARAMETER.IN_RANGE].length > 1 ) {
- 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]
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for in_range");
- }
- }
- break;
- case PARAMETER.GREATER_THAN:
- if ( constraintsArray[i][PARAMETER.GREATER_THAN] != null ) {
- parameter.type = PARAMETER.NUMBER;
- parameter.min = constraintsArray[i][PARAMETER.GREATER_THAN];
- parameter.value = inputs[key][PARAMETER.DEFAULT]
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for greater_than");
-
- }
- break;
- }//switch
- }//for
-
- }//while
- }//if
- };
- var addToList = function(name, value) {
- _this.parameterList.push({
- name : name,
- value : value
- });
- };
- var setInventoryInfo = function(){
- var inventoryItem = DataService.getInventoryItem();
- var inventoryInfo = ComponentService.getInventoryInfo(
- _this.componentId, inventoryItem);
- }
-
- /*
- * The "*Mso*" functions return URL and request details that can be passed
- * to the MSO controller. The request details defines the info passed as
- * part of the POST body.
- */
-
- var getMsoUrl = function() {
- switch (_this.componentId) {
- case COMPONENT.NETWORK:
- return "mso_create_nw_instance/"
- + DataService.getServiceInstanceId();
- case COMPONENT.SERVICE:
- if(DataService.getE2EService() === true)
- return "mso_create_e2e_svc_instance";
- else
- return "mso_create_svc_instance";
- case COMPONENT.VNF:
- return "mso_create_vnf_instance/"
- + DataService.getServiceInstanceId();
- case COMPONENT.VF_MODULE:
- return "mso_create_vfmodule_instance/"
- + DataService.getServiceInstanceId() + "/vnfs/"
- + DataService.getVnfInstanceId();
- case COMPONENT.VOLUME_GROUP:
- return "mso_create_volumegroup_instance/"
- + DataService.getServiceInstanceId() + "/vnfs/"
- + DataService.getVnfInstanceId();
- }
- };
-
- var getMsoE2ERequest = function(parameterList) {
- var modelInfo = DataService.getModelInfo(_this.componentId);
-
- //region id
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- var cloudOwner = _.find(DataService.getCloudRegionTenantList(), function(region){
- return region.cloudRegionId === lcpRegion;
- }).cloudOwner;
-
- var params = [];
- var displayInputs = modelInfo.displayInputs;
- var groupBy = _.groupBy(displayInputs, "templateUUID");
-
- _.forEach(groupBy, function(nodeTemplateInputs, nodeTemplateUUID) {
- var reqParas = {};
- var vfLocations = [];
-
- nodeTemplateInputs.forEach(function(parameter){
- if(parameter.type === 'vf_location') {
- var loc = {
- vnfProfileId: parameter.displayName,
- locationConstraints : {
- vimId: cloudOwner + '_' + lcpRegion
- }
- };
- vfLocations.push(loc);
- } else if(parameter.type === 'sdn_controller') {
- if(parameter.value === undefined || parameter.value === null) {
- reqParas[parameter.name] = '';
- } else {
- reqParas[parameter.name] = parameter.value.value;
- }
- } else {
- var name;
- _.forEach(displayInputs, function(item, key){
- if(item === parameter) {
- name = key;
- }
- });
- var value = _.find(parameterList, function(item){
- return item.id === name;
- }).value;
- reqParas[parameter.displayName] = value;
- }
- });
-
- params.push({
- resourceName: nodeTemplateInputs[0].templateName,
- resourceInvariantUuid: nodeTemplateInputs[0].templateInvariantUUID,
- resourceUuid: nodeTemplateInputs[0].templateUUID,
- resourceCustomizationUuid: nodeTemplateInputs[0].templateCustomizationUUID,
- parameters: {
- locationConstraints: vfLocations,
- //TODO resources: [],
- requestInputs: reqParas
- }
- });
- });
-
- var requestBody = {
- service: {
- name: getValueFromList(FIELD.ID.INSTANCE_NAME, parameterList),
- description: modelInfo["description"],
- serviceInvariantUuid: modelInfo["modelInvariantId"],
- serviceUuid: modelInfo["modelNameVersionId"],
- globalSubscriberId: DataService.getGlobalCustomerId(),
- serviceType: getValueFromList(FIELD.ID.SERVICE_TYPE, parameterList) || modelInfo["serviceTypeName"],
- parameters: {
- locationConstraints: [],
- resources: params,
- requestInputs: {} //TODO
- }
- }
- };
-
- return requestBody;
- };
-
- 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) {
- return getMsoE2ERequest(parameterList);
- }
-
- var modelInfo = DataService.getModelInfo(_this.componentId);
- var requestorloggedInId = DataService.getLoggedInUserId();
- var owningEntityId = getValueFromList(FIELD.ID.OWNING_ENTITY, parameterList);
- if (requestorloggedInId == null)
- requestorloggedInId = "";
- var isSupRollback = false;
- if (getValueFromList(FIELD.ID.SUPPRESS_ROLLBACK,parameterList) === "true") {
- isSupRollback = true;
- }
- var requestDetails = {
- requestInfo : {
- instanceName : getValueFromList(FIELD.ID.INSTANCE_NAME,
- parameterList) || DataService.getVfModuleInstanceName(),
- source : FIELD.ID.VID,
- suppressRollback : isSupRollback,
- requestorId: requestorloggedInId
- },
- modelInfo : {
- modelType : _this.componentId,
- modelInvariantId : modelInfo.modelInvariantId,
- modelVersionId : modelInfo.modelNameVersionId,
- modelName : modelInfo.modelName,
- modelVersion : modelInfo.modelVersion,
- modelCustomizationId: modelInfo.customizationUuid,
- modelCustomizationName : modelInfo.modelCustomizationName
- },
- requestParameters : {
- userParams : getArbitraryParameters(parameterList)
- }
- };
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) {
- if ((_this.componentId != COMPONENT.SERVICE) || ( DataService.getALaCarte() )) {
- requestDetails.requestParameters.testApi = DataService.getMsoRequestParametersTestApi();
- }
- }
- if ( (_this.componentId != COMPONENT.SERVICE) || ( !DataService.getALaCarte() ) ) {
- // include cloud region for everything but service create alacarte
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- requestDetails.cloudConfiguration = {
- lcpCloudRegionId : lcpRegion,
- tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
- };
- }
- switch (_this.componentId) {
-
- case COMPONENT.SERVICE:
- requestDetails.subscriberInfo = {
- globalSubscriberId : DataService.getGlobalCustomerId(),
- subscriberName : DataService.getSubscriberName()
- };
- var isInTop = DataService.getHideServiceFields() || false;
- if(isInTop){
- requestDetails.requestParameters.subscriptionServiceType = DataService.getModelInfo(_this.componentId)["serviceTypeName"];
- }else{
- requestDetails.requestParameters.subscriptionServiceType = getValueFromList(
- FIELD.ID.SERVICE_TYPE, parameterList);
- }
- requestDetails.requestParameters.aLaCarte = DataService.getALaCarte();
- if ( !DataService.getALaCarte() ) {
- requestDetails.requestInfo.productFamilyId = getValueFromList(
- FIELD.ID.PRODUCT_FAMILY, parameterList);
- }
- var svcModelInfo = {
- modelType : _this.componentId,
- modelInvariantId : modelInfo.modelInvariantId,
- modelVersionId : modelInfo.modelNameVersionId,
- modelName : modelInfo.modelName,
- modelVersion : modelInfo.modelVersion
- };
- requestDetails.modelInfo = svcModelInfo;
-
- var selectedProject = getValueFromList(FIELD.ID.PROJECT, parameterList);
-
- if (selectedProject) {
- requestDetails.project = {
- projectName: getValueFromList(FIELD.ID.PROJECT, parameterList)
- };
- }
-
- requestDetails.owningEntity = {
- owningEntityId: owningEntityId,
- owningEntityName: getOwningEntityNameById(owningEntityId)
- };
-
- break;
- case COMPONENT.VNF:
-
- requestDetails.requestInfo.productFamilyId = getValueFromList(
- FIELD.ID.PRODUCT_FAMILY, parameterList);
-
- var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList);
-
- if(lineOfBusiness) {
- var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", ");
-
- requestDetails.lineOfBusiness = {
- lineOfBusinessName: lineOfBusinessNamesString
- }
- }
-
- requestDetails.platform = {
- platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList)
- };
-
- break;
- case COMPONENT.NETWORK:
- requestDetails.requestInfo.productFamilyId = getValueFromList(
- FIELD.ID.PRODUCT_FAMILY, parameterList);
- var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList);
-
- if(lineOfBusiness) {
- var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", ");
-
- requestDetails.lineOfBusiness = {
- lineOfBusinessName: lineOfBusinessNamesString
- }
- }
-
- requestDetails.platform = {
- platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList)
- };
- break;
- case COMPONENT.VF_MODULE:
- requestDetails.requestParameters.usePreload = getValueFromList(
- FIELD.ID.SDN_C_PRELOAD, parameterList);
- if(_this.componentId == COMPONENT.VF_MODULE &&(requestDetails.requestParameters.usePreload== null || requestDetails.requestParameters.usePreload === '')){
- requestDetails.requestParameters.usePreload = false;
- }
- break;
- case COMPONENT.VOLUME_GROUP:
- break;
- }
-
- var relatedInstanceList = getRelatedInstanceList(parameterList);
-
- if (relatedInstanceList !== undefined) {
- requestDetails.relatedInstanceList = relatedInstanceList;
- }
-
- return requestDetails;
- };
-
- var getRelatedInstanceList = function(parameterList) {
- var relatedInstanceList = new Array();
- switch (_this.componentId) {
- case COMPONENT.SERVICE:
- return undefined;
- case COMPONENT.NETWORK:
- case COMPONENT.VNF:
- addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
- DataService.getServiceInstanceId());
- break;
- case COMPONENT.VF_MODULE:
- addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
- DataService.getServiceInstanceId());
- addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
- .getVnfInstanceId());
-
- var availableVolumeGroup = getValueFromList(
- FIELD.ID.AVAILABLE_VOLUME_GROUP, parameterList);
-
- if (UtilityService.hasContents(availableVolumeGroup) && availableVolumeGroup !== "None") {
- var availableVolumeGroups = DataService.getAvailableVolumeGroupList();
-
- for (var i = 0; i < availableVolumeGroups.length; i++) {
- if (availableVolumeGroups[i].instance.name == availableVolumeGroup) {
- DataService.setModelInfo(COMPONENT.VOLUME_GROUP, DataService.getModelInfo(COMPONENT.VF_MODULE));
- DataService.setVolumeGroupInstanceId(availableVolumeGroups[i].instance.object["volume-group-id"]);
- break;
- }
- }
-
- addRelatedInstance(relatedInstanceList, COMPONENT.VOLUME_GROUP,
- DataService.getVolumeGroupInstanceId());
- }
- break;
- case COMPONENT.VOLUME_GROUP:
- addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
- DataService.getServiceInstanceId());
- addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
- .getVnfInstanceId());
- break;
- }
-
- return relatedInstanceList;
- };
-
- var addRelatedInstance = function(relatedInstanceList, componentId,
- instanceId) {
- var modelInfo = DataService.getModelInfo(componentId);
- var relatedInstance;
- if (modelInfo !== undefined) {
- if (componentId === COMPONENT.SERVICE) {
- relatedInstance = {
- "instanceId" : instanceId,
- "modelInfo" : {
- "modelType" : componentId,
- "modelName" : modelInfo.modelName,
- "modelInvariantId" : modelInfo.modelInvariantId,
- "modelVersion" : modelInfo.modelVersion,
- "modelVersionId" : modelInfo.modelNameVersionId,
-
- }
- };
- }
- else {
- relatedInstance = {
- "instanceId" : instanceId,
- "modelInfo" : {
- "modelType" : componentId,
- "modelName" : modelInfo.modelName,
- "modelInvariantId" : modelInfo.modelInvariantId,
- "modelVersion" : modelInfo.modelVersion,
- "modelVersionId" : modelInfo.modelNameVersionId,
- "modelCustomizationId": modelInfo.customizationUuid,
- "modelCustomizationName": modelInfo.modelCustomizationName
- }
- }
- }
- relatedInstanceList.push({
- relatedInstance : relatedInstance
- });
- }
- };
-
- /*
- * var getArbitraryParameters = function(parameterList) { var
- * arbitraryParameters = new Object(); for (var i = 0; i <
- * parameterList.length; i++) { var parameter = parameterList[i]; switch
- * (parameter.id) { case FIELD.ID.INSTANCE_NAME: case
- * FIELD.ID.PRODUCT_FAMILY: case FIELD.ID.LCP_REGION: case
- * FIELD.ID.LCP_REGION_TEXT: case FIELD.ID.SERVICE_TYPE: case
- * FIELD.ID.TENANT: case FIELD.ID.SUPPRESS_ROLLBACK: break; default:
- * arbitraryParameters[parameter.id] = parameter.value; } } return
- * arbitraryParameters; }
- */
- var getArbitraryParameters = function(parameterList) {
- var arbitraryParameters = new Object();
- var arbitraryArray = new Array();
- for (var i = 0; i < parameterList.length; i++) {
- var parameter = parameterList[i];
- switch (parameter.id) {
- case FIELD.ID.AVAILABLE_VOLUME_GROUP:
- case FIELD.ID.INSTANCE_NAME:
- case FIELD.ID.PRODUCT_FAMILY:
- case FIELD.ID.LCP_REGION:
- case FIELD.ID.LCP_REGION_TEXT:
- case FIELD.ID.SERVICE_TYPE:
- case FIELD.ID.TENANT:
- case FIELD.ID.SUPPRESS_ROLLBACK:
- case FIELD.ID.SUBSCRIBER_NAME:
- case FIELD.ID.SDN_C_PRELOAD:
- case FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE:
- case FIELD.ID.OWNING_ENTITY:
- case FIELD.ID.PLATFORM:
- case FIELD.ID.LINE_OF_BUSINESS:
- case FIELD.ID.PROJECT:
- break;
- case FIELD.ID.SUPPLEMENTORY_DATA_FILE:
- arbitraryParameters = FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'];
- arbitraryArray=arbitraryParameters;
- FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value']=[];
- break;
-
- default:
- if (parameter.value != '') {
- arbitraryParameters = {
- name: parameter.id,
- value: parameter.value
- }
- arbitraryArray.push(arbitraryParameters);
- }
- }
- }
- return (arbitraryArray);
- }
-
- var getModel = function() {
- AsdcService.getModel(DataService.getModelId(), function(response) {
- DataService.setModelInfo(_this.componentId, {
- modelInvariantId : response.data.invariantUUID,
- modelNameVersionId : response.data.uuid,
- modelName : response.data.name,
- modelVersion : response.data.version,
- inputs : response.data.inputs
- });
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getSubscriptionServiceTypeList = function() {
- AaiService.getSubscriptionServiceTypeList(DataService
- .getGlobalCustomerId(), function(response) {
- DataService.setSubscriptionServiceTypeList(response);
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getLoggedInUserID = function() {
- AaiService.getLoggedInUserID(function(response) {
- DataService.setLoggedInUserId(response.data);
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getSubscribers = function() {
- AaiService.getSubscribers(function(response) {
- DataService.setSubscribers(response);
- UtilityService.startNextAsyncOperation();
- });
- };
- var getServices = function() {
- AaiService.getServices(function(response) {
- var serviceIdList = [];
- 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);
- });
- });
-
- UtilityService.startNextAsyncOperation();
- });
- };
- var getAicZones = function() {
- AaiService.getAicZones(function(response) {
- var serviceIdList = [];
- angular.forEach(response.data, function(value, key) {
- angular.forEach(value, function(subVal, key) {
- var newVal = {
- "id" : subVal[FIELD.ID.ZONE_ID],
- "name" : subVal[FIELD.ID.ZONE_NAME],
- };
- serviceIdList.push(newVal);
- DataService.setAicZones(serviceIdList);
- });
- });
-
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getOwningEntityProperties = function() {
- OwningEntityService.getOwningEntityProperties(function(owningEntityProperties) {
- DataService.setOwningEntityProperties(owningEntityProperties);
- UtilityService.startNextAsyncOperation();
- });
-
- };
-
- var getLcpCloudRegionTenantList = function() {
- AaiService.getLcpCloudRegionTenantList(DataService
- .getGlobalCustomerId(), DataService.getServiceType(), function(
- response) {
- DataService.setCloudRegionTenantList(response);
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var internalGetParametersHandler = function() {
- if (angular.isFunction(_this.getParametersHandler)) {
- _this.getParametersHandler({
- summaryList : getSummaryList(),
- userProvidedList : getUserProvidedList()
- });
- }
- };
-
- var getSubscribersParameter = function() {
- var subscribers = DataService.getSubscribers();
- var parameter = FIELD.PARAMETER.SUBSCRIBER_NAME;
- if ( UtilityService.hasContents(subscribers)) {
- parameter.optionList = [];
-
- for (var i = 0; i < subscribers.length; i++) {
- parameter.optionList.push({
- id : subscribers[i][FIELD.ID.GLOBAL_CUSTOMER_ID],
- name : subscribers[i][FIELD.ID.SUBNAME],
- isPermitted : subscribers[i][FIELD.ID.IS_PERMITTED]
- })
- }
- }
- return parameter;
- };
-
- var getServiceId = function() {
- var serviceIdList = DataService.getServiceIdList();
- //var serviceTypeList = DataService.getSubscriptionServiceTypeList();
- var parameter = FIELD.PARAMETER.PRODUCT_FAMILY;
- parameter.optionList = new Array();
- if ( UtilityService.hasContents(serviceIdList) ) {
- // load them all
- for (var i = 0; i < serviceIdList.length; i++) {
- parameter.optionList.push({
- id : serviceIdList[i].id,
- name : serviceIdList[i].description,
- isPermitted : serviceIdList[i].isPermitted
- });
- }
- }
-
- return parameter;
- };
-
- var getAicZonesParameter = function() {
- var aicList = DataService.getAicZones();
- var parameter = FIELD.PARAMETER.AIC_ZONES;
- parameter.optionList = new Array();
- if ( UtilityService.hasContents(aicList) ) {
- // load them all
- for (var i = 0; i < aicList.length; i++) {
- parameter.optionList.push({
- id : aicList[i].id,
- name : aicList[i].name,
- isPermitted : true
-
- });
- }
- }
-
- return parameter;
- };
-
- var getProjectParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PROJECT);
- };
-
- var getOwningEntityParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.OWNING_ENTITY);
- };
-
- var getLineOfBusinessParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.LINE_OF_BUSINESS);
- };
-
- var getPlatformParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PLATFORM);
- };
-
- var getOwningEntityNameById = function (id) {
- var properties = DataService.getOwningEntityProperties();
- var parameter = _.find(properties[FIELD.ID.OWNING_ENTITY], {"id": id});
- return parameter && parameter.name;
- };
-
- var getOwningEntityParameterWithOptions = function(parameter) {
- var properties = DataService.getOwningEntityProperties();
- if (properties && properties[parameter.id]) {
- parameter.optionList = _.map(properties[parameter.id], function(parameter) {
- return {
- "id" : parameter.id,
- "name" : parameter.name,
- "isPermitted": true
- };
- });
- }
-
- return parameter;
- };
-
- var getLcpRegionParameter = function() {
- var cloudRegionTenantList = DataService.getCloudRegionTenantList();
- console.log ( "cloudRegionTenantList=");
- console.log ( JSON.stringify (cloudRegionTenantList, null, 4 ));
-
- var parameter = FIELD.PARAMETER.LCP_REGION;
- if ( UtilityService.hasContents (cloudRegionTenantList) ) {
- parameter.optionList = new Array();
- for (var i = 0; i < cloudRegionTenantList.length; i++) {
- for (var j = 0; j < parameter.optionList.length; j++) {
- if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) {
- parameter.optionList[j].isPermitted =
- parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted;
- break;
- }
- }
- if (j < parameter.optionList.length) {
- continue;
- }
-
- var optionName = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) && cloudRegionTenantList[i].cloudOwner ?
- cloudRegionTenantList[i].cloudRegionId + " (" + cloudRegionTenantList[i].cloudOwner.trim().toLowerCase().replace(/^att-/, "").toUpperCase() + ")" :
- cloudRegionTenantList[i].cloudRegionId;
-
- parameter.optionList.push({
- id : cloudRegionTenantList[i].cloudRegionId,
- name: optionName,
- isPermitted : cloudRegionTenantList[i].isPermitted
- });
- }
- }
- return parameter;
- };
-
- var getTenantList = function(cloudRegionId) {
- var cloudRegionTenantList = DataService.getCloudRegionTenantList();
- var parameter = "";
- if ( UtilityService.hasContents (cloudRegionTenantList) ) {
- parameter = FIELD.PARAMETER.TENANT_ENABLED;
- parameter.optionList = new Array();
- for (var i = 0; i < cloudRegionTenantList.length; i++) {
- if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) {
- parameter.optionList.push({
- id : cloudRegionTenantList[i].tenantId,
- name : cloudRegionTenantList[i].tenantName,
- isPermitted : cloudRegionTenantList[i].isPermitted
-
- });
- }
- }
- }
- return parameter;
-
- };
-
- var addOptionList = function(parameter, optionSimpleArray) {
- var optionList = new Array();
- if (!angular.isArray(optionSimpleArray)) {
- return optionList;
- }
- for (var i = 0; i < optionSimpleArray.length; i++) {
- optionList.push({
- name : optionSimpleArray[i],
- isPermitted :true,
- });
- }
- parameter.optionList = optionList;
- return parameter;
- };
-
- var getValueFromList = function(id, parameterList) {
- for (var i = 0; i < parameterList.length; i++) {
- if (parameterList[i].id === id) {
- return parameterList[i].value;
- }
- }
- };
- var updateUserParameterList = function(updatedId, parameterListControl) {
- console.log ("updateUserParameterList() updatedId=" + updatedId);
- if (updatedId === FIELD.ID.PRODUCT_FAMILY && DataService.getHideServiceFields()) {
- var cloudRegionTenantList = new Array();
- AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) {
- DataService.setCloudRegionTenantList(cloudRegionTenantList);
- parameterListControl.updateList([ getLcpRegionParameter() ]);
- });
- }else if (updatedId === FIELD.ID.SDN_C_PRELOAD) {
- var list = parameterListControl.getList(updatedId);
- if($('input[parameter-id="'+updatedId+'"]').is(':checked')){
- FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED.value=true;
- parameterListControl
- .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED ]);
- }else{
- parameterListControl
- .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_UNCHECKED ]);
- }
- }else if (updatedId === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE) {
- if($('input[parameter-id="'+updatedId+'"]').is(':checked')){
- $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').show();
- FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=true;
- parameterListControl
- .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED ]);
- }else{
- $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').hide();
- FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=false;
- parameterListControl
- .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_UNCHECKED ]);
- }
- } else if (updatedId === FIELD.ID.SUPPLEMENTORY_DATA_FILE) {
- var filePath = $('input[parameter-id="'+updatedId+'"]').val();
- var arr =filePath.split('.');
- var fileExt = arr[arr.length-1];
- if(fileExt!='' && fileExt.toLowerCase()!='json'){
- $('input[parameter-id="'+updatedId+'"]').val('');
- alert("Invalid file format. Please select *.json format file.");
- return false;
- }
- } else if (updatedId === FIELD.ID.LCP_REGION) {
- var list = parameterListControl.getList(updatedId);
- if (list[0].selectedIndex >= 0) {
- parameterListControl
- .updateList([ getTenantList(list[0].value) ]);
- } else {
- parameterListControl
- .updateList([ FIELD.PARAMETER.TENANT_DISABLED ]);
- }
- if (list[0].value === FIELD.KEY.LCP_REGION_TEXT) {
- parameterListControl
- .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_VISIBLE ]);
- } else {
- parameterListControl
- .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN ]);
- }
- } else if (updatedId === FIELD.ID.SUBSCRIBER_NAME) {
- var list = parameterListControl.getList(updatedId);
- if (list[0].selectedIndex >= 0) {
- DataService.setGlobalCustomerId(list[0].value);
-
- AaiService.getSubscriptionServiceTypeList(DataService
- .getGlobalCustomerId(), function(response) {
- DataService.setSubscriptionServiceTypeList(response);
- var serviceTypeParameters = FIELD.PARAMETER.SERVICE_TYPE;
- serviceTypeParameters.optionList = [];
-
- for (var i = 0; i < response.length; i++) {
- serviceTypeParameters.optionList.push({
- "id" : response[i].name,
- "name" : response[i].name,
- "isPermitted" :response[i].isPermitted
-
- });
- }
- console.log ( "updateUserParameterList: service type parameters " );
- console.log ( JSON.stringify (serviceTypeParameters, null, 4));
- parameterListControl.updateList([ serviceTypeParameters ]);
- });
-
- }
- } else if ( updatedId === FIELD.ID.SERVICE_TYPE ) {
- var list = parameterListControl.getList(updatedId);
- if (list[0].selectedIndex >= 0) {
-
- DataService.setServiceType(list[0].value);
- var cloudRegionTenantList = new Array();
- AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) {
- DataService.setCloudRegionTenantList(cloudRegionTenantList);
- parameterListControl.updateList([ getLcpRegionParameter() ]);
- });
- } else {
- parameterListControl
- .updateList([ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
- }
- }
-
- };
-
- return {
- initializeComponent : function(componentId) {
- _this.componentId = ComponentService.initialize(componentId);
- },
- setHttpErrorHandler : function(httpErrorHandler) {
- _this.httpErrorHandler = httpErrorHandler;
- },
- getComponentDisplayName : ComponentService.getComponentDisplayName,
- getParameters : function(getParametersHandler) {
- _this.getParametersHandler = getParametersHandler;
- UtilityService.setHttpErrorHandler(_this.httpErrorHandler);
- UtilityService.startAsyncOperations(getAsyncOperationList(),
- internalGetParametersHandler);
- },
- updateUserParameterList : updateUserParameterList,
- getMsoRequestDetails : getMsoRequestDetails,
- getMsoUrl : getMsoUrl,
- setInventoryInfo: setInventoryInfo
- }
-}
-
-appDS2.factory("CreationService", [ "$log", "AaiService", "AsdcService",
- "DataService","VIDCONFIGURATION", "ComponentService", "COMPONENT", "FIELD", "PARAMETER",
- "UtilityService", "OwningEntityService","featureFlags", CreationService ]);
+/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T 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========================================================= + */ + +"use strict"; + +/* + * "CreationService" isolates the "component-specific" logic required by the + * "CreationDialog" controller. + * + * "Components" are defined as the 5 element types managed by the dialogs: A) + * Service B) VNF C) VF Module D) Volume Group and E) Network. + * + */ + +var CreationService = function($log, AaiService, AsdcService, DataService,VIDCONFIGURATION, + ComponentService, COMPONENT, FIELD, PARAMETER, UtilityService, OwningEntityService,featureFlags) { + + var _this = this; + var getAsyncOperationList = function() { + if (DataService.getLoggedInUserId() == null) { + getLoggedInUserID(); + } else { + UtilityService.startNextAsyncOperation(); + } + switch (_this.componentId) { + case COMPONENT.SERVICE: + return [ getSubscribers, getServices, getAicZones, getOwningEntityProperties ]; + case COMPONENT.NETWORK: + return [ getLcpCloudRegionTenantList, getOwningEntityProperties ]; + case COMPONENT.VNF: + return [ getLcpCloudRegionTenantList, getOwningEntityProperties ]; + case COMPONENT.VF_MODULE: + return [ getLcpCloudRegionTenantList ]; + case COMPONENT.VOLUME_GROUP: + return [ getLcpCloudRegionTenantList ]; + } + }; + + /* + * "getSummaryList" and "getUserProvidedList" return parameters that should + * be displayed in the summary and user provided sections, respectively. The + * functions are expected to return lists that are in the format needed by + * the parameter-block directive. + */ + + var getSummaryList = function() { + + /* + * These placeholders should be removed and their usage in + * "getSummaryList" should be replaced by appropriate code as the + * requirements and interfaces firm up. + */ + + var PLACEHOLDER_RESOURCE_DESCRIPTION = "Resource Description (PLACEHOLDER)"; + var PLACEHOLDER_SERVICE_CATEGORY = "Service Category (PLACEHOLDER)"; + var PLACEHOLDER_VF_MODULE_DESCRIPTION = "VF Module Description (PLACEHOLDER)"; + var PLACEHOLDER_VF_MODULE_LABEL = "VF Module Label (PLACEHOLDER)"; + var PLACEHOLDER_VF_MODULE_TYPE = "VF Module Type (PLACEHOLDER)"; + + _this.parameterList = new Array(); + + /* + * Common fields displayed at the top of all create instance screens. + */ + if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]==null + || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==undefined + || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==''){ + addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName()); + } + + switch (_this.componentId) { + case COMPONENT.SERVICE: + if ( !DataService.getALaCarte() ) { + // for macro instantiation need to add the resource names under the node template list + // this field is called modelCustomizationName in the asdc client code + var p; + var rlist = DataService.getResources(); + var res; + if ( rlist != null ) { + for (var i = 0; i < rlist.length; i++) { + res = rlist[i]; + + p = FIELD.NAME.RESOURCE_NAME.concat(" " + (i+1)); + addToList(p, res.name ); + p = FIELD.NAME.RESOURCE_DESCRIPTION.concat(" " + (i+1)); + addToList(p, res.description ); + } + } + } + if(DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=null && DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=''){ + addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService + .getModelInfo(_this.componentId)["createSubscriberName"]); + } + if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=null && DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=''){ + addToList(FIELD.NAME.SERVICE_TYPE, DataService + .getModelInfo(_this.componentId)["serviceTypeName"]); + addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName()); + } + addToList(FIELD.NAME.SERVICE_INVARIANT_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]); + addToList(FIELD.NAME.SERVICE_VERSION, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]); + addToList(FIELD.NAME.SERVICE_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]); + addToList(FIELD.NAME.SERVICE_DESCRIPTION, DataService + .getModelInfo(_this.componentId)[FIELD.ID.DESCRIPTION]); + addToList(FIELD.NAME.SERVICE_CATEGORY, DataService + .getModelInfo(_this.componentId)[FIELD.ID.CATEGORY]); + if (DataService.getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE] != "null") { + addToList(FIELD.NAME.SERVICE_TYPE, DataService + .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE]); + addToList(FIELD.NAME.SERVICE_ROLE, DataService + .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_ROLE]); + } + + break; + case COMPONENT.VF_MODULE: + addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService + .getSubscriberName()); + addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService + .getServiceInstanceName()); + addToList(FIELD.NAME.MODEL_NAME, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]); + addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]); + addToList(FIELD.NAME.MODEL_VERSION, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]); + addToList(FIELD.NAME.MODEL_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]); + addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]); + break; + case COMPONENT.VNF: + addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService + .getSubscriberName()); + addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService + .getServiceInstanceName()); + addToList(FIELD.NAME.MODEL_NAME, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]); + addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]); + addToList(FIELD.NAME.MODEL_VERSION, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]); + addToList(FIELD.NAME.MODEL_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]); + addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]); + addToList(FIELD.NAME.MODEL_CUSTOMIZATION_NAME, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_CUSTOMIZATION_NAME]); + addToList(FIELD.NAME.MODEL_VNF_TYPE, DataService + .getModelInfo(_this.componentId)[COMPONENT.VNF_TYPE]); + addToList(FIELD.NAME.MODEL_VNF_ROLE, DataService + .getModelInfo(_this.componentId)[COMPONENT.VNF_ROLE]); + addToList(FIELD.NAME.MODEL_VNF_FUNCTION, DataService + .getModelInfo(_this.componentId)[COMPONENT.VNF_FUNCTION]); + addToList(FIELD.NAME.MODEL_VNF_CODE, DataService + .getModelInfo(_this.componentId)[COMPONENT.VNF_CODE]); + break; + case COMPONENT.NETWORK: + case COMPONENT.VOLUME_GROUP: + addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService + .getSubscriberName()); + addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService + .getServiceInstanceName()); + addToList(FIELD.NAME.MODEL_NAME, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]); + addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]); + addToList(FIELD.NAME.MODEL_VERSION, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]); + addToList(FIELD.NAME.MODEL_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]); + addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService + .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]); + break; + } + + return _this.parameterList; + }; + + var getUserProvidedList = function() { + var parameterList = []; + var isUserProvidedNaming = false; + if ( ((DataService.getModelInfo(_this.componentId).serviceEcompNaming != null) + && (DataService.getModelInfo(_this.componentId).serviceEcompNaming === "false")) || DataService.getE2EService() ) { + isUserProvidedNaming = true; + } + + var isInTop = DataService.getHideServiceFields() || false; + if (_this.componentId === COMPONENT.SERVICE) { + if ( DataService.getALaCarte() ) { + parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ]; + if(!isInTop){ + parameterList = parameterList.concat([ getSubscribersParameter(), + FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]); + } + } + else { + // macro + + if(!isInTop){ + if (isUserProvidedNaming) { + parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ]; + + } + parameterList = parameterList.concat([ getSubscribersParameter() ]); + parameterList = parameterList.concat([ getServiceId(), + FIELD.PARAMETER.SERVICE_TYPE, + FIELD.PARAMETER.LCP_REGION, + FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN, + FIELD.PARAMETER.TENANT_DISABLED + ]); + if(!DataService.getE2EService()) { + parameterList = parameterList.concat([getAicZonesParameter()]); + } + + }else{ + parameterList = parameterList.concat([ getServiceId(), + FIELD.PARAMETER.LCP_REGION, + FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN, + FIELD.PARAMETER.TENANT_DISABLED ]); + } + } + + if(!DataService.getE2EService()) { + parameterList = parameterList.concat([getProjectParameter()]); + parameterList = parameterList.concat([getOwningEntityParameter()]); + } + + //if service model has a pnf, add a PNF ID parameter + if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PNP_INSTANTIATION) && DataService.getPnf()) { + parameterList = parameterList.concat([ FIELD.PARAMETER.PNF_ID ]); + } + } + else { + parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ]; + switch (_this.componentId) { + case COMPONENT.NETWORK: + case COMPONENT.VNF: + parameterList = parameterList.concat([ getServiceId(), + getLcpRegionParameter(), FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN, + FIELD.PARAMETER.TENANT_DISABLED ]); + parameterList = parameterList.concat([ getLineOfBusinessParameter() ]); + parameterList = parameterList.concat([ getPlatformParameter() ]); + + break; + case COMPONENT.VF_MODULE: + parameterList = parameterList.concat([ + getLcpRegionParameter(), + FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN, + FIELD.PARAMETER.TENANT_DISABLED + ]); + + var availableVolumeGroupList = DataService.getAvailableVolumeGroupList(); + + if (availableVolumeGroupList && availableVolumeGroupList.length > 0) { + var availableVolumeGroupNames = [FIELD.STATUS.NONE]; + + for (var i = 0; i < availableVolumeGroupList.length; i++) { + availableVolumeGroupNames.push(availableVolumeGroupList[i].instance.name); + } + + parameterList.push(addOptionList( + FIELD.PARAMETER.AVAILABLE_VOLUME_GROUP, + availableVolumeGroupNames)); + } + break; + case COMPONENT.VOLUME_GROUP: + parameterList = parameterList.concat([ getLcpRegionParameter(), + FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN, + FIELD.PARAMETER.TENANT_DISABLED ]); + } + } + parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK); + if(_this.componentId === COMPONENT.VF_MODULE ){ + parameterList.push({name: FIELD.NAME.SDN_C_PRELOAD, + id: FIELD.ID.SDN_C_PRELOAD, + type: "checkbox", + isEnabled: true, + isRequired: false, + hideFieldAndLabel: true + } + ); + parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, + type: "checkbox", + isEnabled: true, + isRequired: false, + value:false + } + ); + + parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.SUPPLEMENTORY_DATA_FILE, + type: "file", + isRequired: false, + isVisiblity: false + } + ); + } + + if( VIDCONFIGURATION.UPLOAD_SUPPLEMENTARY_STATUS_CHECK_ENABLED && _this.componentId === COMPONENT.VOLUME_GROUP){ + parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, + type: "checkbox", + isEnabled: true, + isRequired: false + } + ); + + parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE, + id: FIELD.ID.SUPPLEMENTORY_DATA_FILE, + type: "file", + isRequired: false, + isVisiblity: false + } + ); + } + + addArbitraryParameters(parameterList); + + return parameterList; + }; + + var addArbitraryParameters = function(parameterList) { + if ( DataService.getModelInfo(_this.componentId).displayInputs != null ) { + var inputs = DataService.getModelInfo(_this.componentId).displayInputs; + for ( var key in inputs) { + var parameter = { + id : key, + type : PARAMETER.STRING, + name : ComponentService.getFieldDisplayName(key), + value : inputs[key][PARAMETER.DEFAULT], + isRequired : inputs[key][PARAMETER.REQUIRED], + description : inputs[key][PARAMETER.DESCRIPTION] + }; + if ( DataService.getALaCarte() ) { + parameter.name = ComponentService.getFieldDisplayName(inputs[key][PARAMETER.DISPLAY_NAME]); + } + switch (inputs[key][PARAMETER.TYPE]) { + case PARAMETER.INTEGER: + parameter.type = PARAMETER.NUMBER; + break; + case PARAMETER.BOOLEAN: + parameter.type = PARAMETER.BOOLEAN; + break; + case PARAMETER.RANGE: + break; + case PARAMETER.LIST: + parameter.type = PARAMETER.LIST; + break; + case PARAMETER.MAP: + parameter.type = PARAMETER.MAP; + break; + } + + if ( UtilityService.hasContents(inputs[key][PARAMETER.CONSTRAINTS]) + && ( inputs[key][PARAMETER.CONSTRAINTS].length > 0 ) ) { + var constraintsArray = inputs[key][PARAMETER.CONSTRAINTS]; + //console.log ("Calling addConstraintParameters for input name=" + key); + addConstraintParameters (parameterList, constraintsArray, key, inputs, parameter); + } + else { + + parameterList.push(parameter); + } + } + DataService.setArbitraryParameters (parameterList); + } + }; + + var addConstraintParameters = function(parameterList, constraintsArray, key, inputs, parameter) { + // If there are constraints and the operator is "valid_values", + // use a select parameter type. + var i = constraintsArray.length; + var parameterPushed = false; + if ( i > 0 ) { + while ( (i--) && (!parameterPushed) ) { + var keys = Object.keys(constraintsArray[i]); + //var keys_len = keys.length; + for ( var operator in keys ) { + //console.log ("keys[operator]=" + keys[operator]); + switch (keys[operator]) { + case PARAMETER.VALID_VALUES: + var j = constraintsArray[i][PARAMETER.VALID_VALUES].length; + if ( j > 0 ) { + var oList = []; + var option; + while (j--) { + 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 = { + name: constraintsArray[i][PARAMETER.VALID_VALUES][j], + isDefault: true + } + } + oList.push(option); + } + parameter.type = PARAMETER.SELECT; + parameter.optionList = oList; + parameterList.push(parameter); + parameterPushed = true; + //console.log ("pushed param for valid values"); + } + break; + + case PARAMETER.EQUAL: + if ( constraintsArray[i][PARAMETER.EQUAL] != null ) { + //override parameter type + parameter.type = PARAMETER.STRING; + parameter.isReadOnly = true; + parameter.value = constraintsArray[i][PARAMETER.EQUAL]; + parameterList.push(parameter); + parameterPushed = true; + //console.log ("pushed param for equal"); + } + break; + + case PARAMETER.LENGTH: + if ( constraintsArray[i][PARAMETER.LENGTH] != null ) { + parameter.minLength = constraintsArray[i][PARAMETER.LENGTH]; + parameter.maxLength = constraintsArray[i][PARAMETER.LENGTH]; + parameterList.push(parameter); + parameterPushed = true; + //console.log ("pushed param for length: "); + //console.log (JSON.stringify (parameter, null, 4)); + } + break; + case PARAMETER.MAX_LENGTH: + if ( constraintsArray[i][PARAMETER.MAX_LENGTH] != null ) { + parameter.maxLength = constraintsArray[i][PARAMETER.MAX_LENGTH]; + parameterList.push(parameter); + parameterPushed = true; + //console.log ("pushed param for max length: "); + //console.log (JSON.stringify (parameter, null, 4)); + } + break; + case PARAMETER.MIN_LENGTH: + if ( constraintsArray[i][PARAMETER.MIN_LENGTH] != null ) { + parameter.minLength = constraintsArray[i][PARAMETER.MIN_LENGTH]; + parameterList.push(parameter); + parameterPushed = true; + //console.log ("pushed param for min length: "); + //console.log (JSON.stringify (parameter, null, 4)); + } + break; + case PARAMETER.IN_RANGE: + if ( constraintsArray[i][PARAMETER.IN_RANGE] != null ) { + if (constraintsArray[i][PARAMETER.IN_RANGE].length > 1 ) { + 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] + parameterList.push(parameter); + parameterPushed = true; + //console.log ("pushed param for in_range"); + } + } + break; + case PARAMETER.GREATER_THAN: + if ( constraintsArray[i][PARAMETER.GREATER_THAN] != null ) { + parameter.type = PARAMETER.NUMBER; + parameter.min = constraintsArray[i][PARAMETER.GREATER_THAN]; + parameter.value = inputs[key][PARAMETER.DEFAULT] + parameterList.push(parameter); + parameterPushed = true; + //console.log ("pushed param for greater_than"); + + } + break; + }//switch + }//for + + }//while + }//if + }; + var addToList = function(name, value) { + _this.parameterList.push({ + name : name, + value : value + }); + }; + var setInventoryInfo = function(){ + var inventoryItem = DataService.getInventoryItem(); + var inventoryInfo = ComponentService.getInventoryInfo( + _this.componentId, inventoryItem); + } + + /* + * The "*Mso*" functions return URL and request details that can be passed + * to the MSO controller. The request details defines the info passed as + * part of the POST body. + */ + + var getMsoUrl = function() { + switch (_this.componentId) { + case COMPONENT.NETWORK: + return "mso_create_nw_instance/" + + DataService.getServiceInstanceId(); + case COMPONENT.SERVICE: + if(DataService.getE2EService() === true) + return "mso_create_e2e_svc_instance"; + else + return "mso_create_svc_instance"; + case COMPONENT.VNF: + return "mso_create_vnf_instance/" + + DataService.getServiceInstanceId(); + case COMPONENT.VF_MODULE: + return "mso_create_vfmodule_instance/" + + DataService.getServiceInstanceId() + "/vnfs/" + + DataService.getVnfInstanceId(); + case COMPONENT.VOLUME_GROUP: + return "mso_create_volumegroup_instance/" + + DataService.getServiceInstanceId() + "/vnfs/" + + DataService.getVnfInstanceId(); + } + }; + + var getMsoE2ERequest = function(parameterList) { + var modelInfo = DataService.getModelInfo(_this.componentId); + + //region id + var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList); + if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) { + lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT, + parameterList); + } + var cloudOwner = _.find(DataService.getCloudRegionTenantList(), function(region){ + return region.cloudRegionId === lcpRegion; + }).cloudOwner; + + var params = []; + var displayInputs = modelInfo.displayInputs; + var groupBy = _.groupBy(displayInputs, "templateUUID"); + + _.forEach(groupBy, function(nodeTemplateInputs, nodeTemplateUUID) { + var reqParas = {}; + var vfLocations = []; + + nodeTemplateInputs.forEach(function(parameter){ + if(parameter.type === 'vf_location') { + var loc = { + vnfProfileId: parameter.displayName, + locationConstraints : { + vimId: cloudOwner + '_' + lcpRegion + } + }; + vfLocations.push(loc); + } else if(parameter.type === 'sdn_controller') { + if(parameter.value === undefined || parameter.value === null) { + reqParas[parameter.name] = ''; + } else { + reqParas[parameter.name] = parameter.value.value; + } + } else { + var name; + _.forEach(displayInputs, function(item, key){ + if(item === parameter) { + name = key; + } + }); + var value = _.find(parameterList, function(item){ + return item.id === name; + }).value; + reqParas[parameter.displayName] = value; + } + }); + + params.push({ + resourceName: nodeTemplateInputs[0].templateName, + resourceInvariantUuid: nodeTemplateInputs[0].templateInvariantUUID, + resourceUuid: nodeTemplateInputs[0].templateUUID, + resourceCustomizationUuid: nodeTemplateInputs[0].templateCustomizationUUID, + parameters: { + locationConstraints: vfLocations, + //TODO resources: [], + requestInputs: reqParas + } + }); + }); + + var requestBody = { + service: { + name: getValueFromList(FIELD.ID.INSTANCE_NAME, parameterList), + description: modelInfo["description"], + serviceInvariantUuid: modelInfo["modelInvariantId"], + serviceUuid: modelInfo["modelNameVersionId"], + globalSubscriberId: DataService.getGlobalCustomerId(), + serviceType: getValueFromList(FIELD.ID.SERVICE_TYPE, parameterList) || modelInfo["serviceTypeName"], + parameters: { + locationConstraints: [], + resources: params, + requestInputs: {} //TODO + } + } + }; + + return requestBody; + }; + + 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) { + return getMsoE2ERequest(parameterList); + } + + var modelInfo = DataService.getModelInfo(_this.componentId); + var requestorloggedInId = DataService.getLoggedInUserId(); + var owningEntityId = getValueFromList(FIELD.ID.OWNING_ENTITY, parameterList); + if (requestorloggedInId == null) + requestorloggedInId = ""; + var isSupRollback = false; + if (getValueFromList(FIELD.ID.SUPPRESS_ROLLBACK,parameterList) === "true") { + isSupRollback = true; + } + var requestDetails = { + requestInfo : { + instanceName : getValueFromList(FIELD.ID.INSTANCE_NAME, + parameterList) || DataService.getVfModuleInstanceName(), + source : FIELD.ID.VID, + suppressRollback : isSupRollback, + requestorId: requestorloggedInId + }, + modelInfo : { + modelType : _this.componentId, + modelInvariantId : modelInfo.modelInvariantId, + modelVersionId : modelInfo.modelNameVersionId, + modelName : modelInfo.modelName, + modelVersion : modelInfo.modelVersion, + modelCustomizationId: modelInfo.customizationUuid, + modelCustomizationName : modelInfo.modelCustomizationName + }, + requestParameters : { + userParams : getArbitraryParameters(parameterList) + } + }; + if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) { + if ((_this.componentId != COMPONENT.SERVICE) || ( DataService.getALaCarte() )) { + requestDetails.requestParameters.testApi = DataService.getMsoRequestParametersTestApi(); + } + } + if ( (_this.componentId != COMPONENT.SERVICE) || ( !DataService.getALaCarte() ) ) { + // include cloud region for everything but service create alacarte + var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList); + if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) { + lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT, + parameterList); + } + requestDetails.cloudConfiguration = { + lcpCloudRegionId : lcpRegion, + tenantId : getValueFromList(FIELD.ID.TENANT, parameterList) + }; + } + switch (_this.componentId) { + + case COMPONENT.SERVICE: + requestDetails.subscriberInfo = { + globalSubscriberId : DataService.getGlobalCustomerId(), + subscriberName : DataService.getSubscriberName() + }; + var isInTop = DataService.getHideServiceFields() || false; + if(isInTop){ + requestDetails.requestParameters.subscriptionServiceType = DataService.getModelInfo(_this.componentId)["serviceTypeName"]; + }else{ + requestDetails.requestParameters.subscriptionServiceType = getValueFromList( + FIELD.ID.SERVICE_TYPE, parameterList); + } + requestDetails.requestParameters.aLaCarte = DataService.getALaCarte(); + if ( !DataService.getALaCarte() ) { + requestDetails.requestInfo.productFamilyId = getValueFromList( + FIELD.ID.PRODUCT_FAMILY, parameterList); + } + var svcModelInfo = { + modelType : _this.componentId, + modelInvariantId : modelInfo.modelInvariantId, + modelVersionId : modelInfo.modelNameVersionId, + modelName : modelInfo.modelName, + modelVersion : modelInfo.modelVersion + }; + requestDetails.modelInfo = svcModelInfo; + + var selectedProject = getValueFromList(FIELD.ID.PROJECT, parameterList); + + if (selectedProject) { + requestDetails.project = { + projectName: getValueFromList(FIELD.ID.PROJECT, parameterList) + }; + } + + requestDetails.owningEntity = { + owningEntityId: owningEntityId, + owningEntityName: getOwningEntityNameById(owningEntityId) + }; + + break; + case COMPONENT.VNF: + + requestDetails.requestInfo.productFamilyId = getValueFromList( + FIELD.ID.PRODUCT_FAMILY, parameterList); + + var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList); + + if(lineOfBusiness) { + var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", "); + + requestDetails.lineOfBusiness = { + lineOfBusinessName: lineOfBusinessNamesString + } + } + + requestDetails.platform = { + platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList) + }; + + break; + case COMPONENT.NETWORK: + requestDetails.requestInfo.productFamilyId = getValueFromList( + FIELD.ID.PRODUCT_FAMILY, parameterList); + var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList); + + if(lineOfBusiness) { + var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", "); + + requestDetails.lineOfBusiness = { + lineOfBusinessName: lineOfBusinessNamesString + } + } + + requestDetails.platform = { + platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList) + }; + break; + case COMPONENT.VF_MODULE: + requestDetails.requestParameters.usePreload = getValueFromList( + FIELD.ID.SDN_C_PRELOAD, parameterList); + if(_this.componentId == COMPONENT.VF_MODULE &&(requestDetails.requestParameters.usePreload== null || requestDetails.requestParameters.usePreload === '')){ + requestDetails.requestParameters.usePreload = false; + } + break; + case COMPONENT.VOLUME_GROUP: + break; + } + + var relatedInstanceList = getRelatedInstanceList(parameterList); + + if (relatedInstanceList !== undefined) { + requestDetails.relatedInstanceList = relatedInstanceList; + } + + return requestDetails; + }; + + var getRelatedInstanceList = function(parameterList) { + var relatedInstanceList = new Array(); + switch (_this.componentId) { + case COMPONENT.SERVICE: + return undefined; + case COMPONENT.NETWORK: + case COMPONENT.VNF: + addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE, + DataService.getServiceInstanceId()); + break; + case COMPONENT.VF_MODULE: + addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE, + DataService.getServiceInstanceId()); + addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService + .getVnfInstanceId()); + + var availableVolumeGroup = getValueFromList( + FIELD.ID.AVAILABLE_VOLUME_GROUP, parameterList); + + if (UtilityService.hasContents(availableVolumeGroup) && availableVolumeGroup !== "None") { + var availableVolumeGroups = DataService.getAvailableVolumeGroupList(); + + for (var i = 0; i < availableVolumeGroups.length; i++) { + if (availableVolumeGroups[i].instance.name == availableVolumeGroup) { + DataService.setModelInfo(COMPONENT.VOLUME_GROUP, DataService.getModelInfo(COMPONENT.VF_MODULE)); + DataService.setVolumeGroupInstanceId(availableVolumeGroups[i].instance.object["volume-group-id"]); + break; + } + } + + addRelatedInstance(relatedInstanceList, COMPONENT.VOLUME_GROUP, + DataService.getVolumeGroupInstanceId()); + } + break; + case COMPONENT.VOLUME_GROUP: + addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE, + DataService.getServiceInstanceId()); + addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService + .getVnfInstanceId()); + break; + } + + return relatedInstanceList; + }; + + var addRelatedInstance = function(relatedInstanceList, componentId, + instanceId) { + var modelInfo = DataService.getModelInfo(componentId); + var relatedInstance; + if (modelInfo !== undefined) { + if (componentId === COMPONENT.SERVICE) { + relatedInstance = { + "instanceId" : instanceId, + "modelInfo" : { + "modelType" : componentId, + "modelName" : modelInfo.modelName, + "modelInvariantId" : modelInfo.modelInvariantId, + "modelVersion" : modelInfo.modelVersion, + "modelVersionId" : modelInfo.modelNameVersionId, + + } + }; + } + else { + relatedInstance = { + "instanceId" : instanceId, + "modelInfo" : { + "modelType" : componentId, + "modelName" : modelInfo.modelName, + "modelInvariantId" : modelInfo.modelInvariantId, + "modelVersion" : modelInfo.modelVersion, + "modelVersionId" : modelInfo.modelNameVersionId, + "modelCustomizationId": modelInfo.customizationUuid, + "modelCustomizationName": modelInfo.modelCustomizationName + } + } + } + relatedInstanceList.push({ + relatedInstance : relatedInstance + }); + } + }; + + /* + * var getArbitraryParameters = function(parameterList) { var + * arbitraryParameters = new Object(); for (var i = 0; i < + * parameterList.length; i++) { var parameter = parameterList[i]; switch + * (parameter.id) { case FIELD.ID.INSTANCE_NAME: case + * FIELD.ID.PRODUCT_FAMILY: case FIELD.ID.LCP_REGION: case + * FIELD.ID.LCP_REGION_TEXT: case FIELD.ID.SERVICE_TYPE: case + * FIELD.ID.TENANT: case FIELD.ID.SUPPRESS_ROLLBACK: break; default: + * arbitraryParameters[parameter.id] = parameter.value; } } return + * arbitraryParameters; } + */ + var getArbitraryParameters = function(parameterList) { + var arbitraryParameters = new Object(); + var arbitraryArray = new Array(); + for (var i = 0; i < parameterList.length; i++) { + var parameter = parameterList[i]; + switch (parameter.id) { + case FIELD.ID.AVAILABLE_VOLUME_GROUP: + case FIELD.ID.INSTANCE_NAME: + case FIELD.ID.PRODUCT_FAMILY: + case FIELD.ID.LCP_REGION: + case FIELD.ID.LCP_REGION_TEXT: + case FIELD.ID.SERVICE_TYPE: + case FIELD.ID.TENANT: + case FIELD.ID.SUPPRESS_ROLLBACK: + case FIELD.ID.SUBSCRIBER_NAME: + case FIELD.ID.SDN_C_PRELOAD: + case FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE: + case FIELD.ID.OWNING_ENTITY: + case FIELD.ID.PLATFORM: + case FIELD.ID.LINE_OF_BUSINESS: + case FIELD.ID.PROJECT: + break; + case FIELD.ID.SUPPLEMENTORY_DATA_FILE: + arbitraryParameters = FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value']; + arbitraryArray=arbitraryParameters; + FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value']=[]; + break; + + default: + if (parameter.value != '') { + arbitraryParameters = { + name: parameter.id, + value: parameter.value + } + arbitraryArray.push(arbitraryParameters); + } + } + } + return (arbitraryArray); + } + + var getModel = function() { + AsdcService.getModel(DataService.getModelId(), function(response) { + DataService.setModelInfo(_this.componentId, { + modelInvariantId : response.data.invariantUUID, + modelNameVersionId : response.data.uuid, + modelName : response.data.name, + modelVersion : response.data.version, + inputs : response.data.inputs + }); + UtilityService.startNextAsyncOperation(); + }); + }; + + var getSubscriptionServiceTypeList = function() { + AaiService.getSubscriptionServiceTypeList(DataService + .getGlobalCustomerId(), function(response) { + DataService.setSubscriptionServiceTypeList(response); + UtilityService.startNextAsyncOperation(); + }); + }; + + var getLoggedInUserID = function() { + AaiService.getLoggedInUserID(function(response) { + DataService.setLoggedInUserId(response.data); + UtilityService.startNextAsyncOperation(); + }); + }; + + var getSubscribers = function() { + AaiService.getSubscribers(function(response) { + DataService.setSubscribers(response); + UtilityService.startNextAsyncOperation(); + }); + }; + var getServices = function() { + AaiService.getServices(function(response) { + var serviceIdList = []; + 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); + }); + }); + + UtilityService.startNextAsyncOperation(); + }); + }; + var getAicZones = function() { + AaiService.getAicZones(function(response) { + var serviceIdList = []; + angular.forEach(response.data, function(value, key) { + angular.forEach(value, function(subVal, key) { + var newVal = { + "id" : subVal[FIELD.ID.ZONE_ID], + "name" : subVal[FIELD.ID.ZONE_NAME], + }; + serviceIdList.push(newVal); + DataService.setAicZones(serviceIdList); + }); + }); + + UtilityService.startNextAsyncOperation(); + }); + }; + + var getOwningEntityProperties = function() { + OwningEntityService.getOwningEntityProperties(function(owningEntityProperties) { + DataService.setOwningEntityProperties(owningEntityProperties); + UtilityService.startNextAsyncOperation(); + }); + + }; + + var getLcpCloudRegionTenantList = function() { + AaiService.getLcpCloudRegionTenantList(DataService + .getGlobalCustomerId(), DataService.getServiceType(), function( + response) { + DataService.setCloudRegionTenantList(response); + UtilityService.startNextAsyncOperation(); + }); + }; + + var internalGetParametersHandler = function() { + if (angular.isFunction(_this.getParametersHandler)) { + _this.getParametersHandler({ + summaryList : getSummaryList(), + userProvidedList : getUserProvidedList() + }); + } + }; + + var getSubscribersParameter = function() { + var subscribers = DataService.getSubscribers(); + var parameter = FIELD.PARAMETER.SUBSCRIBER_NAME; + if ( UtilityService.hasContents(subscribers)) { + parameter.optionList = []; + + for (var i = 0; i < subscribers.length; i++) { + parameter.optionList.push({ + id : subscribers[i][FIELD.ID.GLOBAL_CUSTOMER_ID], + name : subscribers[i][FIELD.ID.SUBNAME], + isPermitted : subscribers[i][FIELD.ID.IS_PERMITTED] + }) + } + } + return parameter; + }; + + var getServiceId = function() { + var serviceIdList = DataService.getServiceIdList(); + //var serviceTypeList = DataService.getSubscriptionServiceTypeList(); + var parameter = FIELD.PARAMETER.PRODUCT_FAMILY; + parameter.optionList = new Array(); + if ( UtilityService.hasContents(serviceIdList) ) { + // load them all + for (var i = 0; i < serviceIdList.length; i++) { + parameter.optionList.push({ + id : serviceIdList[i].id, + name : serviceIdList[i].description, + isPermitted : serviceIdList[i].isPermitted + }); + } + } + + return parameter; + }; + + var getAicZonesParameter = function() { + var aicList = DataService.getAicZones(); + var parameter = FIELD.PARAMETER.AIC_ZONES; + parameter.optionList = new Array(); + if ( UtilityService.hasContents(aicList) ) { + // load them all + for (var i = 0; i < aicList.length; i++) { + parameter.optionList.push({ + id : aicList[i].id, + name : aicList[i].name, + isPermitted : true + + }); + } + } + + return parameter; + }; + + var getProjectParameter = function() { + return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PROJECT); + }; + + var getOwningEntityParameter = function() { + return getOwningEntityParameterWithOptions(FIELD.PARAMETER.OWNING_ENTITY); + }; + + var getLineOfBusinessParameter = function() { + return getOwningEntityParameterWithOptions(FIELD.PARAMETER.LINE_OF_BUSINESS); + }; + + var getPlatformParameter = function() { + return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PLATFORM); + }; + + var getOwningEntityNameById = function (id) { + var properties = DataService.getOwningEntityProperties(); + var parameter = _.find(properties[FIELD.ID.OWNING_ENTITY], {"id": id}); + return parameter && parameter.name; + }; + + var getOwningEntityParameterWithOptions = function(parameter) { + var properties = DataService.getOwningEntityProperties(); + if (properties && properties[parameter.id]) { + parameter.optionList = _.map(properties[parameter.id], function(parameter) { + return { + "id" : parameter.id, + "name" : parameter.name, + "isPermitted": true + }; + }); + } + + return parameter; + }; + + var getLcpRegionParameter = function() { + var cloudRegionTenantList = DataService.getCloudRegionTenantList(); + console.log ( "cloudRegionTenantList="); + console.log ( JSON.stringify (cloudRegionTenantList, null, 4 )); + + var parameter = FIELD.PARAMETER.LCP_REGION; + if ( UtilityService.hasContents (cloudRegionTenantList) ) { + parameter.optionList = new Array(); + for (var i = 0; i < cloudRegionTenantList.length; i++) { + for (var j = 0; j < parameter.optionList.length; j++) { + if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) { + parameter.optionList[j].isPermitted = + parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted; + break; + } + } + if (j < parameter.optionList.length) { + continue; + } + + var optionName = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) && cloudRegionTenantList[i].cloudOwner ? + cloudRegionTenantList[i].cloudRegionId + " (" + AaiService.removeVendorFromCloudOwner(cloudRegionTenantList[i].cloudOwner).toUpperCase() + ")" : + cloudRegionTenantList[i].cloudRegionId; + + parameter.optionList.push({ + id : cloudRegionTenantList[i].cloudRegionId, + name: optionName, + isPermitted : cloudRegionTenantList[i].isPermitted + }); + } + } + return parameter; + }; + + var getTenantList = function(cloudRegionId) { + var cloudRegionTenantList = DataService.getCloudRegionTenantList(); + var parameter = ""; + if ( UtilityService.hasContents (cloudRegionTenantList) ) { + parameter = FIELD.PARAMETER.TENANT_ENABLED; + parameter.optionList = new Array(); + for (var i = 0; i < cloudRegionTenantList.length; i++) { + if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) { + parameter.optionList.push({ + id : cloudRegionTenantList[i].tenantId, + name : cloudRegionTenantList[i].tenantName, + isPermitted : cloudRegionTenantList[i].isPermitted + + }); + } + } + } + return parameter; + + }; + + var addOptionList = function(parameter, optionSimpleArray) { + var optionList = new Array(); + if (!angular.isArray(optionSimpleArray)) { + return optionList; + } + for (var i = 0; i < optionSimpleArray.length; i++) { + optionList.push({ + name : optionSimpleArray[i], + isPermitted :true, + }); + } + parameter.optionList = optionList; + return parameter; + }; + + var getValueFromList = function(id, parameterList) { + for (var i = 0; i < parameterList.length; i++) { + if (parameterList[i].id === id) { + return parameterList[i].value; + } + } + }; + var updateUserParameterList = function(updatedId, parameterListControl) { + console.log ("updateUserParameterList() updatedId=" + updatedId); + if (updatedId === FIELD.ID.PRODUCT_FAMILY && DataService.getHideServiceFields()) { + var cloudRegionTenantList = new Array(); + AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) { + DataService.setCloudRegionTenantList(cloudRegionTenantList); + parameterListControl.updateList([ getLcpRegionParameter() ]); + }); + }else if (updatedId === FIELD.ID.SDN_C_PRELOAD) { + var list = parameterListControl.getList(updatedId); + if($('input[parameter-id="'+updatedId+'"]').is(':checked')){ + FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED.value=true; + parameterListControl + .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED ]); + }else{ + parameterListControl + .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_UNCHECKED ]); + } + }else if (updatedId === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE) { + if($('input[parameter-id="'+updatedId+'"]').is(':checked')){ + $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').show(); + FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=true; + parameterListControl + .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED ]); + }else{ + $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').hide(); + FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=false; + parameterListControl + .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_UNCHECKED ]); + } + } else if (updatedId === FIELD.ID.SUPPLEMENTORY_DATA_FILE) { + var filePath = $('input[parameter-id="'+updatedId+'"]').val(); + var arr =filePath.split('.'); + var fileExt = arr[arr.length-1]; + if(fileExt!='' && fileExt.toLowerCase()!='json'){ + $('input[parameter-id="'+updatedId+'"]').val(''); + alert("Invalid file format. Please select *.json format file."); + return false; + } + } else if (updatedId === FIELD.ID.LCP_REGION) { + var list = parameterListControl.getList(updatedId); + if (list[0].selectedIndex >= 0) { + parameterListControl + .updateList([ getTenantList(list[0].value) ]); + } else { + parameterListControl + .updateList([ FIELD.PARAMETER.TENANT_DISABLED ]); + } + if (list[0].value === FIELD.KEY.LCP_REGION_TEXT) { + parameterListControl + .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_VISIBLE ]); + } else { + parameterListControl + .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN ]); + } + } else if (updatedId === FIELD.ID.SUBSCRIBER_NAME) { + var list = parameterListControl.getList(updatedId); + if (list[0].selectedIndex >= 0) { + DataService.setGlobalCustomerId(list[0].value); + + AaiService.getSubscriptionServiceTypeList(DataService + .getGlobalCustomerId(), function(response) { + DataService.setSubscriptionServiceTypeList(response); + var serviceTypeParameters = FIELD.PARAMETER.SERVICE_TYPE; + serviceTypeParameters.optionList = []; + + for (var i = 0; i < response.length; i++) { + serviceTypeParameters.optionList.push({ + "id" : response[i].name, + "name" : response[i].name, + "isPermitted" :response[i].isPermitted + + }); + } + console.log ( "updateUserParameterList: service type parameters " ); + console.log ( JSON.stringify (serviceTypeParameters, null, 4)); + parameterListControl.updateList([ serviceTypeParameters ]); + }); + + } + } else if ( updatedId === FIELD.ID.SERVICE_TYPE ) { + var list = parameterListControl.getList(updatedId); + if (list[0].selectedIndex >= 0) { + + DataService.setServiceType(list[0].value); + var cloudRegionTenantList = new Array(); + AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) { + DataService.setCloudRegionTenantList(cloudRegionTenantList); + parameterListControl.updateList([ getLcpRegionParameter() ]); + }); + } else { + parameterListControl + .updateList([ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]); + } + } + + }; + + return { + initializeComponent : function(componentId) { + _this.componentId = ComponentService.initialize(componentId); + }, + setHttpErrorHandler : function(httpErrorHandler) { + _this.httpErrorHandler = httpErrorHandler; + }, + getComponentDisplayName : ComponentService.getComponentDisplayName, + getParameters : function(getParametersHandler) { + _this.getParametersHandler = getParametersHandler; + UtilityService.setHttpErrorHandler(_this.httpErrorHandler); + UtilityService.startAsyncOperations(getAsyncOperationList(), + internalGetParametersHandler); + }, + updateUserParameterList : updateUserParameterList, + getMsoRequestDetails : getMsoRequestDetails, + getMsoUrl : getMsoUrl, + setInventoryInfo: setInventoryInfo + } +} + +appDS2.factory("CreationService", [ "$log", "AaiService", "AsdcService", + "DataService","VIDCONFIGURATION", "ComponentService", "COMPONENT", "FIELD", "PARAMETER", + "UtilityService", "OwningEntityService","featureFlags", CreationService ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js index efb9ebefd..6163184c2 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js @@ -424,7 +424,7 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService, } var optionName = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) && cloudRegionTenantList[i].cloudOwner ? - cloudRegionTenantList[i].cloudRegionId + " (" + cloudRegionTenantList[i].cloudOwner.trim().toLowerCase().replace(/^att-/, "").toUpperCase() + ")" : + cloudRegionTenantList[i].cloudRegionId + " (" + AaiService.removeVendorFromCloudOwner(cloudRegionTenantList[i].cloudOwner).toUpperCase() + ")" : cloudRegionTenantList[i].cloudRegionId; parameter.optionList.push({ |