From b35670742c728d7d85da2f9c856c51a5889449d6 Mon Sep 17 00:00:00 2001 From: Ofir Sonsino Date: Mon, 4 Sep 2017 14:52:07 +0300 Subject: [VID-55] Upgrade Tosca Parser (merge) Change-Id: I5389f1641ef22df3ed569a154b3c367117c04d04 Signed-off-by: Ofir Sonsino --- .../java/org/openecomp/vid/model/ModelUtil.java | 61 ----- .../main/java/org/openecomp/vid/model/Network.java | 2 +- .../java/org/openecomp/vid/model/NewNetwork.java | 56 +++++ .../main/java/org/openecomp/vid/model/NewNode.java | 209 +++++++++++++++++ .../java/org/openecomp/vid/model/NewService.java | 252 ++++++++++++++++++++ .../org/openecomp/vid/model/NewServiceModel.java | 259 +++++++++++++++++++++ .../main/java/org/openecomp/vid/model/NewVNF.java | 123 ++++++++++ .../java/org/openecomp/vid/model/ServiceModel.java | 17 +- .../src/main/java/org/openecomp/vid/model/VNF.java | 2 +- .../java/org/openecomp/vid/model/VfModule.java | 4 +- .../java/org/openecomp/vid/model/VolumeGroup.java | 2 +- 11 files changed, 913 insertions(+), 74 deletions(-) delete mode 100755 vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java create mode 100644 vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java (limited to 'vid-app-common/src/main/java/org/openecomp/vid/model') diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java b/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java deleted file mode 100755 index 4606aa02..00000000 --- a/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.vid.model; - -/** - * The Class ModelUtil. - * - */ -public class ModelUtil { - /** - * Gets the tags for the given element according to the configured namespace - * @param namespaces the namespace list from the configuration - * @param constantValue the constant portion of the tag name, i.e. resource.vf... - * @return the tags - */ - public static String[] getTags ( String[] namespaces, String constantValue ) { - String[] tags; - if ( namespaces == null || namespaces.length == 0 ) { - return null; - } - int le = namespaces.length; - tags = new String[le]; - for ( int i = 0; i < le; i++ ) { - tags[i] = namespaces[i] + constantValue; - } - return (tags); - } - /** - * Determine if a note template type matches a set of configurable tags - * @param type the node template type - * @param tags the model configurable namespaces - * @return true if type starts with a tag in the array, false otherwise - */ - public static boolean isType ( String type, String[] tags ) { - if ( (tags != null) && (tags.length > 0) ) { - for ( int i = 0; i < tags.length; i++ ) { - if ( type.startsWith (tags[i]) ) { - return (true); - } - } - } - return (false); - } -} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java b/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java index 5ab55881..e763496f 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java @@ -49,7 +49,7 @@ public class Network extends Node { * * @param modelCustomizationName the new model customization name */ - private void setModelCustomizationName(String modelCustomizationName) { + public void setModelCustomizationName(String modelCustomizationName) { this.modelCustomizationName = modelCustomizationName; } diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java new file mode 100644 index 00000000..48e3a55f --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.vid.model; + +import org.openecomp.vid.asdc.beans.tosca.NodeTemplate; + +/** + * The Class Network. + */ +public class NewNetwork extends NewNode { + + /** The model customization name. */ + private String modelCustomizationName; + + /** + * Instantiates a new network. + */ + public NewNetwork() { + super(); + } + /** + * Gets the model customization name. + * + * @return the model customization name + */ + public String getModelCustomizationName() { + return modelCustomizationName; + } + /** + * Sets the model customization name. + * + * @param modelCustomizationName the new model customization name + */ + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java new file mode 100644 index 00000000..681131fc --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java @@ -0,0 +1,209 @@ +package org.openecomp.vid.model; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.vid.asdc.beans.tosca.Input; + + +public class NewNode { + + /** The Constant LOG. */ + private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(Node.class); + + /** The Constant dateFormat. */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + + /** The uuid. */ + private String uuid; + + /** The invariant uuid. */ + private String invariantUuid; + + /** The description. */ + private String description; + + /** The name. */ + private String name; + + /** The version. */ + private String version; + + /** The model customization uuid. */ + private String customizationUuid; + + /** The inputs. */ + private Map inputs; + + /** The get_input or other constructs from node template properties. */ + private Map commands; + + /** The get_input or other constructs from node template properties. */ + private Map properties; + /** + * Instantiates a new node. + */ + public NewNode() { + this.commands = new HashMap(); + this.properties = new HashMap(); + } + + /** + * Gets the uuid. + * + * @return the uuid + */ + public String getUuid() { + return uuid; + } + + /** + * Gets the invariant uuid. + * + * @return the invariant uuid + */ + public String getInvariantUuid() { + return invariantUuid; + } + + /** + * Gets the description. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the version. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the customization uuid. + * + * @return the model customization uuid + */ + public String getCustomizationUuid() { + return customizationUuid; + } + /** + * Gets the inputs. + * + * @return the inputs + */ + public Map getInputs() { + return inputs; + } + /** + * Gets the commands. + * + * @return the commands + */ + public Map getCommands() { + return commands; + } + /** + * Gets the properties. + * + * @return the properties + */ + public Map getProperties() { + return properties; + } + /** + * Sets the uuid. + * + * @param uuid the new uuid + */ + public void setUuid(String uuid) { + this.uuid = uuid; + } + + /** + * Sets the invariant uuid. + * + * @param invariantUuid the new invariant uuid + */ + public void setInvariantUuid(String invariantUuid) { + this.invariantUuid = invariantUuid; + } + + /** + * Sets the description. + * + * @param description the new description + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Sets the name. + * + * @param name the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(String version) { + this.version = version; + } + /** + * Sets the customization uuid. + * + * @param u the new customization uuid + */ + public void setCustomizationUuid(String u) { + this.customizationUuid = u; + } + + /** + * Sets the inputs. + * + * @param inputs the inputs + */ + public void setInputs(Map inputs) { + this.inputs = inputs; + } + /** + * Sets the commands. + * + * @param m the commands + */ + public void setCommands( Mapm ) { + commands = m; + } + /** + * Sets the properties. + * + * @param p the properties + */ + public void setProperties( Mapp) { + properties = p; + } + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java new file mode 100644 index 00000000..1dcf0224 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java @@ -0,0 +1,252 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.vid.model; + +import java.util.Map; +import java.util.UUID; + +import org.openecomp.vid.asdc.beans.tosca.Input; + +/** + * The Class Service. + */ +public class NewService { + + /** The uuid. */ + private String uuid; + + /** The invariant uuid. */ + private String invariantUuid; + + /** The name. */ + private String name; + + /** The version. */ + private String version; + + /** The tosca model URL. */ + private String toscaModelURL; + + /** The category. */ + private String category; + + /** The description. */ + private String description; + + /** The service ecomp naming flag */ + private String serviceEcompNaming; + + /** The inputs. */ + private Map inputs; + + /** + * Gets the uuid. + * + * @return the uuid + */ + public String getUuid() { + return uuid; + } + + /** + * Gets the invariant uuid. + * + * @return the invariant uuid + */ + public String getInvariantUuid() { + return invariantUuid; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the version. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the tosca model URL. + * + * @return the tosca model URL + */ + public String getToscaModelURL() { + return toscaModelURL; + } + + /** + * Gets the category. + * + * @return the category + */ + public String getCategory() { + return category; + } + + /** + * Gets the description. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the inputs. + * + * @return the inputs + */ + public Map getInputs() { + return inputs; + } + /** + * Get the serviceEcompNaming value + * + * @return serviceEcompNaming + */ + public String getServiceEcompNaming() { + return serviceEcompNaming; + } + /** + * Sets the uuid. + * + * @param uuid the new uuid + */ + public void setUuid(String uuid) { + this.uuid = uuid; + } + + /** + * Sets the invariant uuid. + * + * @param invariantUuid the new invariant uuid + */ + public void setInvariantUuid(String invariantUuid) { + this.invariantUuid = invariantUuid; + } + + /** + * Sets the name. + * + * @param name the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(String version) { + this.version = version; + } + + /** + * Sets the tosca model URL. + * + * @param toscaModelURL the new tosca model URL + */ + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + /** + * Sets the category. + * + * @param category the new category + */ + public void setCategory(String category) { + this.category = category; + } + + /** + * Sets the description. + * + * @param description the new description + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Sets the inputs. + * + * @param inputs the inputs + */ + public void setInputs(Map inputs) { + this.inputs = inputs; + } + /** + * Sets the service ecomp naming. + * + * @param serviceEcompNaming the new service ecomp naming + */ + public void setServiceEcompNaming(String serviceEcompNaming) { + this.serviceEcompNaming = serviceEcompNaming; + } + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final UUID uuid = UUID.fromString(getUuid()); + + return uuid.hashCode(); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof NewService)) return false; + + final NewService service = (NewService) o; + + return (service.getUuid().equals(getUuid())); + } + /*public static void extractVfModuleCustomizationUUID (Service s, String vnfCustomizationName, VfModule vfMod ) { + + //Look for vnfCustomizationName..vfModuleCustomizationName + String nameToFind = vnfCustomizationName + ".." + vfMod.getModelCustomizationName(); + for (Entry vfModuleComponent : s.getVfModules().entrySet()) { + VfModule xMod = vfModuleComponent.getValue(); + if ( (xMod.getModelCustomizationName() != null) && (xMod.getModelCustomizationName().equalsIgnoreCase(nameToFind)) ) { + vfMod.setCustomizationUuid( xMod.getCustomizationUuid()); + return; + } + } + }*/ +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java new file mode 100644 index 00000000..6fda979c --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java @@ -0,0 +1,259 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.vid.model; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.openecomp.vid.asdc.beans.tosca.Group; +import org.openecomp.vid.asdc.beans.tosca.ToscaModel; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.vid.properties.VidProperties; +/** + * The Class ServiceModel. + */ +public class NewServiceModel { + + /** The Constant LOG. */ + private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(NewServiceModel.class); + + /** The Constant dateFormat. */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + /** The service. */ + private Service service; + + /** The vnfs. */ + private Map vnfs; + + /** The networks. */ + private Map networks; + + /** + * The vf modules. The VNF also has vfmodules but the vfmodules at the service level may have additional info + * that is not present in the VNF, like the vf module customization String + */ + private Map vfModules; + /** + * The volume groups. The VNF also has volume groups but the volume groups will be populated at the service level + * for newer models + */ + private Map volumeGroups; + /** + * Instantiates a new service model. + */ + public NewServiceModel() {} + + /** + * Gets the service. + * + * @return the service + */ + public Service getService() { + return service; + } + + /** + * Gets the vnfs. + * + * @return the vnfs + */ + public Map getVnfs() { + return vnfs; + } + + /** + * Gets the networks. + * + * @return the networks + */ + public Map getNetworks() { + return networks; + } + + /** + * Sets the service. + * + * @param service the new service + */ + public void setService(Service service) { + this.service = service; + } + + /** + * Sets the vnfs. + * + * @param vnfs the vnfs + */ + public void setVnfs(Map vnfs) { + this.vnfs = vnfs; + } + + /** + * Sets the networks. + * + * @param networks the networks + */ + public void setNetworks(Map networks) { + this.networks = networks; + } + /** + * Gets the vf modules. + * + * @return the vf modules + */ + public Map getVfModules() { + return vfModules; + } + /** + * Gets the volume groups. + * + * @return the volume groups + */ + public Map getVolumeGroups() { + return volumeGroups; + } + /** + * Sets the vf modules. + * + * @param vfModules the vf modules + */ + public void setVfModules(Map vfModules) { + this.vfModules = vfModules; + } + /** + * Sets the volume groups. + * + * @param volumeGroups the volume groups + */ + public void setVolumeGroups(Map volumeGroups) { + this.volumeGroups = volumeGroups; + } + /** + * Extract service. + * + * @param serviceToscaModel the service tosca model + * @param asdcServiceMetadata the asdc service metadata + * @return the service + */ + public static Service extractService(ToscaModel serviceToscaModel, org.openecomp.vid.asdc.beans.Service asdcServiceMetadata) { + + final Service service = new Service(); + + service.setCategory(serviceToscaModel.getMetadata().getCategory()); + service.setInvariantUuid(serviceToscaModel.getMetadata().getInvariantUUID()); + service.setName(serviceToscaModel.getMetadata().getName()); + service.setUuid(serviceToscaModel.getMetadata().getUUID()); + service.setDescription(serviceToscaModel.getMetadata().getDescription()); + service.setServiceEcompNaming(serviceToscaModel.getMetadata().getServiceEcompNaming()); + service.setInputs(serviceToscaModel.gettopology_template().getInputs()); + //FIXME: SDC is not sending the Version with the Tosca Model for 1610 - they should send it in 1702 + //THIS IS A TEMPORARY FIX, AT SOME POINT UNCOMMENT ME + //service.setVersion(serviceToscaModel.getMetadata().getVersion()); + service.setVersion(asdcServiceMetadata.getVersion()); + + return service; + } + public static void extractGroups (ToscaModel serviceToscaModel,NewServiceModel serviceModel) { + // Get the groups. The groups may duplicate the groups that are in the VNF model and have + // additional data like the VF module customization String> + + final Map vfModules = new HashMap (); + final Map volumeGroups = new HashMap (); + + String asdcModelNamespace = VidProperties.getAsdcModelNamespace(); + String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE; + + for (Entry component : serviceToscaModel.gettopology_template().getGroups().entrySet()) { + final Group group = component.getValue(); + final String type = group.getType(); + final String customizationName = component.getKey(); + + if (type.startsWith(vfModuleTag)) { + VfModule vfMod = VfModule.extractVfModule(customizationName, group); + vfModules.put(customizationName, vfMod); + if ( vfMod.isVolumeGroupAllowed() ) { + //volume groups have the same customization name as the vf module + volumeGroups.put(customizationName, VolumeGroup.extractVolumeGroup(customizationName,group)); + } + } + } + // add this point vfModules and volume groups are disconnected from VNF + serviceModel.setVfModules (vfModules); + serviceModel.setVolumeGroups (volumeGroups); + + } + /** + * Populate the vf modules and volume groups that we may have under the service level under each VNF. + */ +// public void associateGroups() { +// String methodName = "associateGroups()"; +// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start"); +// // go through the vnfs, get the vnf normalized name and look for a vf module with a customization name that starts +// // with vnf + ".." +// String vnfCustomizationName = null; +// String normalizedVnfCustomizationName = null; +// String vfModuleCustomizationName = null; +// NewVNF tmpVnf = null; +// +// if ( ( getVnfs() != null ) && (!(getVnfs().isEmpty())) ) { +// for (Entry vnfComponent : getVnfs().entrySet()) { +// vnfCustomizationName = vnfComponent.getValue().getModelCustomizationName(); +// normalizedVnfCustomizationName = VNF.normalizeName(vnfCustomizationName); +// +// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + +// " VNF customizationName=" + vnfCustomizationName + "normalized customization name=" + normalizedVnfCustomizationName); +// +// // now check to see if there is a vf module with customization name that starts with normalizedVnfCustomizationName +// +// if (( getVfModules() != null ) && (!(getVfModules().isEmpty()))) { +// for (Entry vfModuleComponent : getVfModules().entrySet()) { +// vfModuleCustomizationName = vfModuleComponent.getValue().getModelCustomizationName(); +// +// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + +// " VF Module customizationName=" + vfModuleCustomizationName ); +// if ( vfModuleCustomizationName.startsWith(normalizedVnfCustomizationName + ".." )) { +// +// // this vf module belongs to the VNF +// tmpVnf = vnfComponent.getValue(); +// (tmpVnf.getVfModules()).put(vfModuleComponent.getKey(), vfModuleComponent.getValue()); +// +// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + +// " Associated VF Module customizationName=" + vfModuleComponent.getKey() + " with VNF customization name=" + vnfCustomizationName); +// +// // now find if this vf module has volume groups, if so, find the volume group with the same customization name and put it under the VNF +// if ( vfModuleComponent.getValue().isVolumeGroupAllowed() ) { +// if (( getVolumeGroups() != null ) && (!(getVolumeGroups().isEmpty()))) { +// if (getVolumeGroups().containsKey((vfModuleCustomizationName))) { +// (vnfComponent.getValue().getVolumeGroups()).put(vfModuleCustomizationName, (getVolumeGroups()).get(vfModuleCustomizationName)); +// } +// } +// } +// } +// } +// } +// } +// } + +// } +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java new file mode 100644 index 00000000..e84f963c --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java @@ -0,0 +1,123 @@ +package org.openecomp.vid.model; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.vid.asdc.beans.tosca.NodeTemplate; + +public class NewVNF extends NewNode { + + /** The Constant LOG. */ + private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VNF.class); + + /** The Constant dateFormat. */ + final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + + /** The pattern used to normalize VNF names */ + final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+"); + + /** The model customization name. */ + private String modelCustomizationName; + + /** The vf modules. */ + private Map vfModules = new HashMap(); + + /** The volume groups. */ + private Map volumeGroups = new HashMap(); + + /** + * Instantiates a newvnf. + */ + public NewVNF() { + super(); + } + + /** + * Gets the model customization name. + * + * @return the model customization name + */ + public String getModelCustomizationName() { + return modelCustomizationName; + } + + /** + * Gets the vf modules. + * + * @return the vf modules + */ + public Map getVfModules() { + return vfModules; + } + + /** + * Sets the vf modules. + * + * @param vfModules the vf modules + */ + public void setVfModules(Map vfModules) { + this.vfModules = vfModules; + } + + /** + * Gets the volume groups. + * + * @return the volume groups + */ + public Map getVolumeGroups() { + return volumeGroups; + } + + /** + * Sets the volume groups. + * + * @param volumeGroups the volume groups + */ + public void setVolumeGroups(Map volumeGroups) { + this.volumeGroups = volumeGroups; + } + + + /** + * Sets the model customization name. + * + * @param modelCustomizationName the new model customization name + */ + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + /** + * Normalize the VNF name + * @param originalName + * @return the normalized name + */ + public static String normalizeName (String originalName) { + + String normalizedName = originalName.toLowerCase(); + normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" "); + String[] splitArr = null; + + try { + splitArr = normalizedName.split(" "); + } + catch (Exception ex ) { + return (normalizedName); + } + StringBuffer sb = new StringBuffer(); + if ( splitArr != null ) { + for (String splitElement : splitArr) { + sb.append(splitElement); + } + return (sb.toString()); + } + else { + return (normalizedName); + } + + } + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java b/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java index 98e65316..8742931c 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java @@ -30,11 +30,11 @@ import java.util.Map.Entry; import org.openecomp.vid.asdc.beans.tosca.Group; import org.openecomp.vid.asdc.beans.tosca.ToscaModel; import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.vid.controller.VidController; import org.openecomp.vid.properties.VidProperties; /** * The Class ServiceModel. */ +@SuppressWarnings("ALL") public class ServiceModel { /** The Constant LOG. */ @@ -176,21 +176,22 @@ public class ServiceModel { return service; } - public void extractGroups (ToscaModel serviceToscaModel) { + public static void extractGroups (ToscaModel serviceToscaModel,ServiceModel serviceModel) { // Get the groups. The groups may duplicate the groups that are in the VNF model and have // additional data like the VF module customization String> final Map vfModules = new HashMap (); final Map volumeGroups = new HashMap (); - String asdcModelNamespaces[] = VidProperties.getAsdcModelNamespace(); - String[] vfModuleTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.VF_MODULE); - + + String asdcModelNamespace = VidProperties.getAsdcModelNamespace(); + String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE; + for (Entry component : serviceToscaModel.gettopology_template().getGroups().entrySet()) { final Group group = component.getValue(); final String type = group.getType(); final String customizationName = component.getKey(); - if ( ModelUtil.isType (type, vfModuleTags) ) { + if (type.startsWith(vfModuleTag)) { VfModule vfMod = VfModule.extractVfModule(customizationName, group); vfModules.put(customizationName, vfMod); if ( vfMod.isVolumeGroupAllowed() ) { @@ -200,8 +201,8 @@ public class ServiceModel { } } // add this point vfModules and volume groups are disconnected from VNF - this.setVfModules (vfModules); - this.setVolumeGroups (volumeGroups); + serviceModel.setVfModules (vfModules); + serviceModel.setVolumeGroups (volumeGroups); } /** diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java b/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java index be37c947..62e101ef 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java @@ -130,7 +130,7 @@ public class VNF extends Node { * * @param modelCustomizationName the new model customization name */ - private void setModelCustomizationName(String modelCustomizationName) { + public void setModelCustomizationName(String modelCustomizationName) { this.modelCustomizationName = modelCustomizationName; } /** diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java b/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java index 4a031a6c..3f6f1da2 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java @@ -207,7 +207,7 @@ public class VfModule { * * @param volumeGroupAllowed the new volume group allowed */ - private void setVolumeGroupAllowed(boolean volumeGroupAllowed) { + public void setVolumeGroupAllowed(boolean volumeGroupAllowed) { this.volumeGroupAllowed = volumeGroupAllowed; } /** @@ -223,7 +223,7 @@ public class VfModule { * * @param modelCustomizationName the new model customization name */ - private void setModelCustomizationName(String modelCustomizationName) { + public void setModelCustomizationName(String modelCustomizationName) { this.modelCustomizationName = modelCustomizationName; } /** diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java b/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java index ea8e151d..d09ef9a3 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java @@ -170,7 +170,7 @@ public class VolumeGroup { * * @param u the new customization name */ - private void setModelCustomizationName(String u) { + public void setModelCustomizationName(String u) { this.modelCustomizationName = u; } -- cgit 1.2.3-korg