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;
507 rajveer 16
import org.apache.struts2.convention.annotation.Action;
17
import org.apache.struts2.convention.annotation.Actions;
317 ashish 18
 
19
/**
20
 * 
650 rajveer 21
 * @author rajveer
317 ashish 22
 *
23
 */
650 rajveer 24
 
25
public class EntityController extends BaseController {
26
 
27
	private static final long serialVersionUID = 1L;
28
 
317 ashish 29
	private static Log log = LogFactory.getLog(EntityController.class);
30
 
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));
55
		htmlSnippets.put("RECOMMENDATIONS", pageLoader.getRecommendationsHtml());
56
		htmlSnippets.put("SIMILAR_PRODUCTS", pageLoader.getSimilarProductsHtml(productId));
57
		htmlSnippets.put("ACCESSORIES", pageLoader.getAccessoriesHtml(productId));
650 rajveer 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();
449 rajveer 64
			long item_id = Long.parseLong(id);
65
			boolean isSessionId = userinfo.isSessionId();
590 chandransh 66
			long user_id = userinfo.getUserId();
449 rajveer 67
			client.updateBrowseHistory(user_id, item_id, isSessionId);
650 rajveer 68
 
449 rajveer 69
		} catch (Exception e) {
70
			// TODO Auto-generated catch block
71
			e.printStackTrace();
72
		}
73
 
650 rajveer 74
    	return "show";
317 ashish 75
    }
76
 
77
    /**
78
     * 
79
     * @param id
80
     */
81
    public void setId(String id) {
507 rajveer 82
    	StringTokenizer tokenizer = new StringTokenizer(id,"-");
83
    	while(tokenizer.hasMoreTokens()){
84
    		this.id = tokenizer.nextToken();
85
    	}
620 rajveer 86
    	this.productId = Long.parseLong(id);
317 ashish 87
    }
88
 
387 rajveer 89
	public Map<String,String> getHtmlSnippets(){
388 rajveer 90
		System.out.println(" getHtmlSnippets  is called");
387 rajveer 91
		return htmlSnippets;
375 ashish 92
	}
388 rajveer 93
 
449 rajveer 94
	public String getSlideGuideSnippet(){
388 rajveer 95
		return htmlSnippets.get("SLIDE_GUIDE");
96
	}
97
 
449 rajveer 98
	public String getProductSummarySnippet(){
99
		return htmlSnippets.get("PRODUCT_SUMMARY");
100
	}
101
 
102
	public String getSocialUtilsSnippet(){
103
		return htmlSnippets.get("SOCIAL_UTILS"); 
104
	}
105
 
106
	public String getLocatorSnippet(){
107
		return htmlSnippets.get("LOCATOR");
108
	}
109
 
110
	public String getRecommendationsSnippet(){
111
		return htmlSnippets.get("RECOMMENDATIONS");
112
	}
650 rajveer 113
 
449 rajveer 114
	public String getSimilarProductsSnippet(){
115
		return htmlSnippets.get("SIMILAR_PRODUCTS");
116
	}
650 rajveer 117
 
449 rajveer 118
	public String getAccessoriesSnippet(){
119
		return htmlSnippets.get("ACCESSORIES");
120
	}
121
 
650 rajveer 122
	public String getReviewsSnippet(){
123
		return htmlSnippets.get("REVIEWS");
449 rajveer 124
	}
125
 
317 ashish 126
}