| 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 in.shop2020.util.Utils;
|
|
|
19 |
|
|
|
20 |
import org.apache.thrift.TException;
|
|
|
21 |
import org.apache.velocity.Template;
|
|
|
22 |
import org.apache.velocity.VelocityContext;
|
|
|
23 |
import org.apache.velocity.app.Velocity;
|
|
|
24 |
import org.apache.velocity.exception.MethodInvocationException;
|
|
|
25 |
import org.apache.velocity.exception.ParseErrorException;
|
|
|
26 |
import org.apache.velocity.exception.ResourceNotFoundException;
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
import in.shop2020.metamodel.definitions.Catalog;
|
|
|
30 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
|
|
31 |
import in.shop2020.metamodel.definitions.EntityContainer;
|
|
|
32 |
import in.shop2020.metamodel.util.ExpandedCategory;
|
|
|
33 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
|
|
34 |
import in.shop2020.model.v1.catalog.InventoryServiceException;
|
|
|
35 |
import in.shop2020.model.v1.catalog.Item;
|
|
|
36 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
|
|
37 |
import in.shop2020.model.v1.order.Order;
|
|
|
38 |
import in.shop2020.model.v1.order.OrderStatus;
|
|
|
39 |
import in.shop2020.model.v1.order.Transaction;
|
| 555 |
chandransh |
40 |
import in.shop2020.model.v1.user.Cart;
|
|
|
41 |
import in.shop2020.model.v1.user.Line;
|
|
|
42 |
import in.shop2020.model.v1.user.LineStatus;
|
|
|
43 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 507 |
rajveer |
44 |
import in.shop2020.model.v1.user.Address;
|
| 555 |
chandransh |
45 |
import in.shop2020.model.v1.user.User;
|
| 507 |
rajveer |
46 |
import in.shop2020.model.v1.user.UserContextException;
|
| 555 |
chandransh |
47 |
import in.shop2020.model.v1.user.RatingType;
|
|
|
48 |
import in.shop2020.model.v1.user.RatingsWidget;
|
|
|
49 |
import in.shop2020.model.v1.user.Widget;
|
|
|
50 |
import in.shop2020.model.v1.user.WidgetItem;
|
|
|
51 |
import in.shop2020.model.v1.user.WidgetType;
|
| 507 |
rajveer |
52 |
import in.shop2020.serving.page.CategoryPage;
|
|
|
53 |
import in.shop2020.serving.page.MyAccountPage;
|
|
|
54 |
import in.shop2020.serving.page.ProductPage;
|
|
|
55 |
import in.shop2020.serving.page.ShoppingCartPage;
|
|
|
56 |
import in.shop2020.serving.utils.*;
|
|
|
57 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
|
|
58 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
|
|
59 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
public class PageLoaderHandler {
|
|
|
63 |
|
|
|
64 |
public Map<String,String> getProductPage(long productId, Map<String, String> params) throws TException {
|
|
|
65 |
|
|
|
66 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
|
|
67 |
|
| 555 |
chandransh |
68 |
boolean isLoggedIn = Boolean.parseBoolean(params.get("IS_LOGGED_IN"));
|
| 507 |
rajveer |
69 |
long userId = Long.parseLong(params.get("USER_ID"));
|
|
|
70 |
String userName = params.get("USER_NAME");
|
|
|
71 |
|
|
|
72 |
long categoryId = 100000;
|
|
|
73 |
long itemCount = Long.parseLong(params.get("ITEM_COUNT"));
|
|
|
74 |
//product.setCategoryId(categoryId);
|
|
|
75 |
|
| 555 |
chandransh |
76 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
77 |
System.out.println("HEADER Snippet generated");
|
|
|
78 |
|
|
|
79 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
80 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
81 |
|
|
|
82 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, categoryId));
|
|
|
83 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
84 |
|
|
|
85 |
htmlSnippet.put("PRODUCT_SUMMARY", getProductSummaryHtml(productId));
|
|
|
86 |
System.out.println("PRODUCT_SUMMARY Snippet generated");
|
|
|
87 |
|
|
|
88 |
htmlSnippet.put("SOCIAL_UTILS", getSocialUtilsHtml(productId));
|
|
|
89 |
System.out.println("SOCIAL_UTILS Snippet generated");
|
|
|
90 |
|
|
|
91 |
htmlSnippet.put("SLIDE_GUIDE", getSlideGuideHtml(productId));
|
|
|
92 |
System.out.println("SLIDE GUIDE Snippet generated");
|
|
|
93 |
|
|
|
94 |
htmlSnippet.put("LOCATOR", getLocatorHtml());
|
|
|
95 |
System.out.println("LOCATOR Snippet generated");
|
|
|
96 |
|
|
|
97 |
htmlSnippet.put("REVIEWS", getReviewsHtml(productId));
|
|
|
98 |
System.out.println("REVIEWS Snippet generated");
|
|
|
99 |
|
|
|
100 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
101 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
102 |
|
| 555 |
chandransh |
103 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
104 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
105 |
|
|
|
106 |
htmlSnippet.put("RECOMMENDATIONS", getRecommendationsHtml());
|
|
|
107 |
System.out.println("RECOMMENDATIONS Snippet generated");
|
|
|
108 |
|
|
|
109 |
htmlSnippet.put("SIMILAR_PRODUCTS", getSimilarProductsHtml(productId));
|
|
|
110 |
System.out.println("RECOMMENDATIONS Snippet generated");
|
|
|
111 |
|
|
|
112 |
htmlSnippet.put("ACCESSORIES", getAccessoriesHtml(productId));
|
|
|
113 |
System.out.println("ACCESSORIES Snippet generated");
|
|
|
114 |
|
|
|
115 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
116 |
System.out.println("Footer Snippet generated");
|
|
|
117 |
|
|
|
118 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
119 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
120 |
|
|
|
121 |
htmlSnippet.put("JS_FILES", "");
|
|
|
122 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
123 |
|
|
|
124 |
System.out.println("Returning Generated Responce");
|
|
|
125 |
|
|
|
126 |
return htmlSnippet;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
public Map<String, String> getRegisterPage(Map<String, String> parameters) {
|
|
|
131 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
132 |
boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
|
| 507 |
rajveer |
133 |
long userId = Long.parseLong(parameters.get("USER_ID"));
|
|
|
134 |
String userName = parameters.get("USER_NAME");
|
|
|
135 |
long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
|
|
|
136 |
|
| 555 |
chandransh |
137 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
138 |
System.out.println("HEADER Snippet generated");
|
|
|
139 |
|
|
|
140 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
141 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
142 |
|
|
|
143 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
144 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
145 |
|
|
|
146 |
htmlSnippet.put("REGISTRATION_HEADER", getRegistrationHeaderHtml());
|
|
|
147 |
System.out.println("REGISTRATION_HEADER Snippet generated");
|
|
|
148 |
|
|
|
149 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
150 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
151 |
|
|
|
152 |
htmlSnippet.put("REGISTRATION_FORM", getRegistrationFormHtml());
|
|
|
153 |
System.out.println("REGISTRATION_FORM Snippet generated");
|
|
|
154 |
|
|
|
155 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
156 |
System.out.println("Footer Snippet generated");
|
|
|
157 |
|
|
|
158 |
htmlSnippet.put("JS_FILES", "");
|
|
|
159 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
return htmlSnippet;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
private String getRegistrationFormHtml() {
|
|
|
166 |
String htmlString = "";
|
|
|
167 |
VelocityContext context = new VelocityContext();
|
|
|
168 |
String templateFile = "templates/registrationform.vm";
|
|
|
169 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
170 |
return htmlString;
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
private String getRegistrationHeaderHtml() {
|
|
|
175 |
String htmlString = "";
|
|
|
176 |
VelocityContext context = new VelocityContext();
|
|
|
177 |
String templateFile = "templates/registrationheader.vm";
|
|
|
178 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
179 |
return htmlString;
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
|
| 555 |
chandransh |
183 |
public Map<String,String> getHomePage(Map<String, String> parameters) throws TException {
|
| 507 |
rajveer |
184 |
|
|
|
185 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
186 |
boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
|
|
|
187 |
long userId = Long.parseLong(parameters.get("USER_ID"));
|
|
|
188 |
String userName = parameters.get("USER_NAME");
|
|
|
189 |
long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
|
| 507 |
rajveer |
190 |
|
|
|
191 |
long categoryId = 100000;
|
|
|
192 |
//product.setCategoryId(categoryId);
|
|
|
193 |
|
| 555 |
chandransh |
194 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
195 |
System.out.println("HEADER Snippet generated");
|
|
|
196 |
|
| 555 |
chandransh |
197 |
|
| 507 |
rajveer |
198 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
199 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
200 |
|
|
|
201 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, categoryId));
|
|
|
202 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
203 |
|
|
|
204 |
htmlSnippet.put("MAIN_BANNER", getMainBannerHtml());
|
|
|
205 |
System.out.println("LOCATOR Snippet generated");
|
|
|
206 |
|
|
|
207 |
htmlSnippet.put("BEST_DEALS", getBestDealsHtml());
|
|
|
208 |
System.out.println("BEST_DEALS Snippet generated");
|
|
|
209 |
|
|
|
210 |
htmlSnippet.put("LATEST_ARRIVALS", getLatestArrivalsHtml());
|
|
|
211 |
System.out.println("LATEST_ARRIVALS Snippet generated");
|
|
|
212 |
|
|
|
213 |
htmlSnippet.put("BEST_SELLERS", getBestSellersHtml());
|
|
|
214 |
System.out.println("BEST_SELLERS Snippet generated");
|
|
|
215 |
|
|
|
216 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
217 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
218 |
|
| 555 |
chandransh |
219 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
220 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
221 |
|
|
|
222 |
htmlSnippet.put("RECOMMENDATIONS", getRecommendationsHtml());
|
|
|
223 |
System.out.println("RECOMMENDATIONS Snippet generated");
|
|
|
224 |
|
| 555 |
chandransh |
225 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
226 |
System.out.println("RECOMMENDATIONS Snippet generated");
|
|
|
227 |
|
|
|
228 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
229 |
System.out.println("Footer Snippet generated");
|
|
|
230 |
|
|
|
231 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
232 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
233 |
|
|
|
234 |
htmlSnippet.put("JS_FILES", "");
|
|
|
235 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
236 |
|
|
|
237 |
System.out.println("Returning Generated Responce");
|
|
|
238 |
|
|
|
239 |
return htmlSnippet;
|
|
|
240 |
}
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
private String getMainBannerHtml() {
|
|
|
244 |
String htmlString = "";
|
|
|
245 |
VelocityContext context = new VelocityContext();
|
|
|
246 |
String templateFile = "templates/mainbanner.vm";
|
|
|
247 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
248 |
return htmlString;
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
private String getBestSellersHtml() {
|
|
|
253 |
String htmlString = "";
|
|
|
254 |
VelocityContext context = new VelocityContext();
|
|
|
255 |
String templateFile = "templates/bestsellers.vm";
|
|
|
256 |
|
|
|
257 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
258 |
Client client = null;
|
|
|
259 |
|
|
|
260 |
try {
|
|
|
261 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
262 |
client = catalogServiceClient.getClient();
|
| 627 |
rajveer |
263 |
List<Long> items = client.getBestSellersCatalogIds(1, 4, -1);
|
| 507 |
rajveer |
264 |
List<String> itemList = new ArrayList<String>();
|
|
|
265 |
for(Long item: items){
|
| 517 |
rajveer |
266 |
itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
|
| 507 |
rajveer |
267 |
}
|
|
|
268 |
context.put("itemList", itemList);
|
|
|
269 |
|
|
|
270 |
} catch(Exception e){
|
|
|
271 |
|
|
|
272 |
}
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
| 517 |
rajveer |
276 |
return htmlString;
|
|
|
277 |
}
|
| 507 |
rajveer |
278 |
|
|
|
279 |
|
|
|
280 |
private String getLatestArrivalsHtml() {
|
|
|
281 |
String htmlString = "";
|
|
|
282 |
VelocityContext context = new VelocityContext();
|
|
|
283 |
String templateFile = "templates/latestarrivals.vm";
|
|
|
284 |
|
|
|
285 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
286 |
Client client = null;
|
|
|
287 |
|
|
|
288 |
try {
|
|
|
289 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
290 |
client = catalogServiceClient.getClient();
|
| 627 |
rajveer |
291 |
List<Long> items = client.getLatestArrivalsCatalogIds(1,4,-1);
|
| 507 |
rajveer |
292 |
List<String> itemList = new ArrayList<String>();
|
|
|
293 |
for(Long item: items){
|
| 517 |
rajveer |
294 |
itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
|
| 507 |
rajveer |
295 |
}
|
|
|
296 |
context.put("itemList", itemList);
|
|
|
297 |
|
|
|
298 |
} catch(Exception e){
|
|
|
299 |
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
304 |
return htmlString;
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
private String getBestDealsHtml() {
|
|
|
309 |
String htmlString = "";
|
|
|
310 |
VelocityContext context = new VelocityContext();
|
|
|
311 |
String templateFile = "templates/bestdeals.vm";
|
|
|
312 |
|
|
|
313 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
314 |
Client client = null;
|
|
|
315 |
|
|
|
316 |
try {
|
|
|
317 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
318 |
client = catalogServiceClient.getClient();
|
| 627 |
rajveer |
319 |
List<Long> items = client.getBestDealsCatalogIds(1,4,-1);
|
| 507 |
rajveer |
320 |
List<String> itemList = new ArrayList<String>();
|
|
|
321 |
for(Long item: items){
|
| 517 |
rajveer |
322 |
itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
|
| 507 |
rajveer |
323 |
}
|
|
|
324 |
context.put("itemList", itemList);
|
|
|
325 |
|
|
|
326 |
} catch(Exception e){
|
|
|
327 |
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
331 |
return htmlString;
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
|
| 517 |
rajveer |
335 |
public String getFooterHtml() {
|
| 507 |
rajveer |
336 |
String htmlString = "";
|
|
|
337 |
VelocityContext context = new VelocityContext();
|
|
|
338 |
String templateFile = "templates/footer.vm";
|
|
|
339 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
340 |
return htmlString;
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
|
|
|
344 |
|
| 620 |
rajveer |
345 |
public String getAccessoriesHtml(long productId) {
|
| 555 |
chandransh |
346 |
return getWidgetDiv(0, WidgetType.ACCESSORIES, "accessories.vm");
|
| 507 |
rajveer |
347 |
}
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
|
| 620 |
rajveer |
351 |
public String getSimilarProductsHtml(long productId) {
|
| 555 |
chandransh |
352 |
return getWidgetDiv(0, WidgetType.SIMILAR_ITEMS, "similaritems.vm");
|
| 507 |
rajveer |
353 |
}
|
|
|
354 |
|
|
|
355 |
|
|
|
356 |
|
| 620 |
rajveer |
357 |
public String getRecommendationsHtml() {
|
| 555 |
chandransh |
358 |
return getWidgetDiv( 0, WidgetType.RECOMMENDED_ITEMS, "recommendations.vm");
|
| 507 |
rajveer |
359 |
}
|
|
|
360 |
|
|
|
361 |
|
|
|
362 |
|
| 555 |
chandransh |
363 |
public String getMyResearchHtml(long userId, boolean isLoggedIn) {
|
|
|
364 |
if(isLoggedIn)
|
|
|
365 |
return getWidgetDiv(userId, WidgetType.MY_RESEARCH, "myresearch.vm");
|
|
|
366 |
else
|
|
|
367 |
return getWidgetDiv(0, WidgetType.MY_RESEARCH, "myresearch.vm");
|
| 507 |
rajveer |
368 |
}
|
|
|
369 |
|
| 569 |
rajveer |
370 |
public String getBrowseHistoryHtml(long userId, boolean isLoggedIn) {
|
| 555 |
chandransh |
371 |
if(isLoggedIn)
|
|
|
372 |
return getWidgetDiv(userId, WidgetType.BROWSE_HISTORY, "browsehistory.vm");
|
|
|
373 |
else
|
|
|
374 |
return getWidgetDiv(0, WidgetType.BROWSE_HISTORY, "browsehistory.vm");
|
| 507 |
rajveer |
375 |
}
|
|
|
376 |
|
| 517 |
rajveer |
377 |
public String getCustomerServiceHtml() {
|
| 507 |
rajveer |
378 |
String htmlString = "";
|
|
|
379 |
VelocityContext context = new VelocityContext();
|
|
|
380 |
String templateFile = "templates/customerservice.vm";
|
|
|
381 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
382 |
return htmlString;
|
|
|
383 |
}
|
|
|
384 |
|
|
|
385 |
|
|
|
386 |
|
| 620 |
rajveer |
387 |
public String getReviewsHtml(long productId) {
|
| 507 |
rajveer |
388 |
String htmlString = "";
|
|
|
389 |
VelocityContext context = new VelocityContext();
|
|
|
390 |
Map<String, String> params = new HashMap<String, String>();
|
|
|
391 |
params.put("PRODUCT_ID", productId+"");
|
|
|
392 |
context.put("params", params);
|
|
|
393 |
String templateFile = "templates/reviews.vm";
|
|
|
394 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
395 |
return htmlString;
|
|
|
396 |
}
|
|
|
397 |
|
|
|
398 |
|
|
|
399 |
|
| 620 |
rajveer |
400 |
public String getLocatorHtml() {
|
| 507 |
rajveer |
401 |
String htmlString = "";
|
|
|
402 |
VelocityContext context = new VelocityContext();
|
|
|
403 |
String templateFile = "templates/locator.vm";
|
|
|
404 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
405 |
return htmlString;
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
// private String getSlideGuideHtml(long productId) {
|
|
|
411 |
// String htmlString = "";
|
|
|
412 |
// try {
|
|
|
413 |
// VelocityContext context = new VelocityContext();
|
|
|
414 |
// String templateFile = "velocity/slideguide.vm";
|
|
|
415 |
// // For an entity
|
|
|
416 |
// EntityContainer entContainer = Catalog.getInstance().getEntityContainer();
|
|
|
417 |
// ExpandedEntity expEntity = entContainer.getExpandedEntity(productId);
|
|
|
418 |
//
|
|
|
419 |
// context.put("expentity", expEntity);
|
|
|
420 |
// htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
421 |
// } catch (Exception e) {
|
|
|
422 |
// e.printStackTrace();
|
|
|
423 |
// }
|
|
|
424 |
// return htmlString;
|
|
|
425 |
// }
|
|
|
426 |
|
| 620 |
rajveer |
427 |
public String getSlideGuideHtml(long productId) {
|
| 507 |
rajveer |
428 |
StringBuilder htmlString = new StringBuilder();
|
| 517 |
rajveer |
429 |
String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "SlideGuide.html";
|
| 507 |
rajveer |
430 |
File f = new File(filename);
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
FileInputStream fis = null;
|
|
|
434 |
try {
|
|
|
435 |
fis = new FileInputStream(f);
|
|
|
436 |
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
|
|
|
437 |
String line;
|
|
|
438 |
while((line = br.readLine()) != null){
|
|
|
439 |
htmlString.append(line+"\n");
|
|
|
440 |
}
|
|
|
441 |
} catch (FileNotFoundException e) {
|
|
|
442 |
// TODO Auto-generated catch block
|
|
|
443 |
e.printStackTrace();
|
|
|
444 |
} catch (IOException e) {
|
|
|
445 |
// TODO Auto-generated catch block
|
|
|
446 |
e.printStackTrace();
|
|
|
447 |
}
|
|
|
448 |
finally {
|
|
|
449 |
if(fis != null) {
|
|
|
450 |
try {
|
|
|
451 |
fis.close();
|
|
|
452 |
} catch (IOException e) {
|
|
|
453 |
// TODO Auto-generated catch block
|
|
|
454 |
e.printStackTrace();
|
|
|
455 |
}
|
|
|
456 |
}
|
|
|
457 |
}
|
|
|
458 |
|
|
|
459 |
return htmlString.toString();
|
|
|
460 |
}
|
|
|
461 |
|
| 517 |
rajveer |
462 |
public String getProductSummaryHtml(long productId) {
|
| 507 |
rajveer |
463 |
StringBuilder htmlString = new StringBuilder();
|
| 517 |
rajveer |
464 |
String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "ProductDetail.html";
|
| 507 |
rajveer |
465 |
File f = new File(filename);
|
|
|
466 |
|
|
|
467 |
|
|
|
468 |
FileInputStream fis = null;
|
|
|
469 |
try {
|
|
|
470 |
fis = new FileInputStream(f);
|
|
|
471 |
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
|
|
|
472 |
String line;
|
|
|
473 |
while((line = br.readLine()) != null){
|
|
|
474 |
htmlString.append(line+"\n");
|
|
|
475 |
}
|
|
|
476 |
} catch (FileNotFoundException e) {
|
|
|
477 |
// TODO Auto-generated catch block
|
|
|
478 |
e.printStackTrace();
|
|
|
479 |
} catch (IOException e) {
|
|
|
480 |
// TODO Auto-generated catch block
|
|
|
481 |
e.printStackTrace();
|
|
|
482 |
}
|
|
|
483 |
finally {
|
|
|
484 |
if(fis != null) {
|
|
|
485 |
try {
|
|
|
486 |
fis.close();
|
|
|
487 |
} catch (IOException e) {
|
|
|
488 |
// TODO Auto-generated catch block
|
|
|
489 |
e.printStackTrace();
|
|
|
490 |
}
|
|
|
491 |
}
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
return htmlString.toString();
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
|
| 620 |
rajveer |
498 |
public String getSocialUtilsHtml(long productId) {
|
| 507 |
rajveer |
499 |
String htmlString = "";
|
|
|
500 |
VelocityContext context = new VelocityContext();
|
|
|
501 |
Map<String, String> params = new HashMap<String, String>();
|
|
|
502 |
params.put("PRODUCT_ID", productId+"");
|
|
|
503 |
String templateFile = "templates/socialutils.vm";
|
|
|
504 |
context.put("params", params);
|
|
|
505 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
506 |
return htmlString;
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
|
|
|
510 |
|
| 620 |
rajveer |
511 |
public String getProductSummaryHtml(long productId, boolean toBeDecided) {
|
| 507 |
rajveer |
512 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
513 |
Client client = null;
|
|
|
514 |
String htmlString = "";
|
|
|
515 |
|
| 555 |
chandransh |
516 |
UserContextServiceClient userServiceClient = null;
|
|
|
517 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
| 507 |
rajveer |
518 |
try {
|
|
|
519 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
520 |
client = catalogServiceClient.getClient();
|
|
|
521 |
|
| 555 |
chandransh |
522 |
userServiceClient = new UserContextServiceClient();
|
|
|
523 |
userClient = userServiceClient.getClient();
|
| 507 |
rajveer |
524 |
|
| 555 |
chandransh |
525 |
RatingsWidget ratingsWidget = userClient.getRatings(productId, 0);
|
| 507 |
rajveer |
526 |
Map<RatingType,Double> ratings = ratingsWidget.getRatings();
|
|
|
527 |
//double rating_amazon = ratings.get(RatingType.AMAZON);
|
|
|
528 |
double rating_all = 0.0;
|
|
|
529 |
if(ratings != null){
|
|
|
530 |
if( ratings.get(RatingType.USER_ALL) != null){
|
|
|
531 |
rating_all = ratings.get(RatingType.USER_ALL);
|
|
|
532 |
}
|
|
|
533 |
}
|
|
|
534 |
|
|
|
535 |
rating_all = Math.round(rating_all);
|
|
|
536 |
|
|
|
537 |
Item item = client.getItemByCatalogId(productId);
|
|
|
538 |
|
|
|
539 |
Double itemPrice = item.getSellingPrice();
|
|
|
540 |
// For an entity
|
|
|
541 |
EntityContainer entContainer = Catalog.getInstance().getEntityContainer();
|
|
|
542 |
ExpandedEntity expEntity = entContainer.getExpandedEntity(productId);
|
|
|
543 |
|
|
|
544 |
String title = expEntity.getBrand() + "" + expEntity.getModelName();
|
|
|
545 |
String categoryName = expEntity.getCategory().getLabel();
|
|
|
546 |
long categoryId = expEntity.getCategory().getID();
|
|
|
547 |
Map<String,String> params = new HashMap<String, String>();
|
|
|
548 |
params.put("TITLE", title);
|
|
|
549 |
params.put("CATEGORY_ID", categoryId+"");
|
|
|
550 |
params.put("CATEGORY_NAME", categoryName);
|
|
|
551 |
params.put("PRICE", itemPrice.toString());
|
|
|
552 |
params.put("RATING_ALL", rating_all+"");
|
|
|
553 |
params.put("PRODUCT_ID", productId+"");
|
|
|
554 |
|
|
|
555 |
VelocityContext context = new VelocityContext();
|
|
|
556 |
String templateFile = "templates/productsummary.vm";
|
|
|
557 |
context.put("params", params);
|
|
|
558 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
559 |
|
|
|
560 |
} catch (Exception e) {
|
|
|
561 |
e.printStackTrace();
|
|
|
562 |
}
|
|
|
563 |
|
|
|
564 |
return htmlString;
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
|
|
|
568 |
|
| 517 |
rajveer |
569 |
public String getMainMenuHtml() {
|
| 507 |
rajveer |
570 |
String htmlString = "";
|
|
|
571 |
VelocityContext context = new VelocityContext();
|
|
|
572 |
String templateFile = "templates/mainmenu.vm";
|
|
|
573 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
574 |
return htmlString;
|
|
|
575 |
}
|
|
|
576 |
|
|
|
577 |
|
| 517 |
rajveer |
578 |
public String getSearchBarHtml(long itemCounts, long categoryId) {
|
| 507 |
rajveer |
579 |
String htmlString = "";
|
|
|
580 |
VelocityContext context = new VelocityContext();
|
|
|
581 |
String templateFile = "templates/searchbar.vm";
|
| 550 |
rajveer |
582 |
|
|
|
583 |
context.put("itemCount", itemCounts+"");
|
|
|
584 |
context.put("categoryId", categoryId+"");
|
|
|
585 |
|
| 507 |
rajveer |
586 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
587 |
return htmlString;
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
|
|
|
591 |
|
| 555 |
chandransh |
592 |
public String getHeaderHtml(boolean isLoggedIn, String userName) {
|
| 550 |
rajveer |
593 |
VelocityContext context = new VelocityContext();
|
| 555 |
chandransh |
594 |
if (isLoggedIn) {
|
|
|
595 |
context.put("LOGGED_IN", "TRUE");
|
|
|
596 |
context.put("WELCOME_MESSAGE", "Hi, " + userName);
|
|
|
597 |
} else {
|
| 550 |
rajveer |
598 |
context.put("WELCOME_MESSAGE", "Hi, Welcome to Shop2020");
|
| 555 |
chandransh |
599 |
}
|
| 507 |
rajveer |
600 |
|
|
|
601 |
String templateFile = "templates/header.vm";
|
| 550 |
rajveer |
602 |
|
| 590 |
chandransh |
603 |
return getHtmlFromVelocity(templateFile, context);
|
| 507 |
rajveer |
604 |
}
|
|
|
605 |
|
|
|
606 |
|
|
|
607 |
|
|
|
608 |
public String getSlideGuideDIV(long productId){
|
|
|
609 |
String htmlString = "";
|
|
|
610 |
try {
|
|
|
611 |
VelocityContext context = new VelocityContext();
|
|
|
612 |
String templateFile = "templates/slideguide.vm";
|
|
|
613 |
// For an entity
|
|
|
614 |
EntityContainer entContainer = Catalog.getInstance().getEntityContainer();
|
|
|
615 |
ExpandedEntity expEntity = entContainer.getExpandedEntity(productId);
|
|
|
616 |
|
|
|
617 |
context.put("expentity", expEntity);
|
|
|
618 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
619 |
} catch (Exception e) {
|
|
|
620 |
e.printStackTrace();
|
|
|
621 |
}
|
|
|
622 |
return htmlString;
|
|
|
623 |
}
|
|
|
624 |
|
|
|
625 |
|
|
|
626 |
public CategoryPage getCategoryPage(long categoryId,
|
|
|
627 |
Map<String, String> params){
|
|
|
628 |
// TODO Auto-generated method stub
|
|
|
629 |
|
|
|
630 |
CategoryPage category = null;
|
|
|
631 |
|
|
|
632 |
try {
|
|
|
633 |
//set velocity properties
|
|
|
634 |
Velocity.init("velocity/velocity.properties");
|
|
|
635 |
VelocityContext context = new VelocityContext();
|
|
|
636 |
|
|
|
637 |
String templateFile = "velocity/category.vm";
|
|
|
638 |
|
|
|
639 |
Template template = null;
|
|
|
640 |
|
|
|
641 |
// For an category
|
|
|
642 |
DefinitionsContainer defsContainer = Catalog.getInstance().getDefinitionsContainer();
|
|
|
643 |
|
|
|
644 |
ExpandedCategory expCategory = defsContainer.getExpandedCategory(categoryId);
|
|
|
645 |
|
|
|
646 |
//Utils.logger.info("expCategory=" + expCategory);
|
|
|
647 |
|
|
|
648 |
context.put("expcategory", expCategory);
|
|
|
649 |
template = Velocity.getTemplate(templateFile);
|
|
|
650 |
|
|
|
651 |
if(template != null) {
|
|
|
652 |
StringWriter writer = new StringWriter();
|
|
|
653 |
|
|
|
654 |
template.merge(context, writer);
|
|
|
655 |
writer.flush();
|
|
|
656 |
writer.close();
|
|
|
657 |
|
|
|
658 |
//Put in the product object
|
|
|
659 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
|
|
660 |
htmlSnippet.put("MAIN", writer.toString());
|
|
|
661 |
|
|
|
662 |
category = new CategoryPage();
|
|
|
663 |
category.setCategoryId(categoryId);
|
|
|
664 |
category.setParams(params);
|
|
|
665 |
category.setHtmlSnippet(htmlSnippet);
|
|
|
666 |
|
|
|
667 |
Utils.info("Snippet generated");
|
|
|
668 |
}
|
|
|
669 |
} catch (ResourceNotFoundException e) {
|
|
|
670 |
// TODO Auto-generated catch block
|
|
|
671 |
e.printStackTrace();
|
|
|
672 |
} catch (ParseErrorException e) {
|
|
|
673 |
// TODO Auto-generated catch block
|
|
|
674 |
e.printStackTrace();
|
|
|
675 |
} catch (MethodInvocationException e) {
|
|
|
676 |
// TODO Auto-generated catch block
|
|
|
677 |
e.printStackTrace();
|
|
|
678 |
} catch (Exception e) {
|
|
|
679 |
// TODO Auto-generated catch block
|
|
|
680 |
e.printStackTrace();
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
return category;
|
|
|
684 |
}
|
|
|
685 |
|
| 555 |
chandransh |
686 |
private String getWidgetDiv(long userId, WidgetType widgetType, String templateFile){
|
| 507 |
rajveer |
687 |
|
| 555 |
chandransh |
688 |
UserContextServiceClient userServiceClient = null;
|
|
|
689 |
in.shop2020.model.v1.user.UserContextService.Client client = null;
|
| 507 |
rajveer |
690 |
Widget widget = null;
|
|
|
691 |
try {
|
| 555 |
chandransh |
692 |
userServiceClient = new UserContextServiceClient();
|
|
|
693 |
client = userServiceClient.getClient();
|
|
|
694 |
widget = client.getWidget(widgetType, userId, true);
|
| 507 |
rajveer |
695 |
} catch (Exception e) {
|
|
|
696 |
e.printStackTrace();
|
|
|
697 |
}
|
|
|
698 |
|
|
|
699 |
|
|
|
700 |
List<Map<String, String>> itemDetails = null;
|
|
|
701 |
|
|
|
702 |
if(widget != null){
|
|
|
703 |
List<WidgetItem> items = widget.getItems();
|
|
|
704 |
itemDetails = new ArrayList<Map<String, String>>();
|
|
|
705 |
|
|
|
706 |
for(WidgetItem item: items){
|
|
|
707 |
Map<String, String> itemDetail = new HashMap<String, String>();
|
|
|
708 |
|
|
|
709 |
itemDetail.put("ITEM_ID", item.getItem_id()+"");
|
|
|
710 |
try {
|
| 517 |
rajveer |
711 |
itemDetail.put("ITEM_SNIPPET", FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item.getItem_id() + File.separator + "WidgetSnippet.html"));
|
| 507 |
rajveer |
712 |
} catch (Exception e) {
|
|
|
713 |
// TODO Auto-generated catch block
|
|
|
714 |
e.printStackTrace();
|
|
|
715 |
}
|
|
|
716 |
itemDetails.add(itemDetail);
|
|
|
717 |
}
|
|
|
718 |
}else{
|
|
|
719 |
System.out.println("widget not found");
|
|
|
720 |
}
|
|
|
721 |
|
|
|
722 |
VelocityContext context = new VelocityContext();
|
| 620 |
rajveer |
723 |
context.put("userId", userId);
|
| 507 |
rajveer |
724 |
context.put("itemDetails", itemDetails);
|
|
|
725 |
|
|
|
726 |
return getHtmlFromVelocity("templates/"+templateFile, context);
|
|
|
727 |
}
|
|
|
728 |
|
|
|
729 |
/*
|
|
|
730 |
private String getWidgetDiv(long productId, String userId, WidgetType widgetType, String templateFile){
|
|
|
731 |
long userID;
|
|
|
732 |
if(userId.compareTo("") == 0){
|
|
|
733 |
userID = 0;
|
|
|
734 |
}else{
|
|
|
735 |
userID = Long.parseLong(userId);
|
|
|
736 |
}
|
|
|
737 |
|
|
|
738 |
WidgetServiceClient widgetServiceClient = null;
|
|
|
739 |
in.shop2020.model.v1.widgets.WidgetService.Client client = null;
|
|
|
740 |
Widget widget = null;
|
|
|
741 |
try {
|
|
|
742 |
widgetServiceClient = new WidgetServiceClient();
|
|
|
743 |
client = widgetServiceClient.getClient();
|
|
|
744 |
widget = client.getWidget(widgetType, userID, true);
|
|
|
745 |
} catch (Exception e) {
|
|
|
746 |
e.printStackTrace();
|
|
|
747 |
}
|
|
|
748 |
|
|
|
749 |
|
|
|
750 |
List<Map<String, String>> itemDetails = null;
|
|
|
751 |
|
|
|
752 |
if(widget != null){
|
|
|
753 |
List<WidgetItem> items = widget.getItems();
|
|
|
754 |
itemDetails = new ArrayList<Map<String, String>>();
|
|
|
755 |
|
|
|
756 |
for(WidgetItem item: items){
|
|
|
757 |
Map<String, String> itemDetail = new HashMap<String, String>();
|
|
|
758 |
|
|
|
759 |
itemDetail.put("ITEM_ID", item.getItem_id()+"");
|
|
|
760 |
itemDetail.put("ITEM_NAME", "ID"+item.getItem_id());
|
|
|
761 |
itemDetail.put("ITEM_SNIPPET", item.getSnippet());
|
|
|
762 |
itemDetail.put("ITEM_PRICE", getItemPriceByCatalogId(item.getItem_id())+"");
|
|
|
763 |
itemDetails.add(itemDetail);
|
|
|
764 |
}
|
|
|
765 |
}else{
|
|
|
766 |
System.out.println("widget not found");
|
|
|
767 |
}
|
|
|
768 |
|
|
|
769 |
VelocityContext context = new VelocityContext();
|
|
|
770 |
context.put("itemDetails", itemDetails);
|
|
|
771 |
|
|
|
772 |
return getHtmlFromVelocity("velocity/"+templateFile, context);
|
|
|
773 |
}
|
|
|
774 |
*/
|
|
|
775 |
|
|
|
776 |
|
|
|
777 |
public Map<String, String> getCompletedOrdersPage(long userId, long itemCount,
|
|
|
778 |
Map<String, String> params) {
|
|
|
779 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
780 |
|
|
|
781 |
htmlSnippet.put("HEADER", getHeaderHtml(false, ""));
|
| 507 |
rajveer |
782 |
System.out.println("HEADER Snippet generated");
|
|
|
783 |
|
|
|
784 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
785 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
786 |
|
|
|
787 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
788 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
789 |
|
|
|
790 |
htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
|
|
|
791 |
System.out.println("MYACCOUNT_HEADER Snippet generated");
|
|
|
792 |
|
|
|
793 |
htmlSnippet.put("MYACCOUNT_DETAILS", getCompletedOrdersHtml(userId));
|
|
|
794 |
System.out.println("MYACCOUNT_DETAILS Snippet generated");
|
|
|
795 |
|
|
|
796 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
797 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
798 |
|
|
|
799 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
|
|
|
800 |
System.out.println("MY_RESEARCH Snippet generated");
|
| 620 |
rajveer |
801 |
|
|
|
802 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
803 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
804 |
|
| 507 |
rajveer |
805 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
806 |
System.out.println("Footer Snippet generated");
|
|
|
807 |
|
|
|
808 |
htmlSnippet.put("JS_FILES", "");
|
|
|
809 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
810 |
|
|
|
811 |
System.out.println("Returning Generated Responce");
|
|
|
812 |
|
|
|
813 |
|
|
|
814 |
return htmlSnippet;
|
|
|
815 |
|
|
|
816 |
}
|
|
|
817 |
|
|
|
818 |
|
| 555 |
chandransh |
819 |
public Map<String, String> getMyAccountPage(long userId, long itemCount, String userName, boolean isLoggedIn)
|
|
|
820 |
{
|
|
|
821 |
|
| 507 |
rajveer |
822 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
823 |
|
|
|
824 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
825 |
System.out.println("HEADER Snippet generated");
|
|
|
826 |
|
|
|
827 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
828 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
829 |
|
|
|
830 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
831 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
832 |
|
|
|
833 |
htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
|
|
|
834 |
System.out.println("MYACCOUNT_HEADER Snippet generated");
|
|
|
835 |
|
|
|
836 |
htmlSnippet.put("MYACCOUNT_DETAILS", getMyaccountDetailsHtml(userId));
|
|
|
837 |
System.out.println("MYACCOUNT_DETAILS Snippet generated");
|
|
|
838 |
|
|
|
839 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
840 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
841 |
|
|
|
842 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
|
|
|
843 |
System.out.println("MY_RESEARCH Snippet generated");
|
| 620 |
rajveer |
844 |
|
|
|
845 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
846 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
| 507 |
rajveer |
847 |
|
|
|
848 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
849 |
System.out.println("Footer Snippet generated");
|
|
|
850 |
|
|
|
851 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
852 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
853 |
|
|
|
854 |
htmlSnippet.put("JS_FILES", "");
|
|
|
855 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
856 |
|
|
|
857 |
System.out.println("Returning Generated Responce");
|
| 555 |
chandransh |
858 |
|
| 507 |
rajveer |
859 |
return htmlSnippet;
|
|
|
860 |
}
|
|
|
861 |
|
|
|
862 |
|
| 555 |
chandransh |
863 |
public Map<String, String> getPersonalDetailsPage(long userId, long itemCount, String userName, boolean isLoggedIn)
|
|
|
864 |
{
|
| 507 |
rajveer |
865 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
866 |
|
|
|
867 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
868 |
System.out.println("HEADER Snippet generated");
|
|
|
869 |
|
|
|
870 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
871 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
872 |
|
|
|
873 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
874 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
875 |
|
|
|
876 |
htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
|
|
|
877 |
System.out.println("MYACCOUNT_HEADER Snippet generated");
|
|
|
878 |
|
|
|
879 |
htmlSnippet.put("PERSONAL_DETAILS", getPersonalDetailsHtml(userId));
|
|
|
880 |
System.out.println("PERSONAL_DETAILS Snippet generated");
|
|
|
881 |
|
|
|
882 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
883 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
884 |
|
|
|
885 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
|
|
|
886 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
887 |
|
| 620 |
rajveer |
888 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
889 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
890 |
|
| 507 |
rajveer |
891 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
892 |
System.out.println("Footer Snippet generated");
|
|
|
893 |
|
|
|
894 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
895 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
896 |
|
|
|
897 |
htmlSnippet.put("JS_FILES", "");
|
|
|
898 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
899 |
|
|
|
900 |
System.out.println("Returning Generated Responce");
|
|
|
901 |
|
|
|
902 |
|
|
|
903 |
return htmlSnippet;
|
|
|
904 |
}
|
|
|
905 |
|
| 555 |
chandransh |
906 |
public Map<String, String> getLoginDetailsPage(long userId, long itemCount, String userName, boolean isLoggedIn)
|
|
|
907 |
{
|
| 507 |
rajveer |
908 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
909 |
|
|
|
910 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
911 |
System.out.println("HEADER Snippet generated");
|
|
|
912 |
|
|
|
913 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
914 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
915 |
|
|
|
916 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
917 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
918 |
|
|
|
919 |
htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
|
|
|
920 |
System.out.println("MYACCOUNT_HEADER Snippet generated");
|
|
|
921 |
|
|
|
922 |
htmlSnippet.put("LOGIN_DETAILS", getLoginDetailsHtml(userId));
|
|
|
923 |
System.out.println("LOGIN_DETAILS Snippet generated");
|
|
|
924 |
|
|
|
925 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
926 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
927 |
|
|
|
928 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
|
|
|
929 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
930 |
|
| 620 |
rajveer |
931 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
932 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
933 |
|
| 507 |
rajveer |
934 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
935 |
System.out.println("Footer Snippet generated");
|
|
|
936 |
|
|
|
937 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
938 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
939 |
|
|
|
940 |
htmlSnippet.put("JS_FILES", "");
|
|
|
941 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
942 |
|
|
|
943 |
System.out.println("Returning Generated Responce");
|
|
|
944 |
|
|
|
945 |
|
|
|
946 |
return htmlSnippet;
|
|
|
947 |
}
|
|
|
948 |
|
|
|
949 |
|
|
|
950 |
|
|
|
951 |
public Map<String, String> getOrderDetailsPage(long userId, long itemCount, long orderId,
|
| 555 |
chandransh |
952 |
Map<String, String> parameters) {
|
| 507 |
rajveer |
953 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
954 |
boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
|
|
|
955 |
String userName = parameters.get("USER_NAME");
|
|
|
956 |
|
|
|
957 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
958 |
System.out.println("HEADER Snippet generated");
|
|
|
959 |
|
|
|
960 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
961 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
962 |
|
|
|
963 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
964 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
965 |
|
|
|
966 |
htmlSnippet.put("MYACCOUNT_HEADER", getMyaccountHeaderHtml());
|
|
|
967 |
System.out.println("MYACCOUNT_HEADER Snippet generated");
|
|
|
968 |
|
|
|
969 |
htmlSnippet.put("ORDER_DETAILS", getOrderDetailsHtml(orderId));
|
|
|
970 |
System.out.println("MYACCOUNT_DETAILS Snippet generated");
|
|
|
971 |
|
|
|
972 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
973 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
974 |
|
|
|
975 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
|
|
|
976 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
977 |
|
| 620 |
rajveer |
978 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, false));
|
|
|
979 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
980 |
|
| 507 |
rajveer |
981 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
982 |
System.out.println("Footer Snippet generated");
|
|
|
983 |
|
|
|
984 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
985 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
986 |
|
|
|
987 |
htmlSnippet.put("JS_FILES", "");
|
|
|
988 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
989 |
|
|
|
990 |
System.out.println("Returning Generated Responce");
|
|
|
991 |
|
|
|
992 |
|
|
|
993 |
return htmlSnippet;
|
|
|
994 |
}
|
|
|
995 |
|
|
|
996 |
|
|
|
997 |
|
|
|
998 |
private String getOrderDetailsHtml(long orderId) {
|
|
|
999 |
String htmlString = "";
|
|
|
1000 |
VelocityContext context = new VelocityContext();
|
|
|
1001 |
String templateFile = "templates/orderdetails.vm";
|
|
|
1002 |
TransactionServiceClient transactionServiceClient = null;
|
|
|
1003 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
|
|
|
1004 |
Order order = null;
|
| 517 |
rajveer |
1005 |
Date orderedOn = null, deliveryEstimate = null;
|
| 507 |
rajveer |
1006 |
try{
|
|
|
1007 |
transactionServiceClient = new TransactionServiceClient();
|
|
|
1008 |
orderClient = transactionServiceClient.getClient();
|
|
|
1009 |
order = orderClient.getOrder(orderId);
|
| 517 |
rajveer |
1010 |
orderedOn = new Date(order.getCreated_timestamp());
|
|
|
1011 |
deliveryEstimate = new Date(order.getExpected_delivery_time());
|
| 507 |
rajveer |
1012 |
}catch (Exception e){
|
|
|
1013 |
|
|
|
1014 |
}
|
| 517 |
rajveer |
1015 |
|
|
|
1016 |
SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
|
| 583 |
rajveer |
1017 |
SimpleDateFormat dateformat1 = new SimpleDateFormat("dd/MM/yyyy");
|
| 507 |
rajveer |
1018 |
context.put("order", order);
|
| 517 |
rajveer |
1019 |
context.put("orderedOn", dateformat.format(orderedOn));
|
| 583 |
rajveer |
1020 |
context.put("deliveryEstimate", dateformat1.format(deliveryEstimate));
|
| 517 |
rajveer |
1021 |
|
|
|
1022 |
|
| 507 |
rajveer |
1023 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1024 |
return htmlString;
|
|
|
1025 |
}
|
|
|
1026 |
|
|
|
1027 |
private String getMyaccountDetailsHtml(long userId) {
|
|
|
1028 |
String htmlString = "";
|
|
|
1029 |
VelocityContext context = new VelocityContext();
|
|
|
1030 |
String templateFile = "templates/myaccount.vm";
|
|
|
1031 |
TransactionServiceClient transactionServiceClient = null;
|
|
|
1032 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
|
|
|
1033 |
List<Order> orders = null;
|
|
|
1034 |
try{
|
|
|
1035 |
transactionServiceClient = new TransactionServiceClient();
|
|
|
1036 |
orderClient = transactionServiceClient.getClient();
|
|
|
1037 |
orders = orderClient.getOrdersForCustomer(userId, 0, (new Date()).getTime(), null);
|
|
|
1038 |
|
|
|
1039 |
}catch (Exception e){
|
|
|
1040 |
|
|
|
1041 |
}
|
|
|
1042 |
context.put("orders", orders);
|
|
|
1043 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1044 |
return htmlString;
|
|
|
1045 |
}
|
|
|
1046 |
|
|
|
1047 |
|
|
|
1048 |
private String getLoginDetailsHtml(long userId) {
|
|
|
1049 |
String htmlString = "";
|
|
|
1050 |
VelocityContext context = new VelocityContext();
|
|
|
1051 |
String templateFile = "templates/logindetails.vm";
|
|
|
1052 |
String email = "";
|
|
|
1053 |
try{
|
| 555 |
chandransh |
1054 |
email = in.shop2020.serving.utils.Utils.getEmailId(userId);
|
| 507 |
rajveer |
1055 |
}catch (Exception e){
|
|
|
1056 |
|
|
|
1057 |
}
|
|
|
1058 |
context.put("email", email);
|
|
|
1059 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1060 |
return htmlString;
|
|
|
1061 |
}
|
|
|
1062 |
|
| 595 |
rajveer |
1063 |
public String getPersonalDetailsHtml(long userId) {
|
| 507 |
rajveer |
1064 |
String htmlString = "";
|
|
|
1065 |
VelocityContext context = new VelocityContext();
|
|
|
1066 |
String templateFile = "templates/personaldetails.vm";
|
|
|
1067 |
String email = "";
|
| 517 |
rajveer |
1068 |
String name = "";
|
| 569 |
rajveer |
1069 |
String dateOfBirth = "";
|
| 517 |
rajveer |
1070 |
String sex = "";
|
|
|
1071 |
String subscribe = "false";
|
| 507 |
rajveer |
1072 |
UserContextServiceClient userContextServiceClient = null;
|
|
|
1073 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
|
|
1074 |
try{
|
| 555 |
chandransh |
1075 |
User user = null;
|
| 507 |
rajveer |
1076 |
userContextServiceClient = new UserContextServiceClient();
|
|
|
1077 |
userClient = userContextServiceClient.getClient();
|
| 555 |
chandransh |
1078 |
user = userClient.getUserById(userId);
|
| 507 |
rajveer |
1079 |
|
| 555 |
chandransh |
1080 |
email = user.getCommunicationEmail();
|
|
|
1081 |
name = user.getName();
|
| 517 |
rajveer |
1082 |
|
| 569 |
rajveer |
1083 |
dateOfBirth = user.getDateOfBirth();
|
| 507 |
rajveer |
1084 |
}catch (Exception e){
|
| 555 |
chandransh |
1085 |
e.printStackTrace();
|
| 507 |
rajveer |
1086 |
}
|
| 517 |
rajveer |
1087 |
context.put("name", name);
|
|
|
1088 |
context.put("email", email);
|
| 569 |
rajveer |
1089 |
context.put("dateOfBirth", dateOfBirth+"");
|
| 517 |
rajveer |
1090 |
context.put("subscribe", subscribe);
|
|
|
1091 |
context.put("sex", sex);
|
| 507 |
rajveer |
1092 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1093 |
return htmlString;
|
|
|
1094 |
}
|
|
|
1095 |
|
| 620 |
rajveer |
1096 |
public String getCompletedOrdersHtml(long userId) {
|
| 507 |
rajveer |
1097 |
String htmlString = "";
|
|
|
1098 |
VelocityContext context = new VelocityContext();
|
|
|
1099 |
String templateFile = "templates/completedorders.vm";
|
|
|
1100 |
TransactionServiceClient transactionServiceClient = null;
|
|
|
1101 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
|
|
|
1102 |
List<Order> orders = null;
|
|
|
1103 |
try{
|
|
|
1104 |
transactionServiceClient = new TransactionServiceClient();
|
|
|
1105 |
orderClient = transactionServiceClient.getClient();
|
|
|
1106 |
orders = orderClient.getOrdersForCustomer(userId, 0, (new Date()).getTime(), OrderStatus.DELIVERY_SUCCESS);
|
|
|
1107 |
|
|
|
1108 |
}catch (Exception e){
|
|
|
1109 |
|
|
|
1110 |
}
|
|
|
1111 |
context.put("orders", orders);
|
|
|
1112 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1113 |
return htmlString;
|
|
|
1114 |
}
|
| 595 |
rajveer |
1115 |
public String getMyaccountHeaderHtml() {
|
| 507 |
rajveer |
1116 |
String htmlString = "";
|
|
|
1117 |
VelocityContext context = new VelocityContext();
|
|
|
1118 |
String templateFile = "templates/myaccountheader.vm";
|
|
|
1119 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1120 |
return htmlString;
|
|
|
1121 |
}
|
|
|
1122 |
|
|
|
1123 |
//ShippingPage
|
| 572 |
chandransh |
1124 |
public Map<String, String> getShippingPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName, String errorMsg){
|
| 507 |
rajveer |
1125 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
1126 |
|
|
|
1127 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
1128 |
System.out.println("HEADER Snippet generated");
|
|
|
1129 |
|
|
|
1130 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
1131 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
1132 |
|
|
|
1133 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
1134 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
1135 |
|
|
|
1136 |
htmlSnippet.put("SHIPPING_HEADER", getShippingHeaderHtml());
|
|
|
1137 |
System.out.println("SHIPPING_HEADER Snippet generated");
|
|
|
1138 |
|
| 572 |
chandransh |
1139 |
htmlSnippet.put("SHIPPING_DETAILS", getShippingDetailsHtml(cartId, errorMsg));
|
| 507 |
rajveer |
1140 |
System.out.println("SHIPPING_BAR Snippet generated");
|
|
|
1141 |
|
|
|
1142 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
1143 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
1144 |
|
|
|
1145 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
1146 |
System.out.println("Footer Snippet generated");
|
|
|
1147 |
|
|
|
1148 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
1149 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
1150 |
|
|
|
1151 |
htmlSnippet.put("JS_FILES", "");
|
|
|
1152 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
1153 |
|
|
|
1154 |
System.out.println("Returning Generated Responce");
|
|
|
1155 |
|
|
|
1156 |
return htmlSnippet;
|
|
|
1157 |
|
|
|
1158 |
}
|
|
|
1159 |
|
|
|
1160 |
//ShippingPage
|
| 555 |
chandransh |
1161 |
public Map<String, String> getShippingAddressPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName){
|
| 507 |
rajveer |
1162 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
1163 |
|
|
|
1164 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
1165 |
System.out.println("HEADER Snippet generated");
|
|
|
1166 |
|
|
|
1167 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
1168 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
1169 |
|
|
|
1170 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
1171 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
1172 |
|
|
|
1173 |
htmlSnippet.put("SHIPPING_ADDRESS_HEADER", getMyaccountHeaderHtml());
|
|
|
1174 |
System.out.println("SHIPPING_ADDRESS_HEADER Snippet generated");
|
|
|
1175 |
|
|
|
1176 |
htmlSnippet.put("SHIPPING_ADDRESS_DETAILS", getShippingAddressDetailsHtml(userId));
|
|
|
1177 |
System.out.println("SHIPPING_ADDRESS_BAR Snippet generated");
|
|
|
1178 |
|
|
|
1179 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
1180 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
1181 |
|
|
|
1182 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, false));
|
|
|
1183 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
1184 |
|
| 620 |
rajveer |
1185 |
htmlSnippet.put("BROWSE_HISTORY", getBrowseHistoryHtml(userId, isLoggedIn));
|
|
|
1186 |
System.out.println("BROWSE_HISTORY Snippet generated");
|
|
|
1187 |
|
| 507 |
rajveer |
1188 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
1189 |
System.out.println("Footer Snippet generated");
|
|
|
1190 |
|
|
|
1191 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
1192 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
1193 |
|
|
|
1194 |
htmlSnippet.put("JS_FILES", "");
|
|
|
1195 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
1196 |
|
|
|
1197 |
System.out.println("Returning Generated Responce");
|
|
|
1198 |
|
|
|
1199 |
return htmlSnippet;
|
|
|
1200 |
|
|
|
1201 |
}
|
|
|
1202 |
|
|
|
1203 |
private String getShippingHeaderHtml() {
|
|
|
1204 |
String htmlString = "";
|
|
|
1205 |
VelocityContext context = new VelocityContext();
|
|
|
1206 |
String templateFile = "templates/shippingheader.vm";
|
|
|
1207 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1208 |
return htmlString;
|
|
|
1209 |
}
|
|
|
1210 |
|
|
|
1211 |
private String getShippingAddressDetailsHtml(long userId){
|
|
|
1212 |
String htmlString = "";
|
|
|
1213 |
VelocityContext context = new VelocityContext();
|
|
|
1214 |
String templateFile = "templates/shippingaddressdetails.vm";
|
|
|
1215 |
long defaultAddressId = 0;
|
| 517 |
rajveer |
1216 |
List<Address> addresses = null;
|
| 507 |
rajveer |
1217 |
|
|
|
1218 |
UserContextServiceClient userContextServiceClient = null;
|
|
|
1219 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
|
|
1220 |
try {
|
|
|
1221 |
userContextServiceClient = new UserContextServiceClient();
|
|
|
1222 |
userClient = userContextServiceClient.getClient();
|
| 620 |
rajveer |
1223 |
|
|
|
1224 |
addresses = userClient.getAllAddressesForUser(userId);
|
|
|
1225 |
defaultAddressId = userClient.getDefaultAddressId(userId);
|
| 507 |
rajveer |
1226 |
} catch (Exception e) {
|
|
|
1227 |
e.printStackTrace();
|
|
|
1228 |
}
|
| 517 |
rajveer |
1229 |
context.put("defaultAddressId", defaultAddressId+"");
|
| 507 |
rajveer |
1230 |
context.put("addresses", addresses);
|
|
|
1231 |
|
|
|
1232 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1233 |
return htmlString;
|
|
|
1234 |
}
|
|
|
1235 |
|
| 572 |
chandransh |
1236 |
private String getShippingDetailsHtml(long cartId, String errorMsg) {
|
| 507 |
rajveer |
1237 |
String htmlString = "";
|
|
|
1238 |
VelocityContext context = new VelocityContext();
|
|
|
1239 |
String templateFile = "templates/shippingdetails.vm";
|
| 517 |
rajveer |
1240 |
List<Map<String,String>> items = null;
|
| 507 |
rajveer |
1241 |
double totalamount= 0.0;
|
| 517 |
rajveer |
1242 |
List<Address> addresses = null;
|
|
|
1243 |
long defaultAddressId = 0;
|
| 555 |
chandransh |
1244 |
|
| 507 |
rajveer |
1245 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
1246 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
|
|
|
1247 |
UserContextServiceClient userContextServiceClient = null;
|
|
|
1248 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
|
|
1249 |
|
|
|
1250 |
try {
|
|
|
1251 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
1252 |
catalogClient = catalogServiceClient.getClient();
|
|
|
1253 |
userContextServiceClient = new UserContextServiceClient();
|
|
|
1254 |
userClient = userContextServiceClient.getClient();
|
|
|
1255 |
|
|
|
1256 |
|
| 555 |
chandransh |
1257 |
Cart cart = userClient.getCart(cartId);
|
| 507 |
rajveer |
1258 |
List<Line> lineItems = cart.getLines();
|
|
|
1259 |
|
| 517 |
rajveer |
1260 |
if( ! lineItems.isEmpty())
|
|
|
1261 |
{
|
|
|
1262 |
items = new ArrayList<Map<String,String>>();
|
| 507 |
rajveer |
1263 |
|
| 517 |
rajveer |
1264 |
for (Line line : lineItems) {
|
|
|
1265 |
Map<String, String> itemdetail = new HashMap<String, String>();
|
|
|
1266 |
Item item = catalogClient.getItemByCatalogId(line.getItemId());
|
|
|
1267 |
String itemName = ((item.getManufacturerName() != null) ? item.getManufacturerName() + " " : "")
|
|
|
1268 |
+ ((item.getModelName() != null) ? item.getModelName() + " " : "")
|
|
|
1269 |
+ (( item.getModelNumber() != null ) ? item.getModelNumber() : "" );
|
|
|
1270 |
|
|
|
1271 |
itemdetail.put("ITEM_NAME", itemName);
|
|
|
1272 |
itemdetail.put("ITEM_ID", line.getItemId()+"");
|
|
|
1273 |
itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
|
|
|
1274 |
itemdetail.put("MRP", ((int)item.getMrp())+"");
|
| 536 |
rajveer |
1275 |
itemdetail.put("SELLING_PRICE", (int)item.getSellingPrice()+"");
|
|
|
1276 |
itemdetail.put("TOTAL_PRICE", (int)(item.getSellingPrice()*line.getQuantity())+"");
|
| 615 |
chandransh |
1277 |
itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
|
| 536 |
rajveer |
1278 |
totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
|
| 517 |
rajveer |
1279 |
items.add(itemdetail);
|
|
|
1280 |
}
|
| 507 |
rajveer |
1281 |
}
|
|
|
1282 |
|
| 555 |
chandransh |
1283 |
User user = userClient.getUserById(cart.getUserId());
|
|
|
1284 |
addresses = user.getAddresses();
|
|
|
1285 |
defaultAddressId = user.getDefaultAddressId();
|
| 507 |
rajveer |
1286 |
|
|
|
1287 |
}catch (Exception e){
|
|
|
1288 |
e.printStackTrace();
|
|
|
1289 |
}
|
|
|
1290 |
|
|
|
1291 |
context.put("items", items);
|
| 536 |
rajveer |
1292 |
context.put("totalamount", (int)totalamount+"");
|
| 507 |
rajveer |
1293 |
context.put("addresses", addresses);
|
| 517 |
rajveer |
1294 |
context.put("defaultAddressId", defaultAddressId+"");
|
| 572 |
chandransh |
1295 |
context.put("errorMsg", errorMsg);
|
| 507 |
rajveer |
1296 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1297 |
return htmlString;
|
|
|
1298 |
}
|
|
|
1299 |
|
|
|
1300 |
|
|
|
1301 |
//ShoppingCartPage
|
| 572 |
chandransh |
1302 |
public Map<String, String> getShoppingCartPage(long userId, boolean isLoggedIn, long cartId, long itemCount, String userName, String errorMsg){
|
| 507 |
rajveer |
1303 |
Map<String,String> htmlSnippet = new HashMap<String, String>();
|
| 555 |
chandransh |
1304 |
|
|
|
1305 |
htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
|
| 507 |
rajveer |
1306 |
System.out.println("HEADER Snippet generated");
|
|
|
1307 |
|
|
|
1308 |
htmlSnippet.put("MAIN_MENU", getMainMenuHtml());
|
|
|
1309 |
System.out.println("MAIN_MENU Snippet generated");
|
|
|
1310 |
|
|
|
1311 |
htmlSnippet.put("SEARCH_BAR", getSearchBarHtml(itemCount, 0));
|
|
|
1312 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
1313 |
|
|
|
1314 |
htmlSnippet.put("CART_HEADER", getCartHeaderHtml());
|
|
|
1315 |
System.out.println("CART_HEADER Snippet generated");
|
|
|
1316 |
|
| 572 |
chandransh |
1317 |
htmlSnippet.put("CART_DETAILS", getCartDetailsHtml(cartId, errorMsg));
|
| 507 |
rajveer |
1318 |
System.out.println("SEARCH_BAR Snippet generated");
|
|
|
1319 |
|
|
|
1320 |
htmlSnippet.put("CUSTOMER_SERVICE", getCustomerServiceHtml());
|
|
|
1321 |
System.out.println("CUSTOMER_SERVICE Snippet generated");
|
|
|
1322 |
|
| 555 |
chandransh |
1323 |
htmlSnippet.put("MY_RESEARCH", getMyResearchHtml(userId, isLoggedIn));
|
| 507 |
rajveer |
1324 |
System.out.println("MY_RESEARCH Snippet generated");
|
|
|
1325 |
|
|
|
1326 |
htmlSnippet.put("FOOTER", getFooterHtml());
|
|
|
1327 |
System.out.println("Footer Snippet generated");
|
|
|
1328 |
|
|
|
1329 |
// htmlSnippet.put("WIDGET_DIV", getWidgetDiv(productId,"", WidgetType.ACCESSORIES));
|
|
|
1330 |
// System.out.println("ACCESSORIES Snippet generated")
|
|
|
1331 |
|
|
|
1332 |
htmlSnippet.put("JS_FILES", "");
|
|
|
1333 |
htmlSnippet.put("CSS_FILES", "");
|
|
|
1334 |
|
|
|
1335 |
System.out.println("Returning Generated Responce");
|
|
|
1336 |
|
|
|
1337 |
return htmlSnippet;
|
|
|
1338 |
|
|
|
1339 |
}
|
|
|
1340 |
|
|
|
1341 |
private String getCartHeaderHtml() {
|
|
|
1342 |
String htmlString = "";
|
|
|
1343 |
VelocityContext context = new VelocityContext();
|
|
|
1344 |
String templateFile = "templates/cartheader.vm";
|
|
|
1345 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1346 |
return htmlString;
|
|
|
1347 |
}
|
|
|
1348 |
|
|
|
1349 |
|
| 572 |
chandransh |
1350 |
private String getCartDetailsHtml(long cartId, String errorMsg) {
|
| 507 |
rajveer |
1351 |
String htmlString = "";
|
|
|
1352 |
VelocityContext context = new VelocityContext();
|
|
|
1353 |
String templateFile = "templates/cartdetails.vm";
|
| 517 |
rajveer |
1354 |
List<Map<String,String>> items = null;
|
| 507 |
rajveer |
1355 |
double totalamount= 0.0;
|
|
|
1356 |
|
| 555 |
chandransh |
1357 |
UserContextServiceClient userServiceClient = null;
|
|
|
1358 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
| 507 |
rajveer |
1359 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
1360 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
|
|
|
1361 |
|
|
|
1362 |
try {
|
|
|
1363 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
1364 |
catalogClient = catalogServiceClient.getClient();
|
| 555 |
chandransh |
1365 |
userServiceClient = new UserContextServiceClient();
|
|
|
1366 |
userClient = userServiceClient.getClient();
|
| 507 |
rajveer |
1367 |
|
| 555 |
chandransh |
1368 |
Cart cart = userClient.getCart(cartId);
|
| 507 |
rajveer |
1369 |
List<Line> lineItems = cart.getLines();
|
| 517 |
rajveer |
1370 |
if(lineItems.size() != 0){
|
|
|
1371 |
items = new ArrayList<Map<String,String>>();
|
|
|
1372 |
for (Line line : lineItems) {
|
|
|
1373 |
|
|
|
1374 |
Map<String, String> itemdetail = new HashMap<String, String>();
|
|
|
1375 |
Item item = catalogClient.getItemByCatalogId(line.getItemId());
|
|
|
1376 |
|
|
|
1377 |
String itemName = ((item.getManufacturerName() != null) ? item.getManufacturerName() + " " : "")
|
|
|
1378 |
+ ((item.getModelName() != null) ? item.getModelName() + " " : "")
|
|
|
1379 |
+ (( item.getModelNumber() != null ) ? item.getModelNumber() : "" );
|
|
|
1380 |
|
|
|
1381 |
itemdetail.put("ITEM_NAME", itemName);
|
|
|
1382 |
System.out.println(itemdetail.get("ITEM_NAME"));
|
|
|
1383 |
itemdetail.put("ITEM_ID", line.getItemId()+"");
|
|
|
1384 |
itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
|
|
|
1385 |
itemdetail.put("MRP", ((int)item.getMrp())+"");
|
|
|
1386 |
itemdetail.put("SELLING_PRICE", ((int)item.getSellingPrice())+"");
|
|
|
1387 |
itemdetail.put("TOTAL_PRICE", ((int)((item.getSellingPrice()*line.getQuantity())))+"");
|
| 615 |
chandransh |
1388 |
itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
|
| 517 |
rajveer |
1389 |
totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
|
|
|
1390 |
items.add(itemdetail);
|
| 507 |
rajveer |
1391 |
}
|
|
|
1392 |
}
|
|
|
1393 |
|
|
|
1394 |
}catch (Exception e){
|
|
|
1395 |
e.printStackTrace();
|
|
|
1396 |
}
|
|
|
1397 |
|
|
|
1398 |
context.put("items", items);
|
| 517 |
rajveer |
1399 |
context.put("totalamount", ((int)totalamount)+"");
|
| 572 |
chandransh |
1400 |
context.put("errorMsg", errorMsg);
|
| 507 |
rajveer |
1401 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1402 |
return htmlString;
|
|
|
1403 |
}
|
|
|
1404 |
|
|
|
1405 |
|
|
|
1406 |
public long getCatalogIdByItemId(long itemId){
|
|
|
1407 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
1408 |
Client client = null;
|
|
|
1409 |
|
|
|
1410 |
try {
|
|
|
1411 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
1412 |
client = catalogServiceClient.getClient();
|
|
|
1413 |
|
|
|
1414 |
return client.getItem(itemId).getCatalogItemId();
|
|
|
1415 |
} catch (InventoryServiceException e) {
|
|
|
1416 |
// TODO Auto-generated catch block
|
|
|
1417 |
e.printStackTrace();
|
|
|
1418 |
} catch (TException e) {
|
|
|
1419 |
// TODO Auto-generated catch block
|
|
|
1420 |
e.printStackTrace();
|
|
|
1421 |
} catch (Exception e) {
|
|
|
1422 |
// TODO Auto-generated catch block
|
|
|
1423 |
e.printStackTrace();
|
|
|
1424 |
}
|
|
|
1425 |
return -1;
|
|
|
1426 |
}
|
|
|
1427 |
|
|
|
1428 |
public String getHtmlFromVelocity(String templateFile, VelocityContext context){
|
|
|
1429 |
Properties p = new Properties();
|
|
|
1430 |
p.setProperty("resource.loader", "class");
|
|
|
1431 |
p.setProperty("class.resource.loader.class",
|
|
|
1432 |
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
|
|
1433 |
|
|
|
1434 |
|
|
|
1435 |
try {
|
|
|
1436 |
Velocity.init(p);
|
|
|
1437 |
Template template = Velocity.getTemplate(templateFile);
|
|
|
1438 |
if(template != null) {
|
|
|
1439 |
StringWriter writer = new StringWriter();
|
|
|
1440 |
template.merge(context, writer);
|
|
|
1441 |
writer.flush();
|
|
|
1442 |
writer.close();
|
|
|
1443 |
return writer.toString();
|
|
|
1444 |
}
|
|
|
1445 |
|
|
|
1446 |
} catch (ResourceNotFoundException e) {
|
|
|
1447 |
// TODO Auto-generated catch block
|
|
|
1448 |
e.printStackTrace();
|
|
|
1449 |
} catch (ParseErrorException e) {
|
|
|
1450 |
// TODO Auto-generated catch block
|
|
|
1451 |
e.printStackTrace();
|
|
|
1452 |
} catch (MethodInvocationException e) {
|
|
|
1453 |
// TODO Auto-generated catch block
|
|
|
1454 |
e.printStackTrace();
|
|
|
1455 |
} catch (IOException e) {
|
|
|
1456 |
// TODO Auto-generated catch block
|
|
|
1457 |
e.printStackTrace();
|
|
|
1458 |
} catch (Exception e) {
|
|
|
1459 |
// TODO Auto-generated catch block
|
|
|
1460 |
e.printStackTrace();
|
|
|
1461 |
}
|
|
|
1462 |
|
|
|
1463 |
return null;
|
|
|
1464 |
}
|
|
|
1465 |
|
|
|
1466 |
public double getItemMrpByCatalogId(long productId){
|
|
|
1467 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
1468 |
Client client = null;
|
|
|
1469 |
Double itemPrice = 0.0;
|
|
|
1470 |
try {
|
|
|
1471 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
1472 |
client = catalogServiceClient.getClient();
|
|
|
1473 |
Item item = client.getItemByCatalogId(productId);
|
|
|
1474 |
itemPrice = item.getMrp();
|
|
|
1475 |
}
|
|
|
1476 |
catch(Exception e){
|
|
|
1477 |
e.printStackTrace();
|
|
|
1478 |
}
|
|
|
1479 |
return itemPrice;
|
|
|
1480 |
}
|
|
|
1481 |
|
|
|
1482 |
public double getItemSellingPriceByCatalogId(long productId){
|
|
|
1483 |
CatalogServiceClient catalogServiceClient = null;
|
|
|
1484 |
Client client = null;
|
|
|
1485 |
Double itemPrice = 0.0;
|
|
|
1486 |
try {
|
|
|
1487 |
catalogServiceClient = new CatalogServiceClient();
|
|
|
1488 |
client = catalogServiceClient.getClient();
|
|
|
1489 |
Item item = client.getItemByCatalogId(productId);
|
|
|
1490 |
itemPrice = item.getSellingPrice();
|
|
|
1491 |
}
|
|
|
1492 |
catch(Exception e){
|
|
|
1493 |
e.printStackTrace();
|
|
|
1494 |
}
|
|
|
1495 |
return itemPrice;
|
|
|
1496 |
}
|
|
|
1497 |
|
| 517 |
rajveer |
1498 |
|
|
|
1499 |
public String getCategoryHeaderSnippet() {
|
|
|
1500 |
String htmlString = "";
|
|
|
1501 |
VelocityContext context = new VelocityContext();
|
|
|
1502 |
String templateFile = "templates/categoryheader.vm";
|
|
|
1503 |
htmlString = getHtmlFromVelocity(templateFile, context);
|
|
|
1504 |
return htmlString;
|
|
|
1505 |
}
|
|
|
1506 |
|
| 507 |
rajveer |
1507 |
|
|
|
1508 |
|
|
|
1509 |
}
|
|
|
1510 |
|