Add external tls info to bpgenerator and component spec schema
[dcaegen2/platform.git] / mod / bpgenerator / src / main / java / org / onap / blueprintgenerator / models / onapbp / OnapNode.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.core.PgaasNodeBuilder;
28 import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
29 import org.onap.blueprintgenerator.models.blueprint.Interfaces;
30 import org.onap.blueprintgenerator.models.blueprint.Node;
31 import org.onap.blueprintgenerator.models.blueprint.Properties;
32 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
33
34 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
35 import com.fasterxml.jackson.annotation.JsonInclude;
36 import com.fasterxml.jackson.annotation.JsonInclude.Include;
37
38 import lombok.AllArgsConstructor;
39 import lombok.Builder;
40 import lombok.Getter; import lombok.Setter;
41 import lombok.EqualsAndHashCode;
42 import lombok.NoArgsConstructor;
43
44 @JsonIgnoreProperties(ignoreUnknown = true)
45 @Getter @Setter
46 @EqualsAndHashCode(callSuper=false)
47 @NoArgsConstructor
48 @JsonInclude(value=Include.NON_NULL)
49
50 public class OnapNode extends Node{
51
52         public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
53                 TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
54                 retInputs = inps;
55
56                 //create and set the interfaces
57                 Interfaces inter = new Interfaces();
58                 retInputs = inter.createInterface(retInputs, cs);
59                 TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
60                 interfaces.put("cloudify.interfaces.lifecycle", inter);
61                 this.setInterfaces(interfaces);
62
63                 //set the type
64                 this.setType("dcae.nodes.ContainerizedServiceComponent");
65
66                 //create and set the relationships
67                 ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
68
69                 //add relationship for policy if exist
70                 if(cs.getPolicyInfo() != null){
71                         ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs);
72                         rets.addAll(policyRelationshipsList);
73                 }
74
75                 //add relationships and env_variables for pgaas dbs if exist
76                 if(cs.getAuxilary().getDatabases() != null){
77                         ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs);
78                         rets.addAll(pgaasRelationshipsList);
79                 }
80
81                 this.setRelationships(rets);
82
83                 //set the properties
84                 Properties props = new Properties();
85                 retInputs = props.createOnapProperties(retInputs, cs, override);
86                 this.setProperties(props);
87
88                 return retInputs;
89         }
90 }