Convert Sparky to Spring-Boot
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / util / OxmModelAndProcessorHelper.java
1 package org.onap.aai.sparky.util;
2
3 import java.io.IOException;
4 import java.util.HashSet;
5 import java.util.Set;
6
7 import org.onap.aai.sparky.config.SparkyResourceLoader;
8 import org.onap.aai.sparky.config.oxm.CrossEntityReferenceLookup;
9 import org.onap.aai.sparky.config.oxm.GeoEntityLookup;
10 import org.onap.aai.sparky.config.oxm.OxmEntityContainerLookup;
11 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
12 import org.onap.aai.sparky.config.oxm.OxmModelLoader;
13 import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
14 import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
15 import org.onap.aai.sparky.config.oxm.SuggestionEntityLookup;
16 import org.onap.aai.sparky.search.filters.config.FiltersConfig;
17 import org.springframework.core.io.DefaultResourceLoader;
18
19 public class OxmModelAndProcessorHelper {
20
21         public static int API_VERSION_OVERRIDE = -1;
22
23         private OxmModelLoader modelLoader;
24         private Set<OxmModelProcessor> processors;
25
26         private CrossEntityReferenceLookup crossEntityReferenceLookup;
27         private GeoEntityLookup geoEntityLookup;
28         private OxmEntityLookup oxmEntityLookup;
29         private SearchableEntityLookup searchableEntityLookup;
30         private SuggestionEntityLookup suggestionEntityLookup;
31         private OxmEntityContainerLookup oxmEntityContainerLookup;
32         private FiltersConfig filtersConfig;
33
34         private static OxmModelAndProcessorHelper instance = null;
35
36         private OxmModelAndProcessorHelper() throws IOException {
37
38           SparkyResourceLoader resourceLoader = new SparkyResourceLoader();
39           resourceLoader.setResourceLoader(new DefaultResourceLoader());
40           
41                 this.filtersConfig = new FiltersConfig();
42                 this.filtersConfig.initializeFiltersDetailsConfig(resourceLoader.getResourceAsFile(SparkyTestConstants.FILTERS_JSON_FILE, false));
43                 this.filtersConfig.initializeFiltersForViewsConfig(resourceLoader.getResourceAsFile(SparkyTestConstants.VIEWS_JSON_FILE, false));
44
45                 this.crossEntityReferenceLookup = new CrossEntityReferenceLookup();
46                 this.geoEntityLookup = new GeoEntityLookup();
47                 this.oxmEntityLookup = new OxmEntityLookup();
48                 this.searchableEntityLookup = new SearchableEntityLookup();
49                 this.suggestionEntityLookup = new SuggestionEntityLookup(filtersConfig);
50                 this.oxmEntityContainerLookup = new OxmEntityContainerLookup();
51
52                 this.processors = new HashSet<OxmModelProcessor>();
53                 processors.add(crossEntityReferenceLookup);
54                 processors.add(geoEntityLookup);
55                 processors.add(oxmEntityLookup);
56                 processors.add(searchableEntityLookup);
57                 processors.add(suggestionEntityLookup);
58                 processors.add(oxmEntityContainerLookup);
59
60                 this.modelLoader = new OxmModelLoader(API_VERSION_OVERRIDE, processors);
61                 modelLoader.loadLatestOxmModel();
62         }
63
64         public static OxmModelAndProcessorHelper getInstance() throws IOException {
65                 if (instance == null) {
66                         instance = new OxmModelAndProcessorHelper();
67                 }
68                 return instance;
69         }
70
71         public OxmModelLoader getModelLoader() {
72                 return modelLoader;
73         }
74
75         public void setModelLoader(OxmModelLoader modelLoader) {
76                 this.modelLoader = modelLoader;
77         }
78
79         public Set<OxmModelProcessor> getProcessors() {
80                 return processors;
81         }
82
83         public void setProcessors(Set<OxmModelProcessor> processors) {
84                 this.processors = processors;
85         }
86
87         public CrossEntityReferenceLookup getCrossEntityReferenceLookup() {
88                 return crossEntityReferenceLookup;
89         }
90
91         public void setCrossEntityReferenceLookup(CrossEntityReferenceLookup crossEntityReferenceLookup) {
92                 this.crossEntityReferenceLookup = crossEntityReferenceLookup;
93         }
94
95         public GeoEntityLookup getGeoEntityLookup() {
96                 return geoEntityLookup;
97         }
98
99         public void setGeoEntityLookup(GeoEntityLookup geoEntityLookup) {
100                 this.geoEntityLookup = geoEntityLookup;
101         }
102
103         public OxmEntityLookup getOxmEntityLookup() {
104                 return oxmEntityLookup;
105         }
106
107         public void setOxmEntityLookup(OxmEntityLookup oxmEntityLookup) {
108                 this.oxmEntityLookup = oxmEntityLookup;
109         }
110
111         public SearchableEntityLookup getSearchableEntityLookup() {
112                 return searchableEntityLookup;
113         }
114
115         public void setSearchableEntityLookup(SearchableEntityLookup searchableEntityLookup) {
116                 this.searchableEntityLookup = searchableEntityLookup;
117         }
118
119         public SuggestionEntityLookup getSuggestionEntityLookup() {
120                 return suggestionEntityLookup;
121         }
122
123         public void setSuggestionEntityLookup(SuggestionEntityLookup suggestionEntityLookup) {
124                 this.suggestionEntityLookup = suggestionEntityLookup;
125         }
126
127         public FiltersConfig getFiltersConfig() {
128                 return filtersConfig;
129         }
130
131         public void setFiltersConfig(FiltersConfig filtersConfig) {
132                 this.filtersConfig = filtersConfig;
133         }
134
135         public OxmEntityContainerLookup getOxmEntityContainerLookup() {
136                 return oxmEntityContainerLookup;
137         }
138
139         public void setOxmEntityContainerLookup(OxmEntityContainerLookup oxmEntityContainerLookup) {
140                 this.oxmEntityContainerLookup = oxmEntityContainerLookup;
141         }
142
143 }