3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * ================================================================================
8 * * Modifications Copyright (c) 2021 Nokia
9 * * ================================================================================
10 * * Licensed under the Apache License, Version 2.0 (the "License");
11 * * you may not use this file except in compliance with the License.
12 * * You may obtain a copy of the License at
14 * * http://www.apache.org/licenses/LICENSE-2.0
16 * * Unless required by applicable law or agreed to in writing, software
17 * * distributed under the License is distributed on an "AS IS" BASIS,
18 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * * See the License for the specific language governing permissions and
20 * * limitations under the License.
21 * * ============LICENSE_END=========================================================
26 package org.onap.blueprintgenerator.service.base;
28 import org.onap.blueprintgenerator.constants.Constants;
29 import org.springframework.stereotype.Service;
31 import java.util.LinkedHashMap;
34 * @author : Ravi Mantena
35 * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAp
36 * and DCAE Blueprint Applications Service: An interface for Common Functions used across Blueprint
39 public class BlueprintHelperService {
42 * creates Input value by contatinating Type, Description and Default value
44 * @param type Input Type
45 * @param description Description
46 * @param defaultValue Default value of Type
49 public LinkedHashMap<String, Object> createInputValue(
50 String type, String description, Object defaultValue) {
51 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
52 inputMap.put("type", type);
53 inputMap.put("description", description);
54 inputMap.put("default", defaultValue);
59 * creates Input value by contatinating Type and Description
61 * @param type Input Type
62 * @param description Description
65 public LinkedHashMap<String, Object> createInputValue(String type, String description) {
66 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
67 inputMap.put("type", type);
68 inputMap.put("description", description);
73 * creates Input value by contatinating Type and Default value
75 * @param type Input Type
76 * @param defaultValue Default value of Type
79 public LinkedHashMap<String, Object> createInputValue(String type, Object defaultValue) {
80 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
81 inputMap.put("type", type);
82 inputMap.put("default", defaultValue);
87 * creates Input value by contatinating Description and Default value
89 * @param description Description
90 * @param defaultValue Default value of Type
93 public LinkedHashMap<String, Object> createIntegerInput(String description,
94 Object defaultValue) {
95 return createInputValue(Constants.INTEGER_TYPE, description, defaultValue);
99 * creates Integer Input value for given Description
101 * @param description Description
104 public LinkedHashMap<String, Object> createIntegerInput(String description) {
105 return createInputValue(Constants.INTEGER_TYPE, description);
109 * creates Integer Input value for given Default value
111 * @param defaultValue Default value of Type
114 public LinkedHashMap<String, Object> createIntegerInput(Object defaultValue) {
115 return createInputValue(Constants.INTEGER_TYPE, defaultValue);
119 * creates Integer Input value for given Description and Default value
121 * @param description Description
122 * @param defaultValue Default value of Type
125 public LinkedHashMap<String, Object> createBooleanInput(String description,
126 Object defaultValue) {
127 return createInputValue(Constants.BOOLEAN_TYPE, description, defaultValue);
131 * creates Boolean Input value for given Description
133 * @param description Description
136 public LinkedHashMap<String, Object> createBooleanInput(String description) {
137 return createInputValue(Constants.BOOLEAN_TYPE, description);
141 * creates Boolean Input value for given Default value
143 * @param defaultValue Default value of Type
146 public LinkedHashMap<String, Object> createBooleanInput(Object defaultValue) {
147 return createInputValue(Constants.BOOLEAN_TYPE, defaultValue);
151 * creates String Input value for given Default value
152 * @param description Description
153 * @param defaultValue Default value of Type
156 public LinkedHashMap<String, Object> createStringInput(String description,
157 Object defaultValue) {
158 return createInputValue(Constants.STRING_TYPE, description, defaultValue);
161 /* public LinkedHashMap<String, Object> createStringInput(String description){
162 return createInputValue(Constants.STRING_TYPE, description);
166 * creates String Input value for given Default value
168 * @param defaultValue Default value of Type
171 public LinkedHashMap<String, Object> createStringInput(Object defaultValue) {
172 return createInputValue(Constants.STRING_TYPE, defaultValue);
176 * Concatenates String Input values with Underscore
178 * @param firstValue Value
179 * @param secondValue Value
182 public String joinUnderscore(String firstValue, String secondValue) {
183 return firstValue + "_" + secondValue;
187 * Returns if the type is Data Router or not
189 * @param type Input Type
192 public boolean isDataRouterType(String type) {
193 return type.equals(Constants.DATA_ROUTER) || type.equals(Constants.DATAROUTER_VALUE);
197 * Returns if the type is Message Router or not
199 * @param type Input Type
202 public boolean isMessageRouterType(String type) {
203 return type.equals(Constants.MESSAGE_ROUTER) || type.equals(Constants.MESSAGEROUTER_VALUE);
207 * Returns if the type is Kafka or not
209 * @param type Input Type
212 public boolean isKafkaStreamType(String type) {
213 return type.equals(Constants.KAFKA_TYPE);
217 * Returns name with underscore for empty input
222 public String getNamePrefix(String name) {
223 return name.isEmpty() ? "" : name + "_";