Subversion Repositories SmartDukaan

Rev

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

Rev 99 Rev 102
Line 83... Line 83...
83
 *   - IR Data Rules
83
 *   - IR Data Rules
84
 *   - IR Meta-data Rules
84
 *   - IR Meta-data Rules
85
 *   - Comparison Rules
85
 *   - Comparison Rules
86
 *   - Comparison Definitions
86
 *   - Comparison Definitions
87
 *   - Comparison Buckets
87
 *   - Comparison Buckets
-
 
88
 *   - Normalization Rules
88
 * 
89
 * 
89
 * - Show
90
 * - Show
90
 * 	 - Datatype definitions
91
 * 	 - Datatype definitions
91
 * 	 - Feature definitions
92
 * 	 - Feature definitions
92
 * 	 - Slide definitions
93
 * 	 - Slide definitions
Line 96... Line 97...
96
 *   - IR Data Rules
97
 *   - IR Data Rules
97
 *   - IR Meta-data Rules
98
 *   - IR Meta-data Rules
98
 *   - Comparison Rules
99
 *   - Comparison Rules
99
 *   - Comparison Definitions
100
 *   - Comparison Definitions
100
 *   - Comparison Buckets
101
 *   - Comparison Buckets
-
 
102
 *   - Normalization Rules
101
 * 
103
 * 
102
 * - Show all definition objects that define a category 
104
 * - Show all definition objects that define a category 
103
 * 
105
 * 
104
 * 
106
 * 
105
 * @author naveen
107
 * @author naveen
Line 124... Line 126...
124
	
126
	
125
	/**
127
	/**
126
	 * Usage: MM [show|import|showcategory] [units|datatypedefinitions|
128
	 * Usage: MM [show|import|showcategory] [units|datatypedefinitions|
127
	 * featuredefinitions|slidedefinitions|categories|facetdefinitions|
129
	 * featuredefinitions|slidedefinitions|categories|facetdefinitions|
128
	 * categoryfacetdefinitions|irdatarules|irmetadatarules|comparisonrules|
130
	 * categoryfacetdefinitions|irdatarules|irmetadatarules|comparisonrules|
129
	 * comparisondefinitions|comparisonbuckets] {Category ID}
131
	 * comparisondefinitions|comparisonbuckets|normalizationrules] {Category ID}
130
	 * 
132
	 * 
131
	 * @param args
133
	 * @param args
132
	 */
134
	 */
133
	public static void main(String[] args) throws Exception {
135
	public static void main(String[] args) throws Exception {
134
		String[] definitionSetNames = new String[] {"units", 
136
		String[] definitionSetNames = new String[] {"units", 
135
				"datatypedefinitions", "featuredefinitions", "slidedefinitions", 
137
				"datatypedefinitions", "featuredefinitions", "slidedefinitions", 
136
				"categories", "facetdefinitions", "categoryfacetdefinitions", 
138
				"categories", "facetdefinitions", "categoryfacetdefinitions", 
137
				"irdatarules", "irmetadatarules", "comparisonrules", 
139
				"irdatarules", "irmetadatarules", "comparisonrules", 
138
				"comparisondefinitions", "comparisonbuckets"};
140
				"comparisondefinitions", "comparisonbuckets", 
-
 
141
				"normalizationrules"};
139
		
142
		
140
		String[] commands = new String[] {"show", "import", "showcategory"};
143
		String[] commands = new String[] {"show", "import", "showcategory"};
141
 
144
 
142
		String usage = "Usage: MM ["+ StringUtils.join(commands, "|") +"] ["+ 
145
		String usage = "Usage: MM ["+ StringUtils.join(commands, "|") +"] ["+ 
143
			StringUtils.join(definitionSetNames, "|") + "] {Category ID}";
146
			StringUtils.join(definitionSetNames, "|") + "] {Category ID}";
Line 227... Line 230...
227
	public void importDefinitionSet() throws Exception {
230
	public void importDefinitionSet() throws Exception {
228
		String type = "core";
231
		String type = "core";
229
		if(this.definitionSetName.equals("facetdefinitions") || 
232
		if(this.definitionSetName.equals("facetdefinitions") || 
230
				this.definitionSetName.equals("categoryfacetdefinitions") ||
233
				this.definitionSetName.equals("categoryfacetdefinitions") ||
231
				this.definitionSetName.equals("irdatarules") || 
234
				this.definitionSetName.equals("irdatarules") || 
232
						this.definitionSetName.equals("irmetadatarules")) {
235
						this.definitionSetName.equals("irmetadatarules") ||
-
 
236
						this.definitionSetName.equals("normalizationrules")) {
233
			type = "facets";
237
			type = "facets";
234
		}
238
		}
235
		else if(this.definitionSetName.equals("comparisonrules") || 
239
		else if(this.definitionSetName.equals("comparisonrules") || 
236
				this.definitionSetName.equals("comparisondefinitions") ||
240
				this.definitionSetName.equals("comparisondefinitions") ||
237
				this.definitionSetName.equals("comparisonbuckets")) {
241
				this.definitionSetName.equals("comparisonbuckets")) {
Line 369... Line 373...
369
 
373
 
370
			objectToStore = comparisonRuleDefsMap;
374
			objectToStore = comparisonRuleDefsMap;
371
		}
375
		}
372
		
376
		
373
		// Comparison Definitions
377
		// Comparison Definitions
374
		else if(this.definitionSetName.equals("comparisondefinitions")){
378
		else if(this.definitionSetName.equals("comparisondefinitions")) {
375
			Map cmpDefsMap = 
379
			Map cmpDefsMap = 
376
				this.convertComparisonDefinitions(cmpDefType);
380
				this.convertComparisonDefinitions(cmpDefType);
377
 
381
 
378
			objectToStore = cmpDefsMap;
382
			objectToStore = cmpDefsMap;
379
		}
383
		}
380
		
384
		
381
		// Comparison Buckets
385
		// Comparison Buckets
382
		else if(this.definitionSetName.equals("comparisonbuckets")){
386
		else if(this.definitionSetName.equals("comparisonbuckets")) {
383
			Map cmpBucketsMap = 
387
			Map cmpBucketsMap = 
384
				this.convertComparisonBuckets(cmpDefType);
388
				this.convertComparisonBuckets(cmpDefType);
385
 
389
 
386
			objectToStore = cmpBucketsMap;
390
			objectToStore = cmpBucketsMap;
387
		}
391
		}
388
		
392
		
-
 
393
		// Normalization rules
-
 
394
		else if(this.definitionSetName.equals("normalizationrules")) {
-
 
395
			Map normalizationRuleDefsMap = 
-
 
396
				this.convertNormalizationRuleDefinitions(irDefType);
-
 
397
 
-
 
398
			objectToStore = normalizationRuleDefsMap;
-
 
399
		}
-
 
400
		
389
		if(objectToStore != null) {
401
		if(objectToStore != null) {
390
			DBUtils.store(objectToStore, this.dbFile);
402
			DBUtils.store(objectToStore, this.dbFile);
391
		}
403
		}
392
	}
404
	}
-
 
405
	
-
 
406
	/**
-
 
407
	 * 
-
 
408
	 * @param irDefType
-
 
409
	 * @return
-
 
410
	 */
-
 
411
	private Map<Long, RuleDefinition> convertNormalizationRuleDefinitions(
-
 
412
			IRDefinitionType defType) {
-
 
413
		
-
 
414
		Map<Long, RuleDefinition> idRuleDef = 
-
 
415
			new TreeMap<Long, RuleDefinition>();
-
 
416
		
-
 
417
		List<RuleDefinitionType> jaxbRuleDefs = defType.getRuleDefinition();
-
 
418
		
-
 
419
		for(RuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
-
 
420
			long id = jaxbRuleDef.getID();
-
 
421
			String script = jaxbRuleDef.getScript();
-
 
422
			
-
 
423
			RuleDefinition ruleDef = new RuleDefinition(id, script);
-
 
424
			ruleDef.setDescription(jaxbRuleDef.getDescription());
-
 
425
			
-
 
426
			idRuleDef.put(new Long(id), ruleDef);
-
 
427
		}
-
 
428
		
-
 
429
		Utils.info("idRuleDef=" + idRuleDef);
-
 
430
		
-
 
431
		return idRuleDef;
-
 
432
	}
393
 
433
 
394
	/**
434
	/**
395
	 * 
435
	 * 
396
	 */
436
	 */
397
	public void showDefinitionSet() throws Exception {
437
	public void showDefinitionSet() throws Exception {
Line 771... Line 811...
771
			BulletDefinitionType jaxbBulletDef = jaxbDef.getBulletDefinition();
811
			BulletDefinitionType jaxbBulletDef = jaxbDef.getBulletDefinition();
772
			if(jaxbBulletDef != null) {
812
			if(jaxbBulletDef != null) {
773
				def.setBulletDefinition(this.convertBulletDefinition(
813
				def.setBulletDefinition(this.convertBulletDefinition(
774
						jaxbBulletDef));
814
						jaxbBulletDef));
775
			}
815
			}
-
 
816
			
-
 
817
			Long normRuleDefID = jaxbDef.getNormalizationRuleDefinitionID();
-
 
818
			if(normRuleDefID != null) {
-
 
819
				def.setNormalizationRuleDefinitionID(normRuleDefID.longValue());
-
 
820
			}
776
			Utils.info("def=" + def);
821
			Utils.info("def=" + def);
777
			
822
			
778
			defs.put(new Long(jaxbDef.getID()), def);
823
			defs.put(new Long(jaxbDef.getID()), def);
779
		}
824
		}
780
			
825