Removal of useless files & bugfix
[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.HolmesPolicyDelegate;
39 import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate;
40 import org.onap.clamp.clds.client.OperationalPolicyDelegate;
41 import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate;
42 import org.onap.clamp.clds.client.PolicyClient;
43 import org.onap.clamp.clds.client.SdcCatalogServices;
44 import org.onap.clamp.clds.client.SdcSendReqDelegate;
45 import org.onap.clamp.clds.client.StringMatchPolicyDelegate;
46 import org.onap.clamp.clds.client.StringMatchPolicyDeleteDelegate;
47 import org.onap.clamp.clds.client.TcaPolicyDelegate;
48 import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate;
49 import org.onap.clamp.clds.dao.CldsDao;
50 import org.onap.clamp.clds.model.refprop.RefProp;
51 import org.onap.clamp.clds.transform.XslTransformer;
52 import org.springframework.beans.factory.annotation.Autowired;
53 import org.springframework.beans.factory.annotation.Qualifier;
54 import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
55 import org.springframework.boot.context.properties.ConfigurationProperties;
56 import org.springframework.context.ApplicationContext;
57 import org.springframework.context.annotation.Bean;
58 import org.springframework.context.annotation.Configuration;
59 import org.springframework.context.annotation.Profile;
60
61 @Configuration
62 @Profile("clamp-default")
63 public class CldsConfiguration {
64
65     @Autowired
66     private ApplicationContext context;
67
68     /**
69      * Clds Identity database DataSource configuration
70      */
71     @Bean(name = "cldsDataSource")
72     @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
73     public DataSource cldsDataSource() {
74         return DataSourceBuilder.create().build();
75     }
76
77     @Bean(name = "jaxrsProviders")
78     public List<?> jaxrsProviders() {
79         return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
80     }
81
82     @Bean(name = "jaxrsServices")
83     public List<?> jaxrsServices() {
84         return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
85     }
86
87     @Bean(name = "cldsDao")
88     public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
89         CldsDao cldsDao = new CldsDao();
90         cldsDao.setDataSource(dataSource);
91         return cldsDao;
92     }
93
94     @Bean(name = "cldsBpmnTransformer")
95     public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
96         XslTransformer xslTransformer = new XslTransformer();
97         xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
98         return xslTransformer;
99     }
100
101     @Bean
102     public RefProp getRefProp() {
103         return new RefProp();
104     }
105
106     @Bean
107     public PolicyClient getPolicyClient() {
108         return new PolicyClient();
109     }
110
111     @Bean(name = "cldsEventDelegate")
112     public CldsEventDelegate getCldsEventDelegate() {
113         return new CldsEventDelegate();
114     }
115
116     @Bean(name = "sdcSendReqDelegate")
117     public SdcSendReqDelegate getSdcSendReqDelegate() {
118         return new SdcSendReqDelegate();
119     }
120
121     @Bean(name = "operationalPolicyDelegate")
122     public OperationalPolicyDelegate getOperationalPolicyDelegate() {
123         return new OperationalPolicyDelegate();
124     }
125
126     @Bean(name = "operationalPolicyDeleteDelegate")
127     public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
128         return new OperationalPolicyDeleteDelegate();
129     }
130
131     @Bean(name = "stringMatchPolicyDelegate")
132     public StringMatchPolicyDelegate getStringMatchPolicyDelegate() {
133         return new StringMatchPolicyDelegate();
134     }
135
136     @Bean(name = "stringMatchPolicyDeleteDelegate")
137     public StringMatchPolicyDeleteDelegate getStringMatchPolicyDeleteDelegate() {
138         return new StringMatchPolicyDeleteDelegate();
139     }
140
141     @Bean(name = "sdcCatalogServices")
142     public SdcCatalogServices getSdcCatalogServices() {
143         return new SdcCatalogServices();
144     }
145
146     @Bean(name = "dcaeDispatcherServices")
147     public DcaeDispatcherServices getDcaeDispatcherServices() {
148         return new DcaeDispatcherServices();
149     }
150
151     @Bean(name = "dcaeInventoryServices")
152     public DcaeInventoryServices getDcaeInventoryServices() {
153         return new DcaeInventoryServices();
154     }
155
156     @Bean(name = "tcaPolicyDelegate")
157     public TcaPolicyDelegate getTcaPolicyDelegate() {
158         return new TcaPolicyDelegate();
159     }
160
161     @Bean(name = "tcaPolicyDeleteDelegate")
162     public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() {
163         return new TcaPolicyDeleteDelegate();
164     }
165
166     @Bean(name = "holmesPolicyDelegate")
167     public HolmesPolicyDelegate getHolmesPolicyDelegate() {
168         return new HolmesPolicyDelegate();
169     }
170
171     @Bean(name = "holmesPolicyDeleteDelegate")
172     public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() {
173         return new HolmesPolicyDeleteDelegate();
174     }
175
176 }