Subversion Repositories SmartDukaan

Rev

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

Rev 81 Rev 82
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.core.Bullet;
-
 
7
import in.shop2020.metamodel.core.Entity;
6
import in.shop2020.metamodel.core.Entity;
8
import in.shop2020.metamodel.core.Feature;
7
import in.shop2020.metamodel.core.Feature;
9
import in.shop2020.metamodel.core.Slide;
8
import in.shop2020.metamodel.core.Slide;
-
 
9
import in.shop2020.metamodel.util.ExpandedBullet;
10
import in.shop2020.metamodel.util.ExpandedEntity;
10
import in.shop2020.metamodel.util.ExpandedEntity;
11
import in.shop2020.util.DBUtils;
11
import in.shop2020.util.DBUtils;
12
import in.shop2020.util.Utils;
12
import in.shop2020.util.Utils;
13
 
13
 
14
import java.io.Serializable;
14
import java.io.Serializable;
Line 42... Line 42...
42
	private Map<Long, List<Entity>> entitiesbycategory;
42
	private Map<Long, List<Entity>> entitiesbycategory;
43
	
43
	
44
	/**
44
	/**
45
	 * Hashtable of Feature Definition ID to list of learned Bullet objects
45
	 * Hashtable of Feature Definition ID to list of learned Bullet objects
46
	 */
46
	 */
47
	private Map<Long, List<Bullet>> learnedBullets;
47
	private Map<Long, List<ExpandedBullet>> learnedBullets;
48
	
48
	
49
	/**
49
	/**
50
	 * Instantiates required data structures only when needed
50
	 * Instantiates required data structures only when needed
51
	 */
51
	 */
52
	public EntityContainer() {
52
	public EntityContainer() {
Line 82... Line 82...
82
	}
82
	}
83
	
83
	
84
	/**
84
	/**
85
	 * Returns hashtable of list bullet objects to feature definition ID
85
	 * Returns hashtable of list bullet objects to feature definition ID
86
	 * 
86
	 * 
87
	 * @return Map<Long, List<Bullet>> 
87
	 * @return Map<Long, List<ExpandedBullet>> 
88
	 * @throws Exception
88
	 * @throws Exception
89
	 */
89
	 */
90
	@SuppressWarnings("unchecked")
90
	@SuppressWarnings("unchecked")
91
	public Map<Long, List<Bullet>> getLearnedBullets() throws Exception {
91
	public Map<Long, List<ExpandedBullet>> getLearnedBullets() throws Exception{
92
		// De-serialize
92
		// De-serialize
93
		if(this.learnedBullets == null) {
93
		if(this.learnedBullets == null) {
94
			String dbFile = Utils.ENTITIES_DB_PATH + "learnedbullets.ser";
94
			String dbFile = Utils.ENTITIES_DB_PATH + "learnedbullets.ser";
95
			
95
			
96
			this.learnedBullets = 
96
			this.learnedBullets = 
97
				(Map<Long, List<Bullet>>) DBUtils.read(dbFile);
97
				(Map<Long, List<ExpandedBullet>>) DBUtils.read(dbFile);
98
		}
98
		}
99
		
99
		
100
		if(this.learnedBullets == null) {
100
		if(this.learnedBullets == null) {
101
			this.learnedBullets = new HashMap<Long, List<Bullet>>();
101
			this.learnedBullets = new HashMap<Long, List<ExpandedBullet>>();
102
		}
102
		}
103
		
103
		
104
		return this.learnedBullets;
104
		return this.learnedBullets;
105
	}
105
	}
106
 
106
 
107
	/**
107
	/**
108
	 * Resolves Feature Definition ID into list of learned Bullet objects
108
	 * Resolves Feature Definition ID into list of learned Bullet objects
109
	 * 
109
	 * 
110
	 * @param featureDefinitionID
110
	 * @param featureDefinitionID
111
	 * @return
111
	 * @return list of ExpandedBullets
112
	 * @throws Exception
112
	 * @throws Exception
113
	 */
113
	 */
114
	public List<Bullet> getLearnedBullets(long featureDefinitionID) 
114
	public List<ExpandedBullet> getLearnedBullets(long featureDefinitionID) 
115
		throws Exception {
115
		throws Exception {
116
		if(this.learnedBullets == null) {
116
		if(this.learnedBullets == null) {
117
			this.getLearnedBullets();
117
			this.getLearnedBullets();
118
		}
118
		}
119
		
119