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;
27 import org.onap.blueprintgenerator.constants.Constants;
28 import org.springframework.stereotype.Service;
30 import java.util.LinkedHashMap;
33 * @author : Ravi Mantena
35 * Application: DCAE/ONAP - Blueprint Generator
36 * Common Module: Used by both ONAp and DCAE Blueprint Applications
37 * Service: For Common Functions used across
41 public class BlueprintHelperService {
44 public LinkedHashMap<String, Object> createInputValue(String type, String description, Object defaultValue) {
45 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
46 inputMap.put("type", type);
47 inputMap.put("description", description);
48 inputMap.put("default", defaultValue);
52 public LinkedHashMap<String, Object> createInputValue(String type, String description) {
53 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
54 inputMap.put("type", type);
55 inputMap.put("description", description);
59 public LinkedHashMap<String, Object> createInputValue(String type, Object defaultValue) {
60 LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
61 inputMap.put("type", type);
62 inputMap.put("default", defaultValue);
66 public LinkedHashMap<String, Object> createIntegerInput(String description, Object defaultValue){
67 return createInputValue(Constants.INTEGER_TYPE, description, defaultValue);
70 public LinkedHashMap<String, Object> createIntegerInput(String description){
71 return createInputValue(Constants.INTEGER_TYPE, description);
74 public LinkedHashMap<String, Object> createIntegerInput(Object defaultValue){
75 return createInputValue(Constants.INTEGER_TYPE, defaultValue);
78 public LinkedHashMap<String, Object> createBooleanInput(String description, Object defaultValue){
79 return createInputValue(Constants.BOOLEAN_TYPE, description, defaultValue);
82 public LinkedHashMap<String, Object> createBooleanInput(String description){
83 return createInputValue(Constants.BOOLEAN_TYPE, description);
86 public LinkedHashMap<String, Object> createBooleanInput(Object defaultValue){
87 return createInputValue(Constants.BOOLEAN_TYPE, defaultValue);
90 public LinkedHashMap<String, Object> createStringInput(String description, Object defaultValue){
91 return createInputValue(Constants.STRING_TYPE, description, defaultValue);
94 /* public LinkedHashMap<String, Object> createStringInput(String description){
95 return createInputValue(Constants.STRING_TYPE, description);
98 public LinkedHashMap<String, Object> createStringInput(Object defaultValue){
99 return createInputValue(Constants.STRING_TYPE, defaultValue);
102 public String joinUnderscore(String firstValue, String secondValue){
103 return firstValue + "_" + secondValue;
106 public boolean isDataRouterType(String type) {
107 return type.equals(Constants.DATA_ROUTER) || type.equals(Constants.DATAROUTER_VALUE);
110 public boolean isMessageRouterType(String type) {
111 return type.equals(Constants.MESSAGE_ROUTER) || type.equals(Constants.MESSAGEROUTER_VALUE);
114 public String getNamePrefix(String name) {
115 return name.isEmpty() ? "" : name + "_";