3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * Copyright (c) 2020 Nokia. All rights reserved.
8 * * ================================================================================
9 * * Licensed under the Apache License, Version 2.0 (the "License");
10 * * you may not use this file except in compliance with the License.
11 * * You may obtain a copy of the License at
13 * * http://www.apache.org/licenses/LICENSE-2.0
15 * * Unless required by applicable law or agreed to in writing, software
16 * * distributed under the License is distributed on an "AS IS" BASIS,
17 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * * See the License for the specific language governing permissions and
19 * * limitations under the License.
20 * * ============LICENSE_END=========================================================
25 package org.onap.blueprintgenerator;
28 import static java.lang.System.exit;
30 import org.onap.blueprintgenerator.model.base.Blueprint;
31 import org.onap.blueprintgenerator.model.common.Input;
32 import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
33 import org.onap.blueprintgenerator.model.componentspec.base.ComponentSpec;
34 import org.onap.blueprintgenerator.service.BlueprintCreatorService;
35 import org.onap.blueprintgenerator.service.base.BlueprintService;
36 import org.onap.blueprintgenerator.service.common.CommonUtils;
37 import org.onap.blueprintgenerator.service.common.ComponentSpecService;
38 import org.onap.policycreate.service.PolicyModelService;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.boot.CommandLineRunner;
41 import org.springframework.boot.SpringApplication;
42 import org.springframework.boot.autoconfigure.SpringBootApplication;
43 import org.springframework.context.annotation.ComponentScan;
46 * @author : Ravi Mantena
47 * @date 10/16/2020 Application: ONAP - Blueprint Generator ONAP - Blueprint Generator Main
48 * Application to create Policy Models or Blueprints
50 @ComponentScan({"org.onap.blueprintgenerator", "org.onap.policycreate"})
51 @SpringBootApplication
52 public class BlueprintGeneratorMainApplication implements CommandLineRunner {
55 private ComponentSpecService componentSpecService;
58 private PolicyModelService policyModelService;
61 private CommonUtils commonUtils;
64 private PolicyModelService onapPolicyModelNodeService;
67 private ComponentSpecService onapComponentSpecService;
70 private CommonUtils onapCommonUtils;
73 private BlueprintCreatorService blueprintCreatorService;
76 private BlueprintService blueprintService;
79 * Main Application to run BPGen to generate Policies/Blueprint based on Input Arguments values
81 * @param args Input Arguments
83 public static void main(String[] args) {
84 SpringApplication.run(BlueprintGeneratorMainApplication.class, args);
88 * Creates Policies/Blueprint based on Input Arguments values
90 * @param args Input Arguments
93 public void run(String... args) {
94 if (args.length >= 2 && args[0].equals("app") && args[1].equals("ONAP")) {
95 onapCommonUtils.printInstructions();
96 if (args.length >= 4 && args[2].equals("-type") && args[3].equals("policycreate")) {
97 Input input = onapCommonUtils.parseInputs(args);
98 ComponentSpec componentSpec =
99 componentSpecService.createComponentSpecFromFile(input.getComponentSpecPath());
100 onapPolicyModelNodeService.createPolicyModels(
101 componentSpec.getParameters(), input.getOutputPath());
103 Input input = onapCommonUtils.parseInputs(args);
104 OnapComponentSpec onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath());
105 Blueprint blueprint = blueprintCreatorService.createBlueprint(onapComponentSpec, input);
106 blueprintService.blueprintToYaml(onapComponentSpec, blueprint, input);
107 System.out.println(blueprintService.blueprintToString(onapComponentSpec, blueprint, input));