2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.asdctool.migration.config;
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;
44 import java.util.ArrayList;
45 import java.util.List;
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"
52 public class MigrationSpringConfig {
54 @Autowired(required=false)
55 private List<Migration> migrations = new ArrayList<>();
57 @Autowired(required=false)
58 private List<PostMigration> postMigrations = new ArrayList<>();
60 @Bean(name = "sdc-migration-tool")
61 public SdcMigrationTool sdcMigrationTool(MigrationResolver migrationResolver, SdcRepoService sdcRepoService) {
62 return new SdcMigrationTool(migrationResolver, sdcRepoService);
65 @Bean(name = "spring-migrations-resolver")
66 public SpringBeansMigrationResolver migrationResolver(SdcRepoService sdcRepoService) {
67 return new SpringBeansMigrationResolver(migrations, postMigrations, sdcRepoService);
70 @Bean(name = "sdc-repo-service")
71 public SdcRepoService sdcRepoService(MigrationTasksDao migrationTasksDao) {
72 return new SdcRepoService(migrationTasksDao);
75 @Bean(name = "sdc-migration-tasks-cassandra-dao")
76 public MigrationTasksDao migrationTasksDao(CassandraClient cassandraClient) {
77 return new MigrationTasksDao(cassandraClient);
80 @Bean(name = "serviceDistributionArtifactsBuilder")
81 public ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder() {
82 return new ServiceDistributionArtifactsBuilder();
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"));
93 @Bean(name = "componentsCleanBusinessLogic")
94 public ComponentsCleanBusinessLogic componentsCleanBusinessLogic() {return new ComponentsCleanBusinessLogic(); }