Subversion Repositories SmartDukaan

Rev

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

Rev 80 Rev 81
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;
6
import in.shop2020.metamodel.core.Entity;
7
import in.shop2020.metamodel.core.Entity;
7
import in.shop2020.metamodel.core.Feature;
8
import in.shop2020.metamodel.core.Feature;
8
import in.shop2020.metamodel.core.Slide;
9
import in.shop2020.metamodel.core.Slide;
9
import in.shop2020.metamodel.util.ExpandedEntity;
10
import in.shop2020.metamodel.util.ExpandedEntity;
10
import in.shop2020.util.DBUtils;
11
import in.shop2020.util.DBUtils;
11
import in.shop2020.util.Utils;
12
import in.shop2020.util.Utils;
12
 
13
 
13
import java.io.Serializable;
14
import java.io.Serializable;
14
import java.util.ArrayList;
15
import java.util.ArrayList;
-
 
16
import java.util.HashMap;
15
import java.util.List;
17
import java.util.List;
16
import java.util.Map;
18
import java.util.Map;
17
import java.util.TreeMap;
19
import java.util.TreeMap;
18
 
20
 
19
/**
21
/**
Line 38... Line 40...
38
	 * Hashtable of Category ID to list of Entity objects
40
	 * Hashtable of Category ID to list of Entity objects
39
	 */
41
	 */
40
	private Map<Long, List<Entity>> entitiesbycategory;
42
	private Map<Long, List<Entity>> entitiesbycategory;
41
	
43
	
42
	/**
44
	/**
-
 
45
	 * Hashtable of Feature Definition ID to list of learned Bullet objects
-
 
46
	 */
-
 
47
	private Map<Long, List<Bullet>> learnedBullets;
-
 
48
	
-
 
49
	/**
43
	 * Instantiates required data structures only when needed
50
	 * Instantiates required data structures only when needed
44
	 */
51
	 */
45
	public EntityContainer() {
52
	public EntityContainer() {
46
		// Lazy initialization
53
		// Lazy initialization
47
	}
54
	}
Line 72... Line 79...
72
		}
79
		}
73
		
80
		
74
		return this.entities;
81
		return this.entities;
75
	}
82
	}
76
	
83
	
-
 
84
	/**
-
 
85
	 * Returns hashtable of list bullet objects to feature definition ID
-
 
86
	 * 
-
 
87
	 * @return Map<Long, List<Bullet>> 
-
 
88
	 * @throws Exception
-
 
89
	 */
-
 
90
	@SuppressWarnings("unchecked")
-
 
91
	public Map<Long, List<Bullet>> getLearnedBullets() throws Exception {
-
 
92
		// De-serialize
-
 
93
		if(this.learnedBullets == null) {
-
 
94
			String dbFile = Utils.ENTITIES_DB_PATH + "learnedbullets.ser";
-
 
95
			
-
 
96
			this.learnedBullets = 
-
 
97
				(Map<Long, List<Bullet>>) DBUtils.read(dbFile);
-
 
98
		}
-
 
99
		
-
 
100
		if(this.learnedBullets == null) {
-
 
101
			this.learnedBullets = new HashMap<Long, List<Bullet>>();
-
 
102
		}
-
 
103
		
-
 
104
		return this.learnedBullets;
-
 
105
	}
-
 
106
 
-
 
107
	/**
-
 
108
	 * Resolves Feature Definition ID into list of learned Bullet objects
-
 
109
	 * 
-
 
110
	 * @param featureDefinitionID
-
 
111
	 * @return
-
 
112
	 * @throws Exception
-
 
113
	 */
-
 
114
	public List<Bullet> getLearnedBullets(long featureDefinitionID) 
-
 
115
		throws Exception {
-
 
116
		if(this.learnedBullets == null) {
-
 
117
			this.getLearnedBullets();
-
 
118
		}
-
 
119
		
-
 
120
		return this.learnedBullets.get(new Long(featureDefinitionID));
-
 
121
	}
-
 
122
	
77
	/** 
123
	/** 
78
	 * Returns hashtable of list entities to category ID
124
	 * Returns hashtable of list entities to category ID
79
	 * 
125
	 * 
80
	 * @return the entitiesbycategory Entities by category
126
	 * @return the entitiesbycategory Entities by category
81
	 * @throws Exception 
127
	 * @throws Exception