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;
24 import java.text.DateFormat;
25 import java.text.SimpleDateFormat;
26 import java.util.Date;
27 import java.util.HashMap;
28 import java.util.Map.Entry;
29 import java.util.regex.Pattern;
31 import org.onap.vid.asdc.beans.tosca.NodeTemplate;
32 import org.onap.vid.controllers.VidController;
33 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
34 import org.onap.vid.asdc.beans.tosca.Group;
35 import org.onap.vid.asdc.beans.tosca.Input;
40 public class VNF extends Node {
42 /** The Constant LOG. */
43 private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VNF.class);
45 /** The Constant dateFormat. */
46 final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
48 /** The pattern used to normalize VNF names */
49 final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
51 /** The model customization name. */
52 private String modelCustomizationName;
54 /** The vf modules. */
55 private Map<String, VfModule> vfModules = new HashMap<String, VfModule>();
57 /** The volume groups. */
58 private Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup>();
61 * Instantiates a new vnf.
68 * Gets the model customization name.
70 * @return the model customization name
72 public String getModelCustomizationName() {
73 return modelCustomizationName;
77 * Gets the vf modules.
79 * @return the vf modules
81 public Map<String, VfModule> getVfModules() {
86 * Sets the vf modules.
88 * @param vfModules the vf modules
90 public void setVfModules(Map<String, VfModule> vfModules) {
91 this.vfModules = vfModules;
95 * Gets the volume groups.
97 * @return the volume groups
99 public Map<String, VolumeGroup> getVolumeGroups() {
104 * Sets the volume groups.
106 * @param volumeGroups the volume groups
108 public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
109 this.volumeGroups = volumeGroups;
115 * @param modelCustomizationName the model customization name
116 * @param nodeTemplate the node template
119 public void extractVnf(String modelCustomizationName, NodeTemplate nodeTemplate) {
121 super.extractNode(nodeTemplate);
122 setModelCustomizationName(modelCustomizationName);
127 * Sets the model customization name.
129 * @param modelCustomizationName the new model customization name
131 public void setModelCustomizationName(String modelCustomizationName) {
132 this.modelCustomizationName = modelCustomizationName;
135 * Normalize the VNF name
136 * @param originalName
137 * @return the normalized name
139 public static String normalizeName (String originalName) {
141 String normalizedName = originalName.toLowerCase();
142 normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
143 String[] splitArr = null;
146 splitArr = normalizedName.split(" ");
148 catch (Exception ex ) {
149 return (normalizedName);
151 StringBuffer sb = new StringBuffer();
152 if ( splitArr != null ) {
153 for (String splitElement : splitArr) {
154 sb.append(splitElement);
156 return (sb.toString());
159 return (normalizedName);