2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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.aaiTree;
23 import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE;
25 import java.util.HashMap;
28 public class Vnf extends Node {
30 private Map<String, Map<String, VfModule>> vfModules = new HashMap<>();
31 private Map<String, Network> networks = new HashMap<>();
33 public Vnf(AAITreeNode node) {
35 fillCloudConfigurationProperties(this, node.getCloudConfiguration());
38 public Map<String, Map<String, VfModule>> getVfModules() {
42 public void setVfModules(Map<String, Map<String, VfModule>> vfModules) {
43 this.vfModules = vfModules;
46 public Map<String, Network> getNetworks() {
50 public void setNetworks(Map<String, Network> networks) {
51 this.networks = networks;
54 public static Vnf from(AAITreeNode node) {
55 Vnf vnf = new Vnf(node);
56 if (node.getAdditionalProperties().get(VNF_TYPE) != null) {
57 vnf.setInstanceType(node.getAdditionalProperties().get(VNF_TYPE).toString());
60 node.getChildren().forEach(child -> {
61 if (child.getType() == NodeType.VF_MODULE) {
62 vnf.getVfModules().putIfAbsent(child.getNodeKey(), new HashMap<>());
63 vnf.getVfModules().get(child.getNodeKey())
64 .put(child.getUniqueNodeKey(), VfModule.from(child));
65 } else if (child.getType() == NodeType.NETWORK) {
66 vnf.getNetworks().put(child.getUniqueNodeKey(), Network.from(child));