Adjust sparky parent pom
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / util / OxmModelAndProcessorHelper.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
22 package org.onap.aai.sparky.util;
23
24 import java.io.IOException;
25 import java.util.HashSet;
26 import java.util.Set;
27
28 import org.onap.aai.sparky.config.SparkyResourceLoader;
29 import org.onap.aai.sparky.config.oxm.CrossEntityReferenceLookup;
30 import org.onap.aai.sparky.config.oxm.GeoEntityLookup;
31 import org.onap.aai.sparky.config.oxm.OxmEntityContainerLookup;
32 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
33 import org.onap.aai.sparky.config.oxm.OxmModelLoader;
34 import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
35 import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
36 import org.onap.aai.sparky.config.oxm.SuggestionEntityLookup;
37 import org.onap.aai.sparky.search.filters.config.FiltersConfig;
38 import org.springframework.core.io.DefaultResourceLoader;
39
40 public class OxmModelAndProcessorHelper {
41
42         public static String API_VERSION_OVERRIDE = "v11";
43
44         private OxmModelLoader modelLoader;
45         private Set<OxmModelProcessor> processors;
46
47         private CrossEntityReferenceLookup crossEntityReferenceLookup;
48         private GeoEntityLookup geoEntityLookup;
49         private OxmEntityLookup oxmEntityLookup;
50         private SearchableEntityLookup searchableEntityLookup;
51         private SuggestionEntityLookup suggestionEntityLookup;
52         private OxmEntityContainerLookup oxmEntityContainerLookup;
53         private FiltersConfig filtersConfig;
54
55         private static OxmModelAndProcessorHelper instance = null;
56
57         private OxmModelAndProcessorHelper() throws IOException {
58
59           SparkyResourceLoader resourceLoader = new SparkyResourceLoader();
60           resourceLoader.setResourceLoader(new DefaultResourceLoader());
61           
62                 this.filtersConfig = new FiltersConfig();
63                 this.filtersConfig.initializeFiltersDetailsConfig(resourceLoader.getResourceAsFile(SparkyTestConstants.FILTERS_JSON_FILE, false));
64                 this.filtersConfig.initializeFiltersForViewsConfig(resourceLoader.getResourceAsFile(SparkyTestConstants.VIEWS_JSON_FILE, false));
65
66                 this.crossEntityReferenceLookup = new CrossEntityReferenceLookup();
67                 this.geoEntityLookup = new GeoEntityLookup();
68                 this.oxmEntityLookup = new OxmEntityLookup();
69                 this.searchableEntityLookup = new SearchableEntityLookup();
70                 this.suggestionEntityLookup = new SuggestionEntityLookup(filtersConfig);
71                 this.oxmEntityContainerLookup = new OxmEntityContainerLookup();
72
73                 this.processors = new HashSet<OxmModelProcessor>();
74                 processors.add(crossEntityReferenceLookup);
75                 processors.add(geoEntityLookup);
76                 processors.add(oxmEntityLookup);
77                 processors.add(searchableEntityLookup);
78                 processors.add(suggestionEntityLookup);
79                 processors.add(oxmEntityContainerLookup);
80                 this.modelLoader = new OxmModelLoader(API_VERSION_OVERRIDE, processors);
81                 
82         }
83
84         public static OxmModelAndProcessorHelper getInstance() throws IOException {
85                 if (instance == null) {
86                         instance = new OxmModelAndProcessorHelper();
87                 }
88                 return instance;
89         }
90
91         public OxmModelLoader getModelLoader() {
92                 return modelLoader;
93         }
94
95         public void setModelLoader(OxmModelLoader modelLoader) {
96                 this.modelLoader = modelLoader;
97         }
98
99         public Set<OxmModelProcessor> getProcessors() {
100                 return processors;
101         }
102
103         public void setProcessors(Set<OxmModelProcessor> processors) {
104                 this.processors = processors;
105         }
106
107         public CrossEntityReferenceLookup getCrossEntityReferenceLookup() {
108                 return crossEntityReferenceLookup;
109         }
110
111         public void setCrossEntityReferenceLookup(CrossEntityReferenceLookup crossEntityReferenceLookup) {
112                 this.crossEntityReferenceLookup = crossEntityReferenceLookup;
113         }
114
115         public GeoEntityLookup getGeoEntityLookup() {
116                 return geoEntityLookup;
117         }
118
119         public void setGeoEntityLookup(GeoEntityLookup geoEntityLookup) {
120                 this.geoEntityLookup = geoEntityLookup;
121         }
122
123         public OxmEntityLookup getOxmEntityLookup() {
124                 return oxmEntityLookup;
125         }
126
127         public void setOxmEntityLookup(OxmEntityLookup oxmEntityLookup) {
128                 this.oxmEntityLookup = oxmEntityLookup;
129         }
130
131         public SearchableEntityLookup getSearchableEntityLookup() {
132                 return searchableEntityLookup;
133         }
134
135         public void setSearchableEntityLookup(SearchableEntityLookup searchableEntityLookup) {
136                 this.searchableEntityLookup = searchableEntityLookup;
137         }
138
139         public SuggestionEntityLookup getSuggestionEntityLookup() {
140                 return suggestionEntityLookup;
141         }
142
143         public void setSuggestionEntityLookup(SuggestionEntityLookup suggestionEntityLookup) {
144                 this.suggestionEntityLookup = suggestionEntityLookup;
145         }
146
147         public FiltersConfig getFiltersConfig() {
148                 return filtersConfig;
149         }
150
151         public void setFiltersConfig(FiltersConfig filtersConfig) {
152                 this.filtersConfig = filtersConfig;
153         }
154
155         public OxmEntityContainerLookup getOxmEntityContainerLookup() {
156                 return oxmEntityContainerLookup;
157         }
158
159         public void setOxmEntityContainerLookup(OxmEntityContainerLookup oxmEntityContainerLookup) {
160                 this.oxmEntityContainerLookup = oxmEntityContainerLookup;
161         }
162
163 }