| 10 |
shop2020 |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.metamodel.definitions;
|
|
|
5 |
|
| 17 |
naveen |
6 |
import in.shop2020.metamodel.util.DBUtils;
|
| 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;
|
| 17 |
naveen |
10 |
import in.shop2020.metamodel.util.MM;
|
|
|
11 |
|
| 10 |
shop2020 |
12 |
import java.io.Serializable;
|
| 18 |
naveen |
13 |
import java.util.ArrayList;
|
|
|
14 |
import java.util.Iterator;
|
|
|
15 |
import java.util.List;
|
| 10 |
shop2020 |
16 |
import java.util.Map;
|
|
|
17 |
|
|
|
18 |
/**
|
| 49 |
naveen |
19 |
* Single point of access to all definition objects
|
|
|
20 |
*
|
| 10 |
shop2020 |
21 |
* @author naveen
|
|
|
22 |
*
|
|
|
23 |
*/
|
|
|
24 |
public class DefinitionsContainer implements Serializable {
|
|
|
25 |
|
| 41 |
naveen |
26 |
/**
|
| 10 |
shop2020 |
27 |
*
|
|
|
28 |
*/
|
|
|
29 |
private static final long serialVersionUID = 1L;
|
| 49 |
naveen |
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Hashtable of Category ID to Category object
|
|
|
33 |
*/
|
| 10 |
shop2020 |
34 |
private Map<Long, Category> categories;
|
| 49 |
naveen |
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Hashtable of Slide ID to SlideDefinition object
|
|
|
38 |
*/
|
| 10 |
shop2020 |
39 |
private Map<Long, SlideDefinition> slideDefinitions;
|
| 49 |
naveen |
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Hashtable of Feature Definition ID to FeatureDefinition object
|
|
|
43 |
*/
|
| 10 |
shop2020 |
44 |
private Map<Long, FeatureDefinition> featureDefinitions;
|
| 49 |
naveen |
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Hashtable of Datatype Definition ID to DatatypeDefinition object
|
|
|
48 |
*/
|
| 10 |
shop2020 |
49 |
private Map<Long, DatatypeDefinition> datatypeDefinitions;
|
| 49 |
naveen |
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Hashtable of Enum value ID to EnumValue object
|
|
|
53 |
*/
|
| 24 |
naveen |
54 |
private Map<Long, EnumValue> enumValues;
|
| 49 |
naveen |
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Hashtable of Unit ID to Unit object
|
|
|
58 |
*/
|
| 10 |
shop2020 |
59 |
private Map<Long, Unit> units;
|
|
|
60 |
|
|
|
61 |
/**
|
| 62 |
naveen |
62 |
* Hashtable of Facet Definition ID to FacetDefinition object
|
|
|
63 |
*/
|
|
|
64 |
private Map<Long, FacetDefinition> facetDefinitions;
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* Hashtable of Category Facet Definition ID to CategoryFacetDefinition
|
|
|
68 |
* object
|
|
|
69 |
*/
|
|
|
70 |
private Map<Long, CategoryFacetDefinition> categoryFacetDefinitions;
|
|
|
71 |
|
|
|
72 |
/**
|
|
|
73 |
* Hashtable of IR Data Rule ID to RuleDefinition object
|
|
|
74 |
*/
|
|
|
75 |
private Map<Long, RuleDefinition> irDataRuleDefinitions;
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* Hashtable of IR Meta Data Rule ID to RuleDefinition object
|
|
|
79 |
*/
|
|
|
80 |
private Map<Long, RuleDefinition> irMetaDataRuleDefinitions;
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
/**
|
| 49 |
naveen |
84 |
* Empty constructor. Data structures are initialised as needed
|
| 10 |
shop2020 |
85 |
*/
|
|
|
86 |
public DefinitionsContainer() {
|
| 17 |
naveen |
87 |
// Lazy initialization
|
| 10 |
shop2020 |
88 |
}
|
|
|
89 |
|
|
|
90 |
/**
|
| 49 |
naveen |
91 |
* Returns all Unit objects in the database
|
| 10 |
shop2020 |
92 |
*
|
| 49 |
naveen |
93 |
* @return Map Null if units are not imported into definitions db
|
|
|
94 |
* (serialized java objects)
|
|
|
95 |
*
|
| 18 |
naveen |
96 |
* @throws Exception
|
| 10 |
shop2020 |
97 |
*/
|
| 18 |
naveen |
98 |
@SuppressWarnings("unchecked")
|
|
|
99 |
public Map<Long, Unit> getUnits() throws Exception {
|
| 17 |
naveen |
100 |
// De-serialize
|
|
|
101 |
if(this.units == null) {
|
| 18 |
naveen |
102 |
String dbFile = MM.DEFINITIONS_DB_PATH + "units" + ".ser";
|
|
|
103 |
|
|
|
104 |
this.units = (Map<Long, Unit>) DBUtils.read(dbFile);
|
| 17 |
naveen |
105 |
}
|
| 18 |
naveen |
106 |
|
| 10 |
shop2020 |
107 |
return this.units;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
/**
|
| 49 |
naveen |
111 |
* Resolves Unit ID into Unit object
|
| 10 |
shop2020 |
112 |
*
|
| 49 |
naveen |
113 |
* @param unitID Unit ID
|
| 10 |
shop2020 |
114 |
* @return Unit
|
| 18 |
naveen |
115 |
* @throws Exception
|
| 10 |
shop2020 |
116 |
*/
|
| 18 |
naveen |
117 |
public Unit getUnit(long unitID) throws Exception {
|
|
|
118 |
// Initialize
|
|
|
119 |
if(this.units == null) {
|
|
|
120 |
this.getUnits();
|
|
|
121 |
}
|
| 17 |
naveen |
122 |
|
| 10 |
shop2020 |
123 |
return this.units.get(new Long(unitID));
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
/**
|
| 49 |
naveen |
127 |
* Returns all DatatypeDefintion object in database
|
|
|
128 |
*
|
|
|
129 |
* @return the datatypeDefinitions List of DatatypeDefinition objects
|
| 18 |
naveen |
130 |
* @throws Exception
|
| 10 |
shop2020 |
131 |
*/
|
| 18 |
naveen |
132 |
@SuppressWarnings("unchecked")
|
|
|
133 |
public Map<Long, DatatypeDefinition> getDatatypeDefinitions()
|
|
|
134 |
throws Exception {
|
|
|
135 |
|
|
|
136 |
// De-serialize
|
|
|
137 |
if(this.datatypeDefinitions == null) {
|
| 19 |
naveen |
138 |
String dbFile = MM.DEFINITIONS_DB_PATH + "datatypedefinitions" +
|
|
|
139 |
".ser";
|
| 18 |
naveen |
140 |
|
|
|
141 |
this.datatypeDefinitions =
|
|
|
142 |
(Map<Long, DatatypeDefinition>) DBUtils.read(dbFile);
|
|
|
143 |
}
|
|
|
144 |
return this.datatypeDefinitions;
|
| 10 |
shop2020 |
145 |
}
|
| 18 |
naveen |
146 |
|
|
|
147 |
/**
|
| 49 |
naveen |
148 |
* Resolves Datatype Definition ID into DatetypeDefinition object
|
| 18 |
naveen |
149 |
*
|
| 49 |
naveen |
150 |
* @param unitID Unit ID
|
| 18 |
naveen |
151 |
* @return Unit
|
|
|
152 |
* @throws Exception
|
|
|
153 |
*/
|
|
|
154 |
public DatatypeDefinition getDatatypeDefinition(long id) throws Exception {
|
|
|
155 |
|
|
|
156 |
// Initialize
|
|
|
157 |
if(this.datatypeDefinitions == null) {
|
|
|
158 |
this.getDatatypeDefinitions();
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
return this.datatypeDefinitions.get(new Long(id));
|
|
|
162 |
}
|
| 19 |
naveen |
163 |
|
|
|
164 |
/**
|
| 49 |
naveen |
165 |
* Returns EnumValue ID for datatype definition ID and enum value string
|
|
|
166 |
* to match. Match is case insensitive
|
| 19 |
naveen |
167 |
*
|
| 49 |
naveen |
168 |
* @param datatypeDefID DatatypeDefinition ID
|
|
|
169 |
* @param value query enum value string
|
| 19 |
naveen |
170 |
* @return long enumValueID - "-1" if not found
|
|
|
171 |
* @throws Exception
|
|
|
172 |
*/
|
|
|
173 |
public long getEnumValueID(long datatypeDefID, String value)
|
|
|
174 |
throws Exception {
|
|
|
175 |
long enumValueID = -1L;
|
|
|
176 |
|
|
|
177 |
// Let the callers catch ClassCastException
|
|
|
178 |
EnumDefinition enumDef =
|
|
|
179 |
(EnumDefinition)this.getDatatypeDefinition(datatypeDefID);
|
|
|
180 |
|
| 24 |
naveen |
181 |
List<EnumValue> enumValues = enumDef.getEnumValues();
|
| 19 |
naveen |
182 |
for(EnumValue enumValue : enumValues) {
|
|
|
183 |
if(value.equalsIgnoreCase(enumValue.getValue())) {
|
|
|
184 |
enumValueID = enumValue.getID();
|
|
|
185 |
break;
|
|
|
186 |
}
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
return enumValueID;
|
|
|
190 |
}
|
| 17 |
naveen |
191 |
|
| 10 |
shop2020 |
192 |
/**
|
| 49 |
naveen |
193 |
* Returns all category objects in the database
|
|
|
194 |
*
|
| 10 |
shop2020 |
195 |
* @return the categories
|
| 17 |
naveen |
196 |
* @throws Exception
|
| 10 |
shop2020 |
197 |
*/
|
| 17 |
naveen |
198 |
@SuppressWarnings("unchecked")
|
|
|
199 |
public Map<Long, Category> getCategories() throws Exception {
|
|
|
200 |
|
|
|
201 |
// De-serialize
|
|
|
202 |
if(this.categories == null) {
|
|
|
203 |
String dbFile = MM.DEFINITIONS_DB_PATH + "categories" + ".ser";
|
|
|
204 |
|
|
|
205 |
this.categories = (Map<Long, Category>) DBUtils.read(dbFile);
|
|
|
206 |
}
|
|
|
207 |
return this.categories;
|
| 10 |
shop2020 |
208 |
}
|
| 17 |
naveen |
209 |
|
| 10 |
shop2020 |
210 |
/**
|
| 49 |
naveen |
211 |
* Resolves Category ID into Category object
|
| 17 |
naveen |
212 |
*
|
| 49 |
naveen |
213 |
* @param categoryID Category ID
|
| 17 |
naveen |
214 |
* @return Category
|
|
|
215 |
* @throws Exception
|
| 10 |
shop2020 |
216 |
*/
|
| 17 |
naveen |
217 |
public Category getCategory(long categoryID) throws Exception {
|
|
|
218 |
|
| 18 |
naveen |
219 |
// Initialize
|
| 17 |
naveen |
220 |
if(this.categories == null) {
|
|
|
221 |
this.getCategories();
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
return this.categories.get(new Long(categoryID));
|
| 10 |
shop2020 |
225 |
}
|
| 17 |
naveen |
226 |
|
| 10 |
shop2020 |
227 |
/**
|
| 49 |
naveen |
228 |
* Returns expanded Category object. All numeric identifiers are resolved
|
|
|
229 |
* into detailed objects
|
| 18 |
naveen |
230 |
*
|
|
|
231 |
* @param categoryID
|
| 45 |
naveen |
232 |
* @return ExpandedCategory
|
|
|
233 |
* @throws Exception
|
|
|
234 |
*/
|
|
|
235 |
public ExpandedCategory getExpandedCategory(long categoryID)
|
|
|
236 |
throws Exception {
|
|
|
237 |
Category category = this.getCategory(categoryID);
|
|
|
238 |
|
|
|
239 |
ExpandedCategory expCategory = new ExpandedCategory(category);
|
|
|
240 |
|
|
|
241 |
return expCategory;
|
|
|
242 |
}
|
|
|
243 |
|
|
|
244 |
/**
|
| 49 |
naveen |
245 |
* Returns all children categories for a Category ID
|
| 45 |
naveen |
246 |
*
|
|
|
247 |
* @param categoryID
|
| 49 |
naveen |
248 |
* @return List<Category> Children Categories
|
| 34 |
naveen |
249 |
* @throws Exception
|
|
|
250 |
*/
|
|
|
251 |
public List<Category> getChildrenCategories(long categoryID)
|
|
|
252 |
throws Exception {
|
|
|
253 |
|
|
|
254 |
// Initialize
|
|
|
255 |
if(this.categories == null) {
|
|
|
256 |
this.getCategories();
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
return this.categories.get(new Long(categoryID)).getChildrenCategory();
|
|
|
260 |
}
|
| 49 |
naveen |
261 |
|
| 34 |
naveen |
262 |
/**
|
| 49 |
naveen |
263 |
* Returns all CategorySlideDefinition objects for a Category ID
|
| 34 |
naveen |
264 |
*
|
| 49 |
naveen |
265 |
* @param categoryID Category ID
|
| 18 |
naveen |
266 |
* @return List<CategorySlideDefinition>
|
|
|
267 |
* @throws Exception
|
|
|
268 |
*/
|
|
|
269 |
public List<CategorySlideDefinition> getCategorySlideDefinitions(
|
|
|
270 |
long categoryID) throws Exception {
|
|
|
271 |
Category category = this.getCategory(categoryID);
|
|
|
272 |
|
|
|
273 |
return category.getCategorySlideDefintions();
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
/**
|
| 49 |
naveen |
277 |
* Returns All SlideDefinition objects in database
|
|
|
278 |
*
|
| 10 |
shop2020 |
279 |
* @return the slideDefinitions
|
| 18 |
naveen |
280 |
* @throws Exception
|
| 10 |
shop2020 |
281 |
*/
|
| 18 |
naveen |
282 |
@SuppressWarnings("unchecked")
|
|
|
283 |
public Map<Long, SlideDefinition> getSlideDefinitions() throws Exception {
|
|
|
284 |
|
|
|
285 |
// De-serialize
|
|
|
286 |
if(this.slideDefinitions == null) {
|
|
|
287 |
String dbFile = MM.DEFINITIONS_DB_PATH + "slidedefinitions" +
|
|
|
288 |
".ser";
|
|
|
289 |
|
|
|
290 |
this.slideDefinitions =
|
|
|
291 |
(Map<Long, SlideDefinition>) DBUtils.read(dbFile);
|
|
|
292 |
}
|
|
|
293 |
return this.slideDefinitions;
|
| 10 |
shop2020 |
294 |
}
|
| 18 |
naveen |
295 |
|
|
|
296 |
/**
|
| 49 |
naveen |
297 |
* Resolves SlideDefinition ID into SlideDefinition object
|
| 18 |
naveen |
298 |
*
|
|
|
299 |
* @param id
|
|
|
300 |
* @return SlideDefinition
|
|
|
301 |
* @throws Exception
|
|
|
302 |
*/
|
|
|
303 |
public SlideDefinition getSlideDefinition(long id) throws Exception {
|
|
|
304 |
|
|
|
305 |
// Initialize
|
|
|
306 |
if(this.slideDefinitions == null) {
|
|
|
307 |
this.getSlideDefinitions();
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
return this.slideDefinitions.get(new Long(id));
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
/**
|
| 49 |
naveen |
314 |
* Returns SlideDefinition objects for a category and matching slide label
|
| 18 |
naveen |
315 |
*
|
| 19 |
naveen |
316 |
* @param label
|
|
|
317 |
* @return List<SlideDefinition>
|
|
|
318 |
* @throws Exception
|
|
|
319 |
*/
|
| 32 |
naveen |
320 |
public List<SlideDefinition> getSlideDefinitions(long categoryID,
|
|
|
321 |
String label) throws Exception {
|
|
|
322 |
|
|
|
323 |
// RE-VISIT
|
|
|
324 |
// May be we need a new data structure, category id to slide definitions
|
|
|
325 |
// for now
|
|
|
326 |
List<SlideDefinition> matchingSlides = new ArrayList<SlideDefinition>();
|
| 19 |
naveen |
327 |
|
| 32 |
naveen |
328 |
List<CategorySlideDefinition> csDefs = this.getCategorySlideDefinitions(
|
|
|
329 |
categoryID);
|
|
|
330 |
|
|
|
331 |
for(CategorySlideDefinition csDef : csDefs) {
|
|
|
332 |
SlideDefinition sDef = this.getSlideDefinition(
|
|
|
333 |
csDef.getSlideDefintionID());
|
|
|
334 |
|
|
|
335 |
if(sDef.getLabel().equalsIgnoreCase(label)) {
|
|
|
336 |
matchingSlides.add(sDef);
|
|
|
337 |
}
|
| 19 |
naveen |
338 |
}
|
|
|
339 |
|
| 32 |
naveen |
340 |
return matchingSlides;
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
/**
|
| 49 |
naveen |
344 |
* Resolves Category ID into Category object
|
| 32 |
naveen |
345 |
*
|
|
|
346 |
* @param categoryID
|
| 49 |
naveen |
347 |
* @return List<SlideDefinition>
|
| 32 |
naveen |
348 |
* @throws Exception
|
|
|
349 |
*/
|
|
|
350 |
public List<SlideDefinition> getSlideDefinitions(long categoryID)
|
|
|
351 |
throws Exception {
|
|
|
352 |
|
|
|
353 |
// RE-VISIT
|
|
|
354 |
// May be we need a new data structure, category id to slide definitions
|
|
|
355 |
// for now
|
| 19 |
naveen |
356 |
List<SlideDefinition> matchingSlides = new ArrayList<SlideDefinition>();
|
| 32 |
naveen |
357 |
|
|
|
358 |
List<CategorySlideDefinition> csDefs = this.getCategorySlideDefinitions(
|
|
|
359 |
categoryID);
|
|
|
360 |
|
|
|
361 |
for(CategorySlideDefinition csDef : csDefs) {
|
|
|
362 |
SlideDefinition sDef = this.getSlideDefinition(
|
|
|
363 |
csDef.getSlideDefintionID());
|
| 19 |
naveen |
364 |
|
| 32 |
naveen |
365 |
matchingSlides.add(sDef);
|
| 19 |
naveen |
366 |
}
|
|
|
367 |
|
|
|
368 |
return matchingSlides;
|
|
|
369 |
}
|
| 49 |
naveen |
370 |
|
| 19 |
naveen |
371 |
/**
|
| 49 |
naveen |
372 |
* Returns list of SlideDefinition objects for a category and editorial
|
|
|
373 |
* importance value
|
| 19 |
naveen |
374 |
*
|
| 18 |
naveen |
375 |
* @param categoryID
|
|
|
376 |
* @param EditorialImportance imp
|
|
|
377 |
* @return List<SlideDefinition>
|
|
|
378 |
* @throws Exception
|
|
|
379 |
*/
|
|
|
380 |
public List<SlideDefinition> getSlides(long categoryID,
|
|
|
381 |
EditorialImportance imp)
|
|
|
382 |
throws Exception {
|
|
|
383 |
|
|
|
384 |
List<CategorySlideDefinition> catSlideDefs =
|
|
|
385 |
this.getCategorySlideDefinitions(categoryID);
|
|
|
386 |
|
|
|
387 |
Iterator<CategorySlideDefinition> itCatSlideDefs =
|
|
|
388 |
catSlideDefs.iterator();
|
|
|
389 |
|
|
|
390 |
List<SlideDefinition> slideDefs = new ArrayList<SlideDefinition>();
|
|
|
391 |
while(itCatSlideDefs.hasNext()) {
|
|
|
392 |
CategorySlideDefinition catSlideDef = itCatSlideDefs.next();
|
|
|
393 |
if(catSlideDef.getEditorialImportance() == imp) {
|
|
|
394 |
long slideDefID = catSlideDef.getSlideDefintionID();
|
|
|
395 |
slideDefs.add(this.getSlideDefinition(slideDefID));
|
|
|
396 |
}
|
|
|
397 |
}
|
|
|
398 |
return slideDefs;
|
|
|
399 |
}
|
|
|
400 |
|
|
|
401 |
/**
|
| 49 |
naveen |
402 |
* Returns all FeatureDefinition object in database
|
| 18 |
naveen |
403 |
*
|
|
|
404 |
* @return Map<Long, FeatureDefinition>
|
|
|
405 |
* @throws Exception
|
|
|
406 |
*/
|
|
|
407 |
@SuppressWarnings("unchecked")
|
|
|
408 |
public Map<Long, FeatureDefinition> getFeatureDefinitions()
|
|
|
409 |
throws Exception {
|
|
|
410 |
|
|
|
411 |
// De-serialize
|
|
|
412 |
if(this.featureDefinitions == null) {
|
|
|
413 |
String dbFile = MM.DEFINITIONS_DB_PATH + "featuredefinitions" +
|
|
|
414 |
".ser";
|
|
|
415 |
|
|
|
416 |
this.featureDefinitions =
|
|
|
417 |
(Map<Long, FeatureDefinition>) DBUtils.read(dbFile);
|
|
|
418 |
}
|
|
|
419 |
return this.featureDefinitions;
|
|
|
420 |
}
|
| 19 |
naveen |
421 |
|
| 10 |
shop2020 |
422 |
/**
|
| 49 |
naveen |
423 |
* Returns all FeatureDefinition objects for a slide
|
| 18 |
naveen |
424 |
*
|
| 19 |
naveen |
425 |
* @param slideID
|
|
|
426 |
* @return List<FeatureDefinition>
|
|
|
427 |
* @throws Exception
|
|
|
428 |
*/
|
|
|
429 |
public List<FeatureDefinition> getFeatureDefinitions(long slideID)
|
|
|
430 |
throws Exception {
|
|
|
431 |
List<FeatureDefinition> featureDefs =
|
|
|
432 |
new ArrayList<FeatureDefinition>();
|
|
|
433 |
|
|
|
434 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
435 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
436 |
slideDef.getSlideFeatureDefinitions();
|
|
|
437 |
|
|
|
438 |
for(int i=0; i<slideFeatureDefs.size(); i++) {
|
|
|
439 |
featureDefs.add(this.getFeatureDefinition(
|
|
|
440 |
slideFeatureDefs.get(i).getFeatureDefintionID()));
|
|
|
441 |
}
|
|
|
442 |
|
|
|
443 |
return featureDefs;
|
|
|
444 |
}
|
|
|
445 |
|
|
|
446 |
/**
|
| 49 |
naveen |
447 |
* Returns list of FeatureDefinition objects for a slide given editorial
|
|
|
448 |
* importance
|
| 19 |
naveen |
449 |
*
|
|
|
450 |
* @param slideID
|
| 49 |
naveen |
451 |
* @param imp Editorial Importance enum object
|
| 19 |
naveen |
452 |
* @return List<FeatureDefinition>
|
|
|
453 |
* @throws Exception
|
|
|
454 |
*/
|
|
|
455 |
public List<FeatureDefinition> getFeatureDefinitions(long slideID,
|
|
|
456 |
EditorialImportance imp) throws Exception {
|
|
|
457 |
List<FeatureDefinition> featureDefs =
|
|
|
458 |
new ArrayList<FeatureDefinition>();
|
|
|
459 |
|
|
|
460 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
461 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
462 |
slideDef.getSlideFeatureDefinitions();
|
|
|
463 |
|
|
|
464 |
for(SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
|
|
|
465 |
if(slideFeatureDef.getEditorialImportance() == imp) {
|
|
|
466 |
featureDefs.add(this.getFeatureDefinition(
|
|
|
467 |
slideFeatureDef.getFeatureDefintionID()));
|
|
|
468 |
}
|
|
|
469 |
}
|
|
|
470 |
|
|
|
471 |
return featureDefs;
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
/**
|
| 49 |
naveen |
475 |
* Resolves Feature Definition ID into FeatureDefinition object
|
| 19 |
naveen |
476 |
*
|
| 49 |
naveen |
477 |
* @param id Feature Definition ID
|
| 19 |
naveen |
478 |
* @return FeatureDefinition
|
| 18 |
naveen |
479 |
* @throws Exception
|
| 10 |
shop2020 |
480 |
*/
|
| 18 |
naveen |
481 |
public FeatureDefinition getFeatureDefinition(long id) throws Exception {
|
|
|
482 |
|
|
|
483 |
// Initialize
|
|
|
484 |
if(this.featureDefinitions == null) {
|
|
|
485 |
this.getFeatureDefinitions();
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
return this.featureDefinitions.get(new Long(id));
|
|
|
489 |
}
|
| 19 |
naveen |
490 |
|
|
|
491 |
/**
|
| 49 |
naveen |
492 |
* Returns matching FeatureDefinition object for slide ID and feature label.
|
|
|
493 |
* Label matching is case insensitive.
|
| 19 |
naveen |
494 |
*
|
| 49 |
naveen |
495 |
* @param slideID Slide ID
|
|
|
496 |
* @param featureLabel label to match, case is ignored
|
| 19 |
naveen |
497 |
* @return FeatureDefinition
|
|
|
498 |
* @throws Exception
|
|
|
499 |
*/
|
|
|
500 |
public FeatureDefinition getFeatureDefinition(long slideID,
|
|
|
501 |
String featureLabel) throws Exception {
|
|
|
502 |
FeatureDefinition featureDef = null;
|
|
|
503 |
|
|
|
504 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
505 |
for(SlideFeatureDefinition slideFeatureDef :
|
|
|
506 |
slideDef.getSlideFeatureDefinitions()) {
|
|
|
507 |
|
|
|
508 |
long featureDefID = slideFeatureDef.getFeatureDefintionID();
|
|
|
509 |
|
|
|
510 |
FeatureDefinition thisFeatureDef = this.getFeatureDefinition(
|
|
|
511 |
featureDefID);
|
|
|
512 |
|
| 28 |
naveen |
513 |
if(featureLabel.equalsIgnoreCase(thisFeatureDef.getLabel())) {
|
| 19 |
naveen |
514 |
featureDef = thisFeatureDef;
|
|
|
515 |
}
|
|
|
516 |
}
|
|
|
517 |
|
|
|
518 |
return featureDef;
|
|
|
519 |
}
|
| 24 |
naveen |
520 |
|
|
|
521 |
/**
|
| 49 |
naveen |
522 |
* Returns all EnumValue objects in the database
|
|
|
523 |
*
|
| 24 |
naveen |
524 |
* @return the enumValues
|
|
|
525 |
* @throws Exception
|
|
|
526 |
*/
|
|
|
527 |
@SuppressWarnings("unchecked")
|
|
|
528 |
public Map<Long, EnumValue> getEnumValues() throws Exception {
|
|
|
529 |
// De-serialise
|
|
|
530 |
if(this.enumValues == null) {
|
|
|
531 |
String dbFile = MM.DEFINITIONS_DB_PATH + "enumvalues" +
|
|
|
532 |
".ser";
|
|
|
533 |
|
|
|
534 |
this.enumValues =
|
|
|
535 |
(Map<Long, EnumValue>) DBUtils.read(dbFile);
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
return this.enumValues;
|
|
|
539 |
}
|
| 19 |
naveen |
540 |
|
| 24 |
naveen |
541 |
/**
|
| 49 |
naveen |
542 |
* Resolves Enum value ID into EnumValue object
|
| 24 |
naveen |
543 |
*
|
|
|
544 |
* @param enumValueID
|
|
|
545 |
* @return EnumValue
|
|
|
546 |
* @throws Exception
|
|
|
547 |
*/
|
|
|
548 |
public EnumValue getEnumValue(long enumValueID) throws Exception {
|
|
|
549 |
// Initialise
|
|
|
550 |
if(this.enumValues == null) {
|
|
|
551 |
this.getEnumValues();
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
return this.enumValues.get(new Long(enumValueID));
|
|
|
555 |
}
|
| 62 |
naveen |
556 |
|
|
|
557 |
/**
|
|
|
558 |
* Returns all FacetDefinition objects in the database
|
|
|
559 |
*
|
|
|
560 |
* @return Map Null if facet definitions are not imported into definitions
|
|
|
561 |
* db (serialized java objects)
|
|
|
562 |
*
|
|
|
563 |
* @throws Exception
|
|
|
564 |
*/
|
|
|
565 |
@SuppressWarnings("unchecked")
|
|
|
566 |
public Map<Long, FacetDefinition> getFacetDefinitions() throws Exception {
|
|
|
567 |
|
|
|
568 |
// De-serialize
|
|
|
569 |
if(this.facetDefinitions == null) {
|
|
|
570 |
String dbFile = MM.DEFINITIONS_DB_PATH + "facetdefintions" + ".ser";
|
|
|
571 |
|
|
|
572 |
this.facetDefinitions =
|
|
|
573 |
(Map<Long, FacetDefinition>) DBUtils.read(dbFile);
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
return this.facetDefinitions;
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
/**
|
|
|
580 |
* Resolves Facet Definition ID into FacetDefinition object
|
|
|
581 |
*
|
|
|
582 |
* @param facetDefinitionID
|
|
|
583 |
* @return FacetDefinition
|
|
|
584 |
* @throws Exception
|
|
|
585 |
*/
|
|
|
586 |
public FacetDefinition getFacetDefinition(long facetDefinitionID)
|
|
|
587 |
throws Exception {
|
|
|
588 |
|
|
|
589 |
if(this.facetDefinitions == null) {
|
|
|
590 |
this.getFacetDefinitions();
|
|
|
591 |
}
|
|
|
592 |
|
|
|
593 |
return this.facetDefinitions.get(new Long(facetDefinitionID));
|
|
|
594 |
}
|
|
|
595 |
|
|
|
596 |
/**
|
|
|
597 |
* Utility method to get Expanded version of ExpandedFacetDefinition object
|
|
|
598 |
*
|
|
|
599 |
* @param facetDefinitionID
|
|
|
600 |
* @return ExpandedFacetDefinition
|
|
|
601 |
* @throws Exception
|
|
|
602 |
*/
|
|
|
603 |
public ExpandedFacetDefinition getExpandedFacetDefinition(
|
|
|
604 |
long facetDefinitionID) throws Exception {
|
|
|
605 |
|
|
|
606 |
FacetDefinition facetDefinition =
|
|
|
607 |
this.getFacetDefinition(facetDefinitionID);
|
|
|
608 |
|
|
|
609 |
ExpandedFacetDefinition expFacetDefinition =
|
|
|
610 |
new ExpandedFacetDefinition(facetDefinition);
|
|
|
611 |
|
|
|
612 |
return expFacetDefinition;
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
/**
|
|
|
616 |
* Returns all CategoryFacetDefinition objects in the database
|
|
|
617 |
*
|
|
|
618 |
* @return Map Null if category facet definitions are not imported into
|
|
|
619 |
* definitions db (serialized java objects)
|
|
|
620 |
*
|
|
|
621 |
* @throws Exception
|
|
|
622 |
*/
|
|
|
623 |
@SuppressWarnings("unchecked")
|
|
|
624 |
public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions()
|
|
|
625 |
throws Exception {
|
|
|
626 |
|
|
|
627 |
// De-serialize
|
|
|
628 |
if(this.categoryFacetDefinitions == null) {
|
|
|
629 |
String dbFile = MM.DEFINITIONS_DB_PATH + "categoryfacetdefintions" +
|
|
|
630 |
".ser";
|
|
|
631 |
|
|
|
632 |
this.categoryFacetDefinitions =
|
|
|
633 |
(Map<Long, CategoryFacetDefinition>) DBUtils.read(dbFile);
|
|
|
634 |
}
|
|
|
635 |
|
|
|
636 |
return this.categoryFacetDefinitions;
|
|
|
637 |
}
|
|
|
638 |
|
|
|
639 |
/**
|
|
|
640 |
* Resolves Category-Facet Definition ID into CategoryFacetDefinition object
|
|
|
641 |
*
|
|
|
642 |
* @param categoryID
|
|
|
643 |
* @return CategoryFacetDefinition
|
|
|
644 |
* @throws Exception
|
|
|
645 |
*/
|
|
|
646 |
public CategoryFacetDefinition getCategoryFacetDefinition(
|
|
|
647 |
long categoryID) throws Exception {
|
|
|
648 |
|
|
|
649 |
if(this.categoryFacetDefinitions == null) {
|
|
|
650 |
this.getCategoryFacetDefinitions();
|
|
|
651 |
}
|
|
|
652 |
|
|
|
653 |
return this.categoryFacetDefinitions.get(
|
|
|
654 |
new Long(categoryID));
|
|
|
655 |
}
|
|
|
656 |
|
|
|
657 |
/**
|
|
|
658 |
* Utility method to get Expanded version of CategoryFacetDefinition object
|
|
|
659 |
*
|
|
|
660 |
* @param categoryID
|
|
|
661 |
* @return ExpandedCategoryFacetDefinition
|
|
|
662 |
* @throws Exception
|
|
|
663 |
*/
|
|
|
664 |
public ExpandedCategoryFacetDefinition getExpandedCategoryFacetDefinition(
|
|
|
665 |
long categoryID) throws Exception {
|
|
|
666 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
667 |
this.getCategoryFacetDefinition(categoryID);
|
|
|
668 |
|
|
|
669 |
ExpandedCategoryFacetDefinition expCategoryFacetDef =
|
|
|
670 |
new ExpandedCategoryFacetDefinition(categoryFacetDef);
|
|
|
671 |
|
|
|
672 |
return expCategoryFacetDef;
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
/**
|
|
|
676 |
* Returns all IR Data RuleDefintion objects in the database
|
|
|
677 |
*
|
|
|
678 |
* @return Map Null if IR data rule definitions are not imported into
|
|
|
679 |
* definitions db (serialized java objects)
|
|
|
680 |
*
|
|
|
681 |
* @throws Exception
|
|
|
682 |
*/
|
|
|
683 |
@SuppressWarnings("unchecked")
|
|
|
684 |
public Map<Long, RuleDefinition> getIrDataRuleDefinitions()
|
|
|
685 |
throws Exception {
|
|
|
686 |
|
|
|
687 |
// De-serialize
|
|
|
688 |
if(this.irDataRuleDefinitions == null) {
|
|
|
689 |
String dbFile = MM.DEFINITIONS_DB_PATH + "irdatarules" + ".ser";
|
|
|
690 |
|
|
|
691 |
this.irDataRuleDefinitions =
|
|
|
692 |
(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
|
|
|
693 |
}
|
|
|
694 |
|
|
|
695 |
return this.irDataRuleDefinitions;
|
|
|
696 |
}
|
|
|
697 |
|
|
|
698 |
/**
|
|
|
699 |
* Resolves IR Data Rule Definition ID into RuleDefinition object
|
|
|
700 |
*
|
|
|
701 |
* @param irDataRuleDefinitionID
|
|
|
702 |
* @return RuleDefinition
|
|
|
703 |
* @throws Exception
|
|
|
704 |
*/
|
|
|
705 |
public RuleDefinition getIrDataRuleDefinition(
|
|
|
706 |
long irDataRuleDefinitionID) throws Exception {
|
|
|
707 |
|
|
|
708 |
if(this.irDataRuleDefinitions == null) {
|
|
|
709 |
this.getIrDataRuleDefinitions();
|
|
|
710 |
}
|
|
|
711 |
|
|
|
712 |
return this.irDataRuleDefinitions.get(new Long(irDataRuleDefinitionID));
|
|
|
713 |
}
|
|
|
714 |
|
|
|
715 |
/**
|
|
|
716 |
* Returns all IR Meta Data RuleDefintion objects in the database
|
|
|
717 |
*
|
|
|
718 |
* @return Map Null if IR meta-data rule definitions are not imported into
|
|
|
719 |
* definitions db (serialized java objects)
|
|
|
720 |
*
|
|
|
721 |
* @throws Exception
|
|
|
722 |
*/
|
|
|
723 |
@SuppressWarnings("unchecked")
|
|
|
724 |
public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions()
|
|
|
725 |
throws Exception {
|
|
|
726 |
|
|
|
727 |
// De-serialize
|
|
|
728 |
if(this.irMetaDataRuleDefinitions == null) {
|
|
|
729 |
String dbFile = MM.DEFINITIONS_DB_PATH + "irmetadatarules" + ".ser";
|
|
|
730 |
|
|
|
731 |
this.irMetaDataRuleDefinitions =
|
|
|
732 |
(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
|
|
|
733 |
}
|
|
|
734 |
|
|
|
735 |
return this.irMetaDataRuleDefinitions;
|
|
|
736 |
}
|
|
|
737 |
|
|
|
738 |
/**
|
|
|
739 |
* Resolves IR Meta Data Rule Definition ID into RuleDefinition object
|
|
|
740 |
*
|
|
|
741 |
* @param irMetaDataRuleDefinitionID
|
|
|
742 |
* @return RuleDefinition
|
|
|
743 |
* @throws Exception
|
|
|
744 |
*/
|
|
|
745 |
public RuleDefinition getIrMetaDataRuleDefinition(
|
|
|
746 |
long irMetaDataRuleDefinitionID) throws Exception {
|
|
|
747 |
|
|
|
748 |
if(this.irMetaDataRuleDefinitions == null) {
|
|
|
749 |
this.getIrMetaDataRuleDefinitions();
|
|
|
750 |
}
|
|
|
751 |
|
|
|
752 |
return this.irMetaDataRuleDefinitions.get(
|
|
|
753 |
new Long(irMetaDataRuleDefinitionID));
|
|
|
754 |
}
|
| 10 |
shop2020 |
755 |
}
|