Subversion Repositories SmartDukaan

Rev

Rev 1034 | Rev 1197 | Go to most recent revision | Details | Compare with Previous | 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
 
832 rajveer 14
import org.apache.log4j.Logger;
507 rajveer 15
import org.apache.struts2.convention.annotation.Action;
16
import org.apache.struts2.convention.annotation.Actions;
974 vikas 17
import org.apache.struts2.convention.annotation.Result;
317 ashish 18
 
19
/**
20
 * 
650 rajveer 21
 * @author rajveer
317 ashish 22
 *
23
 */
650 rajveer 24
 
974 vikas 25
@Result(name = "show", location = "entity-show.vm")
650 rajveer 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
 
974 vikas 42
	// GET /*/1000001
507 rajveer 43
	@Actions({
974 vikas 44
		@Action("/mobile-phones"),
1005 vikas 45
		@Action("/mobile-accessories"),
46
		@Action("/entity")
507 rajveer 47
	})
650 rajveer 48
    public String show() throws SecurityException, IOException {
317 ashish 49
    	log.info("id=" + id);
637 rajveer 50
 
650 rajveer 51
    	htmlSnippets.put("PRODUCT_SUMMARY", pageLoader.getProductSummaryHtml(productId));
620 rajveer 52
		htmlSnippets.put("SOCIAL_UTILS", pageLoader.getSocialUtilsHtml(productId));
53
		htmlSnippets.put("SLIDE_GUIDE", pageLoader.getSlideGuideHtml(productId));
974 vikas 54
		htmlSnippets.put("PAGE_TITLE", pageLoader.getPageTitleHtml(productId));
55
		htmlSnippets.put("PAGE_METADESC", pageLoader.getPageMetaDescriptionHtml(productId));
56
		htmlSnippets.put("PAGE_METAKEYWORDS", pageLoader.getPageMetaKeywordsHtml(productId));
620 rajveer 57
 
650 rajveer 58
		try {
555 chandransh 59
			UserContextServiceClient userServiceClient = new UserContextServiceClient();
60
			Client client = userServiceClient.getClient();
773 rajveer 61
			long itemId = Long.parseLong(id);
62
			long userId = userinfo.getUserId();
63
			client.updateBrowseHistory(userId, itemId);
650 rajveer 64
 
449 rajveer 65
		} catch (Exception e) {
66
			// TODO Auto-generated catch block
67
			e.printStackTrace();
68
		}
69
 
650 rajveer 70
    	return "show";
317 ashish 71
    }
72
 
73
    /**
74
     * 
75
     * @param id
76
     */
77
    public void setId(String id) {
507 rajveer 78
    	StringTokenizer tokenizer = new StringTokenizer(id,"-");
79
    	while(tokenizer.hasMoreTokens()){
80
    		this.id = tokenizer.nextToken();
81
    	}
974 vikas 82
    	this.productId = Long.parseLong(this.id);
317 ashish 83
    }
84
 
387 rajveer 85
	public Map<String,String> getHtmlSnippets(){
388 rajveer 86
		System.out.println(" getHtmlSnippets  is called");
387 rajveer 87
		return htmlSnippets;
375 ashish 88
	}
388 rajveer 89
 
449 rajveer 90
	public String getSlideGuideSnippet(){
388 rajveer 91
		return htmlSnippets.get("SLIDE_GUIDE");
92
	}
93
 
449 rajveer 94
	public String getProductSummarySnippet(){
95
		return htmlSnippets.get("PRODUCT_SUMMARY");
96
	}
97
 
974 vikas 98
	public String getPageTitleSnippet(){
99
		return htmlSnippets.get("PAGE_TITLE");
100
	}
101
 
102
	public String getPageMetaDescSnippet(){
103
		return htmlSnippets.get("PAGE_METADESC");
104
	}
105
 
106
	public String getPageMetaKeywordsSnippet(){
107
		return htmlSnippets.get("PAGE_METAKEYWORDS");
108
	}
109
 
449 rajveer 110
	public String getSocialUtilsSnippet(){
111
		return htmlSnippets.get("SOCIAL_UTILS"); 
112
	}
113
 
114
	public String getLocatorSnippet(){
115
		return htmlSnippets.get("LOCATOR");
116
	}
117
 
118
	public String getRecommendationsSnippet(){
119
		return htmlSnippets.get("RECOMMENDATIONS");
120
	}
650 rajveer 121
 
449 rajveer 122
	public String getSimilarProductsSnippet(){
123
		return htmlSnippets.get("SIMILAR_PRODUCTS");
124
	}
650 rajveer 125
 
449 rajveer 126
	public String getAccessoriesSnippet(){
127
		return htmlSnippets.get("ACCESSORIES");
128
	}
129
 
650 rajveer 130
	public String getReviewsSnippet(){
131
		return htmlSnippets.get("REVIEWS");
449 rajveer 132
	}
133
 
317 ashish 134
}