bp-gen code clone from cli repo
[dcaegen2/platform.git] / mod / bpgenerator / src / main / java / org / onap / blueprintgenerator / models / onapbp / OnapBlueprint.java
1 /**============LICENSE_START======================================================= 
2  org.onap.dcae 
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 
9
10       http://www.apache.org/licenses/LICENSE-2.0 
11
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========================================================= 
18
19  */
20
21 package org.onap.blueprintgenerator.models.onapbp;
22
23 import java.util.ArrayList;
24 import java.util.LinkedHashMap;
25 import java.util.TreeMap;
26
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;
31
32 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
33 import com.fasterxml.jackson.annotation.JsonInclude;
34 import com.fasterxml.jackson.annotation.JsonInclude.Include;
35
36 import lombok.Getter; import lombok.Setter;
37 import lombok.EqualsAndHashCode;
38 import lombok.NoArgsConstructor;
39
40
41 @Getter @Setter
42 @JsonInclude(value=Include.NON_NULL)
43
44 public class OnapBlueprint extends Blueprint{
45         public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
46
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");
51
52                 //set the imports 
53                 if(importPath != "") {
54                         Imports imps = new Imports();
55                         this.setImports(imps.createImportsFromFile(importPath));
56                 }
57                 else {
58                         Imports imps = new Imports();
59                         this.setImports(imps.createOnapImports());
60                 }
61
62                 //create the node template
63                 TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
64                 String nodeName = cs.getSelf().getName();
65
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);
71
72                 //set the inputs
73                 this.setInputs(inputs);
74
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());
80
81                 return bp;
82
83         }
84 }