Controller Blueprints Nitrogen to Oxygen Migration
[ccsdk/features.git] / blueprints-processor / plugin / assignment-provider / src / main / java / org / onap / ccsdk / features / assignment / service / ConfigAssignmentServiceImpl.java
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  * Modifications Copyright © 2018 IBM.\r
4  * \r
5  * Licensed under the Apache License, Version 2.0 (the "License");\r
6  * you may not use this file except in compliance with the License.\r
7  * You may obtain a copy of the License at\r
8  * \r
9  * http://www.apache.org/licenses/LICENSE-2.0\r
10  * \r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 \r
18 package org.onap.ccsdk.features.assignment.service;\r
19 \r
20 import java.util.List;\r
21 \r
22 import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData;\r
23 import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService;\r
24 import org.onap.ccsdk.features.generator.service.ConfigGeneratorService;\r
25 import org.onap.ccsdk.features.model.data.ResourceAssignment;\r
26 import org.onap.ccsdk.features.model.service.ComponentNodeService;\r
27 import org.onap.ccsdk.features.model.service.ConfigModelService;\r
28 import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService;\r
29 import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
30 import com.att.eelf.configuration.EELFLogger;\r
31 import com.att.eelf.configuration.EELFManager;\r
32 \r
33 public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {\r
34 \r
35     private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentServiceImpl.class);\r
36 \r
37     private ComponentNodeService componentNodeService;\r
38     private ConfigResourceService configResourceService;\r
39     private ConfigModelService configModelService;\r
40     private ConfigRestAdaptorService configRestAdaptorService;\r
41     private ConfigGeneratorService configGeneratorService;\r
42 \r
43     private static final String CLASS_NAME = "ConfigAssignmentServiceImpl";\r
44 \r
45     public ConfigAssignmentServiceImpl(ConfigResourceService configResourceService,\r
46             ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,\r
47             ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {\r
48         logger.info("{} Constuctor Initated...", CLASS_NAME);\r
49         this.componentNodeService = componentNodeService;\r
50         this.configResourceService = configResourceService;\r
51         this.configModelService = configModelService;\r
52         this.configRestAdaptorService = configRestAdaptorService;\r
53         this.configGeneratorService = configGeneratorService;\r
54     }\r
55 \r
56     @Override\r
57     public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {\r
58         ConfigAssignmentProcessService configAssignmentProcessService =\r
59                 new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService, configModelService,\r
60                         componentNodeService, configGeneratorService);\r
61         configAssignmentProcessService.resolveResources(resourceAssignmentData);\r
62     }\r
63 \r
64     @Override\r
65     public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,\r
66             List<ResourceAssignment> resourceAssignments) throws SvcLogicException {\r
67         ConfigAssignmentPersistService configAssignmentPersistService =\r
68                 new ConfigAssignmentPersistService(configResourceService);\r
69         configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);\r
70     }\r
71 \r
72     @Override\r
73     public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)\r
74             throws SvcLogicException {\r
75         ConfigPreviewService configPreviewService =\r
76                 new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);\r
77         return configPreviewService.generateTemplateResourceMash(resourceAssignmentData);\r
78     }\r
79 \r
80 }\r