3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * Copyright (c) 2021 Nokia. All rights reserved.
8 * * ================================================================================
9 * * Licensed under the Apache License, Version 2.0 (the "License");
10 * * you may not use this file except in compliance with the License.
11 * * You may obtain a copy of the License at
13 * * http://www.apache.org/licenses/LICENSE-2.0
15 * * Unless required by applicable law or agreed to in writing, software
16 * * distributed under the License is distributed on an "AS IS" BASIS,
17 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * * See the License for the specific language governing permissions and
19 * * limitations under the License.
20 * * ============LICENSE_END=========================================================
25 package org.onap.blueprintgenerator.service;
27 import org.onap.blueprintgenerator.model.common.GetInput;
28 import org.onap.blueprintgenerator.model.common.Info;
29 import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Service;
33 import java.util.HashMap;
34 import java.util.LinkedHashMap;
38 * @author : Ravi Mantena
39 * @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create Message Router and
40 * Data Router Information
43 public class InfoService {
46 private BlueprintHelperService blueprintHelperService;
49 * Creates info for Message Router
51 * @param inputs Inputs
52 * @param config Config
56 public Map<String, Object> createMessageRouterInfo(
57 Map<String, Map<String, Object>> inputs, String config, char type) {
59 Map<String, Object> response = new HashMap<>();
60 Info info = new Info();
62 Map<String, Object> stringType = new LinkedHashMap<>();
63 stringType.put("type", "string");
65 config = config.replaceAll("-", "_");
67 config = config + "_publish_url";
68 } else if (type == 's') {
69 config = config + "_subscribe_url";
72 GetInput topic = new GetInput();
73 topic.setBpInputName(config);
74 info.setTopic_url(topic);
76 inputs.put(config, stringType);
78 response.put("info", info);
79 response.put("inputs", inputs);
84 * Creates info for Data Router
86 * @param inputs Inputs
87 * @param config Config
90 public Map<String, Object> createDataRouterInfo(
91 Map<String, Map<String, Object>> inputs, String config) {
93 Map<String, Object> response = new HashMap<>();
94 Info info = new Info();
96 Map<String, Object> stringType = new LinkedHashMap<>();
97 stringType.put("type", "string");
99 String userNameInputName = blueprintHelperService.joinUnderscore(config, "username");
100 GetInput username = new GetInput(userNameInputName);
101 info.setUsername(username);
102 inputs.put(userNameInputName, stringType);
104 String userpasswordInputName = blueprintHelperService.joinUnderscore(config, "password");
105 GetInput password = new GetInput(userpasswordInputName);
106 info.setPassword(password);
107 inputs.put(userpasswordInputName, stringType);
109 String userlocationInputName = blueprintHelperService.joinUnderscore(config, "location");
110 GetInput location = new GetInput(userlocationInputName);
111 info.setLocation(location);
112 inputs.put(userlocationInputName, stringType);
114 String userdeliveryUrlInputName = blueprintHelperService
115 .joinUnderscore(config, "delivery_url");
116 GetInput deliveryUrl = new GetInput(userdeliveryUrlInputName);
117 info.setDelivery_url(deliveryUrl);
118 inputs.put(userdeliveryUrlInputName, stringType);
120 String usersubscriberIDInputName =
121 blueprintHelperService.joinUnderscore(config, "subscriber_id");
122 GetInput subscriberID = new GetInput(usersubscriberIDInputName);
123 info.setSubscriber_id(subscriberID);
124 inputs.put(usersubscriberIDInputName, stringType);
126 response.put("info", info);
127 response.put("inputs", inputs);