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.common;
26 import com.fasterxml.jackson.databind.ObjectMapper;
27 import org.onap.blueprintgenerator.model.common.Imports;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.beans.factory.annotation.Qualifier;
30 import org.springframework.beans.factory.annotation.Value;
31 import org.springframework.stereotype.Service;
34 import java.io.IOException;
35 import java.util.ArrayList;
36 import java.util.List;
39 * @author : Ravi Mantena
40 * @date 10/16/2020 Application: DCAE/ONAP - Blueprint Generator Common Module: Used by ONAP
41 * Blueprint Application Service: For Imports
44 public class ImportsService {
46 @Value("${imports.onap.types}")
47 private String importsOnapTypes;
49 @Value("${imports.onap.K8s.plugintypes}")
50 private String importsOnapK8sPlugintypes;
52 @Value("${imports.onap.K8s.dcaepolicyplugin}")
53 private String importsOnapK8sDcaepolicyplugin;
55 @Value("${imports.dmaap.dmaapplugin}")
56 private String importsDmaapDmaapplugin;
58 @Value("${import.Postgres}")
59 private String importPostgres;
61 @Value("${import.Clamp}")
62 private String importClamp;
64 @Qualifier("yamlObjectMapper")
66 protected ObjectMapper yamlObjectMapper;
69 * Creates Imports for Blueprint based on Blueprint Type
71 * @param bpType Blueprint Type
74 public List<String> createImports(String bpType) {
75 List<String> imports = new ArrayList<>();
76 if (bpType.equals("o")) {
77 imports.add(importsOnapTypes);
78 imports.add(importsOnapK8sPlugintypes);
79 imports.add(importsOnapK8sDcaepolicyplugin);
80 imports.add(importPostgres);
81 imports.add(importClamp);
83 imports.add(importsOnapTypes);
84 imports.add(importsOnapK8sPlugintypes);
85 imports.add(importsDmaapDmaapplugin);
86 imports.add(importPostgres);
87 imports.add(importClamp);
93 * Creates Imports for Blueprint from the file path provided
95 * @param path Path of Import File
98 public List<String> createImportsFromFile(String path) throws IOException {
99 File importPath = new File(path);
100 Imports imports = yamlObjectMapper.readValue(importPath, Imports.class);
101 imports.getImports().removeIf(String::isBlank);
102 return imports.getImports();