e2847d75b738982a81be80a1537cbd68d0cfc6e3
[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  Copyright (c) 2020 Nokia. All rights reserved.
6  ================================================================================
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10
11       http://www.apache.org/licenses/LICENSE-2.0
12  
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18  ============LICENSE_END=========================================================
19  
20  */
21
22 package org.onap.blueprintgenerator.models.dmaapbp;
23
24 import java.util.LinkedHashMap;
25 import java.util.TreeMap;
26
27 import org.onap.blueprintgenerator.models.blueprint.GetInput;
28 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
29
30 import com.fasterxml.jackson.annotation.JsonInclude;
31 import com.fasterxml.jackson.annotation.JsonInclude.Include;
32
33 import lombok.Getter;
34 import lombok.Setter;
35
36 @Getter @Setter
37 @JsonInclude(value=Include.NON_NULL)
38 public class DmaapStreams {
39
40         private String name;
41         private GetInput location;
42         private GetInput client_role;
43         private String type;
44
45         private GetInput username;
46         private GetInput password;
47         //private GetInput delivery_url;
48
49         private GetInput privileged;
50         private GetInput decompress;
51
52         private String route;
53         private String scheme;
54
55         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){
56                 TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
57                 LinkedHashMap<String, Object> stringType = new LinkedHashMap();
58                 stringType.put("type", "string");
59
60                 //set the name
61                 this.setName(name);
62
63                 //set the type
64                 this.setType(type);
65
66                 //set the location
67                 GetInput location = new GetInput();
68                 location.setBpInputName(key + "_" + name + "_location");
69                 retInputs.put(key + "_" + name + "_location", stringType);
70                 this.setLocation(location);
71
72                 //if its data router we need to add some more
73                 if(type.equals("data_router") || type.equals("data router")) {
74                         if(o == 's') {
75                                 //set the username
76                                 GetInput username = new GetInput();
77                                 username.setBpInputName(key + "_" + name + "_username");
78                                 this.setUsername(username);
79                                 retInputs.put(key + "_" + name + "_username", stringType);
80
81                                 //set the password
82                                 GetInput password = new GetInput();
83                                 password.setBpInputName(key + "_" + name + "_password");
84                                 this.setPassword(password);
85                                 retInputs.put(key + "_" + name + "_password", stringType);
86
87                                 //set privileged
88                                 GetInput priviliged = new GetInput();
89                                 priviliged.setBpInputName(key + "_" + name + "_priviliged");
90                                 this.setPrivileged(priviliged);
91                                 retInputs.put(key + "_" + name + "_priviliged", stringType);
92
93                                 //set decompress
94                                 GetInput decompress = new GetInput();
95                                 decompress.setBpInputName(key + "_" + name + "_decompress");
96                                 this.setDecompress(decompress);
97                                 retInputs.put(key + "_" + name + "_decompress", stringType);
98
99                                 this.setRoute(route);
100                                 this.setScheme("https");
101                         }
102
103 //                      //set the delivery url
104 //                      GetInput delivery = new GetInput();
105 //                      delivery.setGet_input(name + "_delivery_url");
106 //                      this.setDelivery_url(delivery);
107 //                      retInputs.put(name + "delivery_url", stringType);
108
109                 } else {
110                         //set the client role
111                         GetInput client = new GetInput();
112                         client.setBpInputName(key + "_" + name + "_client_role");
113                         this.setClient_role(client);
114                         retInputs.put(key + "_" + name + "_client_role", stringType);
115                 }
116                 return retInputs;
117         }
118 }