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 java.util.ArrayList;
26 import java.util.LinkedHashMap;
27 import java.util.TreeMap;
29 import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
30 import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
31 import org.onap.blueprintgenerator.models.blueprint.Blueprint;
32 import org.onap.blueprintgenerator.models.blueprint.Imports;
33 import org.onap.blueprintgenerator.models.blueprint.Node;
34 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
36 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
37 import com.fasterxml.jackson.annotation.JsonInclude;
38 import com.fasterxml.jackson.annotation.JsonInclude.Include;
40 import lombok.Getter; import lombok.Setter;
41 import lombok.EqualsAndHashCode;
42 import lombok.NoArgsConstructor;
46 @JsonInclude(value=Include.NON_NULL)
48 public class OnapBlueprint extends Blueprint{
49 public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
51 //create the inputs that will be used
52 TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
53 //set the tosca definition which is the same for everything
54 this.setTosca_definitions_version("cloudify_dsl_1_3");
57 if(!"".equals(importPath)) {
58 Imports imps = new Imports();
59 this.setImports(imps.createImportsFromFile(importPath));
62 Imports imps = new Imports();
63 this.setImports(imps.createOnapImports());
66 //create the node template
67 TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
68 String nodeName = cs.getSelf().getName();
70 //create the onap node that will be used
71 OnapNode node = new OnapNode();
72 inputs = node.createOnapNode(inputs, cs, override);
73 nodeTemplate.put(nodeName, node);
74 this.setNode_templates(nodeTemplate);
76 //if present in component spec, populate policyNode information in the blueprint
77 if(cs.getPolicyInfo() != null){
78 PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs);
81 //if present in component spec, populate pgaasNodes information in the blueprint
82 if(cs.getAuxilary().getDatabases() != null){
83 PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs);
87 this.setInputs(inputs);
90 Blueprint bp = new Blueprint();
91 bp.setImports(this.getImports());
92 bp.setInputs(this.getInputs());
93 bp.setNode_templates(this.getNode_templates());
94 bp.setTosca_definitions_version(this.getTosca_definitions_version());