1 /*============LICENSE_START=======================================================
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
11 http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.blueprintgenerator.models.blueprint.dmaap;
24 import com.fasterxml.jackson.annotation.JsonInclude;
25 import com.fasterxml.jackson.annotation.JsonInclude.Include;
28 import org.onap.blueprintgenerator.models.blueprint.GetInput;
30 import java.util.LinkedHashMap;
31 import java.util.TreeMap;
35 @JsonInclude(value = Include.NON_NULL)
36 public class DmaapInfo {
38 private static final String UNDERSCORE = "_";
40 private GetInput topic_url;
41 private GetInput username;
42 private GetInput password;
43 private GetInput location;
44 private GetInput delivery_url;
45 private GetInput subscriber_id;
47 public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRInfo(
48 TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
49 LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
50 stringType.put("type", "string");
52 config = config.replaceAll("-", "_");
54 config = config + "_publish_url";
55 } else if (type == 's') {
56 config = config + "_subscribe_url";
59 GetInput topic = new GetInput();
60 topic.setBpInputName(config);
61 this.setTopic_url(topic);
63 inps.put(config, stringType);
68 public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRInfo(
69 TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
70 TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
71 LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
72 stringType.put("type", "string");
74 String userNameInputName = createInputName(config, "username");
75 GetInput username = new GetInput(userNameInputName);
76 this.setUsername(username);
77 retInputs.put(userNameInputName, stringType);
79 String passwordInputName = createInputName(config, "password");
80 GetInput password = new GetInput(passwordInputName);
81 this.setPassword(password);
82 retInputs.put(passwordInputName, stringType);
84 String locationInputName = createInputName(config, "location");
85 GetInput location = new GetInput(locationInputName);
86 this.setLocation(location);
87 retInputs.put(locationInputName, stringType);
89 String deliveryUrlInputName = createInputName(config, "delivery_url");
90 GetInput deliveryUrl = new GetInput(deliveryUrlInputName);
91 this.setDelivery_url(deliveryUrl);
92 retInputs.put(deliveryUrlInputName, stringType);
94 String subscriberIdInputName = createInputName(config, "subscriber_id");
95 GetInput subscriberID = new GetInput(subscriberIdInputName);
96 this.setSubscriber_id(subscriberID);
97 retInputs.put(subscriberIdInputName, stringType);
102 private String createInputName(String config, String inputName) {
103 return config + UNDERSCORE + inputName;