2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.vid.model;
\r
23 import java.text.DateFormat;
\r
24 import java.text.SimpleDateFormat;
\r
25 import java.util.Date;
\r
26 import java.util.HashMap;
\r
27 import java.util.Map;
\r
28 import java.util.Map.Entry;
\r
29 import org.openecomp.vid.asdc.beans.tosca.Group;
\r
31 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
\r
34 * The Class VfModule.
\r
36 public class VfModule {
\r
38 /** The Constant LOG. */
\r
39 private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VfModule.class);
\r
41 /** The Constant dateFormat. */
\r
42 final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
\r
45 private String uuid;
\r
47 /** The invariant uuid. */
\r
48 private String invariantUuid;
\r
50 /** The customization uuid. */
\r
51 private String customizationUuid;
\r
53 /** The description. */
\r
54 private String description;
\r
57 private String name;
\r
60 private String version;
\r
62 /** The volume group allowed. */
\r
63 private boolean volumeGroupAllowed;
\r
65 /** The get_input or other constructs for VF Module. */
\r
66 private Map<String, CommandProperty> commands;
\r
68 /** The model customization name. */
\r
69 private String modelCustomizationName;
\r
72 * Instantiates a new vf module.
\r
75 commands = new HashMap<String, CommandProperty>();
\r
78 * Gets the model customization name.
\r
80 * @return the model customization name
\r
82 public String getModelCustomizationName() {
\r
83 return modelCustomizationName;
\r
90 public String getUuid() {
\r
95 * Gets the invariant uuid.
\r
97 * @return the invariant uuid
\r
99 public String getInvariantUuid() {
\r
100 return invariantUuid;
\r
103 * Gets the customization uuid.
\r
105 * @return the invariant uuid
\r
107 public String getCustomizationUuid() {
\r
108 return customizationUuid;
\r
111 * Gets the description.
\r
113 * @return the description
\r
115 public String getDescription() {
\r
116 return description;
\r
119 * Gets the commands.
\r
121 * @return the commands
\r
123 public Map<String, CommandProperty> getCommands() {
\r
131 public String getName() {
\r
136 * Gets the version.
\r
138 * @return the version
\r
140 public String getVersion() {
\r
145 * Checks if is volume group allowed.
\r
147 * @return true, if is volume group allowed
\r
149 public boolean isVolumeGroupAllowed() {
\r
150 return volumeGroupAllowed;
\r
156 * @param uuid the new uuid
\r
158 public void setUuid(String uuid) {
\r
163 * Sets the invariant uuid.
\r
165 * @param invariantUuid the new invariant uuid
\r
167 public void setInvariantUuid(String invariantUuid) {
\r
168 this.invariantUuid = invariantUuid;
\r
171 * Sets the customization uuid.
\r
173 * @param customizationUuid the new customization uuid
\r
175 public void setCustomizationUuid(String customizationUuid) {
\r
176 this.customizationUuid = customizationUuid;
\r
179 * Sets the description.
\r
181 * @param description the new description
\r
183 public void setDescription(String description) {
\r
184 this.description = description;
\r
190 * @param name the new name
\r
192 public void setName(String name) {
\r
197 * Sets the version.
\r
199 * @param version the new version
\r
201 public void setVersion(String version) {
\r
202 this.version = version;
\r
206 * Sets the volume group allowed.
\r
208 * @param volumeGroupAllowed the new volume group allowed
\r
210 public void setVolumeGroupAllowed(boolean volumeGroupAllowed) {
\r
211 this.volumeGroupAllowed = volumeGroupAllowed;
\r
214 * Sets the commands.
\r
216 * @param m the commands
\r
218 public void setCommands( Map<String, CommandProperty>m ) {
\r
222 * Sets the model customization name.
\r
224 * @param modelCustomizationName the new model customization name
\r
226 public void setModelCustomizationName(String modelCustomizationName) {
\r
227 this.modelCustomizationName = modelCustomizationName;
\r
230 * Extract vf module.
\r
232 * @param group the group
\r
233 * @return the vf module
\r
235 public static VfModule extractVfModule(String modelCustomizationName, Group group) {
\r
237 String methodName = "extractVfModule";
\r
239 final VfModule vfModule = new VfModule();
\r
242 vfModule.setUuid(group.getMetadata().getVfModuleModelUUID());
\r
243 vfModule.setInvariantUuid(group.getMetadata().getVfModuleModelInvariantUUID());
\r
244 vfModule.setDescription(group.getMetadata().getDescription());
\r
245 vfModule.setName(group.getMetadata().getVfModuleModelName());
\r
246 vfModule.setVersion(group.getMetadata().getVfModuleModelVersion());
\r
247 vfModule.setCustomizationUuid(group.getMetadata().getVfModuleModelCustomizationUUID());
\r
248 vfModule.setModelCustomizationName (modelCustomizationName);
\r
250 if (group.getProperties().containsKey("volume_group")) {
\r
251 if (group.getProperties().get("volume_group") != null) {
\r
253 Class<?> c = group.getProperties().get("volume_group").getClass();
\r
254 LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " class name=" +
\r
257 if ( c.getName().equalsIgnoreCase(Boolean.class.getName()) ) {
\r
258 Boolean b = (Boolean)group.getProperties().get("volume_group");
\r
259 vfModule.setVolumeGroupAllowed( b.booleanValue() );
\r
263 vfModule.setVolumeGroupAllowed(false);
\r
266 catch ( Exception e ) {
\r
267 LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse VF Module from group: e=" +
\r
270 /* Not extracting other types of properties for 1702
\r
273 for (Entry<String, Object> e : group.getProperties().entrySet()) {
\r
275 String k = e.getKey();
\r
276 if ( e.getValue() != null ) {
\r
277 LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " property: " +
\r
278 k + "=" + e.getValue());
\r
279 LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " V class name: " +
\r
280 e.getValue().getClass().getName());
\r
281 Class<?>[] interfaces = e.getValue().getClass().getInterfaces();
\r
283 for(Class<?> ifc: interfaces ){
\r
284 LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " ifc name: " +
\r
288 // only extract get_input for now
\r
289 for (Entry<String, String> entry : v.entrySet()) {
\r
290 // only include get_input for now
\r
291 if ( ModelConstants.GET_INPUT_TAG.equalsIgnoreCase ( entry.getKey() ) ) {
\r
292 CommandProperty cp = new CommandProperty();
\r
293 cp.setDisplayName(entry.getValue());
\r
294 cp.setCommand(entry.getKey());
\r
295 cp.setInputName(k);
\r
296 (vfModule.getCommands()).put(k,cp);
\r
302 catch ( Exception e ) {
\r
303 LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse VF Module properties: e=" +
\r