[DCAE] INFO.yaml update
[dcaegen2/platform.git] / mod / bpgenerator / onap / src / main / java / org / onap / blueprintgenerator / service / BlueprintCreatorService.java
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.dcae
4  * ================================================================================
5  * Copyright (C) 2020 Nokia. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.blueprintgenerator.service;
22
23 import org.onap.blueprintgenerator.model.base.Blueprint;
24 import org.onap.blueprintgenerator.model.common.Input;
25 import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
26 import org.onap.blueprintgenerator.service.dmaap.DmaapBlueprintCreatorService;
27 import org.onap.blueprintgenerator.service.onap.OnapBlueprintCreatorService;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Service;
30
31 /**
32  * @author : Remigiusz Janeczek
33  * @date 12/17/2020 Application: ONAP - Blueprint Generator Service to create ONAP and DMAAP Blueprints
34  */
35 @Service
36 public class BlueprintCreatorService {
37
38     private final OnapBlueprintCreatorService onapBlueprintCreatorService;
39
40     private final DmaapBlueprintCreatorService dmaapBlueprintCreatorService;
41
42     @Autowired
43     public BlueprintCreatorService(OnapBlueprintCreatorService onapBlueprintCreatorService,
44         DmaapBlueprintCreatorService dmaapBlueprintCreatorService) {
45         this.onapBlueprintCreatorService = onapBlueprintCreatorService;
46         this.dmaapBlueprintCreatorService = dmaapBlueprintCreatorService;
47     }
48
49     /**
50      * Creates Blueprint from given OnapComponentSpec and Input objects if the input is json file or not
51      *
52      * @param componentSpec OnapComponentSpec object
53      * @param input         Input object, needs to have bpType defined (either as "o" (ONAP Blueprint) or "d" (DMAAP
54      *                      Blueprint)
55      * @return blueprint generated from componentSpec and input
56      */
57     public Blueprint createBlueprint(OnapComponentSpec componentSpec, Input input) {
58         if (input.getBpType() == null) {
59             return null;
60         }
61         Blueprint blueprint = null;
62         if (input.getBpType().equals("o")) {
63             blueprint = onapBlueprintCreatorService.createBlueprint(componentSpec, input);
64         } else if (input.getBpType().equals("d")) {
65             blueprint = dmaapBlueprintCreatorService.createBlueprint(componentSpec, input);
66         }
67         return blueprint;
68     }
69
70 }