Adding interfaces in documentation
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / autosuggestion / sync / AutoSuggestionSyncController.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.onap.aai.sparky.autosuggestion.sync;
26
27 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
28 import org.onap.aai.sparky.config.oxm.SuggestionEntityLookup;
29 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
30 import org.onap.aai.sparky.dal.ElasticSearchAdapter;
31 import org.onap.aai.sparky.search.filters.config.FiltersConfig;
32 import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
33 import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
34 import org.onap.aai.sparky.sync.IndexCleaner;
35 import org.onap.aai.sparky.sync.IndexIntegrityValidator;
36 import org.onap.aai.sparky.sync.SyncControllerImpl;
37 import org.onap.aai.sparky.sync.SyncControllerRegistrar;
38 import org.onap.aai.sparky.sync.SyncControllerRegistry;
39 import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
40 import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
41 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
42 import org.onap.aai.sparky.sync.config.SyncControllerConfig;
43 import org.springframework.beans.factory.annotation.Autowired;
44
45 public class AutoSuggestionSyncController extends SyncControllerImpl implements SyncControllerRegistrar {
46
47   private SyncControllerRegistry syncControllerRegistry;
48     
49   public AutoSuggestionSyncController(SyncControllerConfig syncControllerConfig,
50       ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
51       ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
52       NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig,
53       OxmEntityLookup oxmEntityLookup, SuggestionEntityLookup suggestionEntityLookup,
54       FiltersConfig filtersConfig,
55       ElasticSearchSchemaFactory elasticSearchSchemaFactory) throws Exception {
56     super(syncControllerConfig);
57
58     // final String controllerName = "Auto Suggestion Synchronizer";
59
60     IndexIntegrityValidator autoSuggestionIndexValidator = new IndexIntegrityValidator(esAdapter,
61         schemaConfig, endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
62
63     registerIndexValidator(autoSuggestionIndexValidator);
64
65     AutosuggestionSynchronizer suggestionSynchronizer = new AutosuggestionSynchronizer(schemaConfig,
66         syncControllerConfig.getNumInternalSyncWorkers(),
67         syncControllerConfig.getNumSyncActiveInventoryWorkers(),
68         syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig,
69         oxmEntityLookup, suggestionEntityLookup, filtersConfig);
70
71     suggestionSynchronizer.setAaiAdapter(aaiAdapter);
72     suggestionSynchronizer.setElasticSearchAdapter(esAdapter);
73
74     registerEntitySynchronizer(suggestionSynchronizer);
75
76     IndexCleaner autosuggestIndexCleaner =
77         new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
78
79     registerIndexCleaner(autosuggestIndexCleaner);
80
81   }
82
83   public SyncControllerRegistry getSyncControllerRegistry() {
84     return syncControllerRegistry;
85   }
86
87
88
89   public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
90     this.syncControllerRegistry = syncControllerRegistry;
91   }
92
93
94
95   @Override
96   public void registerController() {
97
98     if ( syncControllerRegistry != null ) {
99       if ( syncControllerConfig.isEnabled()) { 
100         syncControllerRegistry.registerSyncController(this);
101       }
102     }
103     
104   }
105 }