Subversion Repositories SmartDukaan

Rev

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

Rev 41 Rev 49
Line 14... Line 14...
14
import java.util.List;
14
import java.util.List;
15
import java.util.Map;
15
import java.util.Map;
16
import java.util.TreeMap;
16
import java.util.TreeMap;
17
 
17
 
18
/**
18
/**
-
 
19
 * Single point access to stored shop2020 core objects
-
 
20
 * 
19
 * @author naveen
21
 * @author naveen
20
 *
22
 *
21
 */
23
 */
22
public class EntityContainer implements Serializable {
24
public class EntityContainer implements Serializable {
23
 
25
 
24
	/**
26
	/**
25
	 * 
27
	 * 
26
	 */
28
	 */
27
	private static final long serialVersionUID = 1L;
29
	private static final long serialVersionUID = 1L;
28
	
30
	
-
 
31
	/**
-
 
32
	 * Hashtable of Entity ID to Entity object
-
 
33
	 */
29
	private Map<Long, Entity> entities;
34
	private Map<Long, Entity> entities;
-
 
35
	
-
 
36
	/**
-
 
37
	 * Hashtable of Category ID to list of Entity objects
-
 
38
	 */
30
	private Map<Long, List<Entity>> entitiesbycategory;
39
	private Map<Long, List<Entity>> entitiesbycategory;
31
	
40
	
32
	/**
41
	/**
33
	 * 
-
 
-
 
42
	 * Instantiates required data structures only when needed
34
	 */
43
	 */
35
	public EntityContainer() {
44
	public EntityContainer() {
36
		// Lazy initialization
45
		// Lazy initialization
37
	}
46
	}
38
	
47
	
39
	/**
48
	/**
-
 
49
	 * Returns all stored Entity objects 
40
	 * 
50
	 * 
41
	 * @return Map
51
	 * @return Map
42
	 * @throws Exception 
52
	 * @throws Exception 
43
	 */
53
	 */
44
	@SuppressWarnings("unchecked")
54
	@SuppressWarnings("unchecked")
Line 62... Line 72...
62
		
72
		
63
		return this.entities;
73
		return this.entities;
64
	}
74
	}
65
	
75
	
66
	/** 
76
	/** 
-
 
77
	 * Returns hashtable of list entities to category ID
-
 
78
	 * 
67
	 * @return the entitiesbycategory
79
	 * @return the entitiesbycategory Entities by category
68
	 * @throws Exception 
80
	 * @throws Exception 
69
	 */
81
	 */
70
	public Map<Long, List<Entity>> getEntitiesbyCategory() throws Exception {
82
	public Map<Long, List<Entity>> getEntitiesbyCategory() throws Exception {
71
		if(this.entities == null) {
83
		if(this.entities == null) {
72
			this.getEntities();
84
			this.getEntities();
Line 74... Line 86...
74
		
86
		
75
		return this.entitiesbycategory;
87
		return this.entitiesbycategory;
76
	}
88
	}
77
 
89
 
78
	/**
90
	/**
-
 
91
	 * Resolves Entity ID into Entity object
79
	 * 
92
	 * 
80
	 * @param entityID
93
	 * @param entityID
81
	 * @return Entity
94
	 * @return Entity
82
	 * @throws Exception 
95
	 * @throws Exception 
83
	 */
96
	 */
Line 88... Line 101...
88
		
101
		
89
		return this.entities.get(new Long(entityID));
102
		return this.entities.get(new Long(entityID));
90
	}
103
	}
91
	
104
	
92
	/**
105
	/**
-
 
106
	 * Returns list of entities for a category ID
93
	 * 
107
	 * 
94
	 * @param categoryID
108
	 * @param categoryID
95
	 * @return List<Entity>
109
	 * @return List<Entity>
96
	 * @throws Exception 
110
	 * @throws Exception 
97
	 */
111
	 */
Line 103... Line 117...
103
		
117
		
104
		return this.entitiesbycategory.get(new Long(categoryID));
118
		return this.entitiesbycategory.get(new Long(categoryID));
105
	}
119
	}
106
	
120
	
107
	/**
121
	/**
-
 
122
	 * Convienience method to add new Entity 
108
	 * 
123
	 * 
109
	 * @param newEntity
124
	 * @param newEntity
110
	 * @throws Exception 
125
	 * @throws Exception 
111
	 */
126
	 */
112
	public void addEntity(Entity newEntity) throws Exception {
127
	public void addEntity(Entity newEntity) throws Exception {
Line 128... Line 143...
128
		this.entitiesbycategory.put(new Long(newEntity.getCategoryID()), 
143
		this.entitiesbycategory.put(new Long(newEntity.getCategoryID()), 
129
				catentities);
144
				catentities);
130
	}
145
	}
131
	
146
	
132
	/**
147
	/**
-
 
148
	 * Returns expand form of entity object. All references are resolved into 
-
 
149
	 * corresponding detail object
133
	 * 
150
	 * 
134
	 * @param entityID
151
	 * @param entityID
135
	 * @return ExpandedEntity 
152
	 * @return ExpandedEntity 
136
	 * @throws Exception 
153
	 * @throws Exception 
137
	 */
154
	 */