diff options
author | 2020-12-29 15:03:39 +0100 | |
---|---|---|
committer | 2021-01-12 20:49:57 +0000 | |
commit | cc39d3bce13f716adc3335d4d46a25606598314e (patch) | |
tree | 778bd13ce9eec287e4181ce1096bdb6e4d87fb2e /mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web | |
parent | 9e6c1c2715ac147f39978bb005a6b2ad8ffcf8a0 (diff) |
Update runtime-api with refactored bp-gen
Issue-ID: DCAEGEN2-2529
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: I763a46e01d259b25c656de7544949f19a1e01e11
Diffstat (limited to 'mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web')
-rw-r--r-- | mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java index 0741bfa..ef34ecd 100644 --- a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java +++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java @@ -1,13 +1,14 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nokia. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +18,42 @@ */ package org.onap.dcae.runtime.web.configuration; +import java.io.IOException; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.onap.blueprintgenerator.BlueprintGeneratorConfiguration; +import org.onap.blueprintgenerator.service.BlueprintCreatorService; +import org.onap.blueprintgenerator.service.base.BlueprintService; +import org.onap.blueprintgenerator.service.base.FixesService; +import org.onap.blueprintgenerator.service.common.ComponentSpecService; import org.onap.dcae.runtime.core.FlowGraphParser; import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; import org.yaml.snakeyaml.Yaml; -import java.io.IOException; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - @Configuration +@Import(BlueprintGeneratorConfiguration.class) public class BlueprintCreatorConfig { - @Autowired - Environment env; - + private final Environment env; + private final BlueprintService blueprintService; + private final ComponentSpecService componentSpecService; + private final BlueprintCreatorService blueprintCreatorService; + private final FixesService fixesService; + @Value("${onap.topicUrl}") String onapDublinTopicUrl; @@ -68,12 +78,24 @@ public class BlueprintCreatorConfig { @Value("${onap.import.dmaapPlugin}") String onapDublinImportDmaapPlugin; + @Autowired + public BlueprintCreatorConfig(Environment env, BlueprintService blueprintService, + ComponentSpecService componentSpecService, BlueprintCreatorService blueprintCreatorService, + FixesService fixesService) { + this.env = env; + this.blueprintService = blueprintService; + this.componentSpecService = componentSpecService; + this.blueprintCreatorService = blueprintCreatorService; + this.fixesService = fixesService; + } + @Profile("onap") @Primary @Bean - public FlowGraphParser getFlowGraphParserForOnapDublin(){ - BlueprintCreatorOnap blueprintCreatorOnap = new BlueprintCreatorOnap(); + public FlowGraphParser getFlowGraphParserForOnapDublin() { + BlueprintCreatorOnap blueprintCreatorOnap = new BlueprintCreatorOnap(componentSpecService, + blueprintCreatorService, blueprintService, fixesService); blueprintCreatorOnap.setImportFilePath(writeImportsTofile()); blueprintCreatorOnap.setUseDmaapPlugin(useDmaapPlugin); FlowGraphParser flowGraphParser = new FlowGraphParser(blueprintCreatorOnap); @@ -85,7 +107,7 @@ public class BlueprintCreatorConfig { String fielPath = ""; try { Path path = createDataImportDirAndImportFile(); - fielPath = Files.write(path,contentToWrite.getBytes()).toString(); + fielPath = Files.write(path, contentToWrite.getBytes()).toString(); new String(Files.readAllBytes(path)); } catch (IOException e) { e.printStackTrace(); @@ -100,17 +122,15 @@ public class BlueprintCreatorConfig { try { Files.createDirectories(importDirPath); Files.createFile(onapImportFilePath); - } - catch (FileAlreadyExistsException ignored){ - } - catch (IOException e) { + } catch (FileAlreadyExistsException ignored) { + } catch (IOException e) { e.printStackTrace(); } return onapImportFilePath; } private String getContentToWrite() { - Map<String,Object> result = new HashMap<String, Object>(); + Map<String, Object> result = new HashMap<String, Object>(); List<String> importList = new ArrayList<String>(); importList.add(onapDublinImportCloudifyPlugin); importList.add(onapDublinImportK8sPlugin); @@ -119,10 +139,8 @@ public class BlueprintCreatorConfig { importList.add(onapDublinImportPostgresPlugin); importList.add(onapDublinImportClampPlugin); importList.add(onapDublinImportDmaapPlugin); - - - - result.put("imports",importList); + + result.put("imports", importList); return new Yaml().dump(result); } |