3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * ================================================================================
8 * * Licensed under the Apache License, Version 2.0 (the "License");
9 * * you may not use this file except in compliance with the License.
10 * * You may obtain a copy of the License at
12 * * http://www.apache.org/licenses/LICENSE-2.0
14 * * Unless required by applicable law or agreed to in writing, software
15 * * distributed under the License is distributed on an "AS IS" BASIS,
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * * See the License for the specific language governing permissions and
18 * * limitations under the License.
19 * * ============LICENSE_END=========================================================
24 package org.onap.blueprintgenerator.service;
26 import org.onap.blueprintgenerator.model.common.GetInput;
27 import org.onap.blueprintgenerator.model.common.Info;
28 import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.stereotype.Service;
32 import java.util.HashMap;
33 import java.util.LinkedHashMap;
37 * @author : Ravi Mantena
38 * @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create Message Router and
39 * Data Router Information
42 public class InfoService {
45 private BlueprintHelperService blueprintHelperService;
48 * Creates info for Message Router
50 * @param inputs Inputs
51 * @param config Config
55 public Map<String, Object> createMessageRouterInfo(
56 Map<String, LinkedHashMap<String, Object>> inputs, String config, char type) {
58 Map<String, Object> response = new HashMap<>();
59 Info info = new Info();
61 LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
62 stringType.put("type", "string");
64 config = config.replaceAll("-", "_");
66 config = config + "_publish_url";
67 } else if (type == 's') {
68 config = config + "_subscribe_url";
71 GetInput topic = new GetInput();
72 topic.setBpInputName(config);
73 info.setTopic_url(topic);
75 inputs.put(config, stringType);
77 response.put("info", info);
78 response.put("inputs", inputs);
83 * Creates info for Data Router
85 * @param inputs Inputs
86 * @param config Config
89 public Map<String, Object> createDataRouterInfo(
90 Map<String, LinkedHashMap<String, Object>> inputs, String config) {
92 Map<String, Object> response = new HashMap<>();
93 Info info = new Info();
95 LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
96 stringType.put("type", "string");
98 String userNameInputName = blueprintHelperService.joinUnderscore(config, "username");
99 GetInput username = new GetInput(userNameInputName);
100 info.setUsername(username);
101 inputs.put(userNameInputName, stringType);
103 String userpasswordInputName = blueprintHelperService.joinUnderscore(config, "password");
104 GetInput password = new GetInput(userpasswordInputName);
105 info.setPassword(password);
106 inputs.put(userpasswordInputName, stringType);
108 String userlocationInputName = blueprintHelperService.joinUnderscore(config, "location");
109 GetInput location = new GetInput(userlocationInputName);
110 info.setLocation(location);
111 inputs.put(userlocationInputName, stringType);
113 String userdeliveryUrlInputName = blueprintHelperService
114 .joinUnderscore(config, "delivery_url");
115 GetInput deliveryUrl = new GetInput(userdeliveryUrlInputName);
116 info.setDelivery_url(deliveryUrl);
117 inputs.put(userdeliveryUrlInputName, stringType);
119 String usersubscriberIDInputName =
120 blueprintHelperService.joinUnderscore(config, "subscriber_id");
121 GetInput subscriberID = new GetInput(usersubscriberIDInputName);
122 info.setSubscriber_id(subscriberID);
123 inputs.put(usersubscriberIDInputName, stringType);
125 response.put("info", info);
126 response.put("inputs", inputs);