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 org.onap.vid.aai.util.AAITreeConverter;
24 import org.onap.vid.services.AAITreeNodeBuilder;
26 import java.util.HashMap;
29 import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE;
31 public class Vnf extends Node {
33 private Map<String, Map<String, VfModule>> vfModules = new HashMap<>();
34 private Map<String, Network> networks = new HashMap<>();
36 public Vnf(AAITreeNode node) {
37 super(node, AAITreeConverter.ModelType.vnf);
40 public Map<String, Map<String, VfModule>> getVfModules() {
44 public void setVfModules(Map<String, Map<String, VfModule>> vfModules) {
45 this.vfModules = vfModules;
48 public Map<String, Network> getNetworks() {
52 public void setNetworks(Map<String, Network> networks) {
53 this.networks = networks;
56 public static Vnf from(AAITreeNode node) {
57 Vnf vnf = new Vnf(node);
58 if (node.getAdditionalProperties().get(VNF_TYPE) != null) {
59 vnf.setInstanceType(node.getAdditionalProperties().get(VNF_TYPE).toString());
62 node.getChildren().forEach(child -> {
63 if (child.getType().equals(AAITreeNodeBuilder.VF_MODULE)) {
64 vnf.getVfModules().putIfAbsent(child.getNodeKey(), new HashMap<>());
65 vnf.getVfModules().get(child.getNodeKey())
66 .put(child.getUniqueNodeKey(), VfModule.from(child));
67 } else if (child.getType().equals(AAITreeNodeBuilder.NETWORK)) {
68 vnf.getNetworks().put(child.getUniqueNodeKey(), Network.from(child));