update sync queries to use searh data service
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / autosuggestion / sync / VnfAliasSyncController.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
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 package org.onap.aai.sparky.autosuggestion.sync;
22
23 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
24 import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
25 import org.onap.aai.sparky.search.SearchServiceAdapter;
26 import org.onap.aai.sparky.search.filters.config.FiltersConfig;
27 import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
28 import org.onap.aai.sparky.sync.IndexIntegrityValidator;
29 import org.onap.aai.sparky.sync.SyncControllerImpl;
30 import org.onap.aai.sparky.sync.SyncControllerRegistrar;
31 import org.onap.aai.sparky.sync.SyncControllerRegistry;
32 import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
33 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
34 import org.onap.aai.sparky.sync.config.SyncControllerConfig;
35
36 public class VnfAliasSyncController extends SyncControllerImpl implements SyncControllerRegistrar {
37
38   private SyncControllerRegistry syncControllerRegistry;
39   
40   public VnfAliasSyncController(SyncControllerConfig syncControllerConfig,
41       ActiveInventoryAdapter aaiAdapter, SearchServiceAdapter searchServiceAdapter,
42       ElasticSearchSchemaConfig schemaConfig, RestEndpointConfig endpointConfig,
43       NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig,
44       FiltersConfig filtersConfig,
45       ElasticSearchSchemaFactory elasticSearchSchemaFactory) throws Exception {
46     super(syncControllerConfig);
47     
48     // final String controllerName = "VNFs Alias Suggestion Synchronizer";
49
50     IndexIntegrityValidator indexValidator = new IndexIntegrityValidator(searchServiceAdapter, schemaConfig,
51         endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
52
53     registerIndexValidator(indexValidator);
54
55     VnfAliasSuggestionSynchronizer synchronizer = new VnfAliasSuggestionSynchronizer(schemaConfig,
56         syncControllerConfig.getNumInternalSyncWorkers(),
57         syncControllerConfig.getNumSyncActiveInventoryWorkers(),
58         syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig, filtersConfig);
59
60     synchronizer.setAaiAdapter(aaiAdapter);
61     synchronizer.setSearchServiceAdapter(searchServiceAdapter);
62
63     registerEntitySynchronizer(synchronizer);
64
65   }
66
67   public SyncControllerRegistry getSyncControllerRegistry() {
68     return syncControllerRegistry;
69   }
70
71   public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
72     this.syncControllerRegistry = syncControllerRegistry;
73   }
74
75   @Override
76   public void registerController() {
77     
78     if ( syncControllerRegistry != null ) {
79       if ( syncControllerConfig.isEnabled()) { 
80         syncControllerRegistry.registerSyncController(this);
81       }
82     }
83     
84   }
85   
86   
87 }