Commit for the blueprint generator java tool
[dcaegen2/platform/cli.git] / blueprint-generator / 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         
46         public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath) {
47                 
48                 //create the inputs that will be used
49                 TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
50                 
51                 //set the tosca definition which is the same for everything
52                 this.setTosca_definitions_version("cloudify_dsl_1_3");
53                 
54                 //set the imports 
55                 if(importPath != "") {
56                         Imports imps = new Imports();
57                         this.setImports(imps.createImportsFromFile(importPath));
58                 }
59                 else {
60                         Imports imps = new Imports();
61                         this.setImports(imps.createOnapImports());
62                 }
63
64                 
65                 //create the node template
66                 TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
67                 String nodeName = cs.getSelf().getName();
68                 
69                 //create the onap node that will be used
70                 OnapNode node = new OnapNode();
71                 inputs = node.createOnapNode(inputs, cs);
72                 nodeTemplate.put(nodeName, node);
73                 this.setNode_templates(nodeTemplate);
74                 
75                 //set the inputs
76                 this.setInputs(inputs);
77                 
78                 Blueprint bp = new Blueprint();
79                 bp.setImports(this.getImports());
80                 bp.setInputs(this.getInputs());
81                 bp.setNode_templates(this.getNode_templates());
82                 bp.setTosca_definitions_version(this.getTosca_definitions_version());
83                 
84                 return bp;
85                 
86         }
87
88
89         
90 }