summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator/onap/src/main/java
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-12-17 14:27:01 +0100
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2021-01-04 22:25:10 +0100
commita3c8fc0395e9518c5f0f064a033f4ab4d7040c61 (patch)
tree47e230a0c6ba06a58965d461ba4153dcfaf68f71 /mod/bpgenerator/onap/src/main/java
parent7e2f7f78aa649ded0d3b9018da7a9d4b6bcb5ecc (diff)
Blueprint Generator - Refactor blueprint generation.
Issue-ID: DCAEGEN2-2529 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: I72959f3e6c27d301e46ede24c015ce638d8de324
Diffstat (limited to 'mod/bpgenerator/onap/src/main/java')
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java36
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/BlueprintCreatorService.java70
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintCreatorService.java (renamed from mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java)3
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/onap/OnapBlueprintCreatorService.java (renamed from mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java)5
4 files changed, 87 insertions, 27 deletions
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java
index d680919..796424f 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 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.
@@ -23,14 +24,17 @@
package org.onap.blueprintgenerator;
+
+import static java.lang.System.exit;
+
import org.onap.blueprintgenerator.model.base.Blueprint;
import org.onap.blueprintgenerator.model.common.Input;
import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
import org.onap.blueprintgenerator.model.componentspec.base.ComponentSpec;
-import org.onap.blueprintgenerator.service.OnapBlueprintService;
+import org.onap.blueprintgenerator.service.BlueprintCreatorService;
+import org.onap.blueprintgenerator.service.base.BlueprintService;
import org.onap.blueprintgenerator.service.common.CommonUtils;
import org.onap.blueprintgenerator.service.common.ComponentSpecService;
-import org.onap.blueprintgenerator.service.dmaap.DmaapBlueprintService;
import org.onap.policycreate.service.PolicyModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
@@ -38,8 +42,6 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
-import static java.lang.System.exit;
-
/**
* @author : Ravi Mantena
* @date 10/16/2020 Application: ONAP - Blueprint Generator ONAP - Blueprint Generator Main
@@ -68,10 +70,10 @@ public class BlueprintGeneratorMainApplication implements CommandLineRunner {
private CommonUtils onapCommonUtils;
@Autowired
- private OnapBlueprintService onapBlueprintService;
+ private BlueprintCreatorService blueprintCreatorService;
@Autowired
- private DmaapBlueprintService dmaapBlueprintService;
+ private BlueprintService blueprintService;
/**
* Main Application to run BPGen to generate Policies/Blueprint based on Input Arguments values
@@ -99,24 +101,10 @@ public class BlueprintGeneratorMainApplication implements CommandLineRunner {
componentSpec.getParameters(), input.getOutputPath());
} else {
Input input = onapCommonUtils.parseInputs(args);
- OnapComponentSpec onapComponentSpec =
- onapComponentSpecService
- .createComponentSpecFromFile(input.getComponentSpecPath());
- if (input.getBpType().equals("o")) {
- Blueprint blueprint = onapBlueprintService
- .createBlueprint(onapComponentSpec, input);
- onapBlueprintService.blueprintToYaml(onapComponentSpec, blueprint, input);
- System.out.println(
- onapBlueprintService
- .blueprintToString(onapComponentSpec, blueprint, input));
- } else if (input.getBpType().equals("d")) {
- Blueprint blueprint = dmaapBlueprintService
- .createBlueprint(onapComponentSpec, input);
- dmaapBlueprintService.blueprintToYaml(onapComponentSpec, blueprint, input);
- System.out.println(
- dmaapBlueprintService
- .blueprintToString(onapComponentSpec, blueprint, input));
- }
+ OnapComponentSpec onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath());
+ Blueprint blueprint = blueprintCreatorService.createBlueprint(onapComponentSpec, input);
+ blueprintService.blueprintToYaml(onapComponentSpec, blueprint, input);
+ System.out.println(blueprintService.blueprintToString(onapComponentSpec, blueprint, input));
}
}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/BlueprintCreatorService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/BlueprintCreatorService.java
new file mode 100644
index 0000000..48c196e
--- /dev/null
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/BlueprintCreatorService.java
@@ -0,0 +1,70 @@
+/*
+ * ============LICENSE_START=======================================================
+ * org.onap.dcae
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.service;
+
+import org.onap.blueprintgenerator.model.base.Blueprint;
+import org.onap.blueprintgenerator.model.common.Input;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.service.dmaap.DmaapBlueprintCreatorService;
+import org.onap.blueprintgenerator.service.onap.OnapBlueprintCreatorService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author : Remigiusz Janeczek
+ * @date 12/17/2020 Application: ONAP - Blueprint Generator Service to create ONAP and DMAAP Blueprints
+ */
+@Service
+public class BlueprintCreatorService {
+
+ private final OnapBlueprintCreatorService onapBlueprintCreatorService;
+
+ private final DmaapBlueprintCreatorService dmaapBlueprintCreatorService;
+
+ @Autowired
+ public BlueprintCreatorService(OnapBlueprintCreatorService onapBlueprintCreatorService,
+ DmaapBlueprintCreatorService dmaapBlueprintCreatorService) {
+ this.onapBlueprintCreatorService = onapBlueprintCreatorService;
+ this.dmaapBlueprintCreatorService = dmaapBlueprintCreatorService;
+ }
+
+ /**
+ * Creates Blueprint from given OnapComponentSpec and Input objects if the input is json file or not
+ *
+ * @param componentSpec OnapComponentSpec object
+ * @param input Input object, needs to have bpType defined (either as "o" (ONAP Blueprint) or "d" (DMAAP
+ * Blueprint)
+ * @return blueprint generated from componentSpec and input
+ */
+ public Blueprint createBlueprint(OnapComponentSpec componentSpec, Input input) {
+ if (input.getBpType() == null) {
+ return null;
+ }
+ Blueprint blueprint = null;
+ if (input.getBpType().equals("o")) {
+ blueprint = onapBlueprintCreatorService.createBlueprint(componentSpec, input);
+ } else if (input.getBpType().equals("d")) {
+ blueprint = dmaapBlueprintCreatorService.createBlueprint(componentSpec, input);
+ }
+ return blueprint;
+ }
+
+}
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintCreatorService.java
index 9da2074..bf68f81 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintCreatorService.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 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.
@@ -51,7 +52,7 @@ import java.util.TreeMap;
* @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create DMAAP Blueprint
*/
@Service
-public class DmaapBlueprintService extends BlueprintService {
+public class DmaapBlueprintCreatorService {
@Autowired
protected ImportsService importsService;
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/onap/OnapBlueprintCreatorService.java
index 748facf..afc02f3 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/onap/OnapBlueprintCreatorService.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 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.
@@ -21,7 +22,7 @@
*
*/
-package org.onap.blueprintgenerator.service;
+package org.onap.blueprintgenerator.service.onap;
import org.onap.blueprintgenerator.constants.Constants;
import org.onap.blueprintgenerator.exception.BlueprintException;
@@ -48,7 +49,7 @@ import java.util.TreeMap;
* @date 10/16/2020 Application: ONAP - Blueprint Generator Service to create ONAP Blueprint
*/
@Service
-public class OnapBlueprintService extends BlueprintService {
+public class OnapBlueprintCreatorService {
@Autowired
private NodeService nodeService;