1 /**============LICENSE_START=======================================================
3 ================================================================================
4 Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 ================================================================================
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ============LICENSE_END=========================================================
21 package org.onap.blueprintgenerator.models.onapbp;
23 import java.util.ArrayList;
24 import java.util.LinkedHashMap;
25 import java.util.TreeMap;
27 import org.onap.blueprintgenerator.models.blueprint.Blueprint;
28 import org.onap.blueprintgenerator.models.blueprint.Imports;
29 import org.onap.blueprintgenerator.models.blueprint.Node;
30 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
32 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
33 import com.fasterxml.jackson.annotation.JsonInclude;
34 import com.fasterxml.jackson.annotation.JsonInclude.Include;
36 import lombok.Getter; import lombok.Setter;
37 import lombok.EqualsAndHashCode;
38 import lombok.NoArgsConstructor;
42 @JsonInclude(value=Include.NON_NULL)
44 public class OnapBlueprint extends Blueprint{
45 public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
47 //create the inputs that will be used
48 TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
49 //set the tosca definition which is the same for everything
50 this.setTosca_definitions_version("cloudify_dsl_1_3");
53 if(importPath != "") {
54 Imports imps = new Imports();
55 this.setImports(imps.createImportsFromFile(importPath));
58 Imports imps = new Imports();
59 this.setImports(imps.createOnapImports());
62 //create the node template
63 TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
64 String nodeName = cs.getSelf().getName();
66 //create the onap node that will be used
67 OnapNode node = new OnapNode();
68 inputs = node.createOnapNode(inputs, cs, override);
69 nodeTemplate.put(nodeName, node);
70 this.setNode_templates(nodeTemplate);
73 this.setInputs(inputs);
75 Blueprint bp = new Blueprint();
76 bp.setImports(this.getImports());
77 bp.setInputs(this.getInputs());
78 bp.setNode_templates(this.getNode_templates());
79 bp.setTosca_definitions_version(this.getTosca_definitions_version());