Added oparent to sdc main
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / dao / config / JanusGraphSpringConfig.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. 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.openecomp.sdc.be.dao.config;
22
23 import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
24 import org.openecomp.sdc.be.dao.JanusGraphClientStrategy;
25 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
26 import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
27 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
28 import org.openecomp.sdc.be.dao.janusgraph.transactions.SimpleJanusGraphTransactionManager;
29 import org.springframework.beans.factory.annotation.Qualifier;
30 import org.springframework.context.annotation.Bean;
31 import org.springframework.context.annotation.ComponentScan;
32 import org.springframework.context.annotation.Configuration;
33 import org.springframework.context.annotation.Primary;
34 import org.springframework.transaction.PlatformTransactionManager;
35 import org.springframework.transaction.annotation.EnableTransactionManagement;
36
37 @Configuration
38 @ComponentScan({
39         "org.openecomp.sdc.be.dao.jsongraph",
40 })
41 @EnableTransactionManagement
42 public class JanusGraphSpringConfig {
43
44     @Bean(name = "janusgraph-generic-dao")
45     @Primary
46     public HealingJanusGraphGenericDao janusGraphGenericDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient, @Qualifier("healingPipelineDao") HealingPipelineDao healingPipelineDao) {
47         return new HealingJanusGraphGenericDao(healingPipelineDao, janusGraphClient);
48     }
49
50     @Bean(name = "janusgraph-client", initMethod = "createGraph")
51     @Primary
52     public JanusGraphClient janusGraphClient(@Qualifier("dao-client-strategy")
53                                                  JanusGraphClientStrategy janusGraphClientStrategy) {
54         return new JanusGraphClient(janusGraphClientStrategy);
55     }
56
57     @Bean(name = "dao-client-strategy")
58     public JanusGraphClientStrategy janusGraphClientStrategy() {
59         return new DAOJanusGraphStrategy();
60     }
61
62     @Bean
63     public PlatformTransactionManager txManager() {
64         return new SimpleJanusGraphTransactionManager(janusGraphClient(janusGraphClientStrategy()));
65     }
66
67     @Bean(name = "healingPipelineDao")
68     public HealingPipelineDao  healingPipeline(){
69         HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
70         healingPipelineDao.setHealVersion(1);
71         healingPipelineDao.initHealVersion();
72         return healingPipelineDao;
73     }
74 }