Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
317 ashish 1
/**
2
 * 
3
 */
4
package in.shop2020.serving.controllers;
5
 
650 rajveer 6
 
555 chandransh 7
import in.shop2020.thrift.clients.UserContextServiceClient;
8
import in.shop2020.model.v1.user.UserContextService.Client;
375 ashish 9
 
317 ashish 10
import java.io.IOException;
375 ashish 11
import java.util.Map;
507 rajveer 12
import java.util.StringTokenizer;
317 ashish 13
 
14
import org.apache.juli.logging.Log;
15
import org.apache.juli.logging.LogFactory;
832 rajveer 16
import org.apache.log4j.Logger;
507 rajveer 17
import org.apache.struts2.convention.annotation.Action;
18
import org.apache.struts2.convention.annotation.Actions;
317 ashish 19
 
20
/**
21
 * 
650 rajveer 22
 * @author rajveer
317 ashish 23
 *
24
 */
650 rajveer 25
 
26
public class EntityController extends BaseController {
27
 
28
	private static final long serialVersionUID = 1L;
29
 
832 rajveer 30
	private static Logger log = Logger.getLogger(Class.class);	
317 ashish 31
	/**
32
	 * 
33
	 */
34
	private String id;
375 ashish 35
 
620 rajveer 36
	private long productId;
375 ashish 37
 
38
	public EntityController(){
39
		super();
40
	}
507 rajveer 41
 
42
	// GET /entity/1000001
43
	@Actions({
44
		@Action("/mobiles"),
45
		@Action("/books"),
46
		@Action("/mobile"),
47
		@Action("/entity")
48
	})
650 rajveer 49
    public String show() throws SecurityException, IOException {
317 ashish 50
    	log.info("id=" + id);
637 rajveer 51
 
650 rajveer 52
    	htmlSnippets.put("PRODUCT_SUMMARY", pageLoader.getProductSummaryHtml(productId));
620 rajveer 53
		htmlSnippets.put("SOCIAL_UTILS", pageLoader.getSocialUtilsHtml(productId));
54
		htmlSnippets.put("SLIDE_GUIDE", pageLoader.getSlideGuideHtml(productId));
901 rajveer 55
		//htmlSnippets.put("RECOMMENDATIONS", pageLoader.getRecommendationsHtml());
56
		//htmlSnippets.put("SIMILAR_PRODUCTS", pageLoader.getSimilarProductsHtml(productId));
57
		//htmlSnippets.put("ACCESSORIES", pageLoader.getAccessoriesHtml(productId));
58
		//htmlSnippets.put("LOCATOR", pageLoader.getLocatorHtml());
59
		//htmlSnippets.put("REVIEWS", pageLoader.getReviewsHtml(productId));
620 rajveer 60
 
650 rajveer 61
		try {
555 chandransh 62
			UserContextServiceClient userServiceClient = new UserContextServiceClient();
63
			Client client = userServiceClient.getClient();
773 rajveer 64
			long itemId = Long.parseLong(id);
65
			long userId = userinfo.getUserId();
66
			client.updateBrowseHistory(userId, itemId);
650 rajveer 67
 
449 rajveer 68
		} catch (Exception e) {
69
			// TODO Auto-generated catch block
70
			e.printStackTrace();
71
		}
72
 
650 rajveer 73
    	return "show";
317 ashish 74
    }
75
 
76
    /**
77
     * 
78
     * @param id
79
     */
80
    public void setId(String id) {
507 rajveer 81
    	StringTokenizer tokenizer = new StringTokenizer(id,"-");
82
    	while(tokenizer.hasMoreTokens()){
83
    		this.id = tokenizer.nextToken();
84
    	}
620 rajveer 85
    	this.productId = Long.parseLong(id);
317 ashish 86
    }
87
 
387 rajveer 88
	public Map<String,String> getHtmlSnippets(){
388 rajveer 89
		System.out.println(" getHtmlSnippets  is called");
387 rajveer 90
		return htmlSnippets;
375 ashish 91
	}
388 rajveer 92
 
449 rajveer 93
	public String getSlideGuideSnippet(){
388 rajveer 94
		return htmlSnippets.get("SLIDE_GUIDE");
95
	}
96
 
449 rajveer 97
	public String getProductSummarySnippet(){
98
		return htmlSnippets.get("PRODUCT_SUMMARY");
99
	}
100
 
101
	public String getSocialUtilsSnippet(){
102
		return htmlSnippets.get("SOCIAL_UTILS"); 
103
	}
104
 
105
	public String getLocatorSnippet(){
106
		return htmlSnippets.get("LOCATOR");
107
	}
108
 
109
	public String getRecommendationsSnippet(){
110
		return htmlSnippets.get("RECOMMENDATIONS");
111
	}
650 rajveer 112
 
449 rajveer 113
	public String getSimilarProductsSnippet(){
114
		return htmlSnippets.get("SIMILAR_PRODUCTS");
115
	}
650 rajveer 116
 
449 rajveer 117
	public String getAccessoriesSnippet(){
118
		return htmlSnippets.get("ACCESSORIES");
119
	}
120
 
650 rajveer 121
	public String getReviewsSnippet(){
122
		return htmlSnippets.get("REVIEWS");
449 rajveer 123
	}
124
 
317 ashish 125
}