Subversion Repositories SmartDukaan

Rev

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

Rev 457 Rev 473
Line 107... Line 107...
107
	 * Hashtable of feature definition ID to normalization rule definition ID
107
	 * Hashtable of feature definition ID to normalization rule definition ID
108
	 */
108
	 */
109
	private Map<Long, List<Long>> categorySlideSequence;
109
	private Map<Long, List<Long>> categorySlideSequence;
110
	
110
	
111
	/**
111
	/**
-
 
112
	 * Database path. Just in case we want to override
-
 
113
	 */
-
 
114
	private String dbPath =  Utils.CONTENT_DB_PATH;
-
 
115
	
-
 
116
	/**
112
	 * Empty constructor. Data structures are initialised as needed
117
	 * Empty constructor. Data structures are initialised as needed
113
	 */
118
	 */
114
	public DefinitionsContainer() {
119
	public DefinitionsContainer() {
115
		// Lazy initialization
120
		// Lazy initialization
116
	}
121
	}
117
	
122
	
118
	/**
123
	/**
-
 
124
	 * Empty constructor. Just dbPath is initialised
-
 
125
	 */
-
 
126
	public DefinitionsContainer(String dbPath) {
-
 
127
		this.dbPath = dbPath;
-
 
128
		// Lazy initialization
-
 
129
	}
-
 
130
	
-
 
131
	/**
119
	 * Returns Slide sequence for a category in the database
132
	 * Returns Slide sequence for a category in the database
120
	 * 
133
	 * 
121
	 * @return Map Null if Category-Slide definitions are not imported into 
134
	 * @return Map Null if Category-Slide definitions are not imported into 
122
	 * definitions db 
135
	 * definitions db 
123
	 * (serialized java objects)
136
	 * (serialized java objects)
Line 126... Line 139...
126
	 */
139
	 */
127
	@SuppressWarnings("unchecked")
140
	@SuppressWarnings("unchecked")
128
	public Map<Long, List<Long>> getCategorySlideSequence() throws Exception {		
141
	public Map<Long, List<Long>> getCategorySlideSequence() throws Exception {		
129
		// De-serialize
142
		// De-serialize
130
		if(this.categorySlideSequence == null) {
143
		if(this.categorySlideSequence == null) {
131
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "categoryslidesequence"+
144
			String dbFile = this.dbPath + "definitions" + File.separator + "categoryslidesequence"+
132
				".ser";
145
				".ser";
133
			
146
			
134
			this.categorySlideSequence = (Map<Long, List<Long>>) 
147
			this.categorySlideSequence = (Map<Long, List<Long>>) 
135
				DBUtils.read(dbFile);
148
				DBUtils.read(dbFile);
136
		}
149
		}
Line 163... Line 176...
163
	 */
176
	 */
164
	@SuppressWarnings("unchecked")
177
	@SuppressWarnings("unchecked")
165
	public Map<Long, Unit> getUnits() throws Exception {		
178
	public Map<Long, Unit> getUnits() throws Exception {		
166
		// De-serialize
179
		// De-serialize
167
		if(this.units == null) {
180
		if(this.units == null) {
168
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "units" + ".ser";
181
			String dbFile = this.dbPath + "definitions" + File.separator + "units" + ".ser";
169
			
182
			
170
			this.units = (Map<Long, Unit>) DBUtils.read(dbFile);
183
			this.units = (Map<Long, Unit>) DBUtils.read(dbFile);
171
		}
184
		}
172
		
185
		
173
		return this.units;
186
		return this.units;
Line 199... Line 212...
199
	public Map<Long, DatatypeDefinition> getDatatypeDefinitions() 
212
	public Map<Long, DatatypeDefinition> getDatatypeDefinitions() 
200
		throws Exception {
213
		throws Exception {
201
		
214
		
202
		// De-serialize
215
		// De-serialize
203
		if(this.datatypeDefinitions == null) {
216
		if(this.datatypeDefinitions == null) {
204
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "datatypedefinitions" + 
217
			String dbFile = this.dbPath + "definitions" + File.separator + "datatypedefinitions" + 
205
				".ser";
218
				".ser";
206
			
219
			
207
			this.datatypeDefinitions = 
220
			this.datatypeDefinitions = 
208
				(Map<Long, DatatypeDefinition>) DBUtils.read(dbFile);
221
				(Map<Long, DatatypeDefinition>) DBUtils.read(dbFile);
209
		}
222
		}
Line 264... Line 277...
264
	@SuppressWarnings("unchecked")
277
	@SuppressWarnings("unchecked")
265
	public Map<Long, Category> getCategories() throws Exception {
278
	public Map<Long, Category> getCategories() throws Exception {
266
		
279
		
267
		// De-serialize
280
		// De-serialize
268
		if(this.categories == null) {
281
		if(this.categories == null) {
269
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "categories" + ".ser";
282
			String dbFile = this.dbPath + "definitions" + File.separator + "categories" + ".ser";
270
			
283
			
271
			this.categories = (Map<Long, Category>) DBUtils.read(dbFile);
284
			this.categories = (Map<Long, Category>) DBUtils.read(dbFile);
272
		}
285
		}
273
		return this.categories;
286
		return this.categories;
274
	}
287
	}
Line 348... Line 361...
348
	@SuppressWarnings("unchecked")
361
	@SuppressWarnings("unchecked")
349
	public Map<Long, SlideDefinition> getSlideDefinitions() throws Exception {
362
	public Map<Long, SlideDefinition> getSlideDefinitions() throws Exception {
350
		
363
		
351
		// De-serialize
364
		// De-serialize
352
		if(this.slideDefinitions == null) {
365
		if(this.slideDefinitions == null) {
353
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "slidedefinitions" + 
366
			String dbFile = this.dbPath + "definitions" + File.separator + "slidedefinitions" + 
354
				".ser";
367
				".ser";
355
			
368
			
356
			this.slideDefinitions = 
369
			this.slideDefinitions = 
357
				(Map<Long, SlideDefinition>) DBUtils.read(dbFile);
370
				(Map<Long, SlideDefinition>) DBUtils.read(dbFile);
358
		}
371
		}
Line 487... Line 500...
487
	public Map<Long, FeatureDefinition> getFeatureDefinitions() 
500
	public Map<Long, FeatureDefinition> getFeatureDefinitions() 
488
		throws Exception {
501
		throws Exception {
489
		
502
		
490
		// De-serialize
503
		// De-serialize
491
		if(this.featureDefinitions == null) {
504
		if(this.featureDefinitions == null) {
492
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "featuredefinitions" + 
505
			String dbFile = this.dbPath + "definitions" + File.separator + "featuredefinitions" + 
493
				".ser";
506
				".ser";
494
			
507
			
495
			this.featureDefinitions = 
508
			this.featureDefinitions = 
496
				(Map<Long, FeatureDefinition>) DBUtils.read(dbFile);
509
				(Map<Long, FeatureDefinition>) DBUtils.read(dbFile);
497
		}
510
		}
Line 605... Line 618...
605
	 */
618
	 */
606
	@SuppressWarnings("unchecked")
619
	@SuppressWarnings("unchecked")
607
	public Map<Long, EnumValue> getEnumValues() throws Exception {
620
	public Map<Long, EnumValue> getEnumValues() throws Exception {
608
		// De-serialise
621
		// De-serialise
609
		if(this.enumValues == null) {
622
		if(this.enumValues == null) {
610
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "enumvalues" + 
623
			String dbFile = this.dbPath + "definitions" + File.separator + "enumvalues" + 
611
				".ser";
624
				".ser";
612
			
625
			
613
			this.enumValues = 
626
			this.enumValues = 
614
				(Map<Long, EnumValue>) DBUtils.read(dbFile);
627
				(Map<Long, EnumValue>) DBUtils.read(dbFile);
615
		}
628
		}
Line 644... Line 657...
644
	@SuppressWarnings("unchecked")
657
	@SuppressWarnings("unchecked")
645
	public Map<Long, FacetDefinition> getFacetDefinitions() throws Exception {
658
	public Map<Long, FacetDefinition> getFacetDefinitions() throws Exception {
646
		
659
		
647
		// De-serialize
660
		// De-serialize
648
		if(this.facetDefinitions == null) {
661
		if(this.facetDefinitions == null) {
649
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "facetdefinitions" + 
662
			String dbFile = this.dbPath + "definitions" + File.separator + "facetdefinitions" + 
650
				".ser";
663
				".ser";
651
			
664
			
652
			this.facetDefinitions = 
665
			this.facetDefinitions = 
653
				(Map<Long, FacetDefinition>) DBUtils.read(dbFile);
666
				(Map<Long, FacetDefinition>) DBUtils.read(dbFile);
654
		}
667
		}
Line 704... Line 717...
704
	public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions() 
717
	public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions() 
705
		throws Exception {
718
		throws Exception {
706
		
719
		
707
		// De-serialize
720
		// De-serialize
708
		if(this.categoryFacetDefinitions == null) {
721
		if(this.categoryFacetDefinitions == null) {
709
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + 
722
			String dbFile = this.dbPath + "definitions" + File.separator + 
710
				"categoryfacetdefinitions.ser";
723
				"categoryfacetdefinitions.ser";
711
			
724
			
712
			this.categoryFacetDefinitions = 
725
			this.categoryFacetDefinitions = 
713
				(Map<Long, CategoryFacetDefinition>) DBUtils.read(dbFile);
726
				(Map<Long, CategoryFacetDefinition>) DBUtils.read(dbFile);
714
		}
727
		}
Line 764... Line 777...
764
	public Map<Long, RuleDefinition> getIrDataRuleDefinitions() 
777
	public Map<Long, RuleDefinition> getIrDataRuleDefinitions() 
765
		throws Exception {
778
		throws Exception {
766
		
779
		
767
		// De-serialize
780
		// De-serialize
768
		if(this.irDataRuleDefinitions == null) {
781
		if(this.irDataRuleDefinitions == null) {
769
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "irdatarules" + ".ser";
782
			String dbFile = this.dbPath + "definitions" + File.separator + "irdatarules" + ".ser";
770
			
783
			
771
			this.irDataRuleDefinitions = 
784
			this.irDataRuleDefinitions = 
772
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
785
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
773
		}
786
		}
774
		
787
		
Line 804... Line 817...
804
	public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions() 
817
	public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions() 
805
		throws Exception {
818
		throws Exception {
806
		
819
		
807
		// De-serialize
820
		// De-serialize
808
		if(this.irMetaDataRuleDefinitions == null) {
821
		if(this.irMetaDataRuleDefinitions == null) {
809
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "irmetadatarules" + 
822
			String dbFile = this.dbPath + "definitions" + File.separator + "irmetadatarules" + 
810
				".ser";
823
				".ser";
811
			
824
			
812
			this.irMetaDataRuleDefinitions = 
825
			this.irMetaDataRuleDefinitions = 
813
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
826
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
814
		}
827
		}
Line 846... Line 859...
846
	public Map<Long, CMPRuleDefinition> getComparisonRuleDefinitions() 
859
	public Map<Long, CMPRuleDefinition> getComparisonRuleDefinitions() 
847
		throws Exception {
860
		throws Exception {
848
		
861
		
849
		// De-serialize
862
		// De-serialize
850
		if(this.cmpRuleDefinitions == null) {
863
		if(this.cmpRuleDefinitions == null) {
851
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator + "comparisonrules" + 
864
			String dbFile = this.dbPath + "definitions" + File.separator + "comparisonrules" + 
852
				".ser";
865
				".ser";
853
			
866
			
854
			this.cmpRuleDefinitions = 
867
			this.cmpRuleDefinitions = 
855
				(Map<Long, CMPRuleDefinition>) DBUtils.read(dbFile);
868
				(Map<Long, CMPRuleDefinition>) DBUtils.read(dbFile);
856
		}
869
		}
Line 888... Line 901...
888
	public Map<Long, CMPSlideRuleDefinition> getComparisonSlideRuleDefinitions() 
901
	public Map<Long, CMPSlideRuleDefinition> getComparisonSlideRuleDefinitions() 
889
		throws Exception {
902
		throws Exception {
890
		
903
		
891
		// De-serialize
904
		// De-serialize
892
		if(this.cmpSlideRuleDefinitions == null) {
905
		if(this.cmpSlideRuleDefinitions == null) {
893
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator +	
906
			String dbFile = this.dbPath + "definitions" + File.separator +	
894
				"comparisondefinitions.ser";
907
				"comparisondefinitions.ser";
895
			Utils.info("dbFile=" + dbFile);
908
			Utils.info("dbFile=" + dbFile);
896
			
909
			
897
			this.cmpSlideRuleDefinitions = 
910
			this.cmpSlideRuleDefinitions = 
898
				(Map<Long, CMPSlideRuleDefinition>) DBUtils.read(dbFile);
911
				(Map<Long, CMPSlideRuleDefinition>) DBUtils.read(dbFile);
Line 960... Line 973...
960
	public Map<Long, List<CMPBucketDefinition>> getComparisonBucketDefinitions() 
973
	public Map<Long, List<CMPBucketDefinition>> getComparisonBucketDefinitions() 
961
		throws Exception {
974
		throws Exception {
962
		
975
		
963
		// De-serialize
976
		// De-serialize
964
		if(this.cmpBucketDefinitions == null) {
977
		if(this.cmpBucketDefinitions == null) {
965
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator +	"comparisonbuckets.ser";
978
			String dbFile = this.dbPath + "definitions" + File.separator +	"comparisonbuckets.ser";
966
			Utils.info("dbFile=" + dbFile);
979
			Utils.info("dbFile=" + dbFile);
967
			
980
			
968
			this.cmpBucketDefinitions = 
981
			this.cmpBucketDefinitions = 
969
				(Map<Long, List<CMPBucketDefinition>>) DBUtils.read(dbFile);
982
				(Map<Long, List<CMPBucketDefinition>>) DBUtils.read(dbFile);
970
		}
983
		}
Line 1154... Line 1167...
1154
	@SuppressWarnings("unchecked")
1167
	@SuppressWarnings("unchecked")
1155
	public Map<Long, RuleDefinition> getNormalizationRules() throws Exception {
1168
	public Map<Long, RuleDefinition> getNormalizationRules() throws Exception {
1156
		
1169
		
1157
		// De-serialize
1170
		// De-serialize
1158
		if(this.normalizationRuleDefinitions == null) {
1171
		if(this.normalizationRuleDefinitions == null) {
1159
			String dbFile = Utils.CONTENT_DB_PATH + "definitions" + File.separator +	
1172
			String dbFile = this.dbPath + "definitions" + File.separator +	
1160
				"normalizationrules.ser";
1173
				"normalizationrules.ser";
1161
			
1174
			
1162
			Utils.info("dbFile=" + dbFile);
1175
			Utils.info("dbFile=" + dbFile);
1163
			
1176
			
1164
			this.normalizationRuleDefinitions = 
1177
			this.normalizationRuleDefinitions =