1 /*============LICENSE_START=======================================================
3 ================================================================================
4 Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 ================================================================================
6 Modifications Copyright (c) 2020 Nokia. All rights reserved.
7 ================================================================================
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19 ============LICENSE_END=========================================================
23 package org.onap.blueprintgenerator.models.onapbp;
25 import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3;
27 import com.fasterxml.jackson.annotation.JsonInclude;
28 import com.fasterxml.jackson.annotation.JsonInclude.Include;
29 import java.util.LinkedHashMap;
30 import java.util.TreeMap;
33 import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
34 import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
35 import org.onap.blueprintgenerator.models.blueprint.Blueprint;
36 import org.onap.blueprintgenerator.models.blueprint.Imports;
37 import org.onap.blueprintgenerator.models.blueprint.Node;
38 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
43 @JsonInclude(value = Include.NON_NULL)
45 public class OnapBlueprint extends Blueprint {
47 public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
49 //create the inputs that will be used
50 TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
51 //set the tosca definition which is the same for everything
52 this.setTosca_definitions_version(CLOUDIFY_DSL_1_3);
55 if (!"".equals(importPath)) {
56 Imports imps = new Imports();
57 this.setImports(imps.createImportsFromFile(importPath));
59 Imports imps = new Imports();
60 this.setImports(imps.createOnapImports());
63 //create the node template
64 TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
65 String nodeName = cs.getSelf().getName();
67 //create the onap node that will be used
68 OnapNode node = new OnapNode();
69 inputs = node.createOnapNode(inputs, cs, override);
70 nodeTemplate.put(nodeName, node);
71 this.setNode_templates(nodeTemplate);
73 //if present in component spec, populate policyNode information in the blueprint
74 if (cs.getPolicyInfo() != null) {
75 PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs);
78 //if present in component spec, populate pgaasNodes information in the blueprint
79 if (cs.getAuxilary().getDatabases() != null) {
80 PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs);
84 this.setInputs(inputs);
86 Blueprint bp = new Blueprint();
87 bp.setImports(this.getImports());
88 bp.setInputs(this.getInputs());
89 bp.setNode_templates(this.getNode_templates());
90 bp.setTosca_definitions_version(this.getTosca_definitions_version());