| 10 |
shop2020 |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.metamodel.definitions;
|
|
|
5 |
|
| 70 |
naveen |
6 |
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
|
| 45 |
naveen |
7 |
import in.shop2020.metamodel.util.ExpandedCategory;
|
| 62 |
naveen |
8 |
import in.shop2020.metamodel.util.ExpandedCategoryFacetDefinition;
|
|
|
9 |
import in.shop2020.metamodel.util.ExpandedFacetDefinition;
|
| 64 |
naveen |
10 |
import in.shop2020.util.DBUtils;
|
| 70 |
naveen |
11 |
import in.shop2020.util.Utils;
|
| 17 |
naveen |
12 |
|
| 10 |
shop2020 |
13 |
import java.io.Serializable;
|
| 18 |
naveen |
14 |
import java.util.ArrayList;
|
|
|
15 |
import java.util.Iterator;
|
|
|
16 |
import java.util.List;
|
| 10 |
shop2020 |
17 |
import java.util.Map;
|
|
|
18 |
|
|
|
19 |
/**
|
| 49 |
naveen |
20 |
* Single point of access to all definition objects
|
|
|
21 |
*
|
| 10 |
shop2020 |
22 |
* @author naveen
|
|
|
23 |
*
|
|
|
24 |
*/
|
|
|
25 |
public class DefinitionsContainer implements Serializable {
|
|
|
26 |
|
| 41 |
naveen |
27 |
/**
|
| 10 |
shop2020 |
28 |
*
|
|
|
29 |
*/
|
|
|
30 |
private static final long serialVersionUID = 1L;
|
| 49 |
naveen |
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Hashtable of Category ID to Category object
|
|
|
34 |
*/
|
| 10 |
shop2020 |
35 |
private Map<Long, Category> categories;
|
| 49 |
naveen |
36 |
|
|
|
37 |
/**
|
|
|
38 |
* Hashtable of Slide ID to SlideDefinition object
|
|
|
39 |
*/
|
| 10 |
shop2020 |
40 |
private Map<Long, SlideDefinition> slideDefinitions;
|
| 49 |
naveen |
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Hashtable of Feature Definition ID to FeatureDefinition object
|
|
|
44 |
*/
|
| 10 |
shop2020 |
45 |
private Map<Long, FeatureDefinition> featureDefinitions;
|
| 49 |
naveen |
46 |
|
|
|
47 |
/**
|
|
|
48 |
* Hashtable of Datatype Definition ID to DatatypeDefinition object
|
|
|
49 |
*/
|
| 10 |
shop2020 |
50 |
private Map<Long, DatatypeDefinition> datatypeDefinitions;
|
| 49 |
naveen |
51 |
|
|
|
52 |
/**
|
|
|
53 |
* Hashtable of Enum value ID to EnumValue object
|
|
|
54 |
*/
|
| 24 |
naveen |
55 |
private Map<Long, EnumValue> enumValues;
|
| 49 |
naveen |
56 |
|
|
|
57 |
/**
|
|
|
58 |
* Hashtable of Unit ID to Unit object
|
|
|
59 |
*/
|
| 10 |
shop2020 |
60 |
private Map<Long, Unit> units;
|
|
|
61 |
|
|
|
62 |
/**
|
| 62 |
naveen |
63 |
* Hashtable of Facet Definition ID to FacetDefinition object
|
|
|
64 |
*/
|
|
|
65 |
private Map<Long, FacetDefinition> facetDefinitions;
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Hashtable of Category Facet Definition ID to CategoryFacetDefinition
|
|
|
69 |
* object
|
|
|
70 |
*/
|
|
|
71 |
private Map<Long, CategoryFacetDefinition> categoryFacetDefinitions;
|
|
|
72 |
|
|
|
73 |
/**
|
|
|
74 |
* Hashtable of IR Data Rule ID to RuleDefinition object
|
|
|
75 |
*/
|
|
|
76 |
private Map<Long, RuleDefinition> irDataRuleDefinitions;
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* Hashtable of IR Meta Data Rule ID to RuleDefinition object
|
|
|
80 |
*/
|
|
|
81 |
private Map<Long, RuleDefinition> irMetaDataRuleDefinitions;
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
/**
|
| 70 |
naveen |
85 |
* Hashtable of Comparison Rule ID to CMPRuleDefinition object
|
|
|
86 |
*/
|
|
|
87 |
private Map<Long, CMPRuleDefinition> cmpRuleDefinitions;
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Hashtable of SlideDefinition ID to CMPSlideRuleDefinition object
|
|
|
91 |
*/
|
|
|
92 |
private Map<Long, CMPSlideRuleDefinition> cmpSlideRuleDefinitions;
|
|
|
93 |
|
|
|
94 |
/**
|
| 72 |
naveen |
95 |
* Hashtable of Category ID to list of CMPBucketDefinition object
|
|
|
96 |
*/
|
|
|
97 |
private Map<Long, List<CMPBucketDefinition>> cmpBucketDefinitions;
|
| 102 |
naveen |
98 |
|
|
|
99 |
/**
|
|
|
100 |
* Hashtable of feature definition ID to normalization rule definition ID
|
|
|
101 |
*/
|
|
|
102 |
private Map<Long, RuleDefinition> normalizationRuleDefinitions;
|
| 72 |
naveen |
103 |
|
|
|
104 |
/**
|
| 49 |
naveen |
105 |
* Empty constructor. Data structures are initialised as needed
|
| 10 |
shop2020 |
106 |
*/
|
|
|
107 |
public DefinitionsContainer() {
|
| 17 |
naveen |
108 |
// Lazy initialization
|
| 10 |
shop2020 |
109 |
}
|
|
|
110 |
|
|
|
111 |
/**
|
| 49 |
naveen |
112 |
* Returns all Unit objects in the database
|
| 10 |
shop2020 |
113 |
*
|
| 49 |
naveen |
114 |
* @return Map Null if units are not imported into definitions db
|
|
|
115 |
* (serialized java objects)
|
|
|
116 |
*
|
| 18 |
naveen |
117 |
* @throws Exception
|
| 10 |
shop2020 |
118 |
*/
|
| 18 |
naveen |
119 |
@SuppressWarnings("unchecked")
|
|
|
120 |
public Map<Long, Unit> getUnits() throws Exception {
|
| 17 |
naveen |
121 |
// De-serialize
|
|
|
122 |
if(this.units == null) {
|
| 70 |
naveen |
123 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "units" + ".ser";
|
| 18 |
naveen |
124 |
|
|
|
125 |
this.units = (Map<Long, Unit>) DBUtils.read(dbFile);
|
| 17 |
naveen |
126 |
}
|
| 18 |
naveen |
127 |
|
| 10 |
shop2020 |
128 |
return this.units;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
/**
|
| 49 |
naveen |
132 |
* Resolves Unit ID into Unit object
|
| 10 |
shop2020 |
133 |
*
|
| 49 |
naveen |
134 |
* @param unitID Unit ID
|
| 10 |
shop2020 |
135 |
* @return Unit
|
| 18 |
naveen |
136 |
* @throws Exception
|
| 10 |
shop2020 |
137 |
*/
|
| 18 |
naveen |
138 |
public Unit getUnit(long unitID) throws Exception {
|
|
|
139 |
// Initialize
|
|
|
140 |
if(this.units == null) {
|
|
|
141 |
this.getUnits();
|
|
|
142 |
}
|
| 17 |
naveen |
143 |
|
| 10 |
shop2020 |
144 |
return this.units.get(new Long(unitID));
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
/**
|
| 49 |
naveen |
148 |
* Returns all DatatypeDefintion object in database
|
|
|
149 |
*
|
|
|
150 |
* @return the datatypeDefinitions List of DatatypeDefinition objects
|
| 18 |
naveen |
151 |
* @throws Exception
|
| 10 |
shop2020 |
152 |
*/
|
| 18 |
naveen |
153 |
@SuppressWarnings("unchecked")
|
|
|
154 |
public Map<Long, DatatypeDefinition> getDatatypeDefinitions()
|
|
|
155 |
throws Exception {
|
|
|
156 |
|
|
|
157 |
// De-serialize
|
|
|
158 |
if(this.datatypeDefinitions == null) {
|
| 70 |
naveen |
159 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "datatypedefinitions" +
|
| 19 |
naveen |
160 |
".ser";
|
| 18 |
naveen |
161 |
|
|
|
162 |
this.datatypeDefinitions =
|
|
|
163 |
(Map<Long, DatatypeDefinition>) DBUtils.read(dbFile);
|
|
|
164 |
}
|
|
|
165 |
return this.datatypeDefinitions;
|
| 10 |
shop2020 |
166 |
}
|
| 18 |
naveen |
167 |
|
|
|
168 |
/**
|
| 49 |
naveen |
169 |
* Resolves Datatype Definition ID into DatetypeDefinition object
|
| 18 |
naveen |
170 |
*
|
| 49 |
naveen |
171 |
* @param unitID Unit ID
|
| 18 |
naveen |
172 |
* @return Unit
|
|
|
173 |
* @throws Exception
|
|
|
174 |
*/
|
|
|
175 |
public DatatypeDefinition getDatatypeDefinition(long id) throws Exception {
|
|
|
176 |
|
|
|
177 |
// Initialize
|
|
|
178 |
if(this.datatypeDefinitions == null) {
|
|
|
179 |
this.getDatatypeDefinitions();
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
return this.datatypeDefinitions.get(new Long(id));
|
|
|
183 |
}
|
| 19 |
naveen |
184 |
|
|
|
185 |
/**
|
| 49 |
naveen |
186 |
* Returns EnumValue ID for datatype definition ID and enum value string
|
|
|
187 |
* to match. Match is case insensitive
|
| 19 |
naveen |
188 |
*
|
| 49 |
naveen |
189 |
* @param datatypeDefID DatatypeDefinition ID
|
|
|
190 |
* @param value query enum value string
|
| 19 |
naveen |
191 |
* @return long enumValueID - "-1" if not found
|
|
|
192 |
* @throws Exception
|
|
|
193 |
*/
|
|
|
194 |
public long getEnumValueID(long datatypeDefID, String value)
|
|
|
195 |
throws Exception {
|
|
|
196 |
long enumValueID = -1L;
|
|
|
197 |
|
|
|
198 |
// Let the callers catch ClassCastException
|
|
|
199 |
EnumDefinition enumDef =
|
|
|
200 |
(EnumDefinition)this.getDatatypeDefinition(datatypeDefID);
|
|
|
201 |
|
| 24 |
naveen |
202 |
List<EnumValue> enumValues = enumDef.getEnumValues();
|
| 19 |
naveen |
203 |
for(EnumValue enumValue : enumValues) {
|
|
|
204 |
if(value.equalsIgnoreCase(enumValue.getValue())) {
|
|
|
205 |
enumValueID = enumValue.getID();
|
|
|
206 |
break;
|
|
|
207 |
}
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
return enumValueID;
|
|
|
211 |
}
|
| 17 |
naveen |
212 |
|
| 10 |
shop2020 |
213 |
/**
|
| 49 |
naveen |
214 |
* Returns all category objects in the database
|
|
|
215 |
*
|
| 10 |
shop2020 |
216 |
* @return the categories
|
| 17 |
naveen |
217 |
* @throws Exception
|
| 10 |
shop2020 |
218 |
*/
|
| 17 |
naveen |
219 |
@SuppressWarnings("unchecked")
|
|
|
220 |
public Map<Long, Category> getCategories() throws Exception {
|
|
|
221 |
|
|
|
222 |
// De-serialize
|
|
|
223 |
if(this.categories == null) {
|
| 70 |
naveen |
224 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "categories" + ".ser";
|
| 17 |
naveen |
225 |
|
|
|
226 |
this.categories = (Map<Long, Category>) DBUtils.read(dbFile);
|
|
|
227 |
}
|
|
|
228 |
return this.categories;
|
| 10 |
shop2020 |
229 |
}
|
| 17 |
naveen |
230 |
|
| 10 |
shop2020 |
231 |
/**
|
| 49 |
naveen |
232 |
* Resolves Category ID into Category object
|
| 17 |
naveen |
233 |
*
|
| 49 |
naveen |
234 |
* @param categoryID Category ID
|
| 17 |
naveen |
235 |
* @return Category
|
|
|
236 |
* @throws Exception
|
| 10 |
shop2020 |
237 |
*/
|
| 17 |
naveen |
238 |
public Category getCategory(long categoryID) throws Exception {
|
|
|
239 |
|
| 18 |
naveen |
240 |
// Initialize
|
| 17 |
naveen |
241 |
if(this.categories == null) {
|
|
|
242 |
this.getCategories();
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
return this.categories.get(new Long(categoryID));
|
| 10 |
shop2020 |
246 |
}
|
| 17 |
naveen |
247 |
|
| 10 |
shop2020 |
248 |
/**
|
| 49 |
naveen |
249 |
* Returns expanded Category object. All numeric identifiers are resolved
|
|
|
250 |
* into detailed objects
|
| 18 |
naveen |
251 |
*
|
|
|
252 |
* @param categoryID
|
| 45 |
naveen |
253 |
* @return ExpandedCategory
|
|
|
254 |
* @throws Exception
|
|
|
255 |
*/
|
|
|
256 |
public ExpandedCategory getExpandedCategory(long categoryID)
|
|
|
257 |
throws Exception {
|
|
|
258 |
Category category = this.getCategory(categoryID);
|
|
|
259 |
|
|
|
260 |
ExpandedCategory expCategory = new ExpandedCategory(category);
|
|
|
261 |
|
|
|
262 |
return expCategory;
|
|
|
263 |
}
|
|
|
264 |
|
|
|
265 |
/**
|
| 49 |
naveen |
266 |
* Returns all children categories for a Category ID
|
| 45 |
naveen |
267 |
*
|
|
|
268 |
* @param categoryID
|
| 49 |
naveen |
269 |
* @return List<Category> Children Categories
|
| 34 |
naveen |
270 |
* @throws Exception
|
|
|
271 |
*/
|
|
|
272 |
public List<Category> getChildrenCategories(long categoryID)
|
|
|
273 |
throws Exception {
|
|
|
274 |
|
|
|
275 |
// Initialize
|
|
|
276 |
if(this.categories == null) {
|
|
|
277 |
this.getCategories();
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
return this.categories.get(new Long(categoryID)).getChildrenCategory();
|
|
|
281 |
}
|
| 49 |
naveen |
282 |
|
| 34 |
naveen |
283 |
/**
|
| 49 |
naveen |
284 |
* Returns all CategorySlideDefinition objects for a Category ID
|
| 34 |
naveen |
285 |
*
|
| 49 |
naveen |
286 |
* @param categoryID Category ID
|
| 18 |
naveen |
287 |
* @return List<CategorySlideDefinition>
|
|
|
288 |
* @throws Exception
|
|
|
289 |
*/
|
|
|
290 |
public List<CategorySlideDefinition> getCategorySlideDefinitions(
|
|
|
291 |
long categoryID) throws Exception {
|
|
|
292 |
Category category = this.getCategory(categoryID);
|
|
|
293 |
|
|
|
294 |
return category.getCategorySlideDefintions();
|
|
|
295 |
}
|
|
|
296 |
|
|
|
297 |
/**
|
| 49 |
naveen |
298 |
* Returns All SlideDefinition objects in database
|
|
|
299 |
*
|
| 10 |
shop2020 |
300 |
* @return the slideDefinitions
|
| 18 |
naveen |
301 |
* @throws Exception
|
| 10 |
shop2020 |
302 |
*/
|
| 18 |
naveen |
303 |
@SuppressWarnings("unchecked")
|
|
|
304 |
public Map<Long, SlideDefinition> getSlideDefinitions() throws Exception {
|
|
|
305 |
|
|
|
306 |
// De-serialize
|
|
|
307 |
if(this.slideDefinitions == null) {
|
| 70 |
naveen |
308 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "slidedefinitions" +
|
| 18 |
naveen |
309 |
".ser";
|
|
|
310 |
|
|
|
311 |
this.slideDefinitions =
|
|
|
312 |
(Map<Long, SlideDefinition>) DBUtils.read(dbFile);
|
|
|
313 |
}
|
|
|
314 |
return this.slideDefinitions;
|
| 10 |
shop2020 |
315 |
}
|
| 18 |
naveen |
316 |
|
|
|
317 |
/**
|
| 49 |
naveen |
318 |
* Resolves SlideDefinition ID into SlideDefinition object
|
| 18 |
naveen |
319 |
*
|
|
|
320 |
* @param id
|
|
|
321 |
* @return SlideDefinition
|
|
|
322 |
* @throws Exception
|
|
|
323 |
*/
|
|
|
324 |
public SlideDefinition getSlideDefinition(long id) throws Exception {
|
|
|
325 |
|
|
|
326 |
// Initialize
|
|
|
327 |
if(this.slideDefinitions == null) {
|
|
|
328 |
this.getSlideDefinitions();
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
return this.slideDefinitions.get(new Long(id));
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
/**
|
| 49 |
naveen |
335 |
* Returns SlideDefinition objects for a category and matching slide label
|
| 18 |
naveen |
336 |
*
|
| 19 |
naveen |
337 |
* @param label
|
|
|
338 |
* @return List<SlideDefinition>
|
|
|
339 |
* @throws Exception
|
|
|
340 |
*/
|
| 32 |
naveen |
341 |
public List<SlideDefinition> getSlideDefinitions(long categoryID,
|
|
|
342 |
String label) throws Exception {
|
|
|
343 |
|
|
|
344 |
// RE-VISIT
|
|
|
345 |
// May be we need a new data structure, category id to slide definitions
|
|
|
346 |
// for now
|
|
|
347 |
List<SlideDefinition> matchingSlides = new ArrayList<SlideDefinition>();
|
| 19 |
naveen |
348 |
|
| 32 |
naveen |
349 |
List<CategorySlideDefinition> csDefs = this.getCategorySlideDefinitions(
|
|
|
350 |
categoryID);
|
|
|
351 |
|
|
|
352 |
for(CategorySlideDefinition csDef : csDefs) {
|
|
|
353 |
SlideDefinition sDef = this.getSlideDefinition(
|
|
|
354 |
csDef.getSlideDefintionID());
|
|
|
355 |
|
|
|
356 |
if(sDef.getLabel().equalsIgnoreCase(label)) {
|
|
|
357 |
matchingSlides.add(sDef);
|
|
|
358 |
}
|
| 19 |
naveen |
359 |
}
|
|
|
360 |
|
| 32 |
naveen |
361 |
return matchingSlides;
|
|
|
362 |
}
|
|
|
363 |
|
|
|
364 |
/**
|
| 49 |
naveen |
365 |
* Resolves Category ID into Category object
|
| 32 |
naveen |
366 |
*
|
|
|
367 |
* @param categoryID
|
| 49 |
naveen |
368 |
* @return List<SlideDefinition>
|
| 32 |
naveen |
369 |
* @throws Exception
|
|
|
370 |
*/
|
|
|
371 |
public List<SlideDefinition> getSlideDefinitions(long categoryID)
|
|
|
372 |
throws Exception {
|
|
|
373 |
|
|
|
374 |
// RE-VISIT
|
|
|
375 |
// May be we need a new data structure, category id to slide definitions
|
|
|
376 |
// for now
|
| 19 |
naveen |
377 |
List<SlideDefinition> matchingSlides = new ArrayList<SlideDefinition>();
|
| 32 |
naveen |
378 |
|
|
|
379 |
List<CategorySlideDefinition> csDefs = this.getCategorySlideDefinitions(
|
|
|
380 |
categoryID);
|
|
|
381 |
|
|
|
382 |
for(CategorySlideDefinition csDef : csDefs) {
|
|
|
383 |
SlideDefinition sDef = this.getSlideDefinition(
|
|
|
384 |
csDef.getSlideDefintionID());
|
| 19 |
naveen |
385 |
|
| 32 |
naveen |
386 |
matchingSlides.add(sDef);
|
| 19 |
naveen |
387 |
}
|
|
|
388 |
|
|
|
389 |
return matchingSlides;
|
|
|
390 |
}
|
| 49 |
naveen |
391 |
|
| 19 |
naveen |
392 |
/**
|
| 49 |
naveen |
393 |
* Returns list of SlideDefinition objects for a category and editorial
|
|
|
394 |
* importance value
|
| 19 |
naveen |
395 |
*
|
| 18 |
naveen |
396 |
* @param categoryID
|
|
|
397 |
* @param EditorialImportance imp
|
|
|
398 |
* @return List<SlideDefinition>
|
|
|
399 |
* @throws Exception
|
|
|
400 |
*/
|
|
|
401 |
public List<SlideDefinition> getSlides(long categoryID,
|
|
|
402 |
EditorialImportance imp)
|
|
|
403 |
throws Exception {
|
|
|
404 |
|
|
|
405 |
List<CategorySlideDefinition> catSlideDefs =
|
|
|
406 |
this.getCategorySlideDefinitions(categoryID);
|
|
|
407 |
|
|
|
408 |
Iterator<CategorySlideDefinition> itCatSlideDefs =
|
|
|
409 |
catSlideDefs.iterator();
|
|
|
410 |
|
|
|
411 |
List<SlideDefinition> slideDefs = new ArrayList<SlideDefinition>();
|
|
|
412 |
while(itCatSlideDefs.hasNext()) {
|
|
|
413 |
CategorySlideDefinition catSlideDef = itCatSlideDefs.next();
|
|
|
414 |
if(catSlideDef.getEditorialImportance() == imp) {
|
|
|
415 |
long slideDefID = catSlideDef.getSlideDefintionID();
|
|
|
416 |
slideDefs.add(this.getSlideDefinition(slideDefID));
|
|
|
417 |
}
|
|
|
418 |
}
|
|
|
419 |
return slideDefs;
|
|
|
420 |
}
|
|
|
421 |
|
|
|
422 |
/**
|
| 49 |
naveen |
423 |
* Returns all FeatureDefinition object in database
|
| 18 |
naveen |
424 |
*
|
|
|
425 |
* @return Map<Long, FeatureDefinition>
|
|
|
426 |
* @throws Exception
|
|
|
427 |
*/
|
|
|
428 |
@SuppressWarnings("unchecked")
|
|
|
429 |
public Map<Long, FeatureDefinition> getFeatureDefinitions()
|
|
|
430 |
throws Exception {
|
|
|
431 |
|
|
|
432 |
// De-serialize
|
|
|
433 |
if(this.featureDefinitions == null) {
|
| 70 |
naveen |
434 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "featuredefinitions" +
|
| 18 |
naveen |
435 |
".ser";
|
|
|
436 |
|
|
|
437 |
this.featureDefinitions =
|
|
|
438 |
(Map<Long, FeatureDefinition>) DBUtils.read(dbFile);
|
|
|
439 |
}
|
|
|
440 |
return this.featureDefinitions;
|
|
|
441 |
}
|
| 19 |
naveen |
442 |
|
| 10 |
shop2020 |
443 |
/**
|
| 49 |
naveen |
444 |
* Returns all FeatureDefinition objects for a slide
|
| 18 |
naveen |
445 |
*
|
| 19 |
naveen |
446 |
* @param slideID
|
|
|
447 |
* @return List<FeatureDefinition>
|
|
|
448 |
* @throws Exception
|
|
|
449 |
*/
|
|
|
450 |
public List<FeatureDefinition> getFeatureDefinitions(long slideID)
|
|
|
451 |
throws Exception {
|
|
|
452 |
List<FeatureDefinition> featureDefs =
|
|
|
453 |
new ArrayList<FeatureDefinition>();
|
|
|
454 |
|
|
|
455 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
456 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
457 |
slideDef.getSlideFeatureDefinitions();
|
|
|
458 |
|
|
|
459 |
for(int i=0; i<slideFeatureDefs.size(); i++) {
|
|
|
460 |
featureDefs.add(this.getFeatureDefinition(
|
|
|
461 |
slideFeatureDefs.get(i).getFeatureDefintionID()));
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
return featureDefs;
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
/**
|
| 49 |
naveen |
468 |
* Returns list of FeatureDefinition objects for a slide given editorial
|
|
|
469 |
* importance
|
| 19 |
naveen |
470 |
*
|
|
|
471 |
* @param slideID
|
| 49 |
naveen |
472 |
* @param imp Editorial Importance enum object
|
| 19 |
naveen |
473 |
* @return List<FeatureDefinition>
|
|
|
474 |
* @throws Exception
|
|
|
475 |
*/
|
|
|
476 |
public List<FeatureDefinition> getFeatureDefinitions(long slideID,
|
|
|
477 |
EditorialImportance imp) throws Exception {
|
|
|
478 |
List<FeatureDefinition> featureDefs =
|
|
|
479 |
new ArrayList<FeatureDefinition>();
|
|
|
480 |
|
|
|
481 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
482 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
483 |
slideDef.getSlideFeatureDefinitions();
|
|
|
484 |
|
|
|
485 |
for(SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
|
|
|
486 |
if(slideFeatureDef.getEditorialImportance() == imp) {
|
|
|
487 |
featureDefs.add(this.getFeatureDefinition(
|
|
|
488 |
slideFeatureDef.getFeatureDefintionID()));
|
|
|
489 |
}
|
|
|
490 |
}
|
|
|
491 |
|
|
|
492 |
return featureDefs;
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
/**
|
| 49 |
naveen |
496 |
* Resolves Feature Definition ID into FeatureDefinition object
|
| 19 |
naveen |
497 |
*
|
| 49 |
naveen |
498 |
* @param id Feature Definition ID
|
| 19 |
naveen |
499 |
* @return FeatureDefinition
|
| 18 |
naveen |
500 |
* @throws Exception
|
| 10 |
shop2020 |
501 |
*/
|
| 18 |
naveen |
502 |
public FeatureDefinition getFeatureDefinition(long id) throws Exception {
|
|
|
503 |
|
|
|
504 |
// Initialize
|
|
|
505 |
if(this.featureDefinitions == null) {
|
|
|
506 |
this.getFeatureDefinitions();
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
return this.featureDefinitions.get(new Long(id));
|
|
|
510 |
}
|
| 19 |
naveen |
511 |
|
|
|
512 |
/**
|
| 49 |
naveen |
513 |
* Returns matching FeatureDefinition object for slide ID and feature label.
|
|
|
514 |
* Label matching is case insensitive.
|
| 19 |
naveen |
515 |
*
|
| 49 |
naveen |
516 |
* @param slideID Slide ID
|
|
|
517 |
* @param featureLabel label to match, case is ignored
|
| 19 |
naveen |
518 |
* @return FeatureDefinition
|
|
|
519 |
* @throws Exception
|
|
|
520 |
*/
|
|
|
521 |
public FeatureDefinition getFeatureDefinition(long slideID,
|
|
|
522 |
String featureLabel) throws Exception {
|
|
|
523 |
FeatureDefinition featureDef = null;
|
|
|
524 |
|
|
|
525 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
526 |
for(SlideFeatureDefinition slideFeatureDef :
|
|
|
527 |
slideDef.getSlideFeatureDefinitions()) {
|
|
|
528 |
|
|
|
529 |
long featureDefID = slideFeatureDef.getFeatureDefintionID();
|
|
|
530 |
|
|
|
531 |
FeatureDefinition thisFeatureDef = this.getFeatureDefinition(
|
|
|
532 |
featureDefID);
|
|
|
533 |
|
| 28 |
naveen |
534 |
if(featureLabel.equalsIgnoreCase(thisFeatureDef.getLabel())) {
|
| 19 |
naveen |
535 |
featureDef = thisFeatureDef;
|
|
|
536 |
}
|
|
|
537 |
}
|
|
|
538 |
|
|
|
539 |
return featureDef;
|
|
|
540 |
}
|
| 24 |
naveen |
541 |
|
|
|
542 |
/**
|
| 49 |
naveen |
543 |
* Returns all EnumValue objects in the database
|
|
|
544 |
*
|
| 24 |
naveen |
545 |
* @return the enumValues
|
|
|
546 |
* @throws Exception
|
|
|
547 |
*/
|
|
|
548 |
@SuppressWarnings("unchecked")
|
|
|
549 |
public Map<Long, EnumValue> getEnumValues() throws Exception {
|
|
|
550 |
// De-serialise
|
|
|
551 |
if(this.enumValues == null) {
|
| 70 |
naveen |
552 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "enumvalues" +
|
| 24 |
naveen |
553 |
".ser";
|
|
|
554 |
|
|
|
555 |
this.enumValues =
|
|
|
556 |
(Map<Long, EnumValue>) DBUtils.read(dbFile);
|
|
|
557 |
}
|
|
|
558 |
|
|
|
559 |
return this.enumValues;
|
|
|
560 |
}
|
| 19 |
naveen |
561 |
|
| 24 |
naveen |
562 |
/**
|
| 49 |
naveen |
563 |
* Resolves Enum value ID into EnumValue object
|
| 24 |
naveen |
564 |
*
|
|
|
565 |
* @param enumValueID
|
|
|
566 |
* @return EnumValue
|
|
|
567 |
* @throws Exception
|
|
|
568 |
*/
|
|
|
569 |
public EnumValue getEnumValue(long enumValueID) throws Exception {
|
|
|
570 |
// Initialise
|
|
|
571 |
if(this.enumValues == null) {
|
|
|
572 |
this.getEnumValues();
|
|
|
573 |
}
|
|
|
574 |
|
|
|
575 |
return this.enumValues.get(new Long(enumValueID));
|
|
|
576 |
}
|
| 62 |
naveen |
577 |
|
|
|
578 |
/**
|
|
|
579 |
* Returns all FacetDefinition objects in the database
|
|
|
580 |
*
|
|
|
581 |
* @return Map Null if facet definitions are not imported into definitions
|
|
|
582 |
* db (serialized java objects)
|
|
|
583 |
*
|
|
|
584 |
* @throws Exception
|
|
|
585 |
*/
|
|
|
586 |
@SuppressWarnings("unchecked")
|
|
|
587 |
public Map<Long, FacetDefinition> getFacetDefinitions() throws Exception {
|
|
|
588 |
|
|
|
589 |
// De-serialize
|
|
|
590 |
if(this.facetDefinitions == null) {
|
| 70 |
naveen |
591 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "facetdefinitions" +
|
| 63 |
naveen |
592 |
".ser";
|
| 62 |
naveen |
593 |
|
|
|
594 |
this.facetDefinitions =
|
|
|
595 |
(Map<Long, FacetDefinition>) DBUtils.read(dbFile);
|
|
|
596 |
}
|
|
|
597 |
|
|
|
598 |
return this.facetDefinitions;
|
|
|
599 |
}
|
|
|
600 |
|
|
|
601 |
/**
|
|
|
602 |
* Resolves Facet Definition ID into FacetDefinition object
|
|
|
603 |
*
|
|
|
604 |
* @param facetDefinitionID
|
|
|
605 |
* @return FacetDefinition
|
|
|
606 |
* @throws Exception
|
|
|
607 |
*/
|
|
|
608 |
public FacetDefinition getFacetDefinition(long facetDefinitionID)
|
|
|
609 |
throws Exception {
|
|
|
610 |
|
|
|
611 |
if(this.facetDefinitions == null) {
|
|
|
612 |
this.getFacetDefinitions();
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
return this.facetDefinitions.get(new Long(facetDefinitionID));
|
|
|
616 |
}
|
|
|
617 |
|
|
|
618 |
/**
|
|
|
619 |
* Utility method to get Expanded version of ExpandedFacetDefinition object
|
|
|
620 |
*
|
|
|
621 |
* @param facetDefinitionID
|
|
|
622 |
* @return ExpandedFacetDefinition
|
|
|
623 |
* @throws Exception
|
|
|
624 |
*/
|
|
|
625 |
public ExpandedFacetDefinition getExpandedFacetDefinition(
|
|
|
626 |
long facetDefinitionID) throws Exception {
|
|
|
627 |
|
|
|
628 |
FacetDefinition facetDefinition =
|
|
|
629 |
this.getFacetDefinition(facetDefinitionID);
|
|
|
630 |
|
|
|
631 |
ExpandedFacetDefinition expFacetDefinition =
|
|
|
632 |
new ExpandedFacetDefinition(facetDefinition);
|
|
|
633 |
|
|
|
634 |
return expFacetDefinition;
|
|
|
635 |
}
|
|
|
636 |
|
|
|
637 |
/**
|
|
|
638 |
* Returns all CategoryFacetDefinition objects in the database
|
|
|
639 |
*
|
|
|
640 |
* @return Map Null if category facet definitions are not imported into
|
|
|
641 |
* definitions db (serialized java objects)
|
|
|
642 |
*
|
|
|
643 |
* @throws Exception
|
|
|
644 |
*/
|
|
|
645 |
@SuppressWarnings("unchecked")
|
|
|
646 |
public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions()
|
|
|
647 |
throws Exception {
|
|
|
648 |
|
|
|
649 |
// De-serialize
|
|
|
650 |
if(this.categoryFacetDefinitions == null) {
|
| 70 |
naveen |
651 |
String dbFile = Utils.DEFINITIONS_DB_PATH +
|
| 81 |
naveen |
652 |
"categoryfacetdefinitions.ser";
|
| 62 |
naveen |
653 |
|
|
|
654 |
this.categoryFacetDefinitions =
|
|
|
655 |
(Map<Long, CategoryFacetDefinition>) DBUtils.read(dbFile);
|
|
|
656 |
}
|
|
|
657 |
|
|
|
658 |
return this.categoryFacetDefinitions;
|
|
|
659 |
}
|
|
|
660 |
|
|
|
661 |
/**
|
|
|
662 |
* Resolves Category-Facet Definition ID into CategoryFacetDefinition object
|
|
|
663 |
*
|
|
|
664 |
* @param categoryID
|
|
|
665 |
* @return CategoryFacetDefinition
|
|
|
666 |
* @throws Exception
|
|
|
667 |
*/
|
|
|
668 |
public CategoryFacetDefinition getCategoryFacetDefinition(
|
|
|
669 |
long categoryID) throws Exception {
|
|
|
670 |
|
|
|
671 |
if(this.categoryFacetDefinitions == null) {
|
|
|
672 |
this.getCategoryFacetDefinitions();
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
return this.categoryFacetDefinitions.get(
|
|
|
676 |
new Long(categoryID));
|
|
|
677 |
}
|
|
|
678 |
|
|
|
679 |
/**
|
|
|
680 |
* Utility method to get Expanded version of CategoryFacetDefinition object
|
|
|
681 |
*
|
|
|
682 |
* @param categoryID
|
|
|
683 |
* @return ExpandedCategoryFacetDefinition
|
|
|
684 |
* @throws Exception
|
|
|
685 |
*/
|
|
|
686 |
public ExpandedCategoryFacetDefinition getExpandedCategoryFacetDefinition(
|
|
|
687 |
long categoryID) throws Exception {
|
|
|
688 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
689 |
this.getCategoryFacetDefinition(categoryID);
|
|
|
690 |
|
|
|
691 |
ExpandedCategoryFacetDefinition expCategoryFacetDef =
|
|
|
692 |
new ExpandedCategoryFacetDefinition(categoryFacetDef);
|
|
|
693 |
|
|
|
694 |
return expCategoryFacetDef;
|
|
|
695 |
}
|
|
|
696 |
|
|
|
697 |
/**
|
|
|
698 |
* Returns all IR Data RuleDefintion objects in the database
|
|
|
699 |
*
|
|
|
700 |
* @return Map Null if IR data rule definitions are not imported into
|
|
|
701 |
* definitions db (serialized java objects)
|
|
|
702 |
*
|
|
|
703 |
* @throws Exception
|
|
|
704 |
*/
|
|
|
705 |
@SuppressWarnings("unchecked")
|
|
|
706 |
public Map<Long, RuleDefinition> getIrDataRuleDefinitions()
|
|
|
707 |
throws Exception {
|
|
|
708 |
|
|
|
709 |
// De-serialize
|
|
|
710 |
if(this.irDataRuleDefinitions == null) {
|
| 70 |
naveen |
711 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "irdatarules" + ".ser";
|
| 62 |
naveen |
712 |
|
|
|
713 |
this.irDataRuleDefinitions =
|
|
|
714 |
(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
|
|
|
715 |
}
|
|
|
716 |
|
|
|
717 |
return this.irDataRuleDefinitions;
|
|
|
718 |
}
|
|
|
719 |
|
|
|
720 |
/**
|
|
|
721 |
* Resolves IR Data Rule Definition ID into RuleDefinition object
|
|
|
722 |
*
|
|
|
723 |
* @param irDataRuleDefinitionID
|
|
|
724 |
* @return RuleDefinition
|
|
|
725 |
* @throws Exception
|
|
|
726 |
*/
|
|
|
727 |
public RuleDefinition getIrDataRuleDefinition(
|
|
|
728 |
long irDataRuleDefinitionID) throws Exception {
|
|
|
729 |
|
|
|
730 |
if(this.irDataRuleDefinitions == null) {
|
|
|
731 |
this.getIrDataRuleDefinitions();
|
|
|
732 |
}
|
|
|
733 |
|
|
|
734 |
return this.irDataRuleDefinitions.get(new Long(irDataRuleDefinitionID));
|
|
|
735 |
}
|
|
|
736 |
|
|
|
737 |
/**
|
|
|
738 |
* Returns all IR Meta Data RuleDefintion objects in the database
|
|
|
739 |
*
|
|
|
740 |
* @return Map Null if IR meta-data rule definitions are not imported into
|
|
|
741 |
* definitions db (serialized java objects)
|
|
|
742 |
*
|
|
|
743 |
* @throws Exception
|
|
|
744 |
*/
|
|
|
745 |
@SuppressWarnings("unchecked")
|
|
|
746 |
public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions()
|
|
|
747 |
throws Exception {
|
|
|
748 |
|
|
|
749 |
// De-serialize
|
|
|
750 |
if(this.irMetaDataRuleDefinitions == null) {
|
| 70 |
naveen |
751 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "irmetadatarules" +
|
|
|
752 |
".ser";
|
| 62 |
naveen |
753 |
|
|
|
754 |
this.irMetaDataRuleDefinitions =
|
|
|
755 |
(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
|
|
|
756 |
}
|
|
|
757 |
|
|
|
758 |
return this.irMetaDataRuleDefinitions;
|
|
|
759 |
}
|
|
|
760 |
|
|
|
761 |
/**
|
|
|
762 |
* Resolves IR Meta Data Rule Definition ID into RuleDefinition object
|
|
|
763 |
*
|
|
|
764 |
* @param irMetaDataRuleDefinitionID
|
|
|
765 |
* @return RuleDefinition
|
|
|
766 |
* @throws Exception
|
|
|
767 |
*/
|
|
|
768 |
public RuleDefinition getIrMetaDataRuleDefinition(
|
|
|
769 |
long irMetaDataRuleDefinitionID) throws Exception {
|
|
|
770 |
|
|
|
771 |
if(this.irMetaDataRuleDefinitions == null) {
|
|
|
772 |
this.getIrMetaDataRuleDefinitions();
|
|
|
773 |
}
|
|
|
774 |
|
|
|
775 |
return this.irMetaDataRuleDefinitions.get(
|
|
|
776 |
new Long(irMetaDataRuleDefinitionID));
|
|
|
777 |
}
|
| 70 |
naveen |
778 |
|
|
|
779 |
/**
|
|
|
780 |
* Returns all Comparison RuleDefintion objects in the database
|
|
|
781 |
*
|
|
|
782 |
* @return Map Null if Comparison rule definitions are not imported into
|
|
|
783 |
* definitions db (serialized java objects)
|
|
|
784 |
*
|
|
|
785 |
* @throws Exception
|
|
|
786 |
*/
|
|
|
787 |
@SuppressWarnings("unchecked")
|
|
|
788 |
public Map<Long, CMPRuleDefinition> getComparisonRuleDefinitions()
|
|
|
789 |
throws Exception {
|
|
|
790 |
|
|
|
791 |
// De-serialize
|
|
|
792 |
if(this.cmpRuleDefinitions == null) {
|
|
|
793 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "comparisonrules" +
|
|
|
794 |
".ser";
|
|
|
795 |
|
|
|
796 |
this.cmpRuleDefinitions =
|
|
|
797 |
(Map<Long, CMPRuleDefinition>) DBUtils.read(dbFile);
|
|
|
798 |
}
|
|
|
799 |
|
|
|
800 |
return this.cmpRuleDefinitions;
|
|
|
801 |
}
|
|
|
802 |
|
|
|
803 |
/**
|
|
|
804 |
* Resolves IR Data Rule Definition ID into RuleDefinition object
|
|
|
805 |
*
|
|
|
806 |
* @param cmpRuleDefinitionID
|
|
|
807 |
* @return CMPRuleDefinition
|
|
|
808 |
* @throws Exception
|
|
|
809 |
*/
|
|
|
810 |
public CMPRuleDefinition getComparisonRuleDefinition(
|
|
|
811 |
long cmpRuleDefinitionID) throws Exception {
|
|
|
812 |
|
|
|
813 |
if(this.cmpRuleDefinitions == null) {
|
|
|
814 |
this.getComparisonRuleDefinitions();
|
|
|
815 |
}
|
|
|
816 |
|
|
|
817 |
return this.cmpRuleDefinitions.get(new Long(cmpRuleDefinitionID));
|
|
|
818 |
}
|
|
|
819 |
|
|
|
820 |
|
|
|
821 |
/**
|
|
|
822 |
* Returns all ComparisonSlideRuleDefintion objects in the database
|
|
|
823 |
*
|
|
|
824 |
* @return Map Null if Comparison slide-rule definitions are not imported
|
|
|
825 |
* into definitions db (serialized java objects)
|
|
|
826 |
*
|
|
|
827 |
* @throws Exception
|
|
|
828 |
*/
|
|
|
829 |
@SuppressWarnings("unchecked")
|
|
|
830 |
public Map<Long, CMPSlideRuleDefinition> getComparisonSlideRuleDefinitions()
|
|
|
831 |
throws Exception {
|
|
|
832 |
|
|
|
833 |
// De-serialize
|
|
|
834 |
if(this.cmpSlideRuleDefinitions == null) {
|
|
|
835 |
String dbFile = Utils.DEFINITIONS_DB_PATH +
|
|
|
836 |
"comparisondefinitions.ser";
|
| 71 |
naveen |
837 |
Utils.info("dbFile=" + dbFile);
|
| 70 |
naveen |
838 |
|
|
|
839 |
this.cmpSlideRuleDefinitions =
|
|
|
840 |
(Map<Long, CMPSlideRuleDefinition>) DBUtils.read(dbFile);
|
| 71 |
naveen |
841 |
|
|
|
842 |
//Utils.info("this.cmpSlideRuleDefinitions=" +
|
|
|
843 |
// this.cmpSlideRuleDefinitions);
|
| 70 |
naveen |
844 |
}
|
|
|
845 |
|
|
|
846 |
return this.cmpSlideRuleDefinitions;
|
|
|
847 |
}
|
|
|
848 |
|
|
|
849 |
/**
|
|
|
850 |
* Resolves Category ID into List of CMPSlideRuleDefinition object
|
|
|
851 |
*
|
|
|
852 |
* @param categoryID
|
|
|
853 |
* @return List<CMPSlideRuleDefinition>
|
|
|
854 |
* @throws Exception
|
|
|
855 |
*/
|
|
|
856 |
public CMPSlideRuleDefinition getComparisonSlideRuleDefinition(
|
|
|
857 |
long slideDefinitionID) throws Exception {
|
|
|
858 |
|
|
|
859 |
if(this.cmpSlideRuleDefinitions == null) {
|
|
|
860 |
this.getComparisonSlideRuleDefinitions();
|
|
|
861 |
}
|
|
|
862 |
|
|
|
863 |
return this.cmpSlideRuleDefinitions.get(new Long(slideDefinitionID));
|
|
|
864 |
}
|
|
|
865 |
|
|
|
866 |
|
|
|
867 |
/**
|
|
|
868 |
* Resolves Slide Definition ID into ExpandedCMPSlideRuleDefinition object
|
|
|
869 |
*
|
|
|
870 |
* @param categoryID
|
|
|
871 |
* @return ExpandedCMPSlideRuleDefinition
|
|
|
872 |
* @throws Exception
|
|
|
873 |
*/
|
|
|
874 |
public ExpandedCMPSlideRuleDefinition
|
|
|
875 |
getExpandedComparisonSlideRuleDefinition(long slideDefinitionID)
|
|
|
876 |
throws Exception {
|
| 71 |
naveen |
877 |
Utils.info("slideDefinitionID=" + slideDefinitionID);
|
| 70 |
naveen |
878 |
|
|
|
879 |
CMPSlideRuleDefinition cmpSlideRuleDef =
|
|
|
880 |
this.getComparisonSlideRuleDefinition(slideDefinitionID);
|
|
|
881 |
|
| 71 |
naveen |
882 |
if(cmpSlideRuleDef == null) {
|
|
|
883 |
return null;
|
|
|
884 |
}
|
|
|
885 |
|
| 70 |
naveen |
886 |
ExpandedCMPSlideRuleDefinition expDef =
|
|
|
887 |
new ExpandedCMPSlideRuleDefinition(cmpSlideRuleDef);
|
|
|
888 |
|
|
|
889 |
return expDef;
|
|
|
890 |
}
|
| 72 |
naveen |
891 |
|
| 70 |
naveen |
892 |
|
| 72 |
naveen |
893 |
/**
|
|
|
894 |
* Returns all ComparisonSlideRuleDefintion objects in the database
|
|
|
895 |
*
|
|
|
896 |
* @return Map Null if Comparison slide-rule definitions are not imported
|
|
|
897 |
* into definitions db (serialized java objects)
|
|
|
898 |
*
|
|
|
899 |
* @throws Exception
|
|
|
900 |
*/
|
|
|
901 |
@SuppressWarnings("unchecked")
|
|
|
902 |
public Map<Long, List<CMPBucketDefinition>> getComparisonBucketDefinitions()
|
|
|
903 |
throws Exception {
|
|
|
904 |
|
|
|
905 |
// De-serialize
|
|
|
906 |
if(this.cmpBucketDefinitions == null) {
|
|
|
907 |
String dbFile = Utils.DEFINITIONS_DB_PATH + "comparisonbuckets.ser";
|
|
|
908 |
Utils.info("dbFile=" + dbFile);
|
|
|
909 |
|
|
|
910 |
this.cmpBucketDefinitions =
|
|
|
911 |
(Map<Long, List<CMPBucketDefinition>>) DBUtils.read(dbFile);
|
|
|
912 |
}
|
|
|
913 |
|
|
|
914 |
return this.cmpBucketDefinitions;
|
|
|
915 |
}
|
|
|
916 |
|
|
|
917 |
/**
|
|
|
918 |
* Resolves Category ID into List of CMPBucketDefinition object
|
|
|
919 |
*
|
|
|
920 |
* @param categoryID
|
|
|
921 |
* @return List<CMPBucketDefinition>
|
|
|
922 |
* @throws Exception
|
|
|
923 |
*/
|
|
|
924 |
public List<CMPBucketDefinition> getComparisonBucketDefinitions(
|
|
|
925 |
long categoryID) throws Exception {
|
|
|
926 |
|
|
|
927 |
if(this.cmpBucketDefinitions == null) {
|
|
|
928 |
this.getComparisonBucketDefinitions();
|
|
|
929 |
}
|
|
|
930 |
|
|
|
931 |
return this.cmpBucketDefinitions.get(new Long(categoryID));
|
|
|
932 |
}
|
|
|
933 |
|
|
|
934 |
/**
|
|
|
935 |
* Resolve comparison bucket name for a slide in a particular category
|
|
|
936 |
*
|
|
|
937 |
* @param categoryID
|
|
|
938 |
* @param slideDefintionID
|
|
|
939 |
* @return Bucket Name if found else Null
|
|
|
940 |
* @throws Exception
|
|
|
941 |
*/
|
|
|
942 |
public String getComparisonBucketName(long categoryID,
|
|
|
943 |
long slideDefinitionID) throws Exception {
|
|
|
944 |
List<CMPBucketDefinition> cmpBuckets =
|
|
|
945 |
this.getComparisonBucketDefinitions(categoryID);
|
|
|
946 |
|
|
|
947 |
for (CMPBucketDefinition cmpBucket : cmpBuckets) {
|
|
|
948 |
List<Long> slideDefinitionIDs = cmpBucket.getSlideDefinitionIDs();
|
|
|
949 |
|
|
|
950 |
if(slideDefinitionIDs.contains(new Long(slideDefinitionID))) {
|
|
|
951 |
return cmpBucket.getName();
|
|
|
952 |
}
|
|
|
953 |
}
|
|
|
954 |
|
|
|
955 |
return null;
|
|
|
956 |
}
|
| 83 |
naveen |
957 |
|
|
|
958 |
/**
|
|
|
959 |
* Returns list of facet definition IDs for given category ID
|
|
|
960 |
*
|
|
|
961 |
* @param categoryID
|
|
|
962 |
* @return list of facet definition IDs
|
|
|
963 |
* @throws Exception
|
|
|
964 |
*/
|
|
|
965 |
public List<Long> getFacetDefinitionIDs(long categoryID) throws Exception {
|
|
|
966 |
List<Long> facetDefIDs = new ArrayList<Long>();
|
|
|
967 |
|
|
|
968 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
969 |
this.getCategoryFacetDefinition(categoryID);
|
|
|
970 |
|
|
|
971 |
List<FacetRuleDefinition> facetRuleDefs =
|
|
|
972 |
categoryFacetDef.getFacetRuleDefinitions();
|
|
|
973 |
|
|
|
974 |
for(FacetRuleDefinition facetRuleDef : facetRuleDefs) {
|
|
|
975 |
facetDefIDs.add(new Long(facetRuleDef.getFacetDefinitionID()));
|
|
|
976 |
}
|
|
|
977 |
|
|
|
978 |
return facetDefIDs;
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
/**
|
|
|
982 |
* Returns list of feature definition IDs for given category ID
|
|
|
983 |
*
|
|
|
984 |
* @param categoryID
|
|
|
985 |
* @return list of feature definition IDs
|
|
|
986 |
* @throws Exception
|
|
|
987 |
*/
|
|
|
988 |
public List<Long> getFeatureDefinitionIDs(long categoryID)
|
|
|
989 |
throws Exception {
|
|
|
990 |
|
|
|
991 |
List<Long> featureDefIDs = new ArrayList<Long>();
|
|
|
992 |
|
|
|
993 |
List<SlideDefinition> slideDefs = this.getSlideDefinitions(categoryID);
|
|
|
994 |
|
|
|
995 |
for(SlideDefinition slideDef : slideDefs) {
|
|
|
996 |
List<Long> slideFeatureDefIDs =
|
|
|
997 |
this.getFeatureDefintionIDs(slideDef);
|
|
|
998 |
|
|
|
999 |
featureDefIDs.addAll(slideFeatureDefIDs);
|
|
|
1000 |
}
|
|
|
1001 |
|
|
|
1002 |
return featureDefIDs;
|
|
|
1003 |
}
|
|
|
1004 |
|
|
|
1005 |
/**
|
|
|
1006 |
* Returns list of feature definition IDs for given slide definition ID
|
|
|
1007 |
*
|
|
|
1008 |
* @param slideDef
|
|
|
1009 |
* @return list of feature definition IDs
|
|
|
1010 |
*/
|
|
|
1011 |
public List<Long> getFeatureDefintionIDs(SlideDefinition slideDef) {
|
|
|
1012 |
List<Long> featureDefIDs = new ArrayList<Long>();
|
|
|
1013 |
|
|
|
1014 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
1015 |
slideDef.getSlideFeatureDefinitions();
|
|
|
1016 |
|
|
|
1017 |
for(SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
|
|
|
1018 |
featureDefIDs.add(
|
|
|
1019 |
new Long(slideFeatureDef.getFeatureDefintionID()));
|
|
|
1020 |
}
|
|
|
1021 |
|
|
|
1022 |
return featureDefIDs;
|
|
|
1023 |
}
|
| 88 |
naveen |
1024 |
|
|
|
1025 |
/**
|
|
|
1026 |
*
|
|
|
1027 |
* @param borrowedSlideDefID
|
|
|
1028 |
* @return
|
|
|
1029 |
* @throws Exception
|
|
|
1030 |
*/
|
|
|
1031 |
public boolean isValidSlideDefinitionID(long borrowedSlideDefID)
|
|
|
1032 |
throws Exception {
|
|
|
1033 |
this.getSlideDefinitions();
|
|
|
1034 |
|
|
|
1035 |
return this.slideDefinitions.containsKey(new Long(borrowedSlideDefID));
|
|
|
1036 |
}
|
|
|
1037 |
|
|
|
1038 |
/**
|
|
|
1039 |
* Returns Facet-Rule definition object defined for a category and
|
|
|
1040 |
* slide definition
|
|
|
1041 |
*
|
|
|
1042 |
* @param borrowedCategoryID
|
|
|
1043 |
* @param slideDefID
|
|
|
1044 |
* @return FacetRuleDefinition
|
|
|
1045 |
* @throws Exception
|
|
|
1046 |
*/
|
|
|
1047 |
public FacetRuleDefinition getFacetRuleDefinitionForSlide(long categoryID,
|
|
|
1048 |
long slideDefinitionID) throws Exception {
|
|
|
1049 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
1050 |
this.getCategoryFacetDefinition(categoryID);
|
|
|
1051 |
|
|
|
1052 |
List<FacetRuleDefinition> facetRuleDefs =
|
|
|
1053 |
categoryFacetDef.getFacetRuleDefinitions();
|
|
|
1054 |
|
|
|
1055 |
for(FacetRuleDefinition facetRuleDef : facetRuleDefs) {
|
|
|
1056 |
if(facetRuleDef.getSlideDefinitionID() == slideDefinitionID) {
|
|
|
1057 |
return facetRuleDef;
|
|
|
1058 |
}
|
|
|
1059 |
}
|
|
|
1060 |
|
|
|
1061 |
return null;
|
|
|
1062 |
}
|
|
|
1063 |
|
|
|
1064 |
/**
|
|
|
1065 |
* Returns Facet-Rule definition object defined for a category and
|
|
|
1066 |
* feature definition
|
|
|
1067 |
*
|
|
|
1068 |
* @param categoryID
|
|
|
1069 |
* @param featureDefinitionID
|
|
|
1070 |
* @return FacetRuleDefinition
|
|
|
1071 |
* @throws Exception
|
|
|
1072 |
*/
|
|
|
1073 |
public FacetRuleDefinition getFacetRuleDefinitionForFeature(long categoryID,
|
|
|
1074 |
long featureDefinitionID) throws Exception {
|
|
|
1075 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
1076 |
this.getCategoryFacetDefinition(categoryID);
|
|
|
1077 |
|
|
|
1078 |
List<FacetRuleDefinition> facetRuleDefs =
|
|
|
1079 |
categoryFacetDef.getFacetRuleDefinitions();
|
|
|
1080 |
|
|
|
1081 |
for(FacetRuleDefinition facetRuleDef : facetRuleDefs) {
|
|
|
1082 |
if(facetRuleDef.getFeatureDefinitionID() == featureDefinitionID) {
|
|
|
1083 |
return facetRuleDef;
|
|
|
1084 |
}
|
|
|
1085 |
}
|
|
|
1086 |
|
|
|
1087 |
return null;
|
|
|
1088 |
}
|
| 102 |
naveen |
1089 |
|
|
|
1090 |
/**
|
|
|
1091 |
* Returns all normalization rule defined
|
|
|
1092 |
*
|
|
|
1093 |
* @return Map<Long, RuleDefinition>
|
|
|
1094 |
* @throws Exception
|
|
|
1095 |
*/
|
|
|
1096 |
@SuppressWarnings("unchecked")
|
|
|
1097 |
public Map<Long, RuleDefinition> getNormalizationRules() throws Exception {
|
|
|
1098 |
|
|
|
1099 |
// De-serialize
|
|
|
1100 |
if(this.normalizationRuleDefinitions == null) {
|
|
|
1101 |
String dbFile = Utils.DEFINITIONS_DB_PATH +
|
|
|
1102 |
"normalizationrules.ser";
|
|
|
1103 |
|
|
|
1104 |
Utils.info("dbFile=" + dbFile);
|
|
|
1105 |
|
|
|
1106 |
this.normalizationRuleDefinitions =
|
|
|
1107 |
(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
|
|
|
1108 |
}
|
|
|
1109 |
|
|
|
1110 |
return this.normalizationRuleDefinitions;
|
|
|
1111 |
}
|
|
|
1112 |
|
|
|
1113 |
|
|
|
1114 |
/**
|
|
|
1115 |
* True if feature has normalization rule defined
|
|
|
1116 |
*
|
|
|
1117 |
* @param feature
|
|
|
1118 |
* @return boolean
|
|
|
1119 |
* @throws Exception
|
|
|
1120 |
*/
|
|
|
1121 |
public boolean needsNormalization(long featureDefinitionID)
|
|
|
1122 |
throws Exception {
|
|
|
1123 |
this.getFeatureDefinitions();
|
|
|
1124 |
|
|
|
1125 |
FeatureDefinition featureDef =
|
|
|
1126 |
this.featureDefinitions.get(new Long(featureDefinitionID));
|
|
|
1127 |
|
|
|
1128 |
if(featureDef.getNormalizationRuleDefinitionID() != 0L) {
|
|
|
1129 |
return true;
|
|
|
1130 |
}
|
|
|
1131 |
|
|
|
1132 |
return false;
|
|
|
1133 |
}
|
|
|
1134 |
|
|
|
1135 |
/**
|
|
|
1136 |
* Returns normalization rule definition for rule definition ID
|
|
|
1137 |
*
|
|
|
1138 |
* @param ruleID
|
|
|
1139 |
* @return RuleDefinition
|
|
|
1140 |
* @throws Exception
|
|
|
1141 |
*/
|
|
|
1142 |
public RuleDefinition getNormalizationRuleDefinition(
|
|
|
1143 |
long ruleDefinitionID) throws Exception {
|
|
|
1144 |
this.getNormalizationRules();
|
|
|
1145 |
|
|
|
1146 |
return this.normalizationRuleDefinitions.get(
|
|
|
1147 |
new Long(ruleDefinitionID));
|
|
|
1148 |
}
|
| 10 |
shop2020 |
1149 |
}
|