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;
23 import org.onap.vid.asdc.beans.tosca.Group;
24 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
26 import java.text.DateFormat;
27 import java.text.SimpleDateFormat;
28 import java.util.Date;
33 public class VfModule extends org.onap.vid.model.Group {
35 /** The Constant LOG. */
36 private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VfModule.class);
38 /** The Constant dateFormat. */
39 static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
40 public static final String VOLUME_GROUP = "volume_group";
42 /** The volume group allowed. */
43 private boolean volumeGroupAllowed;
46 * Checks if is volume group allowed.
48 * @return true, if is volume group allowed
50 public boolean isVolumeGroupAllowed() {
51 return volumeGroupAllowed;
56 * Sets the volume group allowed.
58 * @param volumeGroupAllowed the new volume group allowed
60 public void setVolumeGroupAllowed(boolean volumeGroupAllowed) {
61 this.volumeGroupAllowed = volumeGroupAllowed;
68 * @param group the group
69 * @return the vf module
71 public static VfModule extractVfModule(String modelCustomizationName, Group group) {
73 String methodName = "extractVfModule";
75 final VfModule vfModule = new VfModule();
78 vfModule.setUuid(group.getMetadata().getVfModuleModelUUID());
79 vfModule.setInvariantUuid(group.getMetadata().getVfModuleModelInvariantUUID());
80 vfModule.setDescription(group.getMetadata().getDescription());
81 vfModule.setName(group.getMetadata().getVfModuleModelName());
82 vfModule.setVersion(group.getMetadata().getVfModuleModelVersion());
83 vfModule.setCustomizationUuid(group.getMetadata().getVfModuleModelCustomizationUUID());
84 vfModule.setModelCustomizationName (modelCustomizationName);
85 vfModule.setProperties(VfModule.extractPropertiesForGroup(group));
87 if (group.getProperties().containsKey(VOLUME_GROUP)) {
88 if (group.getProperties().get(VOLUME_GROUP) != null) {
90 Class<?> c = group.getProperties().get(VOLUME_GROUP).getClass();
91 LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " class name=" +
94 if ( c.getName().equalsIgnoreCase(Boolean.class.getName()) ) {
95 Boolean b = (Boolean)group.getProperties().get(VOLUME_GROUP);
96 vfModule.setVolumeGroupAllowed( b.booleanValue() );
100 vfModule.setVolumeGroupAllowed(false);
103 catch ( Exception e ) {
104 LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse VF Module from group: e=" +