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.base;
26 import org.onap.blueprintgenerator.constants.Constants;
27 import org.springframework.stereotype.Service;
29 import java.util.LinkedHashMap;
32 * @author : Ravi Mantena
33 * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by both ONAp
34 * and DCAE Blueprint Applications Service: An interface for Common Functions used across Blueprint
37 public class BlueprintHelperService {
40 * creates Input value by contatinating Type, Description and Default value
42 * @param type Input Type
43 * @param description Description
44 * @param defaultValue Default value of Type
47 public LinkedHashMap<String, Object> createInputValue(
48 String type, String description, Object defaultValue) {
49 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
50 inputMap.put("type", type);
51 inputMap.put("description", description);
52 inputMap.put("default", defaultValue);
57 * creates Input value by contatinating Type and Description
59 * @param type Input Type
60 * @param description Description
63 public LinkedHashMap<String, Object> createInputValue(String type, String description) {
64 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
65 inputMap.put("type", type);
66 inputMap.put("description", description);
71 * creates Input value by contatinating Type and Default value
73 * @param type Input Type
74 * @param defaultValue Default value of Type
77 public LinkedHashMap<String, Object> createInputValue(String type, Object defaultValue) {
78 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
79 inputMap.put("type", type);
80 inputMap.put("default", defaultValue);
85 * creates Input value by contatinating Description and Default value
87 * @param description Description
88 * @param defaultValue Default value of Type
91 public LinkedHashMap<String, Object> createIntegerInput(String description,
92 Object defaultValue) {
93 return createInputValue(Constants.INTEGER_TYPE, description, defaultValue);
97 * creates Integer Input value for given Description
99 * @param description Description
102 public LinkedHashMap<String, Object> createIntegerInput(String description) {
103 return createInputValue(Constants.INTEGER_TYPE, description);
107 * creates Integer Input value for given Default value
109 * @param defaultValue Default value of Type
112 public LinkedHashMap<String, Object> createIntegerInput(Object defaultValue) {
113 return createInputValue(Constants.INTEGER_TYPE, defaultValue);
117 * creates Integer Input value for given Description and Default value
119 * @param description Description
120 * @param defaultValue Default value of Type
123 public LinkedHashMap<String, Object> createBooleanInput(String description,
124 Object defaultValue) {
125 return createInputValue(Constants.BOOLEAN_TYPE, description, defaultValue);
129 * creates Boolean Input value for given Description
131 * @param description Description
134 public LinkedHashMap<String, Object> createBooleanInput(String description) {
135 return createInputValue(Constants.BOOLEAN_TYPE, description);
139 * creates Boolean Input value for given Default value
141 * @param defaultValue Default value of Type
144 public LinkedHashMap<String, Object> createBooleanInput(Object defaultValue) {
145 return createInputValue(Constants.BOOLEAN_TYPE, defaultValue);
149 * creates String Input value for given Default value
150 * @param description Description
151 * @param defaultValue Default value of Type
154 public LinkedHashMap<String, Object> createStringInput(String description,
155 Object defaultValue) {
156 return createInputValue(Constants.STRING_TYPE, description, defaultValue);
159 /* public LinkedHashMap<String, Object> createStringInput(String description){
160 return createInputValue(Constants.STRING_TYPE, description);
164 * creates String Input value for given Default value
166 * @param defaultValue Default value of Type
169 public LinkedHashMap<String, Object> createStringInput(Object defaultValue) {
170 return createInputValue(Constants.STRING_TYPE, defaultValue);
174 * Concatenates String Input values with Underscore
176 * @param firstValue Value
177 * @param secondValue Value
180 public String joinUnderscore(String firstValue, String secondValue) {
181 return firstValue + "_" + secondValue;
185 * Returns if the type is Data Router or not
187 * @param type Input Type
190 public boolean isDataRouterType(String type) {
191 return type.equals(Constants.DATA_ROUTER) || type.equals(Constants.DATAROUTER_VALUE);
195 * Returns if the type is Message Router or not
197 * @param type Input Type
200 public boolean isMessageRouterType(String type) {
201 return type.equals(Constants.MESSAGE_ROUTER) || type.equals(Constants.MESSAGEROUTER_VALUE);
205 * Returns name with underscore for empty input
210 public String getNamePrefix(String name) {
211 return name.isEmpty() ? "" : name + "_";