bp-gen code clone from cli repo
[dcaegen2/platform.git] / mod / bpgenerator / src / main / java / org / onap / blueprintgenerator / models / dmaapbp / DmaapStreams.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.dmaapbp;
22
23 import java.util.LinkedHashMap;
24 import java.util.TreeMap;
25
26 import org.onap.blueprintgenerator.models.blueprint.Appconfig;
27 import org.onap.blueprintgenerator.models.blueprint.GetInput;
28 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
29 import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
30
31 import com.fasterxml.jackson.annotation.JsonInclude;
32 import com.fasterxml.jackson.annotation.JsonInclude.Include;
33
34 import lombok.Getter;
35 import lombok.Setter;
36
37 @Getter @Setter
38 @JsonInclude(value=Include.NON_NULL)
39 public class DmaapStreams {
40
41         private String name;
42         private GetInput location;
43         private GetInput client_role;
44         private String type;
45
46         private GetInput username;
47         private GetInput password;
48         //private GetInput delivery_url;
49         private String route;
50         private String scheme;
51
52         public TreeMap<String, LinkedHashMap<String, Object>> createStreams(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String name, String type, String key, String route, char o){
53                 TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
54                 LinkedHashMap<String, Object> stringType = new LinkedHashMap();
55                 stringType.put("type", "string");
56
57                 //set the name
58                 this.setName(name);
59
60                 //set the type
61                 this.setType(type);
62
63                 //set the location
64                 GetInput location = new GetInput();
65                 location.setGet_input(key + "_" + name + "_location");
66                 retInputs.put(key + "_" + name + "_location", stringType);
67                 this.setLocation(location);
68
69                 //if its data router we need to add some more
70                 if(type.equals("data_router") || type.equals("data router")) {
71                         if(o == 's') {
72                                 //set the username
73                                 GetInput username = new GetInput();
74                                 username.setGet_input(key + "_" + name + "_username");
75                                 this.setUsername(username);
76                                 retInputs.put(key + "_" + name + "_username", stringType);
77
78                                 //set the password
79                                 GetInput password = new GetInput();
80                                 password.setGet_input(key + "_" + name + "_password");
81                                 this.setPassword(password);
82                                 retInputs.put(key + "_" + name + "_password", stringType);
83
84                                 this.setRoute(route);
85                                 this.setScheme("https");
86                         }
87
88 //                      //set the delivery url
89 //                      GetInput delivery = new GetInput();
90 //                      delivery.setGet_input(name + "_delivery_url");
91 //                      this.setDelivery_url(delivery);
92 //                      retInputs.put(name + "delivery_url", stringType);
93
94                 } else {
95                         //set the client role
96                         GetInput client = new GetInput();
97                         client.setGet_input(key + "_" + name + "_client_role");
98                         this.setClient_role(client);
99                         retInputs.put(key + "_" + name + "_client_role", stringType);
100                 }
101                 return retInputs;
102         }
103 }