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;
33 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
34 import org.onap.vid.controller.VidController;
36 import org.onap.vid.asdc.beans.tosca.Group;
37 import org.onap.vid.asdc.beans.tosca.Input;
42 public class VNF extends Node {
44 /** The Constant LOG. */
45 private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VNF.class);
47 /** The Constant dateFormat. */
48 final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
50 /** The pattern used to normalize VNF names */
51 final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
53 /** The model customization name. */
54 private String modelCustomizationName;
56 /** The vf modules. */
57 private Map<String, VfModule> vfModules = new HashMap<String, VfModule>();
59 /** The volume groups. */
60 private Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup>();
63 * Instantiates a new vnf.
70 * Gets the model customization name.
72 * @return the model customization name
74 public String getModelCustomizationName() {
75 return modelCustomizationName;
79 * Gets the vf modules.
81 * @return the vf modules
83 public Map<String, VfModule> getVfModules() {
88 * Sets the vf modules.
90 * @param vfModules the vf modules
92 public void setVfModules(Map<String, VfModule> vfModules) {
93 this.vfModules = vfModules;
97 * Gets the volume groups.
99 * @return the volume groups
101 public Map<String, VolumeGroup> getVolumeGroups() {
106 * Sets the volume groups.
108 * @param volumeGroups the volume groups
110 public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
111 this.volumeGroups = volumeGroups;
117 * @param modelCustomizationName the model customization name
118 * @param nodeTemplate the node template
121 public void extractVnf(String modelCustomizationName, NodeTemplate nodeTemplate) {
123 super.extractNode(nodeTemplate);
124 setModelCustomizationName(modelCustomizationName);
129 * Sets the model customization name.
131 * @param modelCustomizationName the new model customization name
133 public void setModelCustomizationName(String modelCustomizationName) {
134 this.modelCustomizationName = modelCustomizationName;
137 * Normalize the VNF name
138 * @param originalName
139 * @return the normalized name
141 public static String normalizeName (String originalName) {
143 String normalizedName = originalName.toLowerCase();
144 normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
145 String[] splitArr = null;
148 splitArr = normalizedName.split(" ");
150 catch (Exception ex ) {
151 return (normalizedName);
153 StringBuffer sb = new StringBuffer();
154 if ( splitArr != null ) {
155 for (String splitElement : splitArr) {
156 sb.append(splitElement);
158 return (sb.toString());
161 return (normalizedName);