[VID-6] Initial rebase push
[vid.git] / vid / src / main / webapp / app / vid / scripts / services / componentService.js
diff --git a/vid/src/main/webapp/app/vid/scripts/services/componentService.js b/vid/src/main/webapp/app/vid/scripts/services/componentService.js
deleted file mode 100644 (file)
index 7c1cfcb..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 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 ComponentService = function($log, COMPONENT, UtilityService) {
-
-    var _this = this;
-
-    var componentList = [ {
-       id : COMPONENT.NETWORK,
-       displayName : "Network"
-    }, {
-       id : COMPONENT.SERVICE,
-       displayName : "Service Instance"
-    }, {
-       id : COMPONENT.VNF,
-       displayName : "Virtual Network Function"
-    }, {
-       id : COMPONENT.VF_MODULE,
-       displayName : "VF Module"
-    }, {
-       id : COMPONENT.VOLUME_GROUP,
-       displayName : "Volume Group"
-    } ];
-
-    var getInventoryInfo = function(suffix, inventoryItem) {
-       var pattern = new RegExp(suffix + "-");
-       for ( var key in inventoryItem) {
-           if (pattern.exec(key)) {
-               return inventoryItem[key];
-           }
-       }
-    };
-
-    /*
-     * Converts 'id' to a user friendly version.
-     * 
-     * The algorithm used is:
-     * 
-     * 1) If "id" found in COMPONENT.FULL_NAME_MAP, return the name found in the
-     * map.
-     * 
-     * 2) Otherwise, if camel case, add "-" between camel case words.
-     * 
-     * 3) Split id into multiple "partial names" assuming "-" is the delimiter.
-     * 
-     * 4) Map any partial names found in COMPONENT.PARTIAL_NAME_MAP to the name
-     * found in the map.
-     * 
-     * 5) Use partial names whenever not found in map.
-     * 
-     * 5) Return name by combining all partial names with " " delimiter.
-     */
-    var getDisplayName = function(id) {
-       var tmp = COMPONENT.FULL_NAME_MAP[id.toLowerCase()];
-       if (UtilityService.hasContents(tmp)) {
-           return tmp;
-       }
-       /*
-        * Add "-" if camel case found.
-        */
-       var id = id.replace(/([a-z](?=[A-Z]))/g, '$1-');
-       var name = "";
-       var arg = id.split("-");
-       for (var i = 0; i < arg.length; i++) {
-           if (i > 0) {
-               name += " ";
-           }
-           var tmp = COMPONENT.PARTIAL_NAME_MAP[arg[i].toLowerCase()];
-           if (UtilityService.hasContents(tmp)) {
-               name += tmp;
-           } else {
-               name += arg[i].slice(0, 1).toUpperCase() + arg[i].slice(1);
-           }
-       }
-       return name;
-    };
-
-    return {
-       initialize : function(componentId) {
-           for (var i = 0; i < componentList.length; i++) {
-               if (componentList[i].id === componentId) {
-                   _this.componentId = componentList[i].id;
-                   return componentId;
-               }
-           }
-           throw "ComponentService:initializeComponent: componentId not found: "
-                   + componentId;
-       },
-       getComponentDisplayName : function() {
-           for (var i = 0; i < componentList.length; i++) {
-               if (componentList[i].id === _this.componentId) {
-                   return componentList[i].displayName;
-               }
-           }
-       },
-       getInventoryInfo : getInventoryInfo,
-       getInventoryParameterList : function(suffix, inventoryItem) {
-           var parameterList = new Array();
-       //    var pattern = new RegExp("-[intv][a-z]*$");
-       //    var inventoryInfo = getInventoryInfo(suffix, inventoryItem);
-           for ( var id in inventoryItem) {
-               //if (pattern.exec(id)) {
-                   parameterList.push({
-                       id : id,
-                       value : inventoryItem[id]
-                   });
-               //}
-           }
-           return parameterList;
-       },
-       getDisplayNames : function(inputList) {
-           var outputList = new Array();
-           for (var i = 0; i < inputList.length; i++) {
-               var entry = angular.copy(inputList[i]);
-               if (!UtilityService.hasContents(entry.name)) {
-                   entry.name = getDisplayName(entry.id);
-               }
-               outputList.push(entry);
-           }
-           return outputList;
-       },
-       getFieldDisplayName : function(name) {
-           return getDisplayName(name);
-       }
-    }
-}
-
-app.factory("ComponentService", [ "$log", "COMPONENT", "UtilityService",
-       ComponentService ]);