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>();
60 private Map<String, VfcInstanceGroup> vfcInstanceGroups = new HashMap<>();
64 * Instantiates a new vnf.
71 * Gets the model customization name.
73 * @return the model customization name
75 public String getModelCustomizationName() {
76 return modelCustomizationName;
80 * Gets the vf modules.
82 * @return the vf modules
84 public Map<String, VfModule> getVfModules() {
89 * Sets the vf modules.
91 * @param vfModules the vf modules
93 public void setVfModules(Map<String, VfModule> vfModules) {
94 this.vfModules = vfModules;
98 * Gets the volume groups.
100 * @return the volume groups
102 public Map<String, VolumeGroup> getVolumeGroups() {
107 * Sets the volume groups.
109 * @param volumeGroups the volume groups
111 public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
112 this.volumeGroups = volumeGroups;
116 public Map<String, VfcInstanceGroup> getVfcInstanceGroups() {
117 return vfcInstanceGroups;
120 public void setVfcInstanceGroups(Map<String, VfcInstanceGroup> vfcInstanceGroups) {
121 this.vfcInstanceGroups = vfcInstanceGroups;
127 * @param modelCustomizationName the model customization name
128 * @param nodeTemplate the node template
131 public void extractVnf(String modelCustomizationName, NodeTemplate nodeTemplate) {
133 super.extractNode(nodeTemplate);
134 setModelCustomizationName(modelCustomizationName);
139 * Sets the model customization name.
141 * @param modelCustomizationName the new model customization name
143 public void setModelCustomizationName(String modelCustomizationName) {
144 this.modelCustomizationName = modelCustomizationName;
147 * Normalize the VNF name
148 * @param originalName
149 * @return the normalized name
151 public static String normalizeName (String originalName) {
153 String normalizedName = originalName.toLowerCase();
154 normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
155 String[] splitArr = null;
158 splitArr = normalizedName.split(" ");
160 catch (Exception ex ) {
161 return (normalizedName);
163 StringBuffer sb = new StringBuffer();
164 if ( splitArr != null ) {
165 for (String splitElement : splitArr) {
166 sb.append(splitElement);
168 return (sb.toString());
171 return (normalizedName);