Subversion Repositories SmartDukaan

Rev

Rev 1981 | Rev 2146 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1981 Rev 2015
Line 45... Line 45...
45
import in.shop2020.thrift.clients.UserContextServiceClient;
45
import in.shop2020.thrift.clients.UserContextServiceClient;
46
 
46
 
47
 
47
 
48
public class PageLoaderHandler {
48
public class PageLoaderHandler {
49
 
49
 
50
	public String getRegistrationFormHtml() {
-
 
51
		String htmlString = "";
-
 
52
		VelocityContext context = new VelocityContext();
-
 
53
		String templateFile = "templates/registrationform.vm";
-
 
54
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
55
		return htmlString;
-
 
56
	}
-
 
57
 
-
 
58
	public String getLoginFormHtml() {
-
 
59
		String htmlString = "";
-
 
60
		VelocityContext context = new VelocityContext();
-
 
61
		String templateFile = "templates/loginform.vm";
-
 
62
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
63
		return htmlString;
-
 
64
	}
-
 
65
 
-
 
66
	public String getRegistrationHeaderHtml() {
-
 
67
		String htmlString = "";
-
 
68
		VelocityContext context = new VelocityContext();
-
 
69
		String templateFile = "templates/registrationheader.vm";
-
 
70
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
71
		return htmlString;
-
 
72
	}
-
 
73
	
-
 
74
 
-
 
75
	public String getLoginHeaderHtml() {
-
 
76
		String htmlString = "";
-
 
77
		VelocityContext context = new VelocityContext();
-
 
78
		String templateFile = "templates/loginheader.vm";
-
 
79
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
80
		return htmlString;
-
 
81
	}
-
 
82
	
-
 
83
 
50
 
84
	public String getMainBannerHtml() {
51
	public String getMainBannerHtml() {
85
		String htmlString = "";
52
		String htmlString = "";
86
		VelocityContext context = new VelocityContext();
53
		VelocityContext context = new VelocityContext();
87
		String templateFile = "templates/mainbanner.vm";
54
		String templateFile = "templates/mainbanner.vm";
Line 189... Line 156...
189
		htmlString = getHtmlFromVelocity(templateFile, context);
156
		htmlString = getHtmlFromVelocity(templateFile, context);
190
		return htmlString;
157
		return htmlString;
191
	}
158
	}
192
 
159
 
193
 
160
 
194
 
-
 
195
	public String getAccessoriesHtml(long productId) {
-
 
196
		return "";
-
 
197
		//return getWidgetDiv(0, WidgetType.ACCESSORIES, "accessories.vm");
-
 
198
	}
-
 
199
 
-
 
200
 
-
 
201
 
-
 
202
	public String getSimilarProductsHtml(long productId) {
-
 
203
		return "";
-
 
204
		//return getWidgetDiv(0, WidgetType.SIMILAR_ITEMS, "similaritems.vm");
-
 
205
	}
-
 
206
 
-
 
207
 
-
 
208
 
-
 
209
	public String getRecommendationsHtml() {
-
 
210
		return "";
-
 
211
		//return getWidgetDiv( 0, WidgetType.RECOMMENDED_ITEMS, "recommendations.vm");
-
 
212
	}
-
 
213
 
-
 
214
 
-
 
215
 
-
 
216
	public String getMyResearchHtml() {
161
	public String getMyResearchHtml() {
217
	    String htmlString = "";
162
	    String htmlString = "";
218
        VelocityContext context = new VelocityContext();
163
        VelocityContext context = new VelocityContext();
219
        String templateFile = "templates/myresearch.vm";
164
        String templateFile = "templates/myresearch.vm";
220
        htmlString = getHtmlFromVelocity(templateFile, context);
165
        htmlString = getHtmlFromVelocity(templateFile, context);
Line 236... Line 181...
236
		htmlString = getHtmlFromVelocity(templateFile, context);
181
		htmlString = getHtmlFromVelocity(templateFile, context);
237
		return htmlString;
182
		return htmlString;
238
	}
183
	}
239
 
184
 
240
 
185
 
241
 
-
 
242
	public String getReviewsHtml(long productId) {
-
 
243
		String htmlString = "";
-
 
244
		VelocityContext context = new VelocityContext();
-
 
245
		Map<String, String> params = new HashMap<String, String>();
-
 
246
		params.put("PRODUCT_ID", productId+"");
-
 
247
		context.put("params", params);
-
 
248
		String templateFile = "templates/reviews.vm";
-
 
249
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
250
		return htmlString;
-
 
251
	}
-
 
252
 
-
 
253
 
-
 
254
 
-
 
255
	public String getLocatorHtml() {
-
 
256
		String htmlString = "";
-
 
257
		VelocityContext context = new VelocityContext();
-
 
258
		String templateFile = "templates/locator.vm";
-
 
259
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
260
		return htmlString;
-
 
261
	}
-
 
262
 
-
 
263
 
-
 
264
	public String getSlideGuideHtml(long productId) {
186
	public String getSlideGuideHtml(long productId) {
265
		StringBuilder htmlString = new StringBuilder();
187
		StringBuilder htmlString = new StringBuilder();
266
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "SlideGuide.html";
188
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "SlideGuide.html";
267
		File f = new File(filename);
189
		File f = new File(filename);
268
		
190
		
Line 472... Line 394...
472
		String templateFile = "templates/header.vm";
394
		String templateFile = "templates/header.vm";
473
		
395
		
474
		return getHtmlFromVelocity(templateFile, context);
396
		return getHtmlFromVelocity(templateFile, context);
475
	}
397
	}
476
 
398
 
477
 
-
 
478
	
-
 
479
	public	String getWidgetDiv(long userId, WidgetType widgetType, String templateFile){
-
 
480
 
-
 
481
		UserContextServiceClient userServiceClient = null;
-
 
482
		in.shop2020.model.v1.user.UserContextService.Client client = null;
-
 
483
		Widget widget = null;
-
 
484
		try {
-
 
485
			userServiceClient = new UserContextServiceClient();
-
 
486
			client = userServiceClient.getClient();
-
 
487
			if(widgetType == WidgetType.MY_RESEARCH && userId != -1){
-
 
488
				widget = client.getMyResearch(userId);
-
 
489
			}
-
 
490
			if(widgetType == WidgetType.BROWSE_HISTORY){
-
 
491
				widget = client.getBrowseHistory(userId);
-
 
492
			}
-
 
493
			
-
 
494
		} catch (Exception e) {
-
 
495
			e.printStackTrace();
-
 
496
		}
-
 
497
 
-
 
498
 
-
 
499
		List<Map<String, String>> itemDetails = null;
-
 
500
		
-
 
501
		if(widget != null){
-
 
502
			List<WidgetItem> items = widget.getItems();
-
 
503
			itemDetails = new ArrayList<Map<String, String>>();
-
 
504
			
-
 
505
			for(WidgetItem item: items){
-
 
506
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
507
				String itemSnippet;
-
 
508
				
-
 
509
					try {
-
 
510
						itemSnippet = FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item.getItem_id() + File.separator + "WidgetSnippet.html");
-
 
511
					} catch (IOException e) {
-
 
512
						e.printStackTrace();
-
 
513
						continue;
-
 
514
					}
-
 
515
					
-
 
516
				itemDetail.put("ITEM_ID", item.getItem_id()+"");
-
 
517
				itemDetail.put("ITEM_SNIPPET", itemSnippet);
-
 
518
				itemDetails.add(itemDetail);
-
 
519
			}
-
 
520
		}else{
-
 
521
			System.out.println("widget not found");
-
 
522
		}
-
 
523
		
-
 
524
		VelocityContext context = new VelocityContext();
-
 
525
		context.put("userId", userId);
-
 
526
		context.put("itemDetails", itemDetails);
-
 
527
		
-
 
528
		return getHtmlFromVelocity("templates/"+templateFile, context);
-
 
529
	}
-
 
530
 
-
 
531
	
399
	
532
	public String getOrderDetailsHtml(long orderId, long userId) {
400
	public String getOrderDetailsHtml(long orderId, long userId) {
533
		String htmlString = "";
401
		String htmlString = "";
534
		VelocityContext context = new VelocityContext();
402
		VelocityContext context = new VelocityContext();
535
		String templateFile = "templates/orderdetails.vm";
403
		String templateFile = "templates/orderdetails.vm";