Added oparent to sdc main
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / migration / config / MigrationSpringConfig.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.asdctool.migration.config;
22
23 import org.openecomp.sdc.asdctool.migration.core.SdcMigrationTool;
24 import org.openecomp.sdc.asdctool.migration.core.task.Migration;
25 import org.openecomp.sdc.asdctool.migration.core.task.PostMigration;
26 import org.openecomp.sdc.asdctool.migration.dao.MigrationTasksDao;
27 import org.openecomp.sdc.asdctool.migration.resolver.MigrationResolver;
28 import org.openecomp.sdc.asdctool.migration.resolver.SpringBeansMigrationResolver;
29 import org.openecomp.sdc.asdctool.migration.service.SdcRepoService;
30 import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
31 import org.openecomp.sdc.be.components.scheduledtasks.ComponentsCleanBusinessLogic;
32 import org.openecomp.sdc.be.config.CatalogModelSpringConfig;
33 import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
34 import org.openecomp.sdc.be.dao.config.DAOSpringConfig;
35 import org.openecomp.sdc.config.CatalogBESpringConfig;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.beans.factory.config.PropertiesFactoryBean;
38 import org.springframework.context.annotation.Bean;
39 import org.springframework.context.annotation.ComponentScan;
40 import org.springframework.context.annotation.Configuration;
41 import org.springframework.context.annotation.Import;
42 import org.springframework.core.io.FileSystemResource;
43
44 import java.util.ArrayList;
45 import java.util.List;
46
47 @Configuration
48 @Import({DAOSpringConfig.class, CatalogBESpringConfig.class, CatalogModelSpringConfig.class})
49 @ComponentScan({"org.openecomp.sdc.asdctool.migration.tasks",//migration tasks
50         "org.openecomp.sdc.asdctool.migration.config.mocks"
51                 })
52 public class MigrationSpringConfig {
53
54     @Autowired(required=false)
55     private List<Migration> migrations = new ArrayList<>();
56     
57     @Autowired(required=false)
58     private List<PostMigration> postMigrations = new ArrayList<>();
59
60     @Bean(name = "sdc-migration-tool")
61     public SdcMigrationTool sdcMigrationTool(MigrationResolver migrationResolver, SdcRepoService sdcRepoService) {
62         return new SdcMigrationTool(migrationResolver, sdcRepoService);
63     }
64
65     @Bean(name = "spring-migrations-resolver")
66     public SpringBeansMigrationResolver migrationResolver(SdcRepoService sdcRepoService) {
67         return new SpringBeansMigrationResolver(migrations, postMigrations, sdcRepoService);
68     }
69
70     @Bean(name = "sdc-repo-service")
71     public SdcRepoService sdcRepoService(MigrationTasksDao migrationTasksDao) {
72         return new SdcRepoService(migrationTasksDao);
73     }
74
75     @Bean(name = "sdc-migration-tasks-cassandra-dao")
76     public MigrationTasksDao migrationTasksDao(CassandraClient cassandraClient) {
77         return new MigrationTasksDao(cassandraClient);
78     }
79
80     @Bean(name = "serviceDistributionArtifactsBuilder")
81     public ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder() {
82         return new ServiceDistributionArtifactsBuilder();
83     }
84
85     @Bean(name = "elasticsearchConfig")
86     public PropertiesFactoryBean mapper() {
87         String configHome = System.getProperty("config.home");
88         PropertiesFactoryBean bean = new PropertiesFactoryBean();
89         bean.setLocation(new FileSystemResource(configHome + "/elasticsearch.yml"));
90         return bean;
91     }
92
93     @Bean(name = "componentsCleanBusinessLogic")
94     public ComponentsCleanBusinessLogic componentsCleanBusinessLogic() {return  new ComponentsCleanBusinessLogic(); }
95
96 }