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
39 * Application: ONAP - Blueprint Generator
40 * Service to create Message Router and Data Router Information
44 public class InfoService {
47 private BlueprintHelperService blueprintHelperService;
49 // Method to create info for Message Router
50 public Map<String,Object> createMessageRouterInfo(Map<String, LinkedHashMap<String, Object>> inputs, String config, char type) {
52 Map<String,Object> response = new HashMap<>();
53 Info info = new Info();
55 LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
56 stringType.put("type", "string");
58 config = config.replaceAll("-", "_");
60 config = config + "_publish_url";
62 else if(type == 's') {
63 config = config+ "_subscribe_url";
66 GetInput topic = new GetInput();
67 topic.setBpInputName(config);
68 info.setTopic_url(topic);
70 inputs.put(config, stringType);
72 response.put("info", info);
73 response.put("inputs", inputs);
77 // Method to create info for Data Router
78 public Map<String,Object> createDataRouterInfo(Map<String, LinkedHashMap<String, Object>> inputs, String config) {
80 Map<String,Object> response = new HashMap<>();
81 Info info = new Info();
83 LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
84 stringType.put("type", "string");
86 String userNameInputName = blueprintHelperService.joinUnderscore(config, "username");
87 GetInput username = new GetInput(userNameInputName);
88 info.setUsername(username);
89 inputs.put(userNameInputName, stringType);
91 String userpasswordInputName = blueprintHelperService.joinUnderscore(config, "password");
92 GetInput password = new GetInput(userpasswordInputName);
93 info.setPassword(password);
94 inputs.put(userpasswordInputName, stringType);
96 String userlocationInputName = blueprintHelperService.joinUnderscore(config, "location");
97 GetInput location = new GetInput(userlocationInputName);
98 info.setLocation(location);
99 inputs.put(userlocationInputName, stringType);
101 String userdeliveryUrlInputName = blueprintHelperService.joinUnderscore(config, "delivery_url");
102 GetInput deliveryUrl = new GetInput(userdeliveryUrlInputName);
103 info.setDelivery_url(deliveryUrl);
104 inputs.put(userdeliveryUrlInputName, stringType);
106 String usersubscriberIDInputName = blueprintHelperService.joinUnderscore(config, "subscriber_id");
107 GetInput subscriberID = new GetInput(usersubscriberIDInputName);
108 info.setSubscriber_id(subscriberID);
109 inputs.put(usersubscriberIDInputName, stringType);
111 response.put("info", info);
112 response.put("inputs", inputs);