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;
27 import org.onap.blueprintgenerator.model.base.Blueprint;
28 import org.onap.blueprintgenerator.model.common.Input;
29 import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
30 import org.onap.blueprintgenerator.model.componentspec.base.ComponentSpec;
31 import org.onap.blueprintgenerator.service.OnapBlueprintService;
32 import org.onap.blueprintgenerator.service.common.CommonUtils;
33 import org.onap.blueprintgenerator.service.common.ComponentSpecService;
34 import org.onap.blueprintgenerator.service.dmaap.DmaapBlueprintService;
35 import org.onap.policycreate.service.PolicyModelService;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.boot.CommandLineRunner;
38 import org.springframework.boot.SpringApplication;
39 import org.springframework.boot.autoconfigure.SpringBootApplication;
40 import org.springframework.context.annotation.ComponentScan;
42 import static java.lang.System.exit;
45 * @author : Ravi Mantena
47 * Application: ONAP - Blueprint Generator
48 * ONAP - Blueprint Generator Main Application to create Policy Models or Blueprints
51 @ComponentScan({"org.onap.blueprintgenerator","org.onap.policycreate"})
52 @SpringBootApplication
53 public class BlueprintGeneratorMainApplication implements CommandLineRunner {
56 private ComponentSpecService componentSpecService;
59 private PolicyModelService policyModelService;
62 private CommonUtils commonUtils;
65 private PolicyModelService onapPolicyModelNodeService;
68 private ComponentSpecService onapComponentSpecService;
71 private CommonUtils onapCommonUtils;
74 private OnapBlueprintService onapBlueprintService;
77 private DmaapBlueprintService dmaapBlueprintService;
79 public static void main(String[] args) {
80 SpringApplication.run(BlueprintGeneratorMainApplication.class, args);
84 public void run(String... args) {
85 if (args.length >=2 && args[0].equals("app") && args[1].equals("ONAP")) {
86 onapCommonUtils.printInstructions();
87 if(args.length >=4 && args[2].equals("-type") && args[3].equals("policycreate")){
88 Input input = onapCommonUtils.parseInputs(args);
89 ComponentSpec componentSpec = componentSpecService.createComponentSpecFromFile(input.getComponentSpecPath());
90 onapPolicyModelNodeService.createPolicyModels(componentSpec.getParameters(), input.getOutputPath());
93 Input input = onapCommonUtils.parseInputs(args);
94 OnapComponentSpec onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath());
95 if (input.getBpType().equals("o")) {
96 Blueprint blueprint = onapBlueprintService.createBlueprint(onapComponentSpec, input);
97 onapBlueprintService.blueprintToYaml(onapComponentSpec, blueprint, input);
98 System.out.println(onapBlueprintService.blueprintToString(onapComponentSpec, blueprint, input));
99 } else if (input.getBpType().equals("d")) {
100 Blueprint blueprint = dmaapBlueprintService.createBlueprint(onapComponentSpec, input);
101 dmaapBlueprintService.blueprintToYaml(onapComponentSpec, blueprint, input);
102 System.out.println(dmaapBlueprintService.blueprintToString(onapComponentSpec, blueprint, input));