Subversion Repositories SmartDukaan

Rev

Rev 516 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 516 Rev 1050
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.metamodel.definitions;
4
package in.shop2020.metamodel.definitions;
5
 
5
 
-
 
6
import in.shop2020.metamodel.jaxb.comparison.CMPBucketDefinitionType;
-
 
7
import in.shop2020.metamodel.jaxb.comparison.CMPDefinitionType;
-
 
8
import in.shop2020.metamodel.jaxb.comparison.CMPRuleDefinitionType;
-
 
9
import in.shop2020.metamodel.jaxb.comparison.CMPSlideRuleDefinitionType;
-
 
10
import in.shop2020.metamodel.jaxb.core.BulletDefinitionType;
-
 
11
import in.shop2020.metamodel.jaxb.core.CategorySlideDefinitionType;
-
 
12
import in.shop2020.metamodel.jaxb.core.CategorySlideSequenceType;
-
 
13
import in.shop2020.metamodel.jaxb.core.CategoryType;
-
 
14
import in.shop2020.metamodel.jaxb.core.CompositeDefinitionType;
-
 
15
import in.shop2020.metamodel.jaxb.core.CompositePartDefinitionType;
-
 
16
import in.shop2020.metamodel.jaxb.core.DatatypeDefinitionType;
-
 
17
import in.shop2020.metamodel.jaxb.core.DefinitionType;
-
 
18
import in.shop2020.metamodel.jaxb.core.EditorialImportanceType;
-
 
19
import in.shop2020.metamodel.jaxb.core.EnumDefinitionType;
-
 
20
import in.shop2020.metamodel.jaxb.core.EnumValueType;
-
 
21
import in.shop2020.metamodel.jaxb.core.FeatureDefinitionType;
-
 
22
import in.shop2020.metamodel.jaxb.core.SlideDefinitionType;
-
 
23
import in.shop2020.metamodel.jaxb.core.SlideFeatureDefinitionType;
-
 
24
import in.shop2020.metamodel.jaxb.core.UnitType;
-
 
25
import in.shop2020.metamodel.jaxb.facets.CategoryFacetDefinitionType;
-
 
26
import in.shop2020.metamodel.jaxb.facets.FacetDefinitionType;
-
 
27
import in.shop2020.metamodel.jaxb.facets.FacetRuleDefinitionType;
-
 
28
import in.shop2020.metamodel.jaxb.facets.IRDefinitionType;
-
 
29
import in.shop2020.metamodel.jaxb.facets.RuleDefinitionType;
6
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
30
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
7
import in.shop2020.metamodel.util.ExpandedCategory;
31
import in.shop2020.metamodel.util.ExpandedCategory;
8
import in.shop2020.metamodel.util.ExpandedCategoryFacetDefinition;
32
import in.shop2020.metamodel.util.ExpandedCategoryFacetDefinition;
9
import in.shop2020.metamodel.util.ExpandedFacetDefinition;
33
import in.shop2020.metamodel.util.ExpandedFacetDefinition;
10
import in.shop2020.metamodel.util.ExpandedSlideDefinition;
34
import in.shop2020.metamodel.util.ExpandedSlideDefinition;
11
import in.shop2020.util.DBUtils;
-
 
12
import in.shop2020.util.Utils;
35
import in.shop2020.util.Utils;
13
 
36
 
14
import java.io.File;
37
import java.io.File;
-
 
38
import java.io.FileInputStream;
15
import java.io.Serializable;
39
import java.io.Serializable;
16
import java.util.ArrayList;
40
import java.util.ArrayList;
-
 
41
import java.util.HashMap;
17
import java.util.Iterator;
42
import java.util.Iterator;
18
import java.util.List;
43
import java.util.List;
19
import java.util.Map;
44
import java.util.Map;
-
 
45
import java.util.TreeMap;
-
 
46
 
-
 
47
import javax.xml.bind.JAXBContext;
-
 
48
import javax.xml.bind.JAXBElement;
-
 
49
import javax.xml.bind.Unmarshaller;
20
 
50
 
21
/**
51
/**
22
 * Single point of access to all definition objects
52
 * Single point of access to all definition objects
23
 * 
53
 * 
24
 * @author naveen
54
 * @author naveen
Line 109... Line 139...
109
	private Map<Long, List<Long>> categorySlideSequence;
139
	private Map<Long, List<Long>> categorySlideSequence;
110
	
140
	
111
	/**
141
	/**
112
	 * Database path. Just in case we want to override
142
	 * Database path. Just in case we want to override
113
	 */
143
	 */
114
	private String dbPath =  Utils.CONTENT_DB_PATH;
144
	private String xmlDefinitionsPath =  Utils.CONTENT_DB_PATH + "definitions" + File.separator;
115
	
145
	
116
	/**
146
	/**
117
	 * Empty constructor. Data structures are initialised as needed
147
	 * Empty constructor. Data structures are initialised as needed
-
 
148
	 * @throws Exception 
118
	 */
149
	 */
119
	public DefinitionsContainer() {
150
	public DefinitionsContainer(){
-
 
151
		try {
120
		// Lazy initialization
152
			initialize();
-
 
153
		} catch (Exception e) {
-
 
154
			// TODO Auto-generated catch block
-
 
155
			e.printStackTrace();
-
 
156
		}
121
	}
157
	}
122
	
158
	
123
	/**
159
	/**
124
	 * Empty constructor. Just dbPath is initialised
160
	 * Empty constructor. Just dbPath is initialised
-
 
161
	 * @throws Exception 
-
 
162
	 */
-
 
163
	public DefinitionsContainer(String xmlDefinitionsPath) throws Exception {
-
 
164
		this.xmlDefinitionsPath = xmlDefinitionsPath;
-
 
165
		initialize();
-
 
166
	}
-
 
167
 
-
 
168
	
-
 
169
	private void initialize() throws Exception{
-
 
170
		initializeCoreDefinitionObjects();
-
 
171
		initializeFacetsDefinitionObjects();
-
 
172
		initializeComparisonDefinitionObjects();
-
 
173
	}
-
 
174
	
-
 
175
	private void initializeCoreDefinitionObjects() throws Exception{
-
 
176
		DefinitionType defType = null;
-
 
177
		String srcFile;
-
 
178
		Object oDefType = null;
-
 
179
 
-
 
180
		// categoriy slide sequence
-
 
181
		srcFile = xmlDefinitionsPath+ "categories.xml";
-
 
182
		oDefType = this.unmarshallSrcFile(srcFile, "core");
-
 
183
		defType = (DefinitionType)oDefType;
-
 
184
		//FIXME
-
 
185
		categories = new HashMap<Long, Category>();
-
 
186
		Category root = this.convertCategories(defType, categories, srcFile);
-
 
187
		
-
 
188
		// category slide sequence
-
 
189
		srcFile = xmlDefinitionsPath+ "categoryslidesequence.xml";
-
 
190
		oDefType = this.unmarshallSrcFile(srcFile, "core");
-
 
191
		defType = (DefinitionType)oDefType;
-
 
192
		this.categorySlideSequence = this.convertCategorySlideSequence(defType);
-
 
193
		
-
 
194
		// units
-
 
195
		srcFile = xmlDefinitionsPath+ "units.xml";
-
 
196
		oDefType = this.unmarshallSrcFile(srcFile, "core");
-
 
197
		defType = (DefinitionType)oDefType;
-
 
198
		this.units = this.convertUnits(defType);
-
 
199
 
-
 
200
		//data type definitions
-
 
201
		srcFile = xmlDefinitionsPath+ "datatypedefinitions.xml";
-
 
202
		oDefType = this.unmarshallSrcFile(srcFile, "core");
-
 
203
		defType = (DefinitionType)oDefType;
-
 
204
		this.datatypeDefinitions = this.convertDatatypeDefinition(defType);
-
 
205
		
-
 
206
		//enum values
-
 
207
		populateEnumValues();
-
 
208
		
-
 
209
		//feature definitions
-
 
210
		srcFile = xmlDefinitionsPath+ "featuredefinitions.xml";
-
 
211
		oDefType = this.unmarshallSrcFile(srcFile, "core");
-
 
212
		defType = (DefinitionType)oDefType;
-
 
213
		this.featureDefinitions = this.convertFeatureDefinitions(defType);
-
 
214
		
-
 
215
		//slide definitions
-
 
216
		srcFile = xmlDefinitionsPath+ "slidedefinitions.xml";
-
 
217
		oDefType = this.unmarshallSrcFile(srcFile, "core");
-
 
218
		defType = (DefinitionType)oDefType;
-
 
219
		this.slideDefinitions = this.convertSlideDefinitions(defType);
-
 
220
 
-
 
221
	}
-
 
222
	
-
 
223
	private void initializeFacetsDefinitionObjects() throws Exception{
-
 
224
		IRDefinitionType irDefType = null;
-
 
225
		String srcFile;
-
 
226
		Object oDefType = null;
-
 
227
 
-
 
228
		//all facet definitions
-
 
229
		srcFile = xmlDefinitionsPath+ "facetdefinitions.xml";
-
 
230
		oDefType = this.unmarshallSrcFile(srcFile, "facets");
-
 
231
		irDefType = (IRDefinitionType)oDefType;
-
 
232
		this.facetDefinitions = this.convertFacetDefinitions(irDefType);
-
 
233
		
-
 
234
		//category facet definitions
-
 
235
		srcFile = xmlDefinitionsPath+ "categoryfacetdefinitions.xml";
-
 
236
		oDefType = this.unmarshallSrcFile(srcFile, "facets");
-
 
237
		irDefType = (IRDefinitionType)oDefType;
-
 
238
		this.categoryFacetDefinitions = this.convertCategoryFacetDefinitions(irDefType);
-
 
239
		
-
 
240
 
-
 
241
		//ir data rules
-
 
242
		srcFile = xmlDefinitionsPath+ "irdatarules.xml";
-
 
243
		oDefType = this.unmarshallSrcFile(srcFile, "facets");
-
 
244
		irDefType = (IRDefinitionType)oDefType;
-
 
245
		irDataRuleDefinitions =  this.convertRuleDefinitions(irDefType);
-
 
246
		
-
 
247
		//ir meta data rules
-
 
248
		srcFile = xmlDefinitionsPath+ "irmetadatarules.xml";
-
 
249
		oDefType = this.unmarshallSrcFile(srcFile, "facets");
-
 
250
		irDefType = (IRDefinitionType)oDefType;
-
 
251
		irDataRuleDefinitions =  this.convertRuleDefinitions(irDefType);
-
 
252
 
-
 
253
		//normalization rules
-
 
254
		srcFile = xmlDefinitionsPath+ "normalizationrules.xml";
-
 
255
		oDefType = this.unmarshallSrcFile(srcFile, "facets");
-
 
256
		irDefType = (IRDefinitionType)oDefType;
-
 
257
		normalizationRuleDefinitions = this.convertNormalizationRuleDefinitions(irDefType);
-
 
258
	}
-
 
259
	
-
 
260
	private void initializeComparisonDefinitionObjects() throws Exception{
-
 
261
		CMPDefinitionType cmpDefType = null;
-
 
262
		String srcFile;
-
 
263
		Object oDefType = null;
-
 
264
 
-
 
265
		//all facet definitions
-
 
266
		srcFile = xmlDefinitionsPath+ "comparisonrules.xml";
-
 
267
		oDefType = this.unmarshallSrcFile(srcFile, "comparison");
-
 
268
		cmpDefType = (CMPDefinitionType)oDefType;
-
 
269
		this.cmpRuleDefinitions = this.convertComparisonRuleDefinitions(cmpDefType);
-
 
270
 
-
 
271
		
-
 
272
		//all f
-
 
273
		srcFile = xmlDefinitionsPath+ "comparisondefinitions.xml";
-
 
274
		oDefType = this.unmarshallSrcFile(srcFile, "comparison");
-
 
275
		cmpDefType = (CMPDefinitionType)oDefType;
-
 
276
		this.cmpSlideRuleDefinitions = this.convertComparisonDefinitions(cmpDefType);
-
 
277
		
-
 
278
		//all facet definitions
-
 
279
		srcFile = xmlDefinitionsPath+ "comparisonbuckets.xml";
-
 
280
		oDefType = this.unmarshallSrcFile(srcFile, "comparison");
-
 
281
		cmpDefType = (CMPDefinitionType)oDefType;
-
 
282
		this.cmpBucketDefinitions = this.convertComparisonBuckets(cmpDefType);
-
 
283
		
-
 
284
	}
-
 
285
 
-
 
286
	
-
 
287
	/**
-
 
288
	 * 
-
 
289
	 * @param irDefType
-
 
290
	 * @return
-
 
291
	 */
-
 
292
	private Map<Long, RuleDefinition> convertNormalizationRuleDefinitions(
-
 
293
			IRDefinitionType defType) {
-
 
294
		
-
 
295
		Map<Long, RuleDefinition> idRuleDef = 
-
 
296
			new TreeMap<Long, RuleDefinition>();
-
 
297
		
-
 
298
		List<RuleDefinitionType> jaxbRuleDefs = defType.getRuleDefinition();
-
 
299
		
-
 
300
		for(RuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
-
 
301
			long id = jaxbRuleDef.getID();
-
 
302
			String script = jaxbRuleDef.getScript();
-
 
303
			
-
 
304
			RuleDefinition ruleDef = new RuleDefinition(id, script);
-
 
305
			ruleDef.setDescription(jaxbRuleDef.getDescription());
-
 
306
			
-
 
307
			idRuleDef.put(new Long(id), ruleDef);
-
 
308
		}
-
 
309
		
-
 
310
		Utils.info("idRuleDef=" + idRuleDef);
-
 
311
		
-
 
312
		return idRuleDef;
-
 
313
	}
-
 
314
 
-
 
315
	
-
 
316
	
-
 
317
	/**
-
 
318
	 * 
-
 
319
	 * @param defType
-
 
320
	 * @return Map<Long, CMPRuleDefinition>
125
	 */
321
	 */
-
 
322
	private Map<Long, CMPRuleDefinition> convertComparisonRuleDefinitions(
126
	public DefinitionsContainer(String dbPath) {
323
			CMPDefinitionType defType) {
-
 
324
		Map<Long, CMPRuleDefinition> idRuleDef = 
-
 
325
			new TreeMap<Long, CMPRuleDefinition>();
-
 
326
		
-
 
327
		List<CMPRuleDefinitionType> jaxbRuleDefs = 
-
 
328
			defType.getCMPRuleDefinition();
-
 
329
		
-
 
330
		for(CMPRuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
-
 
331
			long id = jaxbRuleDef.getID();
-
 
332
			String script = jaxbRuleDef.getScript();
-
 
333
			
-
 
334
			CMPRuleDefinition ruleDef = new CMPRuleDefinition(id, script);
-
 
335
			ruleDef.setDescription(jaxbRuleDef.getDescription());
-
 
336
			
-
 
337
			idRuleDef.put(new Long(id), ruleDef);
-
 
338
		}
-
 
339
		
127
		this.dbPath = dbPath;
340
		Utils.info("idRuleDef=" + idRuleDef);
128
		// Lazy initialization
341
		return idRuleDef;
129
	}
342
	}
130
	
343
	
131
	/**
344
	/**
-
 
345
	 * 
-
 
346
	 * @param defType
-
 
347
	 * @return Map<Long, CMPSlideRuleDefinition> 
-
 
348
	 */
-
 
349
	private Map<Long, CMPSlideRuleDefinition> convertComparisonDefinitions(
-
 
350
			CMPDefinitionType defType) {
-
 
351
		
-
 
352
		Map<Long, CMPSlideRuleDefinition> slideRuleDefs = 
-
 
353
			new TreeMap<Long, CMPSlideRuleDefinition>();
-
 
354
		
-
 
355
		List<CMPSlideRuleDefinitionType> jaxbDefs = 
-
 
356
			defType.getCMPSlideRuleDefinition();
-
 
357
		
-
 
358
		for(CMPSlideRuleDefinitionType jaxbDef : jaxbDefs) {
-
 
359
			long ruleDefID = jaxbDef.getRuleDefinitionID();
-
 
360
			long slideDefID = jaxbDef.getSlideDefinitionID();
-
 
361
			
-
 
362
			CMPSlideRuleDefinition slideRuleDef = 
-
 
363
				new CMPSlideRuleDefinition(slideDefID, ruleDefID);
-
 
364
			
-
 
365
			slideRuleDef.setDescription(jaxbDef.getDescription());
-
 
366
			
-
 
367
			slideRuleDefs.put(new Long(slideDefID), slideRuleDef);
-
 
368
		}
-
 
369
		
-
 
370
		Utils.info("slideRuleDefs=" + slideRuleDefs);
-
 
371
		return slideRuleDefs;
-
 
372
	}
-
 
373
	
-
 
374
	/**
-
 
375
	 * 
-
 
376
	 * @param defType
-
 
377
	 * @return
-
 
378
	 */
-
 
379
	private Map<Long, List<CMPBucketDefinition>> convertComparisonBuckets(
-
 
380
			CMPDefinitionType defType) {
-
 
381
		
-
 
382
		Map<Long, List<CMPBucketDefinition>> cmpBuckets = 
-
 
383
			new HashMap<Long, List<CMPBucketDefinition>>();
-
 
384
		
-
 
385
		List<CMPBucketDefinitionType> jaxbBuckets = 
-
 
386
			defType.getCMPBucketDefinition();
-
 
387
		
-
 
388
		for(CMPBucketDefinitionType jaxbBucket : jaxbBuckets) {
-
 
389
			String name = jaxbBucket.getName();
-
 
390
			long categoryID = jaxbBucket.getCategoryID();
-
 
391
			
-
 
392
			CMPBucketDefinition bucketDef = 
-
 
393
				new CMPBucketDefinition(name, categoryID);
-
 
394
			
-
 
395
			bucketDef.setDescription(jaxbBucket.getDescription());
-
 
396
			bucketDef.setDefaultWeight(
-
 
397
					jaxbBucket.getDefaultWeight().intValue());
-
 
398
			bucketDef.setSlideDefinitionIDs(jaxbBucket.getSlideDefinitionID());
-
 
399
			
-
 
400
			List<CMPBucketDefinition> categoryBuckets = 
-
 
401
				cmpBuckets.get(new Long(categoryID));
-
 
402
			
-
 
403
			if(categoryBuckets == null) {
-
 
404
				categoryBuckets = new ArrayList<CMPBucketDefinition>();
-
 
405
				cmpBuckets.put(new Long(categoryID), categoryBuckets);
-
 
406
			}
-
 
407
			
-
 
408
			categoryBuckets.add(bucketDef);
-
 
409
		}
-
 
410
		Utils.info("cmpBuckets=" + cmpBuckets);
-
 
411
		
-
 
412
		return cmpBuckets;
-
 
413
	}
-
 
414
 
-
 
415
	
-
 
416
	/**
-
 
417
	 * 
-
 
418
	 * @param defType
-
 
419
	 * @return
-
 
420
	 */
-
 
421
	private Map<Long, RuleDefinition> convertRuleDefinitions(
-
 
422
			IRDefinitionType defType) {
-
 
423
		Map<Long, RuleDefinition> idRuleDef = 
-
 
424
			new TreeMap<Long, RuleDefinition>();
-
 
425
		
-
 
426
		List<RuleDefinitionType> jaxbRuleDefs = defType.getRuleDefinition();
-
 
427
		
-
 
428
		for(RuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
-
 
429
			long id = jaxbRuleDef.getID();
-
 
430
			String script = jaxbRuleDef.getScript();
-
 
431
			
-
 
432
			RuleDefinition ruleDef = new RuleDefinition(id, script);
-
 
433
			ruleDef.setDescription(jaxbRuleDef.getDescription());
-
 
434
			
-
 
435
			idRuleDef.put(new Long(id), ruleDef);
-
 
436
		}
-
 
437
		
-
 
438
		Utils.info("idRuleDef=" + idRuleDef);
-
 
439
		return idRuleDef;
-
 
440
	}
-
 
441
 
-
 
442
	
-
 
443
	/**
-
 
444
	 * 
-
 
445
	 * @param defType
-
 
446
	 * @return
-
 
447
	 */
-
 
448
	private Map<Long, FacetDefinition> convertFacetDefinitions(
-
 
449
			IRDefinitionType defType) {
-
 
450
		List<FacetDefinitionType> jaxbFacetDefs = defType.getFacetDefinition();
-
 
451
		
-
 
452
		Map<Long, FacetDefinition> idFacetDefs = 
-
 
453
			new TreeMap<Long, FacetDefinition>();
-
 
454
		
-
 
455
		for(FacetDefinitionType jaxbFacetDef : jaxbFacetDefs) {
-
 
456
			long id = jaxbFacetDef.getID();
-
 
457
			String target = jaxbFacetDef.getTarget();
-
 
458
 
-
 
459
			FacetDefinition facetDef = new FacetDefinition(id, target);
-
 
460
			
-
 
461
			if(jaxbFacetDef.getFeatureDefinitionID() != null) {
-
 
462
				long featureDefID = jaxbFacetDef.getFeatureDefinitionID();
-
 
463
				facetDef.setFeatureDefinitionID(featureDefID);
-
 
464
			}
-
 
465
			
-
 
466
			if(jaxbFacetDef.getSlideDefinitionID() != null) {
-
 
467
				long slideDefID = jaxbFacetDef.getSlideDefinitionID();
-
 
468
				facetDef.setSlideDefinitionID(slideDefID);
-
 
469
			}
-
 
470
			
-
 
471
			long irMetaDataRuleID = jaxbFacetDef.getIRMetaDataRuleID();
-
 
472
			facetDef.setIrMetaDataRuleID(irMetaDataRuleID);
-
 
473
			
-
 
474
			facetDef.setDescription(jaxbFacetDef.getDescription());
-
 
475
			
-
 
476
			idFacetDefs.put(new Long(id), facetDef);
-
 
477
		}
-
 
478
		Utils.info("idFacetDefs=" + idFacetDefs);
-
 
479
		return idFacetDefs;
-
 
480
	}
-
 
481
	
-
 
482
	/**
-
 
483
	 * 
-
 
484
	 * @param defType
-
 
485
	 * @return
-
 
486
	 * @throws Exception 
-
 
487
	 */
-
 
488
	private Map<Long, CategoryFacetDefinition> convertCategoryFacetDefinitions(
-
 
489
			IRDefinitionType defType) throws Exception {
-
 
490
		List<CategoryFacetDefinitionType> jaxbCategoryFacetDefs = 
-
 
491
			defType.getCategoryFacetDefinition();
-
 
492
		
-
 
493
		Map<Long, CategoryFacetDefinition> idCategoryFacetDefs = 
-
 
494
			new TreeMap<Long, CategoryFacetDefinition>();
-
 
495
		
-
 
496
		for(CategoryFacetDefinitionType jaxbCategoryFacetDef : 
-
 
497
			jaxbCategoryFacetDefs) {
-
 
498
			long categoryID = jaxbCategoryFacetDef.getCategoryID();
-
 
499
			
-
 
500
			CategoryFacetDefinition categoryFacetDef = 
-
 
501
				new CategoryFacetDefinition(categoryID);
-
 
502
			
-
 
503
			List<FacetRuleDefinitionType> jaxbFacetRuleDefs = 
-
 
504
					jaxbCategoryFacetDef.getFacetRuleDefinition();
-
 
505
			
-
 
506
			for(FacetRuleDefinitionType jaxbFacetRuleDef : jaxbFacetRuleDefs) {
-
 
507
				
-
 
508
				FacetRuleDefinition facetRuleDef = 
-
 
509
					this.convertFacetRuleDefinition(jaxbFacetRuleDef);
-
 
510
				
-
 
511
				categoryFacetDef.addFacetRuleDefinition(facetRuleDef);
-
 
512
			}
-
 
513
			
-
 
514
			idCategoryFacetDefs.put(new Long(categoryID), categoryFacetDef);
-
 
515
		}
-
 
516
		
-
 
517
		// Append parent's facets 
-
 
518
		// Go only one level for now
-
 
519
		// Categories need to be imported first
-
 
520
		
-
 
521
		for(Long categoryID : idCategoryFacetDefs.keySet()) {
-
 
522
			Category category = this.getCategory(categoryID.longValue());
-
 
523
			Category parentCategory = category.getParentCategory();
-
 
524
			
-
 
525
			if(parentCategory != null) {
-
 
526
				long parentCategoryID = parentCategory.getID();
-
 
527
				
-
 
528
				CategoryFacetDefinition parentCategoryFacetDef = 
-
 
529
					idCategoryFacetDefs.get(new Long(parentCategoryID));
-
 
530
				
-
 
531
				if(parentCategoryFacetDef != null) {
-
 
532
					List<FacetRuleDefinition> parentsFacetRuleDefs = 
-
 
533
						parentCategoryFacetDef.getFacetRuleDefinitions();
-
 
534
					
-
 
535
					if(parentsFacetRuleDefs != null) {
-
 
536
						CategoryFacetDefinition categoryFacetDef = 
-
 
537
							idCategoryFacetDefs.get(categoryID);
-
 
538
						
-
 
539
						categoryFacetDef.appendFacetRuleDefinitions(
-
 
540
								parentsFacetRuleDefs);
-
 
541
					}
-
 
542
				}
-
 
543
			}
-
 
544
		}
-
 
545
		
-
 
546
		Utils.info("idCategoryFacetDefs=" + idCategoryFacetDefs);
-
 
547
		return idCategoryFacetDefs;
-
 
548
	}
-
 
549
	
-
 
550
	/**
-
 
551
	 * 
-
 
552
	 * @param jaxbFacetRuleDef
-
 
553
	 * @return
-
 
554
	 */
-
 
555
	private FacetRuleDefinition convertFacetRuleDefinition(
-
 
556
			FacetRuleDefinitionType jaxbFacetRuleDef) {
-
 
557
		long facetDefID = jaxbFacetRuleDef.getFacetDefinitionID();
-
 
558
		long irDataRuleID = jaxbFacetRuleDef.getIRDataRuleID();
-
 
559
		
-
 
560
		FacetRuleDefinition facetRuleDef = new FacetRuleDefinition(facetDefID, 
-
 
561
				irDataRuleID);
-
 
562
		
-
 
563
		facetRuleDef.setDescription(jaxbFacetRuleDef.getDescription());
-
 
564
		
-
 
565
		if(jaxbFacetRuleDef.getFeatureDefinitionID() != null) {
-
 
566
			facetRuleDef.setFeatureDefinitionID(
-
 
567
					jaxbFacetRuleDef.getFeatureDefinitionID().longValue());
-
 
568
		}
-
 
569
		
-
 
570
		if(jaxbFacetRuleDef.getSlideDefinitionID() != null) {
-
 
571
			facetRuleDef.setSlideDefinitionID(
-
 
572
					jaxbFacetRuleDef.getSlideDefinitionID().longValue());
-
 
573
		}
-
 
574
		
-
 
575
		return facetRuleDef;
-
 
576
	}
-
 
577
 
-
 
578
	private void populateEnumValues(){
-
 
579
		// RE-VISIT - May not be optimal
-
 
580
		Map<Long, EnumValue> enumValuesMap = new TreeMap<Long, EnumValue>();
-
 
581
		for(Long datatypeDefID : datatypeDefinitions.keySet()) {
-
 
582
			DatatypeDefinition datatypeDef = 
-
 
583
				datatypeDefinitions.get(datatypeDefID);
-
 
584
			
-
 
585
			if(datatypeDef instanceof EnumDefinition) {
-
 
586
				List<EnumValue> enumValues = 
-
 
587
					((EnumDefinition) datatypeDef).getEnumValues();
-
 
588
				
-
 
589
				for(EnumValue enumValue : enumValues) {
-
 
590
					enumValuesMap.put(new Long(enumValue.getID()), 
-
 
591
							enumValue);
-
 
592
				}
-
 
593
			}
-
 
594
		}
-
 
595
		this.enumValues = enumValuesMap;
-
 
596
	}
-
 
597
	
-
 
598
	
-
 
599
	/**
132
	 * Returns Slide sequence for a category in the database
600
	 * Returns Slide sequence for a category in the database
133
	 * 
601
	 * 
134
	 * @return Map Null if Category-Slide definitions are not imported into 
602
	 * @return Map Null if Category-Slide definitions are not imported into 
135
	 * definitions db 
603
	 * definitions db 
136
	 * (serialized java objects)
604
	 * (serialized java objects)
137
	 * 
605
	 * 
138
	 * @throws Exception 
606
	 * @throws Exception 
139
	 */
607
	 */
140
	@SuppressWarnings("unchecked")
-
 
141
	public Map<Long, List<Long>> getCategorySlideSequence() throws Exception {		
608
	public Map<Long, List<Long>> getCategorySlideSequence() throws Exception {		
-
 
609
		return this.categorySlideSequence;
-
 
610
	}
-
 
611
 
-
 
612
	
-
 
613
	/**
-
 
614
	 * 
142
		// De-serialize
615
	 * @param defType
-
 
616
	 * @return
-
 
617
	 */
-
 
618
	private Map<Long, List<Long>> convertCategorySlideSequence(
-
 
619
			DefinitionType defType) {
-
 
620
		Map<Long, List<Long>> catSlideSeq = new HashMap<Long, List<Long>>();
-
 
621
		
143
		if(this.categorySlideSequence == null) {
622
		List<CategorySlideSequenceType> jaxbCatSlideSeqs = 
144
			String dbFile = this.dbPath + "definitions" + File.separator + "categoryslidesequence"+
623
			defType.getCategorySlideSequence();
145
				".ser";
624
		
-
 
625
		for(CategorySlideSequenceType jaxbCatSlideSeq : jaxbCatSlideSeqs) {
-
 
626
			long catID = jaxbCatSlideSeq.getCategoryID();
-
 
627
			List<Long> slideDefIDs = jaxbCatSlideSeq.getSlideDefinitionID();
146
			
628
			
147
			this.categorySlideSequence = (Map<Long, List<Long>>) 
629
			Long lCatID = new Long(catID);
148
				DBUtils.read(dbFile);
630
			catSlideSeq.put(lCatID, slideDefIDs);
149
		}
631
		}
150
		
632
		
151
		return this.categorySlideSequence;
633
		return catSlideSeq;
152
	}
634
	}
153
 
635
 
-
 
636
	
154
	/**
637
	/**
155
	 * Given a category ID, returns all slide definition IDs in sequence 
638
	 * Given a category ID, returns all slide definition IDs in sequence 
156
	 * provided by content editor
639
	 * provided by content editor
157
	 * 
640
	 * 
158
	 * @param categoryID
641
	 * @param categoryID
159
	 * @return List of Slide Definition IDs
642
	 * @return List of Slide Definition IDs
160
	 * @throws Exception
643
	 * @throws Exception
161
	 */
644
	 */
162
	public List<Long> getCategorySlideSequence(long categoryID) 
645
	public List<Long> getCategorySlideSequence(long categoryID) throws Exception {	
163
		throws Exception {	
-
 
164
		this.getCategorySlideSequence();
-
 
165
 
-
 
166
		return this.categorySlideSequence.get(new Long(categoryID));
646
		return this.categorySlideSequence.get(new Long(categoryID));
167
	}
647
	}
168
	
648
	
169
	/**
649
	/**
170
	 * Returns all Unit objects in the database
650
	 * Returns all Unit objects in the database
Line 172... Line 652...
172
	 * @return Map Null if units are not imported into definitions db 
652
	 * @return Map Null if units are not imported into definitions db 
173
	 * (serialized java objects)
653
	 * (serialized java objects)
174
	 * 
654
	 * 
175
	 * @throws Exception 
655
	 * @throws Exception 
176
	 */
656
	 */
177
	@SuppressWarnings("unchecked")
-
 
178
	public Map<Long, Unit> getUnits() throws Exception {		
657
	public Map<Long, Unit> getUnits() throws Exception {
-
 
658
		return this.units;
-
 
659
	}
-
 
660
	
-
 
661
 
-
 
662
	/**
-
 
663
	 * 
179
		// De-serialize
664
	 * @param srcFile
-
 
665
	 * @return
-
 
666
	 * @throws Exception
-
 
667
	 */
-
 
668
	private Object unmarshallSrcFile(String srcFile, String type) 
180
		if(this.units == null) {
669
		throws Exception {
-
 
670
		
-
 
671
        JAXBContext jc = JAXBContext.newInstance("in.shop2020.metamodel.jaxb." +
-
 
672
        		type);
-
 
673
        
-
 
674
        // create an Unmarshaller
-
 
675
        Unmarshaller u = jc.createUnmarshaller();
-
 
676
        
-
 
677
        JAXBElement<?> element = (JAXBElement<?>)u.unmarshal(
-
 
678
        		new FileInputStream(srcFile));
-
 
679
        
-
 
680
        return element.getValue();
-
 
681
	}
-
 
682
	
-
 
683
	/**
-
 
684
	 * 
-
 
685
	 * @return Map
-
 
686
	 */
-
 
687
	private Map<Long, Unit> convertUnits(DefinitionType defType) {
-
 
688
		
181
			String dbFile = this.dbPath + "definitions" + File.separator + "units" + ".ser";
689
		Map<Long, Unit> allUnits = new HashMap<Long, Unit>();
-
 
690
		List<UnitType> jaxbUnits = defType.getUnit();
-
 
691
		Iterator<UnitType> it = jaxbUnits.iterator();
-
 
692
		
-
 
693
		while(it.hasNext()) {
-
 
694
			UnitType jaxbUnit = it.next();
182
			
695
			
183
			this.units = (Map<Long, Unit>) DBUtils.read(dbFile);
696
			Unit unit = new Unit(jaxbUnit.getID());
-
 
697
			unit.setDescription(jaxbUnit.getDescription());
-
 
698
			unit.setFullForm(jaxbUnit.getFullform());
-
 
699
			unit.setShortForm(jaxbUnit.getShortform());
-
 
700
			Utils.info("unit=" + unit);
-
 
701
		
-
 
702
			allUnits.put(new Long(jaxbUnit.getID()), unit);
184
		}
703
		}
185
		
704
		
186
		return this.units;
705
		return allUnits;
187
	}
706
	}
188
 
707
 
-
 
708
	
189
	/**
709
	/**
190
	 * Resolves Unit ID into Unit object
710
	 * Resolves Unit ID into Unit object
191
	 * 
711
	 * 
192
	 * @param unitID Unit ID
712
	 * @param unitID Unit ID
193
	 * @return Unit
713
	 * @return Unit
194
	 * @throws Exception 
714
	 * @throws Exception 
195
	 */
715
	 */
196
	public Unit getUnit(long unitID) throws Exception {		
716
	public Unit getUnit(long unitID) throws Exception {		
197
		// Initialize 
-
 
198
		if(this.units == null) {
-
 
199
			this.getUnits();
-
 
200
		}
-
 
201
		
-
 
202
		return this.units.get(new Long(unitID));
717
		return this.units.get(new Long(unitID));
203
	}
718
	}
204
 
719
 
205
	/**
720
	/**
206
	 * Returns all DatatypeDefintion object in database
721
	 * Returns all DatatypeDefintion object in database
207
	 * 
722
	 * 
208
	 * @return the datatypeDefinitions List of DatatypeDefinition objects
723
	 * @return the datatypeDefinitions List of DatatypeDefinition objects
209
	 * @throws Exception 
724
	 * @throws Exception 
210
	 */
725
	 */
211
	@SuppressWarnings("unchecked")
-
 
212
	public Map<Long, DatatypeDefinition> getDatatypeDefinitions() 
726
	public Map<Long, DatatypeDefinition> getDatatypeDefinitions(){
213
		throws Exception {
727
		return this.datatypeDefinitions;
-
 
728
	}
-
 
729
 
-
 
730
	
-
 
731
	/**
-
 
732
	 * 
-
 
733
	 * @param defType
-
 
734
	 * @return
-
 
735
	 */
-
 
736
	private Map<Long, DatatypeDefinition> convertDatatypeDefinition(DefinitionType defType) {
214
		
737
		
-
 
738
		Map<Long, DatatypeDefinition> defs = new HashMap<Long, DatatypeDefinition>();
-
 
739
		
-
 
740
		List<DatatypeDefinitionType> jaxbDefs = defType.getDatatypeDefinition();
-
 
741
		Iterator<DatatypeDefinitionType> it = jaxbDefs.iterator();
-
 
742
		
-
 
743
		while(it.hasNext()) {
-
 
744
			DatatypeDefinitionType jaxbDef = it.next();
-
 
745
			
-
 
746
			DatatypeDefinition def = null;
-
 
747
			CompositeDefinitionType compositeDefType = jaxbDef.getCompositeDefinition();
-
 
748
 
-
 
749
			EnumDefinitionType enumDefType = jaxbDef.getEnumDefinition();
-
 
750
			
215
		// De-serialize
751
			// Composite data type
216
		if(this.datatypeDefinitions == null) {
752
			if(compositeDefType != null) {
-
 
753
				CompositeDefinition compDef = new CompositeDefinition(jaxbDef.getID(), jaxbDef.getName(), compositeDefType.getSeparator());
-
 
754
				
-
 
755
				List<CompositePartDefinitionType> jaxbPartDefs = compositeDefType.getCompositePartDefinition();
-
 
756
				
217
			String dbFile = this.dbPath + "definitions" + File.separator + "datatypedefinitions" + 
757
				Iterator<CompositePartDefinitionType> itPartDefs = jaxbPartDefs.iterator();
-
 
758
				
-
 
759
				// Collect parts
-
 
760
				while(itPartDefs.hasNext()) {
-
 
761
					CompositePartDefinitionType jaxbPartDef = itPartDefs.next();
-
 
762
					CompositePartDefinition partDef = this.convertCompositePartDefinition(jaxbPartDef);
-
 
763
					
-
 
764
					compDef.addCompositePartDefinition(partDef);
-
 
765
				}
-
 
766
				
-
 
767
				def = compDef;
-
 
768
			}
-
 
769
			
-
 
770
			// Enumerated values
-
 
771
			else if(enumDefType != null) {
-
 
772
				EnumDefinition enumDef = new EnumDefinition(jaxbDef.getID(), 
-
 
773
						jaxbDef.getName());
-
 
774
				
-
 
775
				List<EnumValueType> jaxbEnumValues = 
-
 
776
					enumDefType.getEnumValue();
-
 
777
					
-
 
778
				Iterator<EnumValueType> itEnumValues = 
-
 
779
					jaxbEnumValues.iterator();
-
 
780
				
-
 
781
				// Collect individual value
-
 
782
				while(itEnumValues.hasNext()) {
-
 
783
					EnumValueType jaxbEnumValue = itEnumValues.next();
-
 
784
					EnumValue enumValue = 
-
 
785
						this.convertEnumValueDefinition(jaxbEnumValue);
-
 
786
					
-
 
787
					enumDef.addEnumValue(enumValue);
218
				".ser";
788
				}
-
 
789
				
-
 
790
				def = enumDef;
-
 
791
			}
219
			
792
			
220
			this.datatypeDefinitions = 
793
			// Primitive
-
 
794
			else {
221
				(Map<Long, DatatypeDefinition>) DBUtils.read(dbFile);
795
				def = new DatatypeDefinition(jaxbDef.getID(), 
-
 
796
						jaxbDef.getName());
-
 
797
			}
-
 
798
			
-
 
799
			def.setDescription(jaxbDef.getDescription());
-
 
800
			Utils.info("def=" + def);
-
 
801
			
-
 
802
			defs.put(new Long(jaxbDef.getID()), def);
222
		}
803
		}
-
 
804
		
-
 
805
		return defs;
-
 
806
	}
-
 
807
 
-
 
808
	/**
-
 
809
	 * 
-
 
810
	 * @param jaxbPartDef
223
		return this.datatypeDefinitions;
811
	 * @return CompositePartDefinition
-
 
812
	 */
-
 
813
	private CompositePartDefinition convertCompositePartDefinition(
-
 
814
			CompositePartDefinitionType jaxbPartDef) {
-
 
815
		
-
 
816
		CompositePartDefinition partDef = new CompositePartDefinition(
-
 
817
				jaxbPartDef.getLabel(), jaxbPartDef.getDatatypeDefinitionID(), 
-
 
818
				jaxbPartDef.getUnitID());
-
 
819
		
-
 
820
		partDef.setDescription(jaxbPartDef.getDescription());
-
 
821
		
-
 
822
		return partDef;
224
	}
823
	}
225
 
824
 
226
	/**
825
	/**
227
	 * Resolves Datatype Definition ID into DatetypeDefinition object
826
	 * Resolves Datatype Definition ID into DatetypeDefinition object
228
	 * 
827
	 * 
Line 239... Line 838...
239
		
838
		
240
		return this.datatypeDefinitions.get(new Long(id));
839
		return this.datatypeDefinitions.get(new Long(id));
241
	}
840
	}
242
 
841
 
243
	/**
842
	/**
-
 
843
	 * 
-
 
844
	 * @param jaxbEnumValue
-
 
845
	 * @return EnumValue
-
 
846
	 */
-
 
847
	private EnumValue convertEnumValueDefinition(EnumValueType jaxbEnumValue) {
-
 
848
		
-
 
849
		EnumValue enumValue = new EnumValue(jaxbEnumValue.getID(), 
-
 
850
				jaxbEnumValue.getValue());
-
 
851
 
-
 
852
		return enumValue;
-
 
853
	}
-
 
854
	/**
244
	 * Returns EnumValue ID for datatype definition ID and enum value string 
855
	 * Returns EnumValue ID for datatype definition ID and enum value string 
245
	 * to match. Match is case insensitive
856
	 * to match. Match is case insensitive
246
	 * 
857
	 * 
247
	 * @param datatypeDefID DatatypeDefinition ID
858
	 * @param datatypeDefID DatatypeDefinition ID
248
	 * @param value query enum value string
859
	 * @param value query enum value string
Line 272... Line 883...
272
	 * Returns all category objects in the database
883
	 * Returns all category objects in the database
273
	 * 
884
	 * 
274
	 * @return the categories
885
	 * @return the categories
275
	 * @throws Exception 
886
	 * @throws Exception 
276
	 */
887
	 */
-
 
888
	public Map<Long, Category> getCategories() {
-
 
889
		return this.categories;
-
 
890
	}
-
 
891
	
-
 
892
	
-
 
893
	/**
-
 
894
	 * 
-
 
895
	 * @param defType
-
 
896
	 * @param catMap
-
 
897
	 * @return
-
 
898
	 */
-
 
899
	private Category convertCategories(DefinitionType defType, 
-
 
900
			Map<Long, Category> catMap, String srcFile) {
-
 
901
		
-
 
902
		List<CategoryType> jaxbCats = defType.getCategory();
-
 
903
		Iterator<CategoryType> it = jaxbCats.iterator();
-
 
904
		
-
 
905
		// Get root category
-
 
906
		CategoryType jaxbCat = it.next();
-
 
907
		if(jaxbCat == null) {
-
 
908
			Utils.info("Invalid file: " + srcFile);
-
 
909
			return null;
-
 
910
		}
-
 
911
		
-
 
912
		Category root = this.convertCategoryType(jaxbCat, null, catMap);
-
 
913
		return root;
-
 
914
	}
-
 
915
	
-
 
916
	
-
 
917
	/**
-
 
918
	 * 
-
 
919
	 * @param jaxbCat
-
 
920
	 * @param parentCat
-
 
921
	 * @param catMap
-
 
922
	 * @return
-
 
923
	 */
277
	@SuppressWarnings("unchecked")
924
	@SuppressWarnings("unchecked")
278
	public Map<Long, Category> getCategories() throws Exception {
925
	private Category convertCategoryType(CategoryType jaxbCat, 
-
 
926
			Category parentCat, Map<Long, Category> catMap) {
279
		
927
		
-
 
928
		Category cat = new Category(jaxbCat.getID());
280
		// De-serialize
929
		cat.setLabel(jaxbCat.getName());
-
 
930
		cat.setDescription(jaxbCat.getDescription());
281
		if(this.categories == null) {
931
		if(parentCat != null) {
-
 
932
			cat.setParentCategory(parentCat);
-
 
933
			
-
 
934
			// Copy parent's category-slide definitions
282
			String dbFile = this.dbPath + "definitions" + File.separator + "categories" + ".ser";
935
			ArrayList<CategorySlideDefinition> parentCSDef = 
-
 
936
				(ArrayList<CategorySlideDefinition>) 
-
 
937
				parentCat.getCategorySlideDefintions();
283
			
938
			
-
 
939
			if(parentCSDef != null) {
-
 
940
				cat.setCategorySlideDefintions(
284
			this.categories = (Map<Long, Category>) DBUtils.read(dbFile);
941
					(List<CategorySlideDefinition>) parentCSDef.clone());
-
 
942
			}
285
		}
943
		}
-
 
944
		
-
 
945
		// Category Slide Definition
-
 
946
		List<CategorySlideDefinitionType> jaxbDefs = 
-
 
947
			jaxbCat.getCategorySlideDefinition();
-
 
948
		
-
 
949
		Iterator<CategorySlideDefinitionType> it = jaxbDefs.iterator();
-
 
950
		while(it.hasNext()) {
-
 
951
			CategorySlideDefinitionType jaxbDef = it.next();
-
 
952
			CategorySlideDefinition catSlideDef 
-
 
953
			= this.convertCategorySlideDefinitionType(jaxbCat.getID(), jaxbDef);
-
 
954
			
-
 
955
			cat.addCategorySlideDefintion(catSlideDef);
-
 
956
		}
-
 
957
		
-
 
958
		// Children
-
 
959
		List<CategoryType> jaxbChildren = jaxbCat.getChildCategory();
-
 
960
		//Utils.info("jaxbChildren.size: " + jaxbChildren.size());
-
 
961
		
-
 
962
		Iterator<CategoryType> itChildren = jaxbChildren.iterator();
-
 
963
		while(itChildren.hasNext()) {
-
 
964
			CategoryType jaxbChildCat = itChildren.next();
-
 
965
			Category childCat = this.convertCategoryType(jaxbChildCat, cat, 
-
 
966
					catMap);
-
 
967
			cat.addChild(childCat);
-
 
968
		}
-
 
969
		
-
 
970
		//FIXME put debug messages
-
 
971
		//Utils.info("Parent cat: " + cat);
-
 
972
		// DEBUG ONLY
-
 
973
		Utils.info("####### Cat ID: " + cat.getID());
-
 
974
		if(cat.getCategorySlideDefintions() != null) {
-
 
975
			for(CategorySlideDefinition csd : cat.getCategorySlideDefintions()){
-
 
976
				Utils.info("####### SlideDefintionID=" + csd.getSlideDefintionID());
-
 
977
			}
-
 
978
		}
-
 
979
		
-
 
980
		catMap.put(new Long(jaxbCat.getID()), cat);
286
		return this.categories;
981
		return cat;
287
	}
982
	}
288
	
983
	
289
	/**
984
	/**
-
 
985
	 * 
-
 
986
	 * @param categoryID
-
 
987
	 * @param jaxbDef
-
 
988
	 * @return
-
 
989
	 */
-
 
990
	private CategorySlideDefinition convertCategorySlideDefinitionType(
-
 
991
			long categoryID, CategorySlideDefinitionType jaxbDef) {
-
 
992
		
-
 
993
		CategorySlideDefinition catSlideDef = new CategorySlideDefinition(
-
 
994
				jaxbDef.getSlideDefinitionID());
-
 
995
		
-
 
996
		catSlideDef.setDescription(jaxbDef.getDescription());
-
 
997
		
-
 
998
		EditorialImportanceType jaxbEdImp = jaxbDef.getEditorialImportance();
-
 
999
		EditorialImportance edImp = this.convertEditorialImportance(jaxbEdImp);
-
 
1000
		catSlideDef.setEditorialImportance(edImp);
-
 
1001
		
-
 
1002
		return catSlideDef;
-
 
1003
	}
-
 
1004
	
-
 
1005
	/**
-
 
1006
	 * 
-
 
1007
	 * @param jaxbEdImp
-
 
1008
	 * @return EditorialImportance
-
 
1009
	 */
-
 
1010
	private EditorialImportance convertEditorialImportance(
-
 
1011
			EditorialImportanceType jaxbEdImp) {
-
 
1012
		
-
 
1013
		String strEdImp = jaxbEdImp.value();
-
 
1014
		EditorialImportance edImp = null;
-
 
1015
		
-
 
1016
		if(strEdImp.equals("Mandatory"))
-
 
1017
			edImp = EditorialImportance.MANDATORY;
-
 
1018
		else if(strEdImp.equals("Optional"))
-
 
1019
			edImp = EditorialImportance.OPTIONAL;
-
 
1020
		else 
-
 
1021
			edImp = EditorialImportance.RECOMMENDED;
-
 
1022
		
-
 
1023
		return edImp;
-
 
1024
	}
-
 
1025
 
-
 
1026
	
-
 
1027
	/**
290
	 * Resolves Category ID into Category object
1028
	 * Resolves Category ID into Category object
291
	 * 
1029
	 * 
292
	 * @param categoryID Category ID
1030
	 * @param categoryID Category ID
293
	 * @return Category
1031
	 * @return Category
294
	 * @throws Exception 
1032
	 * @throws Exception 
295
	 */
1033
	 */
296
	public Category getCategory(long categoryID) throws Exception {
1034
	public Category getCategory(long categoryID) {
297
		
-
 
298
		// Initialize 
-
 
299
		if(this.categories == null) {
-
 
300
			this.getCategories();
-
 
301
		}
-
 
302
		
-
 
303
		return this.categories.get(new Long(categoryID));
1035
		return this.categories.get(new Long(categoryID));
304
	}
1036
	}
305
	
1037
	
306
	/**
1038
	/**
307
	 * Returns expanded Category object. All numeric identifiers are resolved 
1039
	 * Returns expanded Category object. All numeric identifiers are resolved 
Line 325... Line 1057...
325
	 * 
1057
	 * 
326
	 * @param categoryID
1058
	 * @param categoryID
327
	 * @return List<Category> Children Categories
1059
	 * @return List<Category> Children Categories
328
	 * @throws Exception
1060
	 * @throws Exception
329
	 */
1061
	 */
330
	public List<Category> getChildrenCategories(long categoryID) 
1062
	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();
1063
		return this.categories.get(new Long(categoryID)).getChildrenCategory();
339
	}
1064
	}
340
	
1065
	
341
	/**
1066
	/**
342
	 * Returns all CategorySlideDefinition objects for a Category ID
1067
	 * Returns all CategorySlideDefinition objects for a Category ID
Line 356... Line 1081...
356
	 * Returns All SlideDefinition objects in database
1081
	 * Returns All SlideDefinition objects in database
357
	 * 
1082
	 * 
358
	 * @return the slideDefinitions
1083
	 * @return the slideDefinitions
359
	 * @throws Exception 
1084
	 * @throws Exception 
360
	 */
1085
	 */
-
 
1086
	public Map<Long, SlideDefinition> getSlideDefinitions(){
361
	@SuppressWarnings("unchecked")
1087
		return this.slideDefinitions;
-
 
1088
	}
-
 
1089
	
-
 
1090
	/**
-
 
1091
	 * 
-
 
1092
	 * @return Map
-
 
1093
	 */
362
	public Map<Long, SlideDefinition> getSlideDefinitions() throws Exception {
1094
	private Map<Long, SlideDefinition> convertSlideDefinitions(
-
 
1095
			DefinitionType defType) {
363
		
1096
		
-
 
1097
		Map<Long, SlideDefinition> defs = 
-
 
1098
			new HashMap<Long, SlideDefinition>();
-
 
1099
		
-
 
1100
		List<SlideDefinitionType> jaxbDefs = defType.getSlideDefinition();
-
 
1101
		Iterator<SlideDefinitionType> itjaxbDefs = jaxbDefs.iterator();
-
 
1102
		
-
 
1103
		// Slide definitions
-
 
1104
		while(itjaxbDefs.hasNext()) {
-
 
1105
			SlideDefinitionType jaxbDef = itjaxbDefs.next();
-
 
1106
			
-
 
1107
			Utils.info("Slide label=" + jaxbDef.getLabel());
-
 
1108
			SlideDefinition def = new SlideDefinition(jaxbDef.getID(),
-
 
1109
					jaxbDef.getLabel());
-
 
1110
			def.setDescription(jaxbDef.getDescription());
-
 
1111
			
364
		// De-serialize
1112
			// Children Slides
-
 
1113
			Utils.info("jaxbDef.getChildSlideID=" + jaxbDef.getChildSlideID());
-
 
1114
			def.setChildrenSlideDefinitionIDs(jaxbDef.getChildSlideID());
-
 
1115
			
-
 
1116
			// Slide Feature Definition
-
 
1117
			List<SlideFeatureDefinitionType> jaxbSlideFeatureDefs = 
-
 
1118
				jaxbDef.getSlideFeatureDefinition();
-
 
1119
			
365
		if(this.slideDefinitions == null) {
1120
			if(jaxbSlideFeatureDefs != null) {
-
 
1121
				def.setSlideFeatureDefinitions((
366
			String dbFile = this.dbPath + "definitions" + File.separator + "slidedefinitions" + 
1122
						this.convertSlideFeatureDefinitions(
-
 
1123
								jaxbSlideFeatureDefs)));
367
				".ser";
1124
			}
-
 
1125
			Utils.info("def=" + def);
368
			
1126
			
369
			this.slideDefinitions = 
-
 
370
				(Map<Long, SlideDefinition>) DBUtils.read(dbFile);
1127
			defs.put(new Long(jaxbDef.getID()), def);
371
		}
1128
		}
-
 
1129
			
-
 
1130
		return defs;
-
 
1131
	}
-
 
1132
 
-
 
1133
	
-
 
1134
	/**
-
 
1135
	 * 
-
 
1136
	 * @param jaxbDefs
372
		return this.slideDefinitions;
1137
	 * @return List<SlideFeatureDefinition>
-
 
1138
	 */
-
 
1139
	private List<SlideFeatureDefinition> convertSlideFeatureDefinitions(
-
 
1140
			List<SlideFeatureDefinitionType> jaxbDefs) {
-
 
1141
		
-
 
1142
		List<SlideFeatureDefinition> defs = 
-
 
1143
			new ArrayList<SlideFeatureDefinition>();
-
 
1144
		
-
 
1145
		Iterator<SlideFeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
-
 
1146
		
-
 
1147
		// Slide-feature definitions
-
 
1148
		while(itjaxbDefs.hasNext()) {
-
 
1149
			SlideFeatureDefinitionType jaxbDef = itjaxbDefs.next();
-
 
1150
			SlideFeatureDefinition def = new SlideFeatureDefinition(
-
 
1151
					jaxbDef.getFeatureDefinitionID());
-
 
1152
			
-
 
1153
			def.setEditorialImportance(this.convertEditorialImportance(
-
 
1154
					jaxbDef.getEditorialImportance()));
-
 
1155
			
-
 
1156
			def.setDescription(jaxbDef.getDescription());
-
 
1157
			
-
 
1158
			defs.add(def);
-
 
1159
		}
-
 
1160
		
-
 
1161
		return defs;
373
	}
1162
	}
-
 
1163
 
374
	
1164
	
375
	/**
1165
	/**
376
	 * Resolves SlideDefinition ID into SlideDefinition object
1166
	 * Resolves SlideDefinition ID into SlideDefinition object
377
	 * 
1167
	 * 
378
	 * @param id
1168
	 * @param id
Line 494... Line 1284...
494
	 * Returns all FeatureDefinition object in database
1284
	 * Returns all FeatureDefinition object in database
495
	 * 
1285
	 * 
496
	 * @return Map<Long, FeatureDefinition>
1286
	 * @return Map<Long, FeatureDefinition>
497
	 * @throws Exception
1287
	 * @throws Exception
498
	 */
1288
	 */
-
 
1289
	public Map<Long, FeatureDefinition> getFeatureDefinitions(){
499
	@SuppressWarnings("unchecked")
1290
		return this.featureDefinitions;
-
 
1291
	}
-
 
1292
	
-
 
1293
	
-
 
1294
	/**
-
 
1295
	 * 
-
 
1296
	 * @param defType
-
 
1297
	 * @return
-
 
1298
	 */
500
	public Map<Long, FeatureDefinition> getFeatureDefinitions() 
1299
	private Map<Long, FeatureDefinition> convertFeatureDefinitions(
501
		throws Exception {
1300
			DefinitionType defType) {
502
		
1301
		
-
 
1302
		Map<Long, FeatureDefinition> defs = 
-
 
1303
			new HashMap<Long, FeatureDefinition>();
-
 
1304
		
-
 
1305
		List<FeatureDefinitionType> jaxbDefs = defType.getFeatureDefinition();
-
 
1306
		Iterator<FeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
-
 
1307
		
-
 
1308
		// Feature definitions
-
 
1309
		while(itjaxbDefs.hasNext()) {
-
 
1310
			FeatureDefinitionType jaxbDef = itjaxbDefs.next();
-
 
1311
			
-
 
1312
			//Utils.info("Feature label=" + jaxbDef.getLabel());
-
 
1313
			FeatureDefinition def = new FeatureDefinition(jaxbDef.getID(),
-
 
1314
					jaxbDef.getLabel());
-
 
1315
			def.setAllowsBlank(jaxbDef.isCanbeBlank());
-
 
1316
			def.setDescription(jaxbDef.getDescription());
-
 
1317
			
503
		// De-serialize
1318
			// Bullet Definition
-
 
1319
			BulletDefinitionType jaxbBulletDef = jaxbDef.getBulletDefinition();
504
		if(this.featureDefinitions == null) {
1320
			if(jaxbBulletDef != null) {
505
			String dbFile = this.dbPath + "definitions" + File.separator + "featuredefinitions" + 
1321
				def.setBulletDefinition(this.convertBulletDefinition(
-
 
1322
						jaxbBulletDef));
-
 
1323
			}
-
 
1324
			
-
 
1325
			Long normRuleDefID = jaxbDef.getNormalizationRuleDefinitionID();
-
 
1326
			if(normRuleDefID != null) {
-
 
1327
				def.setNormalizationRuleDefinitionID(normRuleDefID.longValue());
506
				".ser";
1328
			}
-
 
1329
			Utils.info("def=" + def);
507
			
1330
			
508
			this.featureDefinitions = 
1331
			defs.put(new Long(jaxbDef.getID()), def);
509
				(Map<Long, FeatureDefinition>) DBUtils.read(dbFile);
-
 
510
		}
1332
		}
-
 
1333
			
511
		return this.featureDefinitions;
1334
		return defs;
512
	}
1335
	}
-
 
1336
 
-
 
1337
	
-
 
1338
	/**
-
 
1339
	 * 
-
 
1340
	 * @param jaxbDef BulletDefinitionType
-
 
1341
	 * @return BulletDefinition
-
 
1342
	 */
-
 
1343
	private BulletDefinition convertBulletDefinition(
-
 
1344
			BulletDefinitionType jaxbDef) {
-
 
1345
		
-
 
1346
		BulletDefinition def = new BulletDefinition(
-
 
1347
				jaxbDef.getDatatypeDefinitionID());
-
 
1348
		
-
 
1349
		List<Long> unitIDs = jaxbDef.getUnitID();
-
 
1350
		if(unitIDs != null && !unitIDs.isEmpty()) {
-
 
1351
			def.setUnitIDs(unitIDs);
-
 
1352
		}
-
 
1353
		Utils.info("jaxbDef.isIsMultivalue=" + jaxbDef.isIsMultivalue());
-
 
1354
		
-
 
1355
		def.setMultivalue(jaxbDef.isIsMultivalue());
-
 
1356
		def.setLearned(jaxbDef.isIsLearned());
-
 
1357
		def.setDescription(jaxbDef.getDescription());
-
 
1358
		
-
 
1359
		return def;
-
 
1360
	}
-
 
1361
 
513
	
1362
	
514
	/**
1363
	/**
515
	 * Returns all FeatureDefinition objects for a slide
1364
	 * Returns all FeatureDefinition objects for a slide
516
	 * 
1365
	 * 
517
	 * @param slideID
1366
	 * @param slideID
Line 614... Line 1463...
614
	 * Returns all EnumValue objects in the database
1463
	 * Returns all EnumValue objects in the database
615
	 * 
1464
	 * 
616
	 * @return the enumValues
1465
	 * @return the enumValues
617
	 * @throws Exception 
1466
	 * @throws Exception 
618
	 */
1467
	 */
619
	@SuppressWarnings("unchecked")
-
 
620
	public Map<Long, EnumValue> getEnumValues() throws Exception {
1468
	public Map<Long, EnumValue> getEnumValues() throws Exception {
621
		// De-serialise
-
 
622
		if(this.enumValues == null) {
-
 
623
			String dbFile = this.dbPath + "definitions" + File.separator + "enumvalues" + 
-
 
624
				".ser";
-
 
625
			
-
 
626
			this.enumValues = 
-
 
627
				(Map<Long, EnumValue>) DBUtils.read(dbFile);
-
 
628
		}
-
 
629
		
-
 
630
		return this.enumValues;
1469
		return this.enumValues;
631
	}
1470
	}
632
	
1471
	
-
 
1472
	
633
	/**
1473
	/**
634
	 * Resolves Enum value ID into EnumValue object
1474
	 * Resolves Enum value ID into EnumValue object
635
	 * 
1475
	 * 
636
	 * @param enumValueID
1476
	 * @param enumValueID
637
	 * @return EnumValue
1477
	 * @return EnumValue
638
	 * @throws Exception
1478
	 * @throws Exception
639
	 */
1479
	 */
640
	public EnumValue getEnumValue(long enumValueID) throws Exception {
1480
	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));
1481
		return this.enumValues.get(new Long(enumValueID));
647
	}
1482
	}
648
	
1483
	
649
	/**
1484
	/**
650
	 * Returns all FacetDefinition objects in the database
1485
	 * Returns all FacetDefinition objects in the database
Line 652... Line 1487...
652
	 * @return Map Null if facet definitions are not imported into definitions 
1487
	 * @return Map Null if facet definitions are not imported into definitions 
653
	 * db (serialized java objects)
1488
	 * db (serialized java objects)
654
	 * 
1489
	 * 
655
	 * @throws Exception 
1490
	 * @throws Exception 
656
	 */
1491
	 */
657
	@SuppressWarnings("unchecked")
-
 
658
	public Map<Long, FacetDefinition> getFacetDefinitions() throws Exception {
1492
	public Map<Long, FacetDefinition> getFacetDefinitions(){
659
		
-
 
660
		// De-serialize
-
 
661
		if(this.facetDefinitions == null) {
-
 
662
			String dbFile = this.dbPath + "definitions" + File.separator + "facetdefinitions" + 
-
 
663
				".ser";
-
 
664
			
-
 
665
			this.facetDefinitions = 
-
 
666
				(Map<Long, FacetDefinition>) DBUtils.read(dbFile);
-
 
667
		}
-
 
668
		
-
 
669
		return this.facetDefinitions;
1493
		return this.facetDefinitions;
670
	}
1494
	}
671
	
1495
	
672
	/**
1496
	/**
673
	 * Resolves Facet Definition ID into FacetDefinition object
1497
	 * Resolves Facet Definition ID into FacetDefinition object
Line 711... Line 1535...
711
	 * @return Map Null if category facet definitions are not imported into 
1535
	 * @return Map Null if category facet definitions are not imported into 
712
	 * definitions db (serialized java objects)
1536
	 * definitions db (serialized java objects)
713
	 * 
1537
	 * 
714
	 * @throws Exception 
1538
	 * @throws Exception 
715
	 */
1539
	 */
716
	@SuppressWarnings("unchecked")
-
 
717
	public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions() 
1540
	public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions(){
718
		throws Exception {
-
 
719
		
-
 
720
		// De-serialize
-
 
721
		if(this.categoryFacetDefinitions == null) {
-
 
722
			String dbFile = this.dbPath + "definitions" + File.separator + 
-
 
723
				"categoryfacetdefinitions.ser";
-
 
724
			
-
 
725
			this.categoryFacetDefinitions = 
-
 
726
				(Map<Long, CategoryFacetDefinition>) DBUtils.read(dbFile);
-
 
727
		}
-
 
728
		
-
 
729
		return this.categoryFacetDefinitions;
1541
		return this.categoryFacetDefinitions;
730
	}
1542
	}
731
	
1543
	
732
	/**
1544
	/**
733
	 * Resolves Category-Facet Definition ID into CategoryFacetDefinition object
1545
	 * Resolves Category-Facet Definition ID into CategoryFacetDefinition object
734
	 * 
1546
	 * 
735
	 * @param categoryID
1547
	 * @param categoryID
736
	 * @return CategoryFacetDefinition
1548
	 * @return CategoryFacetDefinition
737
	 * @throws Exception
1549
	 * @throws Exception
738
	 */
1550
	 */
739
	public CategoryFacetDefinition getCategoryFacetDefinition(
1551
	public CategoryFacetDefinition getCategoryFacetDefinition(long categoryID){
740
			long categoryID) throws Exception {
-
 
741
		
-
 
742
		if(this.categoryFacetDefinitions == null) {
-
 
743
			this.getCategoryFacetDefinitions();
-
 
744
		}
-
 
745
		
-
 
746
		return this.categoryFacetDefinitions.get(
1552
		return this.categoryFacetDefinitions.get(new Long(categoryID));
747
				new Long(categoryID));
-
 
748
	}
1553
	}
749
	
1554
	
-
 
1555
	
750
	/**
1556
	/**
751
	 * Utility method to get Expanded version of CategoryFacetDefinition object 
1557
	 * Utility method to get Expanded version of CategoryFacetDefinition object 
752
	 * 
1558
	 * 
753
	 * @param categoryID
1559
	 * @param categoryID
754
	 * @return ExpandedCategoryFacetDefinition
1560
	 * @return ExpandedCategoryFacetDefinition
Line 771... Line 1577...
771
	 * @return Map Null if IR data rule definitions are not imported into 
1577
	 * @return Map Null if IR data rule definitions are not imported into 
772
	 * definitions db (serialized java objects)
1578
	 * definitions db (serialized java objects)
773
	 * 
1579
	 * 
774
	 * @throws Exception 
1580
	 * @throws Exception 
775
	 */
1581
	 */
776
	@SuppressWarnings("unchecked")
-
 
777
	public Map<Long, RuleDefinition> getIrDataRuleDefinitions() 
1582
	public Map<Long, RuleDefinition> getIrDataRuleDefinitions(){
778
		throws Exception {
-
 
779
		
-
 
780
		// De-serialize
-
 
781
		if(this.irDataRuleDefinitions == null) {
-
 
782
			String dbFile = this.dbPath + "definitions" + File.separator + "irdatarules" + ".ser";
-
 
783
			
-
 
784
			this.irDataRuleDefinitions = 
-
 
785
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
-
 
786
		}
-
 
787
		
-
 
788
		return this.irDataRuleDefinitions;
1583
		return this.irDataRuleDefinitions;
789
	}
1584
	}
790
	
1585
	
791
	/**
1586
	/**
792
	 * Resolves IR Data Rule Definition ID into RuleDefinition object
1587
	 * Resolves IR Data Rule Definition ID into RuleDefinition object
793
	 * 
1588
	 * 
794
	 * @param irDataRuleDefinitionID
1589
	 * @param irDataRuleDefinitionID
795
	 * @return RuleDefinition
1590
	 * @return RuleDefinition
796
	 * @throws Exception
1591
	 * @throws Exception
797
	 */
1592
	 */
798
	public RuleDefinition getIrDataRuleDefinition(
1593
	public RuleDefinition getIrDataRuleDefinition(long irDataRuleDefinitionID){
799
			long irDataRuleDefinitionID) throws Exception {
-
 
800
		
-
 
801
		if(this.irDataRuleDefinitions == null) {
-
 
802
			this.getIrDataRuleDefinitions();
-
 
803
		}
-
 
804
		
-
 
805
		return this.irDataRuleDefinitions.get(new Long(irDataRuleDefinitionID));
1594
		return this.irDataRuleDefinitions.get(new Long(irDataRuleDefinitionID));
806
	}
1595
	}
807
	
1596
	
808
	/**
1597
	/**
809
	 * Returns all IR Meta Data RuleDefintion objects in the database
1598
	 * Returns all IR Meta Data RuleDefintion objects in the database
Line 811... Line 1600...
811
	 * @return Map Null if IR meta-data rule definitions are not imported into 
1600
	 * @return Map Null if IR meta-data rule definitions are not imported into 
812
	 * definitions db (serialized java objects)
1601
	 * definitions db (serialized java objects)
813
	 * 
1602
	 * 
814
	 * @throws Exception 
1603
	 * @throws Exception 
815
	 */
1604
	 */
816
	@SuppressWarnings("unchecked")
-
 
817
	public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions() 
1605
	public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions(){
818
		throws Exception {
-
 
819
		
-
 
820
		// De-serialize
-
 
821
		if(this.irMetaDataRuleDefinitions == null) {
-
 
822
			String dbFile = this.dbPath + "definitions" + File.separator + "irmetadatarules" + 
-
 
823
				".ser";
-
 
824
			
-
 
825
			this.irMetaDataRuleDefinitions = 
-
 
826
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
-
 
827
		}
-
 
828
		
-
 
829
		return this.irMetaDataRuleDefinitions;
1606
		return this.irMetaDataRuleDefinitions;
830
	}
1607
	}
831
	
1608
	
832
	/**
1609
	/**
833
	 * Resolves IR Meta Data Rule Definition ID into RuleDefinition object
1610
	 * Resolves IR Meta Data Rule Definition ID into RuleDefinition object
834
	 * 
1611
	 * 
835
	 * @param irMetaDataRuleDefinitionID
1612
	 * @param irMetaDataRuleDefinitionID
836
	 * @return RuleDefinition
1613
	 * @return RuleDefinition
837
	 * @throws Exception
1614
	 * @throws Exception
838
	 */
1615
	 */
839
	public RuleDefinition getIrMetaDataRuleDefinition(
1616
	public RuleDefinition getIrMetaDataRuleDefinition(long irMetaDataRuleDefinitionID) {
840
			long irMetaDataRuleDefinitionID) throws Exception {
-
 
841
		
-
 
842
		if(this.irMetaDataRuleDefinitions == null) {
-
 
843
			this.getIrMetaDataRuleDefinitions();
-
 
844
		}
-
 
845
		
-
 
846
		return this.irMetaDataRuleDefinitions.get(
1617
		return this.irMetaDataRuleDefinitions.get(new Long(irMetaDataRuleDefinitionID));
847
				new Long(irMetaDataRuleDefinitionID));
-
 
848
	}
1618
	}
849
	
1619
	
850
	/**
1620
	/**
851
	 * Returns all Comparison RuleDefintion objects in the database
1621
	 * Returns all Comparison RuleDefintion objects in the database
852
	 * 
1622
	 * 
853
	 * @return Map Null if Comparison rule definitions are not imported into 
1623
	 * @return Map Null if Comparison rule definitions are not imported into 
854
	 * definitions db (serialized java objects)
1624
	 * definitions db (serialized java objects)
855
	 * 
1625
	 * 
856
	 * @throws Exception 
1626
	 * @throws Exception 
857
	 */
1627
	 */
858
	@SuppressWarnings("unchecked")
-
 
859
	public Map<Long, CMPRuleDefinition> getComparisonRuleDefinitions() 
1628
	public Map<Long, CMPRuleDefinition> getComparisonRuleDefinitions(){
860
		throws Exception {
-
 
861
		
-
 
862
		// De-serialize
-
 
863
		if(this.cmpRuleDefinitions == null) {
-
 
864
			String dbFile = this.dbPath + "definitions" + File.separator + "comparisonrules" + 
-
 
865
				".ser";
-
 
866
			
-
 
867
			this.cmpRuleDefinitions = 
-
 
868
				(Map<Long, CMPRuleDefinition>) DBUtils.read(dbFile);
-
 
869
		}
-
 
870
		
-
 
871
		return this.cmpRuleDefinitions;
1629
		return this.cmpRuleDefinitions;
872
	}
1630
	}
873
	
1631
	
874
	/**
1632
	/**
875
	 * Resolves IR Data Rule Definition ID into RuleDefinition object
1633
	 * Resolves IR Data Rule Definition ID into RuleDefinition object
876
	 * 
1634
	 * 
877
	 * @param cmpRuleDefinitionID
1635
	 * @param cmpRuleDefinitionID
878
	 * @return CMPRuleDefinition
1636
	 * @return CMPRuleDefinition
879
	 * @throws Exception
1637
	 * @throws Exception
880
	 */
1638
	 */
881
	public CMPRuleDefinition getComparisonRuleDefinition(
1639
	public CMPRuleDefinition getComparisonRuleDefinition(long cmpRuleDefinitionID) {
882
			long cmpRuleDefinitionID) throws Exception {
-
 
883
		
-
 
884
		if(this.cmpRuleDefinitions == null) {
-
 
885
			this.getComparisonRuleDefinitions();
-
 
886
		}
-
 
887
		
-
 
888
		return this.cmpRuleDefinitions.get(new Long(cmpRuleDefinitionID));
1640
		return this.cmpRuleDefinitions.get(new Long(cmpRuleDefinitionID));
889
	}
1641
	}
890
 
1642
 
891
	
1643
	
892
	/**
1644
	/**
Line 895... Line 1647...
895
	 * @return Map Null if Comparison slide-rule definitions are not imported 
1647
	 * @return Map Null if Comparison slide-rule definitions are not imported 
896
	 * into definitions db (serialized java objects)
1648
	 * into definitions db (serialized java objects)
897
	 * 
1649
	 * 
898
	 * @throws Exception 
1650
	 * @throws Exception 
899
	 */
1651
	 */
900
	@SuppressWarnings("unchecked")
-
 
901
	public Map<Long, CMPSlideRuleDefinition> getComparisonSlideRuleDefinitions() 
1652
	public Map<Long, CMPSlideRuleDefinition> getComparisonSlideRuleDefinitions() {
902
		throws Exception {
-
 
903
		
-
 
904
		// De-serialize
-
 
905
		if(this.cmpSlideRuleDefinitions == null) {
-
 
906
			String dbFile = this.dbPath + "definitions" + File.separator +	
-
 
907
				"comparisondefinitions.ser";
-
 
908
			Utils.info("dbFile=" + dbFile);
-
 
909
			
-
 
910
			this.cmpSlideRuleDefinitions = 
-
 
911
				(Map<Long, CMPSlideRuleDefinition>) DBUtils.read(dbFile);
-
 
912
			
-
 
913
			//Utils.info("this.cmpSlideRuleDefinitions=" +
-
 
914
			//		this.cmpSlideRuleDefinitions);
-
 
915
		}
-
 
916
		
-
 
917
		return this.cmpSlideRuleDefinitions;
1653
		return this.cmpSlideRuleDefinitions;
918
	}
1654
	}
919
	
1655
	
920
	/**
1656
	/**
921
	 * Resolves Category ID into List of CMPSlideRuleDefinition object
1657
	 * Resolves Category ID into List of CMPSlideRuleDefinition object
922
	 * 
1658
	 * 
923
	 * @param categoryID
1659
	 * @param categoryID
924
	 * @return List<CMPSlideRuleDefinition> 
1660
	 * @return List<CMPSlideRuleDefinition> 
925
	 * @throws Exception
1661
	 * @throws Exception
926
	 */
1662
	 */
927
	public CMPSlideRuleDefinition getComparisonSlideRuleDefinition(
1663
	public CMPSlideRuleDefinition getComparisonSlideRuleDefinition(long slideDefinitionID) {
928
			long slideDefinitionID) throws Exception {
-
 
929
		
-
 
930
		if(this.cmpSlideRuleDefinitions == null) {
-
 
931
			this.getComparisonSlideRuleDefinitions();
-
 
932
		}
-
 
933
		
-
 
934
		return this.cmpSlideRuleDefinitions.get(new Long(slideDefinitionID));
1664
		return this.cmpSlideRuleDefinitions.get(new Long(slideDefinitionID));
935
	}
1665
	}
936
 
1666
 
937
	
1667
	
938
	/**
1668
	/**
Line 940... Line 1670...
940
	 * 
1670
	 * 
941
	 * @param categoryID
1671
	 * @param categoryID
942
	 * @return ExpandedCMPSlideRuleDefinition 
1672
	 * @return ExpandedCMPSlideRuleDefinition 
943
	 * @throws Exception
1673
	 * @throws Exception
944
	 */
1674
	 */
945
	public ExpandedCMPSlideRuleDefinition
-
 
946
		getExpandedComparisonSlideRuleDefinition(long slideDefinitionID) 
1675
	public ExpandedCMPSlideRuleDefinition getExpandedComparisonSlideRuleDefinition(long slideDefinitionID) throws Exception{
947
		throws Exception {
-
 
948
		Utils.info("slideDefinitionID=" + slideDefinitionID);
1676
		Utils.info("slideDefinitionID=" + slideDefinitionID);
949
		
1677
		
950
		CMPSlideRuleDefinition cmpSlideRuleDef = 
-
 
951
			this.getComparisonSlideRuleDefinition(slideDefinitionID);
1678
		CMPSlideRuleDefinition cmpSlideRuleDef = this.getComparisonSlideRuleDefinition(slideDefinitionID);
952
		
1679
		
953
		if(cmpSlideRuleDef == null) {
1680
		if(cmpSlideRuleDef == null) {
954
			return null;
1681
			return null;
955
		}
1682
		}
956
		
1683
		
957
		ExpandedCMPSlideRuleDefinition expDef = 
-
 
958
			new ExpandedCMPSlideRuleDefinition(cmpSlideRuleDef);
1684
		ExpandedCMPSlideRuleDefinition expDef = new ExpandedCMPSlideRuleDefinition(cmpSlideRuleDef);
959
		
-
 
960
		return expDef;
1685
		return expDef;
961
	}
1686
	}
962
 
1687
 
963
	
1688
	
964
	/**
1689
	/**
Line 967... Line 1692...
967
	 * @return Map Null if Comparison slide-rule definitions are not imported 
1692
	 * @return Map Null if Comparison slide-rule definitions are not imported 
968
	 * into definitions db (serialized java objects)
1693
	 * into definitions db (serialized java objects)
969
	 * 
1694
	 * 
970
	 * @throws Exception 
1695
	 * @throws Exception 
971
	 */
1696
	 */
972
	@SuppressWarnings("unchecked")
-
 
973
	public Map<Long, List<CMPBucketDefinition>> getComparisonBucketDefinitions() 
-
 
974
		throws Exception {
-
 
975
		
1697
	
976
		// De-serialize
-
 
977
		if(this.cmpBucketDefinitions == null) {
-
 
978
			String dbFile = this.dbPath + "definitions" + File.separator +	"comparisonbuckets.ser";
-
 
979
			Utils.info("dbFile=" + dbFile);
-
 
980
			
-
 
981
			this.cmpBucketDefinitions = 
-
 
982
				(Map<Long, List<CMPBucketDefinition>>) DBUtils.read(dbFile);
1698
	public Map<Long, List<CMPBucketDefinition>> getComparisonBucketDefinitions(){
983
		}
-
 
984
		
-
 
985
		return this.cmpBucketDefinitions;
1699
		return this.cmpBucketDefinitions;
986
	}
1700
	}
987
	
1701
	
988
	/**
1702
	/**
989
	 * Resolves Category ID into List of CMPBucketDefinition object
1703
	 * Resolves Category ID into List of CMPBucketDefinition object
990
	 * 
1704
	 * 
991
	 * @param categoryID
1705
	 * @param categoryID
992
	 * @return List<CMPBucketDefinition> 
1706
	 * @return List<CMPBucketDefinition> 
993
	 * @throws Exception
1707
	 * @throws Exception
994
	 */
1708
	 */
995
	public List<CMPBucketDefinition> getComparisonBucketDefinitions(
1709
	public List<CMPBucketDefinition> getComparisonBucketDefinitions(long categoryID) {
996
			long categoryID) throws Exception {
-
 
997
		
-
 
998
		if(this.cmpBucketDefinitions == null) {
-
 
999
			this.getComparisonBucketDefinitions();
-
 
1000
		}
-
 
1001
		
-
 
1002
		return this.cmpBucketDefinitions.get(new Long(categoryID));
1710
		return this.cmpBucketDefinitions.get(new Long(categoryID));
1003
	}
1711
	}
1004
	
1712
	
1005
	/**
1713
	/**
1006
	 * Resolve comparison bucket name for a slide in a particular category
1714
	 * Resolve comparison bucket name for a slide in a particular category
Line 1020... Line 1728...
1020
			
1728
			
1021
			if(slideDefinitionIDs.contains(new Long(slideDefinitionID))) {
1729
			if(slideDefinitionIDs.contains(new Long(slideDefinitionID))) {
1022
				return cmpBucket.getName();
1730
				return cmpBucket.getName();
1023
			}
1731
			}
1024
		}
1732
		}
1025
		
-
 
1026
		return null;
1733
		return null;
1027
	}
1734
	}
1028
	
1735
	
1029
	/**
1736
	/**
1030
	 * Returns list of facet definition IDs for given category ID
1737
	 * Returns list of facet definition IDs for given category ID
Line 1085... Line 1792...
1085
		
1792
		
1086
		List<SlideFeatureDefinition> slideFeatureDefs = 
1793
		List<SlideFeatureDefinition> slideFeatureDefs = 
1087
			slideDef.getSlideFeatureDefinitions();
1794
			slideDef.getSlideFeatureDefinitions();
1088
		
1795
		
1089
		for(SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
1796
		for(SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
1090
			featureDefIDs.add(
-
 
1091
					new Long(slideFeatureDef.getFeatureDefintionID()));
1797
			featureDefIDs.add(new Long(slideFeatureDef.getFeatureDefintionID()));
1092
		}
1798
		}
1093
		
1799
		
1094
		return featureDefIDs;
1800
		return featureDefIDs;
1095
	}
1801
	}
1096
	
1802
	
Line 1163... Line 1869...
1163
	 * Returns all normalization rule defined
1869
	 * Returns all normalization rule defined
1164
	 * 
1870
	 * 
1165
	 * @return Map<Long, RuleDefinition> 
1871
	 * @return Map<Long, RuleDefinition> 
1166
	 * @throws Exception 
1872
	 * @throws Exception 
1167
	 */
1873
	 */
1168
	@SuppressWarnings("unchecked")
-
 
1169
	public Map<Long, RuleDefinition> getNormalizationRules() throws Exception {
1874
	public Map<Long, RuleDefinition> getNormalizationRules() {
1170
		
-
 
1171
		// De-serialize
-
 
1172
		if(this.normalizationRuleDefinitions == null) {
-
 
1173
			String dbFile = this.dbPath + "definitions" + File.separator +	
-
 
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;
1875
		return this.normalizationRuleDefinitions;
1183
	}
1876
	}
1184
 
1877
 
1185
	
1878
	
1186
	/**
1879
	/**
Line 1209... Line 1902...
1209
	 * 
1902
	 * 
1210
	 * @param ruleID
1903
	 * @param ruleID
1211
	 * @return RuleDefinition 
1904
	 * @return RuleDefinition 
1212
	 * @throws Exception 
1905
	 * @throws Exception 
1213
	 */
1906
	 */
1214
	public RuleDefinition getNormalizationRuleDefinition(
1907
	public RuleDefinition getNormalizationRuleDefinition(long ruleDefinitionID){
1215
			long ruleDefinitionID) throws Exception {
-
 
1216
		this.getNormalizationRules();
-
 
1217
		
-
 
1218
		return this.normalizationRuleDefinitions.get(
1908
		return this.normalizationRuleDefinitions.get(new Long(ruleDefinitionID));
1219
				new Long(ruleDefinitionID));
-
 
1220
	}
1909
	}
1221
}
1910
}