2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.model;
23 import org.onap.vid.asdc.beans.tosca.NodeTemplate;
25 import java.util.HashMap;
27 import java.util.regex.Pattern;
32 public class VNF extends Node {
33 /** The pattern used to normalize VNF names */
34 static final Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
36 /** The model customization name. */
37 private String modelCustomizationName;
39 /** The vf modules. */
40 private Map<String, VfModule> vfModules = new HashMap<>();
42 /** The volume groups. */
43 private Map<String, VolumeGroup> volumeGroups = new HashMap<>();
45 private Map<String, VfcInstanceGroup> vfcInstanceGroups = new HashMap<>();
49 * Instantiates a new vnf.
56 * Gets the model customization name.
58 * @return the model customization name
60 public String getModelCustomizationName() {
61 return modelCustomizationName;
65 * Gets the vf modules.
67 * @return the vf modules
69 public Map<String, VfModule> getVfModules() {
74 * Sets the vf modules.
76 * @param vfModules the vf modules
78 public void setVfModules(Map<String, VfModule> vfModules) {
79 this.vfModules = vfModules;
83 * Gets the volume groups.
85 * @return the volume groups
87 public Map<String, VolumeGroup> getVolumeGroups() {
92 * Sets the volume groups.
94 * @param volumeGroups the volume groups
96 public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
97 this.volumeGroups = volumeGroups;
101 public Map<String, VfcInstanceGroup> getVfcInstanceGroups() {
102 return vfcInstanceGroups;
105 public void setVfcInstanceGroups(Map<String, VfcInstanceGroup> vfcInstanceGroups) {
106 this.vfcInstanceGroups = vfcInstanceGroups;
112 * @param modelCustomizationName the model customization name
113 * @param nodeTemplate the node template
116 public void extractVnf(String modelCustomizationName, NodeTemplate nodeTemplate) {
118 super.extractNode(nodeTemplate);
119 setModelCustomizationName(modelCustomizationName);
124 * Sets the model customization name.
126 * @param modelCustomizationName the new model customization name
128 public void setModelCustomizationName(String modelCustomizationName) {
129 this.modelCustomizationName = modelCustomizationName;
132 * Normalize the VNF name
133 * @param originalName
134 * @return the normalized name
136 public static String normalizeName (String originalName) {
138 String normalizedName = originalName.toLowerCase();
139 normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
140 String[] splitArr = null;
143 splitArr = normalizedName.split(" ");
145 catch (Exception ex ) {
146 return (normalizedName);
148 StringBuilder sb = new StringBuilder();
149 if ( splitArr != null ) {
150 for (String splitElement : splitArr) {
151 sb.append(splitElement);
153 return (sb.toString());
156 return (normalizedName);