Merge "Improve code quality in ResourceConfig"
[dcaegen2/platform.git] / mod / bpgenerator / src / main / java / org / onap / blueprintgenerator / models / blueprint / dmaap / DmaapObj.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.blueprint.dmaap;
23
24 import com.fasterxml.jackson.annotation.JsonInclude;
25 import com.fasterxml.jackson.annotation.JsonInclude.Include;
26 import lombok.Getter;
27 import lombok.Setter;
28 import org.onap.blueprintgenerator.models.blueprint.GetInput;
29
30 import java.util.LinkedHashMap;
31 import java.util.TreeMap;
32
33 @JsonInclude(value=Include.NON_NULL)
34 @Getter @Setter
35 public class DmaapObj {
36         private Object dmaap_info;
37         private String type;
38         private GetInput pass;
39         private GetInput user;
40
41         public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps,
42                                                                                                                                                            String config, char type, String n, String num, boolean isDmaap) {
43                 LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
44                 stringType.put("type", "string");
45
46                 //set the dmaapinfo
47                 DmaapInfo info = new DmaapInfo();
48                 if(!isDmaap){
49                         info.createOnapDmaapMRInfo(inps, config, type);
50                         this.setDmaap_info(info);
51                 }
52                 else{
53                         String infoType = "<<" + n + ">>";
54                         this.setDmaap_info(infoType);
55                         //set username
56                         GetInput u = new GetInput();
57                         u.setBpInputName(config + "_" + num +"_aaf_username");
58                         this.setUser(u);
59                         inps.put(config + "_" + num +"_aaf_username", stringType);
60
61                         //set password
62                         GetInput p = new GetInput();
63                         p.setBpInputName(config + "_" + num +"_aaf_password");
64                         this.setPass(p);
65                         inps.put(config + "_" + num +"_aaf_password", stringType);
66                 }
67                 return inps;
68         }
69         public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num, boolean isDmaap) {
70
71                 //set the dmaapinfo
72                 DmaapInfo info = new DmaapInfo();
73                 if(!isDmaap){
74                         info.createOnapDmaapDRInfo(inps, config, type);
75                         this.setDmaap_info(info);
76                 }
77                 else {
78                         String infoType = "<<" + n + ">>";
79                         this.setDmaap_info(infoType);
80                 }
81                 return inps;
82         }
83 }