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