| 507 |
rajveer |
1 |
package in.shop2020.serving.services;
|
|
|
2 |
|
|
|
3 |
import java.io.BufferedReader;
|
|
|
4 |
import java.io.File;
|
|
|
5 |
import java.io.FileInputStream;
|
|
|
6 |
import java.io.FileNotFoundException;
|
|
|
7 |
import java.io.IOException;
|
|
|
8 |
import java.io.InputStreamReader;
|
|
|
9 |
import java.io.StringWriter;
|
| 517 |
rajveer |
10 |
import java.text.SimpleDateFormat;
|
| 507 |
rajveer |
11 |
import java.util.ArrayList;
|
|
|
12 |
import java.util.Date;
|
|
|
13 |
import java.util.HashMap;
|
|
|
14 |
import java.util.List;
|
|
|
15 |
import java.util.Map;
|
|
|
16 |
import java.util.Properties;
|
|
|
17 |
|
|
|
18 |
import org.apache.thrift.TException;
|
|
|
19 |
import org.apache.velocity.Template;
|
|
|
20 |
import org.apache.velocity.VelocityContext;
|
|
|
21 |
import org.apache.velocity.app.Velocity;
|
|
|
22 |
import org.apache.velocity.exception.MethodInvocationException;
|
|
|
23 |
import org.apache.velocity.exception.ParseErrorException;
|
|
|
24 |
import org.apache.velocity.exception.ResourceNotFoundException;
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
|
|
28 |
import in.shop2020.model.v1.catalog.Item;
|
|
|
29 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
|
|
30 |
import in.shop2020.model.v1.order.Order;
|
|
|
31 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 555 |
chandransh |
32 |
import in.shop2020.model.v1.user.Cart;
|
|
|
33 |
import in.shop2020.model.v1.user.Line;
|
| 507 |
rajveer |
34 |
import in.shop2020.model.v1.user.Address;
|
| 555 |
chandransh |
35 |
import in.shop2020.model.v1.user.User;
|
|
|
36 |
import in.shop2020.model.v1.user.RatingType;
|
|
|
37 |
import in.shop2020.model.v1.user.RatingsWidget;
|
|
|
38 |
import in.shop2020.model.v1.user.Widget;
|
|
|
39 |
import in.shop2020.model.v1.user.WidgetItem;
|
|
|
40 |
import in.shop2020.model.v1.user.WidgetType;
|
| 507 |
rajveer |
41 |
import in.shop2020.serving.page.CategoryPage;
|
|
|
42 |
import in.shop2020.serving.utils.*;
|
|
|
43 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
|
|
44 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
|
|
45 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
public class PageLoaderHandler {
|
|
|
49 |
|
|
|
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 |
|
| 555 |
chandransh |
54 |
boolean isLoggedIn = Boolean.parseBoolean(params.get("IS_LOGGED_IN"));
|
| 507 |
rajveer |
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 |
|
| 555 |
chandransh |
62 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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 |
|
| 555 |
chandransh |
89 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
90 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
91 |
|
| 637 |
rajveer |
92 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
|
|
|
93 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
94 |
|
| 507 |
rajveer |
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>();
|
| 555 |
chandransh |
121 |
boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
|
| 507 |
rajveer |
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 |
|
| 555 |
chandransh |
126 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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 |
|
| 637 |
rajveer |
154 |
public String getRegistrationFormHtml() {
|
| 507 |
rajveer |
155 |
String htmlString = "";
|
|
|
156 |
VelocityContext context = new VelocityContext();
|
|
|
157 |
String templateFile = "templates/registrationform.vm";
|
|
|
158 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
159 |
return htmlString;
|
|
|
160 |
}
|
|
|
161 |
|
| 637 |
rajveer |
162 |
public String getLoginFormHtml() {
|
|
|
163 |
String htmlString = "";
|
|
|
164 |
VelocityContext context = new VelocityContext();
|
|
|
165 |
String templateFile = "templates/loginform.vm";
|
|
|
166 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
167 |
return htmlString;
|
|
|
168 |
}
|
| 507 |
rajveer |
169 |
|
| 637 |
rajveer |
170 |
public String getRegistrationHeaderHtml() {
|
| 507 |
rajveer |
171 |
String htmlString = "";
|
|
|
172 |
VelocityContext context = new VelocityContext();
|
|
|
173 |
String templateFile = "templates/registrationheader.vm";
|
|
|
174 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
175 |
return htmlString;
|
|
|
176 |
}
|
|
|
177 |
|
| 637 |
rajveer |
178 |
public String getLoginHeaderHtml() {
|
|
|
179 |
String htmlString = "";
|
|
|
180 |
VelocityContext context = new VelocityContext();
|
|
|
181 |
String templateFile = "templates/loginheader.vm";
|
|
|
182 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
183 |
return htmlString;
|
|
|
184 |
}
|
|
|
185 |
|
| 555 |
chandransh |
186 |
public Map<String,String> getHomePage(Map<String, String> parameters) throws TException {
|
| 507 |
rajveer |
187 |
|
|
|
188 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
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"));
|
| 507 |
rajveer |
193 |
|
|
|
194 |
long categoryId = 100000;
|
|
|
195 |
//product.setCategoryId(categoryId);
|
|
|
196 |
|
| 555 |
chandransh |
197 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
198 |
System.out.println("HEADER Snippet generated");
|
|
|
199 |
|
| 555 |
chandransh |
200 |
|
| 507 |
rajveer |
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 |
|
| 555 |
chandransh |
222 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
223 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
224 |
|
|
|
225 |
htmlSnippet.put("RECOMMENDATIONS", getRecommendationsHtml());
|
|
|
226 |
System.out.println("RECOMMENDATIONS Snippet generated");
|
|
|
227 |
|
| 555 |
chandransh |
228 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
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 |
|
| 650 |
rajveer |
246 |
public String getMainBannerHtml() {
|
| 507 |
rajveer |
247 |
String htmlString = "";
|
|
|
248 |
VelocityContext context = new VelocityContext();
|
|
|
249 |
String templateFile = "templates/mainbanner.vm";
|
|
|
250 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
251 |
return htmlString;
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
|
| 650 |
rajveer |
255 |
public String getBestSellersHtml() {
|
| 507 |
rajveer |
256 |
String htmlString = "";
|
|
|
257 |
VelocityContext context = new VelocityContext();
|
|
|
258 |
String templateFile = "templates/bestsellers.vm";
|
|
|
259 |
|
|
|
260 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
261 |
Client client = null;
|
|
|
262 |
|
|
|
263 |
try {
|
|
|
264 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
265 |
client = catalogServiceClient.getClient();
|
| 627 |
rajveer |
266 |
List<Long> items = client.getBestSellersCatalogIds(1, 4, -1);
|
| 507 |
rajveer |
267 |
List<String> itemList = new ArrayList<String>();
|
|
|
268 |
for(Long item: items){
|
| 517 |
rajveer |
269 |
itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
|
| 507 |
rajveer |
270 |
}
|
|
|
271 |
context.put("itemList", itemList);
|
|
|
272 |
|
|
|
273 |
} catch(Exception e){
|
|
|
274 |
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
| 517 |
rajveer |
279 |
return htmlString;
|
|
|
280 |
}
|
| 507 |
rajveer |
281 |
|
|
|
282 |
|
| 650 |
rajveer |
283 |
public String getLatestArrivalsHtml() {
|
| 507 |
rajveer |
284 |
String htmlString = "";
|
|
|
285 |
VelocityContext context = new VelocityContext();
|
|
|
286 |
String templateFile = "templates/latestarrivals.vm";
|
|
|
287 |
|
|
|
288 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
289 |
Client client = null;
|
|
|
290 |
|
|
|
291 |
try {
|
|
|
292 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
293 |
client = catalogServiceClient.getClient();
|
| 627 |
rajveer |
294 |
List<Long> items = client.getLatestArrivalsCatalogIds(1,4,-1);
|
| 507 |
rajveer |
295 |
List<String> itemList = new ArrayList<String>();
|
|
|
296 |
for(Long item: items){
|
| 517 |
rajveer |
297 |
itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
|
| 507 |
rajveer |
298 |
}
|
|
|
299 |
context.put("itemList", itemList);
|
|
|
300 |
|
|
|
301 |
} catch(Exception e){
|
|
|
302 |
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
307 |
return htmlString;
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
|
| 650 |
rajveer |
311 |
public String getBestDealsHtml() {
|
| 507 |
rajveer |
312 |
String htmlString = "";
|
|
|
313 |
VelocityContext context = new VelocityContext();
|
|
|
314 |
String templateFile = "templates/bestdeals.vm";
|
|
|
315 |
|
|
|
316 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
317 |
Client client = null;
|
|
|
318 |
|
|
|
319 |
try {
|
|
|
320 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
321 |
client = catalogServiceClient.getClient();
|
| 627 |
rajveer |
322 |
List<Long> items = client.getBestDealsCatalogIds(1,4,-1);
|
| 507 |
rajveer |
323 |
List<String> itemList = new ArrayList<String>();
|
|
|
324 |
for(Long item: items){
|
| 517 |
rajveer |
325 |
itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
|
| 507 |
rajveer |
326 |
}
|
|
|
327 |
context.put("itemList", itemList);
|
|
|
328 |
|
|
|
329 |
} catch(Exception e){
|
|
|
330 |
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
334 |
return htmlString;
|
|
|
335 |
}
|
|
|
336 |
|
|
|
337 |
|
| 517 |
rajveer |
338 |
public String getFooterHtml() {
|
| 507 |
rajveer |
339 |
String htmlString = "";
|
|
|
340 |
VelocityContext context = new VelocityContext();
|
|
|
341 |
String templateFile = "templates/footer.vm";
|
|
|
342 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
343 |
return htmlString;
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
|
|
|
347 |
|
| 620 |
rajveer |
348 |
public String getAccessoriesHtml(long productId) {
|
| 637 |
rajveer |
349 |
return "";
|
|
|
350 |
//return getWidgetDiv(0, WidgetType.ACCESSORIES, "accessories.vm");
|
| 507 |
rajveer |
351 |
}
|
|
|
352 |
|
|
|
353 |
|
|
|
354 |
|
| 620 |
rajveer |
355 |
public String getSimilarProductsHtml(long productId) {
|
| 637 |
rajveer |
356 |
return "";
|
|
|
357 |
//return getWidgetDiv(0, WidgetType.SIMILAR_ITEMS, "similaritems.vm");
|
| 507 |
rajveer |
358 |
}
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
|
| 620 |
rajveer |
362 |
public String getRecommendationsHtml() {
|
| 637 |
rajveer |
363 |
return "";
|
|
|
364 |
//return getWidgetDiv( 0, WidgetType.RECOMMENDED_ITEMS, "recommendations.vm");
|
| 507 |
rajveer |
365 |
}
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
|
| 555 |
chandransh |
369 |
public String getMyResearchHtml(long userId, boolean isLoggedIn) {
|
|
|
370 |
if(isLoggedIn)
|
|
|
371 |
return getWidgetDiv(userId, WidgetType.MY_RESEARCH, "myresearch.vm");
|
|
|
372 |
else
|
|
|
373 |
return getWidgetDiv(0, WidgetType.MY_RESEARCH, "myresearch.vm");
|
| 507 |
rajveer |
374 |
}
|
|
|
375 |
|
| 569 |
rajveer |
376 |
public String getBrowseHistoryHtml(long userId, boolean isLoggedIn) {
|
| 555 |
chandransh |
377 |
if(isLoggedIn)
|
|
|
378 |
return getWidgetDiv(userId, WidgetType.BROWSE_HISTORY, "browsehistory.vm");
|
|
|
379 |
else
|
|
|
380 |
return getWidgetDiv(0, WidgetType.BROWSE_HISTORY, "browsehistory.vm");
|
| 507 |
rajveer |
381 |
}
|
|
|
382 |
|
| 517 |
rajveer |
383 |
public String getCustomerServiceHtml() {
|
| 507 |
rajveer |
384 |
String htmlString = "";
|
|
|
385 |
VelocityContext context = new VelocityContext();
|
|
|
386 |
String templateFile = "templates/customerservice.vm";
|
|
|
387 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
388 |
return htmlString;
|
|
|
389 |
}
|
|
|
390 |
|
|
|
391 |
|
|
|
392 |
|
| 620 |
rajveer |
393 |
public String getReviewsHtml(long productId) {
|
| 507 |
rajveer |
394 |
String htmlString = "";
|
|
|
395 |
VelocityContext context = new VelocityContext();
|
|
|
396 |
Map<String, String> params = new HashMap<String, String>();
|
|
|
397 |
params.put("PRODUCT_ID", productId+"");
|
|
|
398 |
context.put("params", params);
|
|
|
399 |
String templateFile = "templates/reviews.vm";
|
|
|
400 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
401 |
return htmlString;
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
|
|
|
405 |
|
| 620 |
rajveer |
406 |
public String getLocatorHtml() {
|
| 507 |
rajveer |
407 |
String htmlString = "";
|
|
|
408 |
VelocityContext context = new VelocityContext();
|
|
|
409 |
String templateFile = "templates/locator.vm";
|
|
|
410 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
411 |
return htmlString;
|
|
|
412 |
}
|
|
|
413 |
|
|
|
414 |
|
|
|
415 |
|
| 650 |
rajveer |
416 |
// public String getSlideGuideHtml(long productId) {
|
| 507 |
rajveer |
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 |
|
| 620 |
rajveer |
433 |
public String getSlideGuideHtml(long productId) {
|
| 507 |
rajveer |
434 |
StringBuilder htmlString = new StringBuilder();
|
| 517 |
rajveer |
435 |
String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "SlideGuide.html";
|
| 507 |
rajveer |
436 |
File f = new File(filename);
|
|
|
437 |
|
|
|
438 |
|
|
|
439 |
FileInputStream fis = null;
|
|
|
440 |
try {
|
|
|
441 |
fis = new FileInputStream(f);
|
|
|
442 |
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
|
|
|
443 |
String line;
|
|
|
444 |
while((line = br.readLine()) != null){
|
|
|
445 |
htmlString.append(line+"\n");
|
|
|
446 |
}
|
|
|
447 |
} catch (FileNotFoundException e) {
|
|
|
448 |
// TODO Auto-generated catch block
|
|
|
449 |
e.printStackTrace();
|
|
|
450 |
} catch (IOException e) {
|
|
|
451 |
// TODO Auto-generated catch block
|
|
|
452 |
e.printStackTrace();
|
|
|
453 |
}
|
|
|
454 |
finally {
|
|
|
455 |
if(fis != null) {
|
|
|
456 |
try {
|
|
|
457 |
fis.close();
|
|
|
458 |
} catch (IOException e) {
|
|
|
459 |
// TODO Auto-generated catch block
|
|
|
460 |
e.printStackTrace();
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
}
|
|
|
464 |
|
|
|
465 |
return htmlString.toString();
|
|
|
466 |
}
|
|
|
467 |
|
| 517 |
rajveer |
468 |
public String getProductSummaryHtml(long productId) {
|
| 507 |
rajveer |
469 |
StringBuilder htmlString = new StringBuilder();
|
| 517 |
rajveer |
470 |
String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "ProductDetail.html";
|
| 507 |
rajveer |
471 |
File f = new File(filename);
|
|
|
472 |
|
|
|
473 |
|
|
|
474 |
FileInputStream fis = null;
|
|
|
475 |
try {
|
|
|
476 |
fis = new FileInputStream(f);
|
|
|
477 |
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
|
|
|
478 |
String line;
|
|
|
479 |
while((line = br.readLine()) != null){
|
|
|
480 |
htmlString.append(line+"\n");
|
|
|
481 |
}
|
|
|
482 |
} catch (FileNotFoundException e) {
|
|
|
483 |
// TODO Auto-generated catch block
|
|
|
484 |
e.printStackTrace();
|
|
|
485 |
} catch (IOException e) {
|
|
|
486 |
// TODO Auto-generated catch block
|
|
|
487 |
e.printStackTrace();
|
|
|
488 |
}
|
|
|
489 |
finally {
|
|
|
490 |
if(fis != null) {
|
|
|
491 |
try {
|
|
|
492 |
fis.close();
|
|
|
493 |
} catch (IOException e) {
|
|
|
494 |
// TODO Auto-generated catch block
|
|
|
495 |
e.printStackTrace();
|
|
|
496 |
}
|
|
|
497 |
}
|
|
|
498 |
}
|
|
|
499 |
|
|
|
500 |
return htmlString.toString();
|
|
|
501 |
}
|
|
|
502 |
|
|
|
503 |
|
| 620 |
rajveer |
504 |
public String getSocialUtilsHtml(long productId) {
|
| 507 |
rajveer |
505 |
String htmlString = "";
|
|
|
506 |
VelocityContext context = new VelocityContext();
|
|
|
507 |
Map<String, String> params = new HashMap<String, String>();
|
|
|
508 |
params.put("PRODUCT_ID", productId+"");
|
|
|
509 |
String templateFile = "templates/socialutils.vm";
|
|
|
510 |
context.put("params", params);
|
|
|
511 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
512 |
return htmlString;
|
|
|
513 |
}
|
|
|
514 |
|
|
|
515 |
|
| 517 |
rajveer |
516 |
public String getMainMenuHtml() {
|
| 507 |
rajveer |
517 |
String htmlString = "";
|
|
|
518 |
VelocityContext context = new VelocityContext();
|
|
|
519 |
String templateFile = "templates/mainmenu.vm";
|
|
|
520 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
521 |
return htmlString;
|
|
|
522 |
}
|
|
|
523 |
|
|
|
524 |
|
| 517 |
rajveer |
525 |
public String getSearchBarHtml(long itemCounts, long categoryId) {
|
| 507 |
rajveer |
526 |
String htmlString = "";
|
|
|
527 |
VelocityContext context = new VelocityContext();
|
|
|
528 |
String templateFile = "templates/searchbar.vm";
|
| 550 |
rajveer |
529 |
|
|
|
530 |
context.put("itemCount", itemCounts+"");
|
|
|
531 |
context.put("categoryId", categoryId+"");
|
|
|
532 |
|
| 507 |
rajveer |
533 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
534 |
return htmlString;
|
|
|
535 |
}
|
|
|
536 |
|
|
|
537 |
|
|
|
538 |
|
| 555 |
chandransh |
539 |
public String getHeaderHtml(boolean isLoggedIn, String userName) {
|
| 550 |
rajveer |
540 |
VelocityContext context = new VelocityContext();
|
| 555 |
chandransh |
541 |
if (isLoggedIn) {
|
|
|
542 |
context.put("LOGGED_IN", "TRUE");
|
|
|
543 |
context.put("WELCOME_MESSAGE", "Hi, " + userName);
|
|
|
544 |
} else {
|
| 550 |
rajveer |
545 |
context.put("WELCOME_MESSAGE", "Hi, Welcome to Shop2020");
|
| 555 |
chandransh |
546 |
}
|
| 507 |
rajveer |
547 |
|
|
|
548 |
String templateFile = "templates/header.vm";
|
| 550 |
rajveer |
549 |
|
| 590 |
chandransh |
550 |
return getHtmlFromVelocity(templateFile, context);
|
| 507 |
rajveer |
551 |
}
|
|
|
552 |
|
|
|
553 |
|
|
|
554 |
|
| 650 |
rajveer |
555 |
public String getWidgetDiv(long userId, WidgetType widgetType, String templateFile){
|
| 507 |
rajveer |
556 |
|
| 555 |
chandransh |
557 |
UserContextServiceClient userServiceClient = null;
|
|
|
558 |
in.shop2020.model.v1.user.UserContextService.Client client = null;
|
| 507 |
rajveer |
559 |
Widget widget = null;
|
|
|
560 |
try {
|
| 555 |
chandransh |
561 |
userServiceClient = new UserContextServiceClient();
|
|
|
562 |
client = userServiceClient.getClient();
|
|
|
563 |
widget = client.getWidget(widgetType, userId, true);
|
| 507 |
rajveer |
564 |
} catch (Exception e) {
|
|
|
565 |
e.printStackTrace();
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
|
|
|
569 |
List<Map<String, String>> itemDetails = null;
|
|
|
570 |
|
|
|
571 |
if(widget != null){
|
|
|
572 |
List<WidgetItem> items = widget.getItems();
|
|
|
573 |
itemDetails = new ArrayList<Map<String, String>>();
|
|
|
574 |
|
|
|
575 |
for(WidgetItem item: items){
|
|
|
576 |
Map<String, String> itemDetail = new HashMap<String, String>();
|
|
|
577 |
|
|
|
578 |
itemDetail.put("ITEM_ID", item.getItem_id()+"");
|
|
|
579 |
try {
|
| 517 |
rajveer |
580 |
itemDetail.put("ITEM_SNIPPET", FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item.getItem_id() + File.separator + "WidgetSnippet.html"));
|
| 507 |
rajveer |
581 |
} catch (Exception e) {
|
|
|
582 |
// TODO Auto-generated catch block
|
|
|
583 |
e.printStackTrace();
|
|
|
584 |
}
|
|
|
585 |
itemDetails.add(itemDetail);
|
|
|
586 |
}
|
|
|
587 |
}else{
|
|
|
588 |
System.out.println("widget not found");
|
|
|
589 |
}
|
|
|
590 |
|
|
|
591 |
VelocityContext context = new VelocityContext();
|
| 620 |
rajveer |
592 |
context.put("userId", userId);
|
| 507 |
rajveer |
593 |
context.put("itemDetails", itemDetails);
|
|
|
594 |
|
|
|
595 |
return getHtmlFromVelocity("templates/"+templateFile, context);
|
|
|
596 |
}
|
|
|
597 |
|
|
|
598 |
/*
|
| 650 |
rajveer |
599 |
public String getWidgetDiv(long productId, String userId, WidgetType widgetType, String templateFile){
|
| 507 |
rajveer |
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>();
|
| 555 |
chandransh |
649 |
|
|
|
650 |
htmlSnippet.put("HEADER", getHeaderHtml(false, ""));
|
| 507 |
rajveer |
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");
|
| 620 |
rajveer |
670 |
|
|
|
671 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
672 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
673 |
|
| 507 |
rajveer |
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 |
|
|
|
685 |
}
|
|
|
686 |
|
|
|
687 |
|
| 555 |
chandransh |
688 |
public Map<String, String> getMyAccountPage(long userId, long itemCount, String userName, boolean isLoggedIn)
|
|
|
689 |
{
|
|
|
690 |
|
| 507 |
rajveer |
691 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
692 |
|
|
|
693 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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");
|
| 620 |
rajveer |
713 |
|
|
|
714 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
715 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
| 507 |
rajveer |
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");
|
| 555 |
chandransh |
727 |
|
| 507 |
rajveer |
728 |
return htmlSnippet;
|
|
|
729 |
}
|
|
|
730 |
|
|
|
731 |
|
| 555 |
chandransh |
732 |
public Map<String, String> getPersonalDetailsPage(long userId, long itemCount, String userName, boolean isLoggedIn)
|
|
|
733 |
{
|
| 507 |
rajveer |
734 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
735 |
|
|
|
736 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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 |
|
| 620 |
rajveer |
757 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
758 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
759 |
|
| 507 |
rajveer |
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 |
|
| 555 |
chandransh |
775 |
public Map<String, String> getLoginDetailsPage(long userId, long itemCount, String userName, boolean isLoggedIn)
|
|
|
776 |
{
|
| 507 |
rajveer |
777 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
778 |
|
|
|
779 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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 |
|
| 620 |
rajveer |
800 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
801 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
802 |
|
| 507 |
rajveer |
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,
|
| 555 |
chandransh |
821 |
Map<String, String> parameters) {
|
| 507 |
rajveer |
822 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
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));
|
| 507 |
rajveer |
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 |
|
| 620 |
rajveer |
847 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
848 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
849 |
|
| 507 |
rajveer |
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 |
|
|
|
865 |
|
|
|
866 |
|
| 650 |
rajveer |
867 |
public String getOrderDetailsHtml(long orderId) {
|
| 507 |
rajveer |
868 |
String htmlString = "";
|
|
|
869 |
VelocityContext context = new VelocityContext();
|
|
|
870 |
String templateFile = "templates/orderdetails.vm";
|
|
|
871 |
TransactionServiceClient transactionServiceClient = null;
|
|
|
872 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
|
|
|
873 |
Order order = null;
|
| 517 |
rajveer |
874 |
Date orderedOn = null, deliveryEstimate = null;
|
| 507 |
rajveer |
875 |
try{
|
|
|
876 |
transactionServiceClient = new TransactionServiceClient();
|
|
|
877 |
orderClient = transactionServiceClient.getClient();
|
|
|
878 |
order = orderClient.getOrder(orderId);
|
| 517 |
rajveer |
879 |
orderedOn = new Date(order.getCreated_timestamp());
|
|
|
880 |
deliveryEstimate = new Date(order.getExpected_delivery_time());
|
| 507 |
rajveer |
881 |
}catch (Exception e){
|
|
|
882 |
|
|
|
883 |
}
|
| 517 |
rajveer |
884 |
|
|
|
885 |
SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
|
| 583 |
rajveer |
886 |
SimpleDateFormat dateformat1 = new SimpleDateFormat("dd/MM/yyyy");
|
| 507 |
rajveer |
887 |
context.put("order", order);
|
| 517 |
rajveer |
888 |
context.put("orderedOn", dateformat.format(orderedOn));
|
| 583 |
rajveer |
889 |
context.put("deliveryEstimate", dateformat1.format(deliveryEstimate));
|
| 517 |
rajveer |
890 |
|
|
|
891 |
|
| 507 |
rajveer |
892 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
893 |
return htmlString;
|
|
|
894 |
}
|
|
|
895 |
|
| 650 |
rajveer |
896 |
public String getMyaccountDetailsHtml(long userId) {
|
| 507 |
rajveer |
897 |
String htmlString = "";
|
|
|
898 |
VelocityContext context = new VelocityContext();
|
|
|
899 |
String templateFile = "templates/myaccount.vm";
|
|
|
900 |
TransactionServiceClient transactionServiceClient = null;
|
|
|
901 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
|
|
|
902 |
List<Order> orders = null;
|
|
|
903 |
try{
|
|
|
904 |
transactionServiceClient = new TransactionServiceClient();
|
|
|
905 |
orderClient = transactionServiceClient.getClient();
|
|
|
906 |
orders = orderClient.getOrdersForCustomer(userId, 0, (new Date()).getTime(), null);
|
|
|
907 |
|
|
|
908 |
}catch (Exception e){
|
|
|
909 |
|
|
|
910 |
}
|
|
|
911 |
context.put("orders", orders);
|
|
|
912 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
913 |
return htmlString;
|
|
|
914 |
}
|
|
|
915 |
|
|
|
916 |
|
| 650 |
rajveer |
917 |
public String getLoginDetailsHtml(long userId) {
|
| 507 |
rajveer |
918 |
String htmlString = "";
|
|
|
919 |
VelocityContext context = new VelocityContext();
|
|
|
920 |
String templateFile = "templates/logindetails.vm";
|
|
|
921 |
String email = "";
|
|
|
922 |
try{
|
| 555 |
chandransh |
923 |
email = in.shop2020.serving.utils.Utils.getEmailId(userId);
|
| 507 |
rajveer |
924 |
}catch (Exception e){
|
|
|
925 |
|
|
|
926 |
}
|
|
|
927 |
context.put("email", email);
|
|
|
928 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
929 |
return htmlString;
|
|
|
930 |
}
|
|
|
931 |
|
| 595 |
rajveer |
932 |
public String getPersonalDetailsHtml(long userId) {
|
| 507 |
rajveer |
933 |
String htmlString = "";
|
|
|
934 |
VelocityContext context = new VelocityContext();
|
|
|
935 |
String templateFile = "templates/personaldetails.vm";
|
|
|
936 |
String email = "";
|
| 517 |
rajveer |
937 |
String name = "";
|
| 569 |
rajveer |
938 |
String dateOfBirth = "";
|
| 517 |
rajveer |
939 |
String sex = "";
|
|
|
940 |
String subscribe = "false";
|
| 507 |
rajveer |
941 |
UserContextServiceClient userContextServiceClient = null;
|
|
|
942 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
|
|
943 |
try{
|
| 555 |
chandransh |
944 |
User user = null;
|
| 507 |
rajveer |
945 |
userContextServiceClient = new UserContextServiceClient();
|
|
|
946 |
userClient = userContextServiceClient.getClient();
|
| 555 |
chandransh |
947 |
user = userClient.getUserById(userId);
|
| 507 |
rajveer |
948 |
|
| 555 |
chandransh |
949 |
email = user.getCommunicationEmail();
|
|
|
950 |
name = user.getName();
|
| 517 |
rajveer |
951 |
|
| 569 |
rajveer |
952 |
dateOfBirth = user.getDateOfBirth();
|
| 507 |
rajveer |
953 |
}catch (Exception e){
|
| 555 |
chandransh |
954 |
e.printStackTrace();
|
| 507 |
rajveer |
955 |
}
|
| 517 |
rajveer |
956 |
context.put("name", name);
|
|
|
957 |
context.put("email", email);
|
| 569 |
rajveer |
958 |
context.put("dateOfBirth", dateOfBirth+"");
|
| 517 |
rajveer |
959 |
context.put("subscribe", subscribe);
|
|
|
960 |
context.put("sex", sex);
|
| 507 |
rajveer |
961 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
962 |
return htmlString;
|
|
|
963 |
}
|
|
|
964 |
|
| 620 |
rajveer |
965 |
public String getCompletedOrdersHtml(long userId) {
|
| 507 |
rajveer |
966 |
String htmlString = "";
|
|
|
967 |
VelocityContext context = new VelocityContext();
|
|
|
968 |
String templateFile = "templates/completedorders.vm";
|
|
|
969 |
TransactionServiceClient transactionServiceClient = null;
|
|
|
970 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
|
|
|
971 |
List<Order> orders = null;
|
|
|
972 |
try{
|
|
|
973 |
transactionServiceClient = new TransactionServiceClient();
|
|
|
974 |
orderClient = transactionServiceClient.getClient();
|
|
|
975 |
orders = orderClient.getOrdersForCustomer(userId, 0, (new Date()).getTime(), OrderStatus.DELIVERY_SUCCESS);
|
|
|
976 |
|
|
|
977 |
}catch (Exception e){
|
|
|
978 |
|
|
|
979 |
}
|
|
|
980 |
context.put("orders", orders);
|
|
|
981 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
982 |
return htmlString;
|
|
|
983 |
}
|
| 595 |
rajveer |
984 |
public String getMyaccountHeaderHtml() {
|
| 507 |
rajveer |
985 |
String htmlString = "";
|
|
|
986 |
VelocityContext context = new VelocityContext();
|
|
|
987 |
String templateFile = "templates/myaccountheader.vm";
|
|
|
988 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
989 |
return htmlString;
|
|
|
990 |
}
|
|
|
991 |
|
|
|
992 |
//ShippingPage
|
| 572 |
chandransh |
993 |
public Map<String, String> getShippingPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName, String errorMsg){
|
| 507 |
rajveer |
994 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
995 |
|
|
|
996 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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 |
|
| 572 |
chandransh |
1008 |
htmlSnippet.put("SHIPPING_DETAILS", getShippingDetailsHtml(cartId, errorMsg));
|
| 507 |
rajveer |
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
|
| 555 |
chandransh |
1030 |
public Map<String, String> getShippingAddressPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName){
|
| 507 |
rajveer |
1031 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
1032 |
|
|
|
1033 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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 |
|
| 650 |
rajveer |
1051 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
1052 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
1053 |
|
| 620 |
rajveer |
1054 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
|
|
|
1055 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
1056 |
|
| 507 |
rajveer |
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 |
|
| 650 |
rajveer |
1072 |
public String getShippingHeaderHtml() {
|
| 507 |
rajveer |
1073 |
String htmlString = "";
|
|
|
1074 |
VelocityContext context = new VelocityContext();
|
|
|
1075 |
String templateFile = "templates/shippingheader.vm";
|
|
|
1076 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1077 |
return htmlString;
|
|
|
1078 |
}
|
|
|
1079 |
|
| 650 |
rajveer |
1080 |
public String getShippingAddressDetailsHtml(long userId){
|
| 507 |
rajveer |
1081 |
String htmlString = "";
|
|
|
1082 |
VelocityContext context = new VelocityContext();
|
|
|
1083 |
String templateFile = "templates/shippingaddressdetails.vm";
|
|
|
1084 |
long defaultAddressId = 0;
|
| 517 |
rajveer |
1085 |
List<Address> addresses = null;
|
| 507 |
rajveer |
1086 |
|
|
|
1087 |
UserContextServiceClient userContextServiceClient = null;
|
|
|
1088 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
|
|
1089 |
try {
|
|
|
1090 |
userContextServiceClient = new UserContextServiceClient();
|
|
|
1091 |
userClient = userContextServiceClient.getClient();
|
| 620 |
rajveer |
1092 |
|
|
|
1093 |
addresses = userClient.getAllAddressesForUser(userId);
|
|
|
1094 |
defaultAddressId = userClient.getDefaultAddressId(userId);
|
| 507 |
rajveer |
1095 |
} catch (Exception e) {
|
|
|
1096 |
e.printStackTrace();
|
|
|
1097 |
}
|
| 517 |
rajveer |
1098 |
context.put("defaultAddressId", defaultAddressId+"");
|
| 507 |
rajveer |
1099 |
context.put("addresses", addresses);
|
|
|
1100 |
|
|
|
1101 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1102 |
return htmlString;
|
|
|
1103 |
}
|
|
|
1104 |
|
| 650 |
rajveer |
1105 |
public String getShippingDetailsHtml(long cartId, String errorMsg) {
|
| 507 |
rajveer |
1106 |
String htmlString = "";
|
|
|
1107 |
VelocityContext context = new VelocityContext();
|
|
|
1108 |
String templateFile = "templates/shippingdetails.vm";
|
| 517 |
rajveer |
1109 |
List<Map<String,String>> items = null;
|
| 507 |
rajveer |
1110 |
double totalamount= 0.0;
|
| 517 |
rajveer |
1111 |
List<Address> addresses = null;
|
|
|
1112 |
long defaultAddressId = 0;
|
| 555 |
chandransh |
1113 |
|
| 507 |
rajveer |
1114 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
1115 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
|
|
|
1116 |
UserContextServiceClient userContextServiceClient = null;
|
|
|
1117 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
|
|
1118 |
|
|
|
1119 |
try {
|
|
|
1120 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
1121 |
catalogClient = catalogServiceClient.getClient();
|
|
|
1122 |
userContextServiceClient = new UserContextServiceClient();
|
|
|
1123 |
userClient = userContextServiceClient.getClient();
|
|
|
1124 |
|
|
|
1125 |
|
| 555 |
chandransh |
1126 |
Cart cart = userClient.getCart(cartId);
|
| 507 |
rajveer |
1127 |
List<Line> lineItems = cart.getLines();
|
|
|
1128 |
|
| 517 |
rajveer |
1129 |
if( ! lineItems.isEmpty())
|
|
|
1130 |
{
|
|
|
1131 |
items = new ArrayList<Map<String,String>>();
|
| 507 |
rajveer |
1132 |
|
| 517 |
rajveer |
1133 |
for (Line line : lineItems) {
|
|
|
1134 |
Map<String, String> itemdetail = new HashMap<String, String>();
|
| 637 |
rajveer |
1135 |
Item item = catalogClient.getItem(line.getItemId());
|
| 517 |
rajveer |
1136 |
String itemName = ((item.getManufacturerName() != null) ? item.getManufacturerName() + " " : "")
|
|
|
1137 |
+ ((item.getModelName() != null) ? item.getModelName() + " " : "")
|
| 637 |
rajveer |
1138 |
+ (( item.getModelNumber() != null ) ? item.getModelNumber() + " " : "" )
|
|
|
1139 |
+ (( (item.getColor() != null && !item.getColor().trim().equals("NA"))) ? "("+item.getColor()+")" : "" );
|
| 517 |
rajveer |
1140 |
|
|
|
1141 |
itemdetail.put("ITEM_NAME", itemName);
|
|
|
1142 |
itemdetail.put("ITEM_ID", line.getItemId()+"");
|
|
|
1143 |
itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
|
|
|
1144 |
itemdetail.put("MRP", ((int)item.getMrp())+"");
|
| 536 |
rajveer |
1145 |
itemdetail.put("SELLING_PRICE", (int)item.getSellingPrice()+"");
|
|
|
1146 |
itemdetail.put("TOTAL_PRICE", (int)(item.getSellingPrice()*line.getQuantity())+"");
|
| 615 |
chandransh |
1147 |
itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
|
| 536 |
rajveer |
1148 |
totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
|
| 517 |
rajveer |
1149 |
items.add(itemdetail);
|
|
|
1150 |
}
|
| 507 |
rajveer |
1151 |
}
|
|
|
1152 |
|
| 637 |
rajveer |
1153 |
addresses = userClient.getAllAddressesForUser(cart.getUserId());
|
| 650 |
rajveer |
1154 |
if(cart.isSetAddressId()){
|
|
|
1155 |
defaultAddressId = cart.getAddressId();
|
|
|
1156 |
}else{
|
|
|
1157 |
defaultAddressId = userClient.getDefaultAddressId(cart.getUserId());
|
|
|
1158 |
}
|
| 507 |
rajveer |
1159 |
|
|
|
1160 |
}catch (Exception e){
|
|
|
1161 |
e.printStackTrace();
|
|
|
1162 |
}
|
|
|
1163 |
|
|
|
1164 |
context.put("items", items);
|
| 536 |
rajveer |
1165 |
context.put("totalamount", (int)totalamount+"");
|
| 507 |
rajveer |
1166 |
context.put("addresses", addresses);
|
| 517 |
rajveer |
1167 |
context.put("defaultAddressId", defaultAddressId+"");
|
| 572 |
chandransh |
1168 |
context.put("errorMsg", errorMsg);
|
| 507 |
rajveer |
1169 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1170 |
return htmlString;
|
|
|
1171 |
}
|
|
|
1172 |
|
|
|
1173 |
|
|
|
1174 |
//ShoppingCartPage
|
| 572 |
chandransh |
1175 |
public Map<String, String> getShoppingCartPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName, String errorMsg){
|
| 507 |
rajveer |
1176 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
1177 |
|
|
|
1178 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
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 |
|
| 572 |
chandransh |
1190 |
htmlSnippet.put("CART_DETAILS", getCartDetailsHtml(cartId, errorMsg));
|
| 507 |
rajveer |
1191 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
1192 |
|
|
|
1193 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
1194 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
1195 |
|
| 555 |
chandransh |
1196 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
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 |
|
| 650 |
rajveer |
1214 |
public String getCartHeaderHtml() {
|
| 507 |
rajveer |
1215 |
String htmlString = "";
|
|
|
1216 |
VelocityContext context = new VelocityContext();
|
|
|
1217 |
String templateFile = "templates/cartheader.vm";
|
|
|
1218 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1219 |
return htmlString;
|
|
|
1220 |
}
|
|
|
1221 |
|
|
|
1222 |
|
| 650 |
rajveer |
1223 |
public String getCartDetailsHtml(long cartId, String errorMsg) {
|
| 507 |
rajveer |
1224 |
String htmlString = "";
|
|
|
1225 |
VelocityContext context = new VelocityContext();
|
|
|
1226 |
String templateFile = "templates/cartdetails.vm";
|
| 517 |
rajveer |
1227 |
List<Map<String,String>> items = null;
|
| 507 |
rajveer |
1228 |
double totalamount= 0.0;
|
|
|
1229 |
|
| 555 |
chandransh |
1230 |
UserContextServiceClient userServiceClient = null;
|
|
|
1231 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
| 507 |
rajveer |
1232 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
1233 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
|
|
|
1234 |
|
|
|
1235 |
try {
|
|
|
1236 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
1237 |
catalogClient = catalogServiceClient.getClient();
|
| 555 |
chandransh |
1238 |
userServiceClient = new UserContextServiceClient();
|
|
|
1239 |
userClient = userServiceClient.getClient();
|
| 507 |
rajveer |
1240 |
|
| 555 |
chandransh |
1241 |
Cart cart = userClient.getCart(cartId);
|
| 507 |
rajveer |
1242 |
List<Line> lineItems = cart.getLines();
|
| 517 |
rajveer |
1243 |
if(lineItems.size() != 0){
|
|
|
1244 |
items = new ArrayList<Map<String,String>>();
|
|
|
1245 |
for (Line line : lineItems) {
|
|
|
1246 |
|
|
|
1247 |
Map<String, String> itemdetail = new HashMap<String, String>();
|
| 637 |
rajveer |
1248 |
Item item = catalogClient.getItem(line.getItemId());
|
| 517 |
rajveer |
1249 |
|
|
|
1250 |
String itemName = ((item.getManufacturerName() != null) ? item.getManufacturerName() + " " : "")
|
|
|
1251 |
+ ((item.getModelName() != null) ? item.getModelName() + " " : "")
|
| 637 |
rajveer |
1252 |
+ (( item.getModelNumber() != null ) ? item.getModelNumber() + " " : "" )
|
|
|
1253 |
+ (( (item.getColor() != null && !item.getColor().trim().equals("NA"))) ? "("+item.getColor()+")" : "" );
|
| 517 |
rajveer |
1254 |
|
|
|
1255 |
itemdetail.put("ITEM_NAME", itemName);
|
|
|
1256 |
System.out.println(itemdetail.get("ITEM_NAME"));
|
|
|
1257 |
itemdetail.put("ITEM_ID", line.getItemId()+"");
|
|
|
1258 |
itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
|
|
|
1259 |
itemdetail.put("MRP", ((int)item.getMrp())+"");
|
|
|
1260 |
itemdetail.put("SELLING_PRICE", ((int)item.getSellingPrice())+"");
|
|
|
1261 |
itemdetail.put("TOTAL_PRICE", ((int)((item.getSellingPrice()*line.getQuantity())))+"");
|
| 615 |
chandransh |
1262 |
itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
|
| 517 |
rajveer |
1263 |
totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
|
|
|
1264 |
items.add(itemdetail);
|
| 507 |
rajveer |
1265 |
}
|
|
|
1266 |
}
|
|
|
1267 |
|
|
|
1268 |
}catch (Exception e){
|
|
|
1269 |
e.printStackTrace();
|
|
|
1270 |
}
|
|
|
1271 |
|
|
|
1272 |
context.put("items", items);
|
| 517 |
rajveer |
1273 |
context.put("totalamount", ((int)totalamount)+"");
|
| 572 |
chandransh |
1274 |
context.put("errorMsg", errorMsg);
|
| 507 |
rajveer |
1275 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1276 |
return htmlString;
|
|
|
1277 |
}
|
|
|
1278 |
|
|
|
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){
|
|
|
1303 |
Properties p = new Properties();
|
|
|
1304 |
p.setProperty("resource.loader", "class");
|
|
|
1305 |
p.setProperty("class.resource.loader.class",
|
|
|
1306 |
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
|
|
1307 |
|
|
|
1308 |
|
|
|
1309 |
try {
|
|
|
1310 |
Velocity.init(p);
|
|
|
1311 |
Template template = Velocity.getTemplate(templateFile);
|
|
|
1312 |
if(template != null) {
|
|
|
1313 |
StringWriter writer = new StringWriter();
|
|
|
1314 |
template.merge(context, writer);
|
|
|
1315 |
writer.flush();
|
|
|
1316 |
writer.close();
|
|
|
1317 |
return writer.toString();
|
|
|
1318 |
}
|
|
|
1319 |
|
|
|
1320 |
} catch (ResourceNotFoundException e) {
|
|
|
1321 |
// TODO Auto-generated catch block
|
|
|
1322 |
e.printStackTrace();
|
|
|
1323 |
} catch (ParseErrorException e) {
|
|
|
1324 |
// TODO Auto-generated catch block
|
|
|
1325 |
e.printStackTrace();
|
|
|
1326 |
} catch (MethodInvocationException e) {
|
|
|
1327 |
// TODO Auto-generated catch block
|
|
|
1328 |
e.printStackTrace();
|
|
|
1329 |
} catch (IOException e) {
|
|
|
1330 |
// TODO Auto-generated catch block
|
|
|
1331 |
e.printStackTrace();
|
|
|
1332 |
} catch (Exception e) {
|
|
|
1333 |
// TODO Auto-generated catch block
|
|
|
1334 |
e.printStackTrace();
|
|
|
1335 |
}
|
|
|
1336 |
|
|
|
1337 |
return null;
|
|
|
1338 |
}
|
|
|
1339 |
|
|
|
1340 |
|
| 517 |
rajveer |
1341 |
public String getCategoryHeaderSnippet() {
|
|
|
1342 |
String htmlString = "";
|
|
|
1343 |
VelocityContext context = new VelocityContext();
|
|
|
1344 |
String templateFile = "templates/categoryheader.vm";
|
|
|
1345 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1346 |
return htmlString;
|
|
|
1347 |
}
|
|
|
1348 |
|
| 507 |
rajveer |
1349 |
|
|
|
1350 |
|
|
|
1351 |
}
|
|
|
1352 |
|