Subversion Repositories SmartDukaan

Rev

Rev 650 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 650 Rev 681
Line 36... Line 36...
36
import in.shop2020.model.v1.user.RatingType;
36
import in.shop2020.model.v1.user.RatingType;
37
import in.shop2020.model.v1.user.RatingsWidget;
37
import in.shop2020.model.v1.user.RatingsWidget;
38
import in.shop2020.model.v1.user.Widget;
38
import in.shop2020.model.v1.user.Widget;
39
import in.shop2020.model.v1.user.WidgetItem;
39
import in.shop2020.model.v1.user.WidgetItem;
40
import in.shop2020.model.v1.user.WidgetType;
40
import in.shop2020.model.v1.user.WidgetType;
41
import in.shop2020.serving.page.CategoryPage;
-
 
42
import in.shop2020.serving.utils.*;
41
import in.shop2020.serving.utils.*;
43
import in.shop2020.thrift.clients.CatalogServiceClient;
42
import in.shop2020.thrift.clients.CatalogServiceClient;
44
import in.shop2020.thrift.clients.TransactionServiceClient;
43
import in.shop2020.thrift.clients.TransactionServiceClient;
45
import in.shop2020.thrift.clients.UserContextServiceClient;
44
import in.shop2020.thrift.clients.UserContextServiceClient;
46
 
45
 
47
 
46
 
48
public class PageLoaderHandler {
47
public class PageLoaderHandler {
49
 
48
 
50
	public Map<String,String> getProductPage(long productId, Map<String, String> params) throws TException {
-
 
51
 
-
 
52
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
53
 
-
 
54
		boolean isLoggedIn = Boolean.parseBoolean(params.get("IS_LOGGED_IN"));
-
 
55
		long userId = Long.parseLong(params.get("USER_ID"));
-
 
56
		String userName = params.get("USER_NAME");
-
 
57
		
-
 
58
		long categoryId = 100000;
-
 
59
		long itemCount = Long.parseLong(params.get("ITEM_COUNT"));
-
 
60
		//product.setCategoryId(categoryId);
-
 
61
		
-
 
62
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
63
		System.out.println("HEADER Snippet generated");
-
 
64
		
-
 
65
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
66
		System.out.println("MAIN_MENU Snippet generated");
-
 
67
		
-
 
68
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, categoryId));
-
 
69
		System.out.println("SEARCH_BAR Snippet generated");
-
 
70
		
-
 
71
		htmlSnippet.put("PRODUCT_SUMMARY", getProductSummaryHtml(productId));
-
 
72
		System.out.println("PRODUCT_SUMMARY Snippet generated");
-
 
73
		
-
 
74
		htmlSnippet.put("SOCIAL_UTILS", getSocialUtilsHtml(productId));
-
 
75
		System.out.println("SOCIAL_UTILS Snippet generated");
-
 
76
		
-
 
77
		htmlSnippet.put("SLIDE_GUIDE", getSlideGuideHtml(productId));
-
 
78
		System.out.println("SLIDE GUIDE Snippet generated");
-
 
79
		
-
 
80
		htmlSnippet.put("LOCATOR", getLocatorHtml());
-
 
81
		System.out.println("LOCATOR Snippet generated");
-
 
82
 
-
 
83
		htmlSnippet.put("REVIEWS", getReviewsHtml(productId));
-
 
84
		System.out.println("REVIEWS Snippet generated");
-
 
85
 
-
 
86
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
87
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
88
		
-
 
89
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
-
 
90
		System.out.println("MY_RESEARCH Snippet generated");
-
 
91
 
-
 
92
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
-
 
93
		System.out.println("BROWSE_HISTORY Snippet generated");
-
 
94
		
-
 
95
		htmlSnippet.put("RECOMMENDATIONS", getRecommendationsHtml());
-
 
96
		System.out.println("RECOMMENDATIONS Snippet generated");
-
 
97
 
-
 
98
		htmlSnippet.put("SIMILAR_PRODUCTS", getSimilarProductsHtml(productId));
-
 
99
		System.out.println("RECOMMENDATIONS Snippet generated");
-
 
100
		
-
 
101
		htmlSnippet.put("ACCESSORIES", getAccessoriesHtml(productId));
-
 
102
		System.out.println("ACCESSORIES Snippet generated");
-
 
103
 
-
 
104
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
105
		System.out.println("Footer Snippet generated");
-
 
106
 
-
 
107
//		htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
108
//		System.out.println("ACCESSORIES Snippet generated")
-
 
109
		
-
 
110
		htmlSnippet.put("JS_FILES", "");
-
 
111
		htmlSnippet.put("CSS_FILES", "");
-
 
112
		
-
 
113
		System.out.println("Returning Generated Responce");
-
 
114
		
-
 
115
		return htmlSnippet;
-
 
116
	}
-
 
117
 
-
 
118
 
-
 
119
	public Map<String, String> getRegisterPage(Map<String, String> parameters) {
-
 
120
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
121
		boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
-
 
122
		long userId = Long.parseLong(parameters.get("USER_ID"));
-
 
123
		String userName = parameters.get("USER_NAME");
-
 
124
		long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
-
 
125
		
-
 
126
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
127
		System.out.println("HEADER Snippet generated");
-
 
128
		
-
 
129
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
130
		System.out.println("MAIN_MENU Snippet generated");
-
 
131
		
-
 
132
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
133
		System.out.println("SEARCH_BAR Snippet generated");
-
 
134
		
-
 
135
		htmlSnippet.put("REGISTRATION_HEADER", getRegistrationHeaderHtml());
-
 
136
		System.out.println("REGISTRATION_HEADER Snippet generated");
-
 
137
		
-
 
138
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
139
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
140
		
-
 
141
		htmlSnippet.put("REGISTRATION_FORM", getRegistrationFormHtml());
-
 
142
		System.out.println("REGISTRATION_FORM Snippet generated");
-
 
143
		
-
 
144
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
145
		System.out.println("Footer Snippet generated");
-
 
146
		
-
 
147
		htmlSnippet.put("JS_FILES", "");
-
 
148
		htmlSnippet.put("CSS_FILES", "");
-
 
149
 
-
 
150
		
-
 
151
		return htmlSnippet;
-
 
152
	}
-
 
153
	
-
 
154
	public String getRegistrationFormHtml() {
49
	public String getRegistrationFormHtml() {
155
		String htmlString = "";
50
		String htmlString = "";
156
		VelocityContext context = new VelocityContext();
51
		VelocityContext context = new VelocityContext();
157
		String templateFile = "templates/registrationform.vm";
52
		String templateFile = "templates/registrationform.vm";
158
		htmlString = getHtmlFromVelocity(templateFile, context);
53
		htmlString = getHtmlFromVelocity(templateFile, context);
Line 181... Line 76...
181
		String templateFile = "templates/loginheader.vm";
76
		String templateFile = "templates/loginheader.vm";
182
		htmlString = getHtmlFromVelocity(templateFile, context);
77
		htmlString = getHtmlFromVelocity(templateFile, context);
183
		return htmlString;
78
		return htmlString;
184
	}
79
	}
185
	
80
	
186
	public Map<String,String> getHomePage(Map<String, String> parameters) throws TException {
-
 
187
 
-
 
188
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
189
		boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
-
 
190
		long userId = Long.parseLong(parameters.get("USER_ID"));
-
 
191
		String userName = parameters.get("USER_NAME");
-
 
192
		long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
-
 
193
		
-
 
194
		long categoryId = 100000;
-
 
195
		//product.setCategoryId(categoryId);
-
 
196
		
-
 
197
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
198
		System.out.println("HEADER Snippet generated");
-
 
199
		
-
 
200
		
-
 
201
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
202
		System.out.println("MAIN_MENU Snippet generated");
-
 
203
		
-
 
204
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, categoryId));
-
 
205
		System.out.println("SEARCH_BAR Snippet generated");
-
 
206
		
-
 
207
		htmlSnippet.put("MAIN_BANNER", getMainBannerHtml());
-
 
208
		System.out.println("LOCATOR Snippet generated");
-
 
209
 
-
 
210
		htmlSnippet.put("BEST_DEALS", getBestDealsHtml());
-
 
211
		System.out.println("BEST_DEALS Snippet generated");
-
 
212
		
-
 
213
		htmlSnippet.put("LATEST_ARRIVALS", getLatestArrivalsHtml());
-
 
214
		System.out.println("LATEST_ARRIVALS Snippet generated");
-
 
215
		
-
 
216
		htmlSnippet.put("BEST_SELLERS", getBestSellersHtml());
-
 
217
		System.out.println("BEST_SELLERS Snippet generated");
-
 
218
		
-
 
219
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
220
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
221
		
-
 
222
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
-
 
223
		System.out.println("MY_RESEARCH Snippet generated");
-
 
224
 
81
 
225
		htmlSnippet.put("RECOMMENDATIONS", getRecommendationsHtml());
-
 
226
		System.out.println("RECOMMENDATIONS Snippet generated");
-
 
227
 
-
 
228
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
-
 
229
		System.out.println("RECOMMENDATIONS Snippet generated");
-
 
230
 
-
 
231
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
232
		System.out.println("Footer Snippet generated");
-
 
233
 
-
 
234
//		htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
235
//		System.out.println("ACCESSORIES Snippet generated")
-
 
236
		
-
 
237
		htmlSnippet.put("JS_FILES", "");
-
 
238
		htmlSnippet.put("CSS_FILES", "");
-
 
239
		
-
 
240
		System.out.println("Returning Generated Responce");
-
 
241
		
-
 
242
		return htmlSnippet;
-
 
243
	}
-
 
244
 
-
 
245
	
-
 
246
	public String getMainBannerHtml() {
82
	public String getMainBannerHtml() {
247
		String htmlString = "";
83
		String htmlString = "";
248
		VelocityContext context = new VelocityContext();
84
		VelocityContext context = new VelocityContext();
249
		String templateFile = "templates/mainbanner.vm";
85
		String templateFile = "templates/mainbanner.vm";
250
		htmlString = getHtmlFromVelocity(templateFile, context);
86
		htmlString = getHtmlFromVelocity(templateFile, context);
Line 410... Line 246...
410
		htmlString = getHtmlFromVelocity(templateFile, context);
246
		htmlString = getHtmlFromVelocity(templateFile, context);
411
		return htmlString;
247
		return htmlString;
412
	}
248
	}
413
 
249
 
414
 
250
 
415
 
-
 
416
//	public String getSlideGuideHtml(long productId) {
-
 
417
//		String htmlString = "";
-
 
418
//		try {
-
 
419
//			VelocityContext context = new VelocityContext();
-
 
420
//			String templateFile = "velocity/slideguide.vm";
-
 
421
//			// For an entity
-
 
422
//			EntityContainer entContainer = 	Catalog.getInstance().getEntityContainer();
-
 
423
//			ExpandedEntity expEntity = entContainer.getExpandedEntity(productId);
-
 
424
//			
-
 
425
//			context.put("expentity", expEntity);
-
 
426
//			htmlString = getHtmlFromVelocity(templateFile, context);
-
 
427
//			} catch (Exception e) {
-
 
428
//				e.printStackTrace();
-
 
429
//			}
-
 
430
//		return htmlString;
-
 
431
//	}
-
 
432
 
-
 
433
	public String getSlideGuideHtml(long productId) {
251
	public String getSlideGuideHtml(long productId) {
434
		StringBuilder htmlString = new StringBuilder();
252
		StringBuilder htmlString = new StringBuilder();
435
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "SlideGuide.html";
253
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "SlideGuide.html";
436
		File f = new File(filename);
254
		File f = new File(filename);
437
		
255
		
Line 592... Line 410...
592
		context.put("userId", userId);
410
		context.put("userId", userId);
593
		context.put("itemDetails", itemDetails);
411
		context.put("itemDetails", itemDetails);
594
		
412
		
595
		return getHtmlFromVelocity("templates/"+templateFile, context);
413
		return getHtmlFromVelocity("templates/"+templateFile, context);
596
	}
414
	}
597
 
-
 
598
	/*
-
 
599
	public	String getWidgetDiv(long productId, String userId, WidgetType widgetType, String templateFile){
-
 
600
		long userID;
-
 
601
		if(userId.compareTo("") == 0){
-
 
602
			userID = 0;
-
 
603
		}else{
-
 
604
			userID = Long.parseLong(userId);
-
 
605
		}
-
 
606
 
-
 
607
		WidgetServiceClient widgetServiceClient = null;
-
 
608
		in.shop2020.model.v1.widgets.WidgetService.Client client = null;
-
 
609
		Widget widget = null;
-
 
610
		try {
-
 
611
			widgetServiceClient = new WidgetServiceClient();
-
 
612
			client = widgetServiceClient.getClient();
-
 
613
			widget = client.getWidget(widgetType, userID, true);
-
 
614
		} catch (Exception e) {
-
 
615
			e.printStackTrace();
-
 
616
		}
-
 
617
 
-
 
618
 
-
 
619
		List<Map<String, String>> itemDetails = null;
-
 
620
		
-
 
621
		if(widget != null){
-
 
622
			List<WidgetItem> items = widget.getItems();
-
 
623
			itemDetails = new ArrayList<Map<String, String>>();
-
 
624
			
-
 
625
			for(WidgetItem item: items){
-
 
626
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
627
				
-
 
628
				itemDetail.put("ITEM_ID", item.getItem_id()+"");
-
 
629
				itemDetail.put("ITEM_NAME", "ID"+item.getItem_id());
-
 
630
				itemDetail.put("ITEM_SNIPPET", item.getSnippet());
-
 
631
				itemDetail.put("ITEM_PRICE", getItemPriceByCatalogId(item.getItem_id())+"");
-
 
632
				itemDetails.add(itemDetail);
-
 
633
			}
-
 
634
		}else{
-
 
635
			System.out.println("widget not found");
-
 
636
		}
-
 
637
		
-
 
638
		VelocityContext context = new VelocityContext();
-
 
639
		context.put("itemDetails", itemDetails);
-
 
640
		
-
 
641
		return getHtmlFromVelocity("velocity/"+templateFile, context);
-
 
642
	}
-
 
643
*/
-
 
644
 
-
 
645
 
-
 
646
	public Map<String, String> getCompletedOrdersPage(long userId, long itemCount,
-
 
647
			Map<String, String> params) {
-
 
648
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
649
		
-
 
650
		htmlSnippet.put("HEADER", getHeaderHtml(false, ""));
-
 
651
		System.out.println("HEADER Snippet generated");
-
 
652
		
-
 
653
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
654
		System.out.println("MAIN_MENU Snippet generated");
-
 
655
		
-
 
656
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
657
		System.out.println("SEARCH_BAR Snippet generated");
-
 
658
		
-
 
659
		htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
-
 
660
		System.out.println("MYACCOUNT_HEADER Snippet generated");
-
 
661
		
-
 
662
		htmlSnippet.put("MYACCOUNT_DETAILS", getCompletedOrdersHtml(userId));
-
 
663
		System.out.println("MYACCOUNT_DETAILS Snippet generated");
-
 
664
		
-
 
665
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
666
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
667
 
-
 
668
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
-
 
669
		System.out.println("MY_RESEARCH Snippet generated");
-
 
670
 
-
 
671
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
-
 
672
		System.out.println("BROWSE_HISTORY Snippet generated");
-
 
673
 
-
 
674
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
675
		System.out.println("Footer Snippet generated");
-
 
676
	
-
 
677
		htmlSnippet.put("JS_FILES", "");
-
 
678
		htmlSnippet.put("CSS_FILES", "");
-
 
679
		
-
 
680
		System.out.println("Returning Generated Responce");
-
 
681
		
-
 
682
		
-
 
683
		return htmlSnippet;
-
 
684
	
415
	
685
	}
-
 
686
 
-
 
687
	
-
 
688
	public Map<String, String> getMyAccountPage(long userId, long itemCount, String userName, boolean isLoggedIn)
-
 
689
	{
-
 
690
		
-
 
691
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
692
		
-
 
693
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
694
		System.out.println("HEADER Snippet generated");
-
 
695
		
-
 
696
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
697
		System.out.println("MAIN_MENU Snippet generated");
-
 
698
		
-
 
699
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
700
		System.out.println("SEARCH_BAR Snippet generated");
-
 
701
		
-
 
702
		htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
-
 
703
		System.out.println("MYACCOUNT_HEADER Snippet generated");
-
 
704
		
-
 
705
		htmlSnippet.put("MYACCOUNT_DETAILS", getMyaccountDetailsHtml(userId));
-
 
706
		System.out.println("MYACCOUNT_DETAILS Snippet generated");
-
 
707
		
-
 
708
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
709
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
710
 
-
 
711
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
-
 
712
		System.out.println("MY_RESEARCH Snippet generated");
-
 
713
 
-
 
714
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
-
 
715
		System.out.println("BROWSE_HISTORY Snippet generated");
-
 
716
		
-
 
717
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
718
		System.out.println("Footer Snippet generated");
-
 
719
	
-
 
720
	//	htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
721
	//	System.out.println("ACCESSORIES Snippet generated")
-
 
722
		
-
 
723
		htmlSnippet.put("JS_FILES", "");
-
 
724
		htmlSnippet.put("CSS_FILES", "");
-
 
725
		
-
 
726
		System.out.println("Returning Generated Responce");
-
 
727
 
-
 
728
		return htmlSnippet;
-
 
729
	}
-
 
730
 
-
 
731
 
-
 
732
	public Map<String, String> getPersonalDetailsPage(long userId, long itemCount, String userName, boolean isLoggedIn)
-
 
733
	{
-
 
734
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
735
		
-
 
736
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
737
		System.out.println("HEADER Snippet generated");
-
 
738
		
-
 
739
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
740
		System.out.println("MAIN_MENU Snippet generated");
-
 
741
		
-
 
742
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
743
		System.out.println("SEARCH_BAR Snippet generated");
-
 
744
		
-
 
745
		htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
-
 
746
		System.out.println("MYACCOUNT_HEADER Snippet generated");
-
 
747
		
-
 
748
		htmlSnippet.put("PERSONAL_DETAILS", getPersonalDetailsHtml(userId));
-
 
749
		System.out.println("PERSONAL_DETAILS Snippet generated");
-
 
750
		
-
 
751
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
752
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
753
 
-
 
754
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
-
 
755
		System.out.println("MY_RESEARCH Snippet generated");
-
 
756
		
-
 
757
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
-
 
758
		System.out.println("BROWSE_HISTORY Snippet generated");
-
 
759
		
-
 
760
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
761
		System.out.println("Footer Snippet generated");
-
 
762
	
-
 
763
	//	htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
764
	//	System.out.println("ACCESSORIES Snippet generated")
-
 
765
		
-
 
766
		htmlSnippet.put("JS_FILES", "");
-
 
767
		htmlSnippet.put("CSS_FILES", "");
-
 
768
		
-
 
769
		System.out.println("Returning Generated Responce");
-
 
770
		
-
 
771
		
-
 
772
		return htmlSnippet;
-
 
773
	}
-
 
774
	
-
 
775
	public Map<String, String> getLoginDetailsPage(long userId, long itemCount, String userName, boolean isLoggedIn)
-
 
776
	{
-
 
777
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
778
		
-
 
779
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
780
		System.out.println("HEADER Snippet generated");
-
 
781
		
-
 
782
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
783
		System.out.println("MAIN_MENU Snippet generated");
-
 
784
		
-
 
785
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
786
		System.out.println("SEARCH_BAR Snippet generated");
-
 
787
		
-
 
788
		htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
-
 
789
		System.out.println("MYACCOUNT_HEADER Snippet generated");
-
 
790
		
-
 
791
		htmlSnippet.put("LOGIN_DETAILS", getLoginDetailsHtml(userId));
-
 
792
		System.out.println("LOGIN_DETAILS Snippet generated");
-
 
793
		
-
 
794
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
795
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
796
 
-
 
797
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
-
 
798
		System.out.println("MY_RESEARCH Snippet generated");
-
 
799
		
-
 
800
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
-
 
801
		System.out.println("BROWSE_HISTORY Snippet generated");
-
 
802
		
-
 
803
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
804
		System.out.println("Footer Snippet generated");
-
 
805
	
-
 
806
	//	htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
807
	//	System.out.println("ACCESSORIES Snippet generated")
-
 
808
		
-
 
809
		htmlSnippet.put("JS_FILES", "");
-
 
810
		htmlSnippet.put("CSS_FILES", "");
-
 
811
		
-
 
812
		System.out.println("Returning Generated Responce");
-
 
813
		
-
 
814
		
-
 
815
		return htmlSnippet;
-
 
816
	}
-
 
817
 
-
 
818
 
-
 
819
	
-
 
820
	public Map<String, String> getOrderDetailsPage(long userId, long itemCount, long orderId,
-
 
821
			Map<String, String> parameters) {
-
 
822
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
823
		boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
-
 
824
		String userName = parameters.get("USER_NAME");
-
 
825
		
-
 
826
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
827
		System.out.println("HEADER Snippet generated");
-
 
828
		
-
 
829
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
830
		System.out.println("MAIN_MENU Snippet generated");
-
 
831
		
-
 
832
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
833
		System.out.println("SEARCH_BAR Snippet generated");
-
 
834
		
-
 
835
		htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
-
 
836
		System.out.println("MYACCOUNT_HEADER Snippet generated");
-
 
837
		
-
 
838
		htmlSnippet.put("ORDER_DETAILS", getOrderDetailsHtml(orderId));
-
 
839
		System.out.println("MYACCOUNT_DETAILS Snippet generated");
-
 
840
		
-
 
841
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
842
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
843
 
-
 
844
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
-
 
845
		System.out.println("MY_RESEARCH Snippet generated");
-
 
846
		
-
 
847
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
-
 
848
		System.out.println("BROWSE_HISTORY Snippet generated");
-
 
849
		
-
 
850
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
851
		System.out.println("Footer Snippet generated");
-
 
852
	
-
 
853
	//	htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
854
	//	System.out.println("ACCESSORIES Snippet generated")
-
 
855
		
-
 
856
		htmlSnippet.put("JS_FILES", "");
-
 
857
		htmlSnippet.put("CSS_FILES", "");
-
 
858
		
-
 
859
		System.out.println("Returning Generated Responce");
-
 
860
		
-
 
861
		
-
 
862
		return htmlSnippet;
-
 
863
	}
-
 
864
 
416
 
865
	
417
	
866
	
418
	
867
	public String getOrderDetailsHtml(long orderId) {
419
	public String getOrderDetailsHtml(long orderId) {
868
		String htmlString = "";
420
		String htmlString = "";
Line 987... Line 539...
987
		String templateFile = "templates/myaccountheader.vm";
539
		String templateFile = "templates/myaccountheader.vm";
988
		htmlString = getHtmlFromVelocity(templateFile, context);
540
		htmlString = getHtmlFromVelocity(templateFile, context);
989
		return htmlString;
541
		return htmlString;
990
	}
542
	}
991
 
543
 
992
	//ShippingPage
-
 
993
	public Map<String, String> getShippingPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName, String errorMsg){
-
 
994
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
995
		
-
 
996
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
997
		System.out.println("HEADER Snippet generated");
-
 
998
		
-
 
999
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
1000
		System.out.println("MAIN_MENU Snippet generated");
-
 
1001
		
-
 
1002
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
1003
		System.out.println("SEARCH_BAR Snippet generated");
-
 
1004
		
-
 
1005
		htmlSnippet.put("SHIPPING_HEADER", getShippingHeaderHtml());
-
 
1006
		System.out.println("SHIPPING_HEADER Snippet generated");
-
 
1007
		
-
 
1008
		htmlSnippet.put("SHIPPING_DETAILS", getShippingDetailsHtml(cartId, errorMsg));
-
 
1009
		System.out.println("SHIPPING_BAR Snippet generated");
-
 
1010
		
-
 
1011
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
1012
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
1013
		
-
 
1014
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
1015
		System.out.println("Footer Snippet generated");
-
 
1016
	
-
 
1017
	//	htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
1018
	//	System.out.println("ACCESSORIES Snippet generated")
-
 
1019
		
-
 
1020
		htmlSnippet.put("JS_FILES", "");
-
 
1021
		htmlSnippet.put("CSS_FILES", "");
-
 
1022
		
-
 
1023
		System.out.println("Returning Generated Responce");
-
 
1024
		
-
 
1025
		return htmlSnippet;
-
 
1026
	
-
 
1027
	}
-
 
1028
 
-
 
1029
	//ShippingPage
-
 
1030
	public Map<String, String> getShippingAddressPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName){
-
 
1031
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
1032
		
-
 
1033
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
1034
		System.out.println("HEADER Snippet generated");
-
 
1035
		
-
 
1036
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
1037
		System.out.println("MAIN_MENU Snippet generated");
-
 
1038
		
-
 
1039
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
1040
		System.out.println("SEARCH_BAR Snippet generated");
-
 
1041
		
-
 
1042
		htmlSnippet.put("SHIPPING_ADDRESS_HEADER", getMyaccountHeaderHtml());
-
 
1043
		System.out.println("SHIPPING_ADDRESS_HEADER Snippet generated");
-
 
1044
		
-
 
1045
		htmlSnippet.put("SHIPPING_ADDRESS_DETAILS", getShippingAddressDetailsHtml(userId));
-
 
1046
		System.out.println("SHIPPING_ADDRESS_BAR Snippet generated");
-
 
1047
		
-
 
1048
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
1049
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
1050
		
-
 
1051
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
-
 
1052
		System.out.println("MY_RESEARCH Snippet generated");
-
 
1053
 
-
 
1054
		htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
-
 
1055
		System.out.println("BROWSE_HISTORY Snippet generated");
-
 
1056
 
-
 
1057
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
1058
		System.out.println("Footer Snippet generated");
-
 
1059
	
-
 
1060
	//	htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
1061
	//	System.out.println("ACCESSORIES Snippet generated")
-
 
1062
		
-
 
1063
		htmlSnippet.put("JS_FILES", "");
-
 
1064
		htmlSnippet.put("CSS_FILES", "");
-
 
1065
		
-
 
1066
		System.out.println("Returning Generated Responce");
-
 
1067
		
-
 
1068
		return htmlSnippet;
-
 
1069
	
-
 
1070
	}
-
 
1071
 
-
 
1072
	public String getShippingHeaderHtml() {
544
	public String getShippingHeaderHtml() {
1073
		String htmlString = "";
545
		String htmlString = "";
1074
		VelocityContext context = new VelocityContext();
546
		VelocityContext context = new VelocityContext();
1075
		String templateFile = "templates/shippingheader.vm";
547
		String templateFile = "templates/shippingheader.vm";
1076
		htmlString = getHtmlFromVelocity(templateFile, context);
548
		htmlString = getHtmlFromVelocity(templateFile, context);
Line 1169... Line 641...
1169
		htmlString = getHtmlFromVelocity(templateFile, context);
641
		htmlString = getHtmlFromVelocity(templateFile, context);
1170
		return htmlString;
642
		return htmlString;
1171
	}
643
	}
1172
 
644
 
1173
	
645
	
1174
	//ShoppingCartPage
-
 
1175
	public Map<String, String> getShoppingCartPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName, String errorMsg){
-
 
1176
		Map<String,String> htmlSnippet = new HashMap<String, String>();
-
 
1177
		
-
 
1178
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
-
 
1179
		System.out.println("HEADER Snippet generated");
-
 
1180
		
-
 
1181
		htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
-
 
1182
		System.out.println("MAIN_MENU Snippet generated");
-
 
1183
		
-
 
1184
		htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
-
 
1185
		System.out.println("SEARCH_BAR Snippet generated");
-
 
1186
		
-
 
1187
		htmlSnippet.put("CART_HEADER", getCartHeaderHtml());
-
 
1188
		System.out.println("CART_HEADER Snippet generated");
-
 
1189
		
-
 
1190
		htmlSnippet.put("CART_DETAILS", getCartDetailsHtml(cartId, errorMsg));
-
 
1191
		System.out.println("SEARCH_BAR Snippet generated");
-
 
1192
		
-
 
1193
		htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
-
 
1194
		System.out.println("CUSTOMER_SERVICE Snippet generated");
-
 
1195
		
-
 
1196
		htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
-
 
1197
		System.out.println("MY_RESEARCH Snippet generated");
-
 
1198
	
-
 
1199
		htmlSnippet.put("FOOTER", getFooterHtml());
-
 
1200
		System.out.println("Footer Snippet generated");
-
 
1201
	
-
 
1202
	//	htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
-
 
1203
	//	System.out.println("ACCESSORIES Snippet generated")
-
 
1204
		
-
 
1205
		htmlSnippet.put("JS_FILES", "");
-
 
1206
		htmlSnippet.put("CSS_FILES", "");
-
 
1207
		
-
 
1208
		System.out.println("Returning Generated Responce");
-
 
1209
		
-
 
1210
		return htmlSnippet;
-
 
1211
	
-
 
1212
	}
-
 
1213
 
-
 
1214
	public String getCartHeaderHtml() {
646
	public String getCartHeaderHtml() {
1215
		String htmlString = "";
647
		String htmlString = "";
1216
		VelocityContext context = new VelocityContext();
648
		VelocityContext context = new VelocityContext();
1217
		String templateFile = "templates/cartheader.vm";
649
		String templateFile = "templates/cartheader.vm";
1218
		htmlString = getHtmlFromVelocity(templateFile, context);
650
		htmlString = getHtmlFromVelocity(templateFile, context);
Line 1274... Line 706...
1274
		context.put("errorMsg", errorMsg);
706
		context.put("errorMsg", errorMsg);
1275
		htmlString = getHtmlFromVelocity(templateFile, context);
707
		htmlString = getHtmlFromVelocity(templateFile, context);
1276
		return htmlString;
708
		return htmlString;
1277
	}
709
	}
1278
 
710
 
1279
 
-
 
1280
	public long getCatalogIdByItemId(long itemId){
-
 
1281
		CatalogServiceClient catalogServiceClient = null;
-
 
1282
		Client client = null;
-
 
1283
		
-
 
1284
		try {
-
 
1285
			catalogServiceClient = new CatalogServiceClient();
-
 
1286
			client = catalogServiceClient.getClient();
-
 
1287
			
-
 
1288
			return client.getItem(itemId).getCatalogItemId();
-
 
1289
		} catch (InventoryServiceException e) {
-
 
1290
			// TODO Auto-generated catch block
-
 
1291
			e.printStackTrace();
-
 
1292
		} catch (TException e) {
-
 
1293
			// TODO Auto-generated catch block
-
 
1294
			e.printStackTrace();
-
 
1295
		} catch (Exception e) {
-
 
1296
			// TODO Auto-generated catch block
-
 
1297
			e.printStackTrace();
-
 
1298
		}
-
 
1299
		return -1;
-
 
1300
	}
-
 
1301
		
-
 
1302
	public String getHtmlFromVelocity(String templateFile, VelocityContext context){
711
	public String getHtmlFromVelocity(String templateFile, VelocityContext context){
1303
		Properties p = new Properties();
712
		Properties p = new Properties();
1304
		p.setProperty("resource.loader", "class");
713
		p.setProperty("resource.loader", "class");
1305
		p.setProperty("class.resource.loader.class",
714
		p.setProperty("class.resource.loader.class",
1306
		"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
715
		"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
1307
 
-
 
1308
		
716
		
1309
		try {
717
		try {
1310
			Velocity.init(p);
718
			Velocity.init(p);
1311
			Template template = Velocity.getTemplate(templateFile);
719
			Template template = Velocity.getTemplate(templateFile);
1312
			if(template != null) {
720
			if(template != null) {