Merge "Fix Holmes delegates and sdc"
[clamp.git] / src / main / java / org / onap / clamp / clds / config / CldsConfiguration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             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
11  * 
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * 
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============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.config;
25
26 import com.att.ajsc.common.AjscProvider;
27 import com.att.ajsc.common.AjscService;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import javax.sql.DataSource;
33 import javax.xml.transform.TransformerConfigurationException;
34
35 import org.onap.clamp.clds.client.CldsEventDelegate;
36 import org.onap.clamp.clds.client.DcaeDispatcherServices;
37 import org.onap.clamp.clds.client.DcaeInventoryServices;
38 import org.onap.clamp.clds.client.DcaeReqDelegate;
39 import org.onap.clamp.clds.client.DcaeReqDeleteDelegate;
40 import org.onap.clamp.clds.client.HolmesPolicyDelegate;
41 import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate;
42 import org.onap.clamp.clds.client.OperationalPolicyDelegate;
43 import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate;
44 import org.onap.clamp.clds.client.PolicyClient;
45 import org.onap.clamp.clds.client.SdcCatalogServices;
46 import org.onap.clamp.clds.client.SdcSendReqDelegate;
47 import org.onap.clamp.clds.client.StringMatchPolicyDelegate;
48 import org.onap.clamp.clds.client.StringMatchPolicyDeleteDelegate;
49 import org.onap.clamp.clds.client.TcaPolicyDelegate;
50 import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate;
51 import org.onap.clamp.clds.dao.CldsDao;
52 import org.onap.clamp.clds.model.refprop.RefProp;
53 import org.onap.clamp.clds.transform.XslTransformer;
54 import org.springframework.beans.factory.annotation.Autowired;
55 import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
56 import org.springframework.boot.context.properties.ConfigurationProperties;
57 import org.springframework.context.ApplicationContext;
58 import org.springframework.context.annotation.Bean;
59 import org.springframework.context.annotation.Configuration;
60 import org.springframework.context.annotation.Profile;
61
62 @Configuration
63 @Profile("clamp-default")
64 public class CldsConfiguration {
65
66     @Autowired
67     private ApplicationContext context;
68
69     /**
70      * Clds Identity databse DataSource configuration
71      */
72     @Bean(name = "cldsDataSource")
73     @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
74     public DataSource cldsDataSource() {
75         return DataSourceBuilder.create().build();
76     }
77
78     @Bean(name = "jaxrsProviders")
79     public List<?> jaxrsProviders() {
80         return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
81     }
82
83     @Bean(name = "jaxrsServices")
84     public List<?> jaxrsServices() {
85         return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
86     }
87
88     @Bean(name = "cldsDao")
89     public CldsDao getCldsDao() {
90         CldsDao cldsDao = new CldsDao();
91         cldsDao.setDataSource(cldsDataSource());
92         return cldsDao;
93     }
94
95     @Bean(name = "cldsBpmnTransformer")
96     public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
97         XslTransformer xslTransformer = new XslTransformer();
98         xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
99         return xslTransformer;
100     }
101
102     @Bean
103     public RefProp getRefProp() {
104         return new RefProp();
105     }
106
107     @Bean
108     public PolicyClient getPolicyClient() {
109         return new PolicyClient();
110     }
111
112     @Bean(name = "cldsEventDelegate")
113     public CldsEventDelegate getCldsEventDelegate() {
114         return new CldsEventDelegate();
115     }
116
117     @Bean(name = "dcaeReqDelegate")
118     public DcaeReqDelegate getDcaeReqDelegate() {
119         return new DcaeReqDelegate();
120     }
121
122     @Bean(name = "sdcSendReqDelegate")
123     public SdcSendReqDelegate getSdcSendReqDelegate() {
124         return new SdcSendReqDelegate();
125     }
126
127     @Bean(name = "dcaeReqDeleteDelegate")
128     public DcaeReqDeleteDelegate getDcaeReqDeleteDelegate() {
129         return new DcaeReqDeleteDelegate();
130     }
131
132     @Bean(name = "operationalPolicyDelegate")
133     public OperationalPolicyDelegate getOperationalPolicyDelegate() {
134         return new OperationalPolicyDelegate();
135     }
136
137     @Bean(name = "operationalPolicyDeleteDelegate")
138     public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
139         return new OperationalPolicyDeleteDelegate();
140     }
141
142     @Bean(name = "stringMatchPolicyDelegate")
143     public StringMatchPolicyDelegate getStringMatchPolicyDelegate() {
144         return new StringMatchPolicyDelegate();
145     }
146
147     @Bean(name = "stringMatchPolicyDeleteDelegate")
148     public StringMatchPolicyDeleteDelegate getStringMatchPolicyDeleteDelegate() {
149         return new StringMatchPolicyDeleteDelegate();
150     }
151
152     @Bean(name = "sdcCatalogServices")
153     public SdcCatalogServices getSdcCatalogServices() {
154         return new SdcCatalogServices();
155     }
156
157     @Bean(name = "dcaeDispatcherServices")
158     public DcaeDispatcherServices getDcaeDispatcherServices() {
159         return new DcaeDispatcherServices();
160     }
161
162     @Bean(name = "dcaeInventoryServices")
163     public DcaeInventoryServices getDcaeInventoryServices() {
164         return new DcaeInventoryServices();
165     }
166
167     @Bean(name = "tcaPolicyDelegate")
168     public TcaPolicyDelegate getTcaPolicyDelegate() {
169         return new TcaPolicyDelegate();
170     }
171
172     @Bean(name = "tcaPolicyDeleteDelegate")
173     public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() {
174         return new TcaPolicyDeleteDelegate();
175     }
176
177     @Bean(name = "holmesPolicyDelegate")
178     public HolmesPolicyDelegate getHolmesPolicyDelegate() {
179         return new HolmesPolicyDelegate();
180     }
181
182     @Bean(name = "holmesPolicyDeleteDelegate")
183     public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() {
184         return new HolmesPolicyDeleteDelegate();
185     }
186
187 }