Subversion Repositories SmartDukaan

Rev

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

Rev 457 Rev 473
Line 63... Line 63...
63
	 * Hashtable of Entity ID > Final Score
63
	 * Hashtable of Entity ID > Final Score
64
	 */
64
	 */
65
	private Map<Long, Integer> entityIDFinalScore;
65
	private Map<Long, Integer> entityIDFinalScore;
66
	
66
	
67
	/**
67
	/**
-
 
68
	 * Database path. Just in case we want to override
-
 
69
	 */
-
 
70
	private String dbPath =  Utils.CONTENT_DB_PATH;
-
 
71
	
-
 
72
	/**
68
	 * Instantiates required data structures only when needed
73
	 * Instantiates required data structures only when needed
69
	 */
74
	 */
70
	public EntityContainer() {
75
	public EntityContainer() {
71
		// Lazy initialization
76
		// Lazy initialization
72
	}
77
	}
-
 
78
 
-
 
79
	public EntityContainer(String dbPath) {
-
 
80
		this.dbPath = dbPath;
-
 
81
		// Lazy initialization
-
 
82
	}
73
	
83
	
74
	/**
84
	/**
75
	 * Returns all stored Entity objects 
85
	 * Returns all stored Entity objects 
76
	 * 
86
	 * 
77
	 * @return Map
87
	 * @return Map
Line 79... Line 89...
79
	 */
89
	 */
80
	@SuppressWarnings("unchecked")
90
	@SuppressWarnings("unchecked")
81
	public Map<Long, Entity> getEntities() throws Exception {
91
	public Map<Long, Entity> getEntities() throws Exception {
82
		// De-serialize
92
		// De-serialize
83
		if(this.entities == null) {
93
		if(this.entities == null) {
84
			String entitiesDBFile = Utils.CONTENT_DB_PATH + "entities" + File.separator + "entities.ser";
94
			String entitiesDBFile = this.dbPath + "entities" + File.separator + "entities.ser";
85
			String entitiesbycategoryDBFile = Utils.CONTENT_DB_PATH + "entities" + File.separator + 
95
			String entitiesbycategoryDBFile = this.dbPath + "entities" + File.separator + 
86
				"entitiesbycategory.ser";
96
				"entitiesbycategory.ser";
87
			
97
			
88
			this.entities = (Map<Long, Entity>) DBUtils.read(entitiesDBFile);
98
			this.entities = (Map<Long, Entity>) DBUtils.read(entitiesDBFile);
89
			this.entitiesbycategory = (Map<Long, List<Entity>>) 
99
			this.entitiesbycategory = (Map<Long, List<Entity>>) 
90
				DBUtils.read(entitiesbycategoryDBFile);
100
				DBUtils.read(entitiesbycategoryDBFile);
Line 107... Line 117...
107
	 */
117
	 */
108
	@SuppressWarnings("unchecked")
118
	@SuppressWarnings("unchecked")
109
	public Map<Long, List<ExpandedBullet>> getLearnedBullets() throws Exception{
119
	public Map<Long, List<ExpandedBullet>> getLearnedBullets() throws Exception{
110
		// De-serialize
120
		// De-serialize
111
		if(this.learnedBullets == null) {
121
		if(this.learnedBullets == null) {
112
			String dbFile = Utils.CONTENT_DB_PATH + "entities" + File.separator + "learnedbullets.ser";
122
			String dbFile = this.dbPath + "entities" + File.separator + "learnedbullets.ser";
113
			
123
			
114
			this.learnedBullets = 
124
			this.learnedBullets = 
115
				(Map<Long, List<ExpandedBullet>>) DBUtils.read(dbFile);
125
				(Map<Long, List<ExpandedBullet>>) DBUtils.read(dbFile);
116
		}
126
		}
117
		
127
		
Line 284... Line 294...
284
	 */
294
	 */
285
	@SuppressWarnings("unchecked")
295
	@SuppressWarnings("unchecked")
286
	public Map<Long, List<String>> getFacetValues() throws Exception {
296
	public Map<Long, List<String>> getFacetValues() throws Exception {
287
		// De-serialize
297
		// De-serialize
288
		if(this.facetDefinitionIDFacetValues == null) {
298
		if(this.facetDefinitionIDFacetValues == null) {
289
			String dbFile = Utils.CONTENT_DB_PATH + "entities" + File.separator + "facetvalues.ser";
299
			String dbFile = this.dbPath + "entities" + File.separator + "facetvalues.ser";
290
			
300
			
291
			this.facetDefinitionIDFacetValues = 
301
			this.facetDefinitionIDFacetValues = 
292
				(Map<Long, List<String>>) DBUtils.read(dbFile);
302
				(Map<Long, List<String>>) DBUtils.read(dbFile);
293
		}
303
		}
294
		
304
		
Line 501... Line 511...
501
	@SuppressWarnings("unchecked")
511
	@SuppressWarnings("unchecked")
502
	public Map<Long, Map<Long, Integer>> getEntitySlideComparisonScores() 
512
	public Map<Long, Map<Long, Integer>> getEntitySlideComparisonScores() 
503
		throws Exception {
513
		throws Exception {
504
		// De-serialize
514
		// De-serialize
505
		if(this.entityIDSlideIDsScore == null) {
515
		if(this.entityIDSlideIDsScore == null) {
506
			String dbFile = Utils.CONTENT_DB_PATH + "comparisons" + File.separator + "slidescores.ser";
516
			String dbFile = this.dbPath + "comparisons" + File.separator + "slidescores.ser";
507
			
517
			
508
			this.entityIDSlideIDsScore = 
518
			this.entityIDSlideIDsScore = 
509
				(Map<Long, Map<Long, Integer>>) DBUtils.read(dbFile);
519
				(Map<Long, Map<Long, Integer>>) DBUtils.read(dbFile);
510
		}
520
		}
511
		
521
		
Line 525... Line 535...
525
	 */
535
	 */
526
	@SuppressWarnings("unchecked")
536
	@SuppressWarnings("unchecked")
527
	public Map<Long, Integer> getEntityComparisonScores() throws Exception {
537
	public Map<Long, Integer> getEntityComparisonScores() throws Exception {
528
		// De-serialize
538
		// De-serialize
529
		if(this.entityIDFinalScore == null) {
539
		if(this.entityIDFinalScore == null) {
530
			String dbFile = Utils.CONTENT_DB_PATH + "comparisons" + File.separator + 
540
			String dbFile = this.dbPath + "comparisons" + File.separator + 
531
				"defaultentityscores.ser";
541
				"defaultentityscores.ser";
532
			
542
			
533
			this.entityIDFinalScore = 
543
			this.entityIDFinalScore = 
534
				(Map<Long, Integer>) DBUtils.read(dbFile);
544
				(Map<Long, Integer>) DBUtils.read(dbFile);
535
		}
545
		}