Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20424 kshitij.so 1
package com.hotspotstore.controllers;
2
 
3
import org.json.JSONObject;
4
 
5
import com.hotspotstore.storage.Mongo;
6
 
7
 
8
public class ProductsController extends BaseController{
9
 
10
	/**
11
	 * 
12
	 */
13
	private static final long serialVersionUID = 1L;
14
	private String entityId;
15
	private String result;
16
 
17
 
18
	public String getResult() {
19
		return result;
20
	}
21
 
22
	public void setResult(String result) {
23
		this.result = result;
24
	}
25
 
26
	public String getEntityId() {
27
		return entityId;
28
	}
29
 
30
	public void setEntityId(String entityId) {
31
		this.entityId = entityId;
32
	}
33
 
34
	public String index(){
35
		return "index";
36
	}
37
 
38
	public String fetchEntityDetails() throws NumberFormatException, Exception{
39
		JSONObject entityData = Mongo.getEntityById(Long.valueOf(entityId));
40
		setResult(entityData.getString("title"));
41
		return "result";
42
	}
43
 
44
	public String addEntity() throws NumberFormatException, Exception{
45
		try{
46
			JSONObject entityData = Mongo.getEntityById(Long.valueOf(entityId));
47
			Mongo.addEntityToHotspot(entityData.getLong("_id"), entityData.getString("title"));
48
			setResult("Entity added");
49
		}
50
		catch(Exception e){
51
			setResult("Entity already added");
52
		}
53
		return "result";
54
	}
55
 
56
}