org.onap migration
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / NewVNF.java
1 package org.onap.vid.model;
2
3 import java.text.DateFormat;
4 import java.text.SimpleDateFormat;
5 import java.util.HashMap;
6 import java.util.Map;
7 import java.util.regex.Pattern;
8
9 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
10 import org.onap.vid.asdc.beans.tosca.NodeTemplate;
11
12 public class NewVNF extends NewNode {
13         
14         /** The Constant LOG. */
15         private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VNF.class);
16         
17         /** The Constant dateFormat. */
18         final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
19
20         /** The pattern used to normalize VNF names */
21         final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
22         
23         /** The model customization name. */
24         private String modelCustomizationName;
25         
26         /** The vf modules. */
27         private Map<String, VfModule> vfModules = new HashMap<String, VfModule>();
28         
29         /** The volume groups. */
30         private Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup>();
31         
32         /**
33          * Instantiates a newvnf.
34          */
35         public NewVNF() {
36                 super();
37         }
38
39         /**
40          * Gets the model customization name.
41          *
42          * @return the model customization name
43          */
44         public String getModelCustomizationName() {
45                 return modelCustomizationName;
46         }
47
48         /**
49          * Gets the vf modules.
50          *
51          * @return the vf modules
52          */
53         public Map<String, VfModule> getVfModules() {
54                 return vfModules;
55         }
56
57         /**
58          * Sets the vf modules.
59          *
60          * @param vfModules the vf modules
61          */
62         public void setVfModules(Map<String, VfModule> vfModules) {
63                 this.vfModules = vfModules;
64         }
65
66         /**
67          * Gets the volume groups.
68          *
69          * @return the volume groups
70          */
71         public Map<String, VolumeGroup> getVolumeGroups() {
72                 return volumeGroups;
73         }
74
75         /**
76          * Sets the volume groups.
77          *
78          * @param volumeGroups the volume groups
79          */
80         public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
81                 this.volumeGroups = volumeGroups;
82         }
83
84
85         /**
86          * Sets the model customization name.
87          *
88          * @param modelCustomizationName the new model customization name
89          */
90         public void setModelCustomizationName(String modelCustomizationName) {
91                 this.modelCustomizationName = modelCustomizationName;
92         }
93         /**
94          * Normalize the VNF name
95          * @param originalName
96          * @return the normalized name
97          */
98         public static String normalizeName (String originalName) {
99
100                 String normalizedName = originalName.toLowerCase();
101                 normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
102                 String[] splitArr = null;
103                 
104                 try {
105                         splitArr = normalizedName.split(" ");
106                 }
107                 catch (Exception ex ) {
108                         return (normalizedName);
109                 }
110                 StringBuffer sb = new StringBuffer();
111                 if ( splitArr != null ) {
112                         for (String splitElement : splitArr) {
113                                 sb.append(splitElement);
114                         }
115                         return (sb.toString());
116                 }
117                 else {
118                         return (normalizedName);
119                 }
120                 
121         }
122
123 }