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