Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 shop2020 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.definitions;
5
 
45 naveen 6
import in.shop2020.metamodel.util.ExpandedCategory;
62 naveen 7
import in.shop2020.metamodel.util.ExpandedCategoryFacetDefinition;
8
import in.shop2020.metamodel.util.ExpandedFacetDefinition;
17 naveen 9
import in.shop2020.metamodel.util.MM;
64 naveen 10
import in.shop2020.util.DBUtils;
17 naveen 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) {
63 naveen 570
			String dbFile = MM.DEFINITIONS_DB_PATH + "facetdefinitions" + 
571
				".ser";
62 naveen 572
 
573
			this.facetDefinitions = 
574
				(Map<Long, FacetDefinition>) DBUtils.read(dbFile);
575
		}
576
 
577
		return this.facetDefinitions;
578
	}
579
 
580
	/**
581
	 * Resolves Facet Definition ID into FacetDefinition object
582
	 * 
583
	 * @param facetDefinitionID
584
	 * @return FacetDefinition
585
	 * @throws Exception
586
	 */
587
	public FacetDefinition getFacetDefinition(long facetDefinitionID) 
588
		throws Exception {
589
 
590
		if(this.facetDefinitions == null) {
591
			this.getFacetDefinitions();
592
		}
593
 
594
		return this.facetDefinitions.get(new Long(facetDefinitionID));
595
	}
596
 
597
	/**
598
	 * Utility method to get Expanded version of ExpandedFacetDefinition object 
599
	 * 
600
	 * @param facetDefinitionID
601
	 * @return ExpandedFacetDefinition
602
	 * @throws Exception
603
	 */
604
	public ExpandedFacetDefinition getExpandedFacetDefinition(
605
			long facetDefinitionID) throws Exception {
606
 
607
		FacetDefinition facetDefinition = 
608
			this.getFacetDefinition(facetDefinitionID);
609
 
610
		ExpandedFacetDefinition expFacetDefinition = 
611
			new ExpandedFacetDefinition(facetDefinition);
612
 
613
		return expFacetDefinition;
614
	}
615
 
616
	/**
617
	 * Returns all CategoryFacetDefinition objects in the database
618
	 * 
619
	 * @return Map Null if category facet definitions are not imported into 
620
	 * definitions db (serialized java objects)
621
	 * 
622
	 * @throws Exception 
623
	 */
624
	@SuppressWarnings("unchecked")
625
	public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions() 
626
		throws Exception {
627
 
628
		// De-serialize
629
		if(this.categoryFacetDefinitions == null) {
63 naveen 630
			String dbFile = MM.DEFINITIONS_DB_PATH + "categoryfacetdefinitions" + 
62 naveen 631
				".ser";
632
 
633
			this.categoryFacetDefinitions = 
634
				(Map<Long, CategoryFacetDefinition>) DBUtils.read(dbFile);
635
		}
636
 
637
		return this.categoryFacetDefinitions;
638
	}
639
 
640
	/**
641
	 * Resolves Category-Facet Definition ID into CategoryFacetDefinition object
642
	 * 
643
	 * @param categoryID
644
	 * @return CategoryFacetDefinition
645
	 * @throws Exception
646
	 */
647
	public CategoryFacetDefinition getCategoryFacetDefinition(
648
			long categoryID) throws Exception {
649
 
650
		if(this.categoryFacetDefinitions == null) {
651
			this.getCategoryFacetDefinitions();
652
		}
653
 
654
		return this.categoryFacetDefinitions.get(
655
				new Long(categoryID));
656
	}
657
 
658
	/**
659
	 * Utility method to get Expanded version of CategoryFacetDefinition object 
660
	 * 
661
	 * @param categoryID
662
	 * @return ExpandedCategoryFacetDefinition
663
	 * @throws Exception
664
	 */
665
	public ExpandedCategoryFacetDefinition getExpandedCategoryFacetDefinition(
666
			long categoryID) throws Exception  {
667
		CategoryFacetDefinition categoryFacetDef = 
668
			this.getCategoryFacetDefinition(categoryID);
669
 
670
		ExpandedCategoryFacetDefinition expCategoryFacetDef = 
671
			new ExpandedCategoryFacetDefinition(categoryFacetDef);
672
 
673
		return expCategoryFacetDef;
674
	}
675
 
676
	/**
677
	 * Returns all IR Data RuleDefintion objects in the database
678
	 * 
679
	 * @return Map Null if IR data rule definitions are not imported into 
680
	 * definitions db (serialized java objects)
681
	 * 
682
	 * @throws Exception 
683
	 */
684
	@SuppressWarnings("unchecked")
685
	public Map<Long, RuleDefinition> getIrDataRuleDefinitions() 
686
		throws Exception {
687
 
688
		// De-serialize
689
		if(this.irDataRuleDefinitions == null) {
690
			String dbFile = MM.DEFINITIONS_DB_PATH + "irdatarules" + ".ser";
691
 
692
			this.irDataRuleDefinitions = 
693
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
694
		}
695
 
696
		return this.irDataRuleDefinitions;
697
	}
698
 
699
	/**
700
	 * Resolves IR Data Rule Definition ID into RuleDefinition object
701
	 * 
702
	 * @param irDataRuleDefinitionID
703
	 * @return RuleDefinition
704
	 * @throws Exception
705
	 */
706
	public RuleDefinition getIrDataRuleDefinition(
707
			long irDataRuleDefinitionID) throws Exception {
708
 
709
		if(this.irDataRuleDefinitions == null) {
710
			this.getIrDataRuleDefinitions();
711
		}
712
 
713
		return this.irDataRuleDefinitions.get(new Long(irDataRuleDefinitionID));
714
	}
715
 
716
	/**
717
	 * Returns all IR Meta Data RuleDefintion objects in the database
718
	 * 
719
	 * @return Map Null if IR meta-data rule definitions are not imported into 
720
	 * definitions db (serialized java objects)
721
	 * 
722
	 * @throws Exception 
723
	 */
724
	@SuppressWarnings("unchecked")
725
	public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions() 
726
		throws Exception {
727
 
728
		// De-serialize
729
		if(this.irMetaDataRuleDefinitions == null) {
730
			String dbFile = MM.DEFINITIONS_DB_PATH + "irmetadatarules" + ".ser";
731
 
732
			this.irMetaDataRuleDefinitions = 
733
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
734
		}
735
 
736
		return this.irMetaDataRuleDefinitions;
737
	}
738
 
739
	/**
740
	 * Resolves IR Meta Data Rule Definition ID into RuleDefinition object
741
	 * 
742
	 * @param irMetaDataRuleDefinitionID
743
	 * @return RuleDefinition
744
	 * @throws Exception
745
	 */
746
	public RuleDefinition getIrMetaDataRuleDefinition(
747
			long irMetaDataRuleDefinitionID) throws Exception {
748
 
749
		if(this.irMetaDataRuleDefinitions == null) {
750
			this.getIrMetaDataRuleDefinitions();
751
		}
752
 
753
		return this.irMetaDataRuleDefinitions.get(
754
				new Long(irMetaDataRuleDefinitionID));
755
	}
10 shop2020 756
}