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
41 * Application: DCAE/ONAP - Blueprint Generator
42 * Common Module: Used by ONAP Blueprint Application
43 * Service: For Imports
47 public class ImportsService {
49 @Value("${imports.onap.types}")
50 private String importsOnapTypes;
52 @Value("${imports.onap.K8s.plugintypes}")
53 private String importsOnapK8sPlugintypes;
55 @Value("${imports.onap.K8s.dcaepolicyplugin}")
56 private String importsOnapK8sDcaepolicyplugin;
58 @Value("${imports.dmaap.dmaapplugin}")
59 private String importsDmaapDmaapplugin;
61 @Value("${import.Postgres}")
62 private String importPostgres;
64 @Value("${import.Clamp}")
65 private String importClamp;
68 @Qualifier("yamlObjectMapper")
70 protected ObjectMapper yamlObjectMapper;
72 public List<String> createImports(String bpType) {
73 List<String> imports = new ArrayList<>();
74 if (bpType.equals("o")) {
75 imports.add(importsOnapTypes);
76 imports.add(importsOnapK8sPlugintypes);
77 imports.add(importsOnapK8sDcaepolicyplugin);
78 imports.add(importPostgres);
79 imports.add(importClamp);
82 imports.add(importsOnapTypes);
83 imports.add(importsOnapK8sPlugintypes);
84 imports.add(importsDmaapDmaapplugin);
85 imports.add(importPostgres);
86 imports.add(importClamp);
91 public List<String> createImportsFromFile(String path) throws IOException {
92 File importPath = new File(path);
93 Imports imports = yamlObjectMapper.readValue(importPath, Imports.class);
94 imports.getImports().removeIf(String::isBlank);
95 return imports.getImports();