Subversion Repositories SmartDukaan

Rev

Rev 12616 | Rev 13142 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
410 rajveer 1
package in.shop2020.serving.controllers;
2
 
2263 vikas 3
import in.shop2020.datalogger.EventType;
7839 rajveer 4
import in.shop2020.logistics.DeliveryType;
5945 mandeep.dh 5
import in.shop2020.model.v1.catalog.CatalogService.Client;
6903 anupam.sin 6
import in.shop2020.model.v1.catalog.Insurer;
9301 kshitij.so 7
import in.shop2020.model.v1.catalog.InsurerType;
1981 varun.gupt 8
import in.shop2020.model.v1.catalog.Item;
9
import in.shop2020.model.v1.user.Cart;
10
import in.shop2020.model.v1.user.Line;
555 chandransh 11
import in.shop2020.model.v1.user.ShoppingCartException;
572 chandransh 12
import in.shop2020.model.v1.user.UserContextService;
11980 amit.gupta 13
import in.shop2020.serving.interceptors.UserInterceptor;
3599 rajveer 14
import in.shop2020.serving.services.ContentServingService;
2137 chandransh 15
import in.shop2020.serving.utils.FormattingUtils;
3599 rajveer 16
import in.shop2020.serving.utils.SnippetType;
3126 rajveer 17
import in.shop2020.thrift.clients.CatalogClient;
18
import in.shop2020.thrift.clients.UserClient;
2511 vikas 19
import in.shop2020.utils.DataLogger;
410 rajveer 20
 
2419 vikas 21
import java.util.ArrayList;
22
import java.util.HashMap;
23
import java.util.List;
24
import java.util.Map;
25
import java.util.StringTokenizer;
26
 
6736 amit.gupta 27
import org.apache.commons.lang.StringUtils;
832 rajveer 28
import org.apache.log4j.Logger;
1614 rajveer 29
import org.apache.struts2.convention.annotation.Action;
4046 varun.gupt 30
import org.apache.struts2.convention.annotation.Actions;
1614 rajveer 31
import org.apache.struts2.convention.annotation.InterceptorRef;
801 rajveer 32
import org.apache.struts2.convention.annotation.Result;
1614 rajveer 33
import org.apache.struts2.convention.annotation.Results;
410 rajveer 34
import org.apache.struts2.interceptor.ParameterAware;
35
import org.apache.thrift.TException;
36
 
1614 rajveer 37
 
38
@Results({
9301 kshitij.so 39
	@Result(name = "index", location = "cart-index.vm"),
4046 varun.gupt 40
	@Result(name="redirect", type="redirectAction", params = {"actionName" , "cart"}),
1614 rajveer 41
	@Result(name="failure", location="cart-failure.vm"),
42
	@Result(name="success", location="cart-success.vm")
43
})
44
 
507 rajveer 45
public class CartController extends BaseController implements ParameterAware{
9301 kshitij.so 46
 
410 rajveer 47
	private static final long serialVersionUID = 1L;
1957 vikas 48
	private static Logger log = Logger.getLogger(Class.class);
507 rajveer 49
	Map<String, String[]> reqparams = null;
9301 kshitij.so 50
 
4046 varun.gupt 51
	private int variationId = 0;
9301 kshitij.so 52
	private String totalamount;
53
 
9840 amit.gupta 54
	private String errorMsg = null;
3970 varun.gupt 55
	private String cartMsg = "";
9301 kshitij.so 56
 
1981 varun.gupt 57
	private String pincode = "110001";
9301 kshitij.so 58
 
1981 varun.gupt 59
	private String couponCode = null;
9301 kshitij.so 60
 
2137 chandransh 61
	private String discountedAmount;
9301 kshitij.so 62
 
2810 rajveer 63
	private long itemId;
9301 kshitij.so 64
	private String insuranceResult;
65
 
66
	private boolean toInsure;
67
	private long productId;
68
 
69
	private int insurerType; 
70
 
410 rajveer 71
	public CartController(){
507 rajveer 72
		super();
73
	}
9301 kshitij.so 74
 
75
	// GET /cart
4046 varun.gupt 76
	@Actions({
77
		@Action(value="cart", interceptorRefs={@InterceptorRef("myDefault")}),
4453 varun.gupt 78
		@Action(value="cart1", interceptorRefs={@InterceptorRef("myDefault")})
4046 varun.gupt 79
	})
4344 anupam.sin 80
	public String index()  {
4046 varun.gupt 81
		this.setVariationId(request.getRequestURI());
82
		log.info(this.getVariationId());
1614 rajveer 83
 
4046 varun.gupt 84
		long cartId = userinfo.getCartId();
9301 kshitij.so 85
 
86
		if(cartId != -1){
87
			try {
88
				UserContextService.Client userClient = (new UserClient()).getClient();
11980 amit.gupta 89
				String cc = null; 
90
				if(userinfo.isPrivateDealUser() && !cookiesMap.containsKey(UserInterceptor.DEAL_COUPON_REMOVED)) {
91
					cc="saholicdeals";
92
				}
12788 amit.gupta 93
				List<String> cartResponse  = userClient.validateCartWithDealerCoupon(cartId, sourceId, cc);
9301 kshitij.so 94
				errorMsg = cartResponse.get(0);
95
				log.info("Cart Change/EMI Message rcvd from the service is:" + errorMsg);
11923 amit.gupta 96
				if(cartResponse.get(1)!=null & !cartResponse.get(1).equals("")){
11917 amit.gupta 97
					addActionMessage(cartResponse.get(1));
98
				}
9301 kshitij.so 99
 
100
				// As per ticket #119 in trac
101
				Cart cart = userClient.getCart(cartId);
102
				int totalItems = cart.getLinesSize();
103
				double totalAmount = cart.getTotalPrice();
4046 varun.gupt 104
				userinfo.setTotalItems(totalItems);
105
				userinfo.setTotalAmount(totalAmount);
9301 kshitij.so 106
			} catch (Exception e) {
107
				// This exception can be ignored for showing the cart. Not so
108
				// innocent when this occurs at the time of checkout or when the
109
				// user is proceeding to pay.
110
				log.warn("Unable to validate the cart: ", e);
111
			}
112
		}
3970 varun.gupt 113
		return "index";
114
	}
4046 varun.gupt 115
 
572 chandransh 116
	// POST /entity
1614 rajveer 117
 
118
	@Action(value="addtocart",interceptorRefs={@InterceptorRef("createuser"),@InterceptorRef("myDefault")})
572 chandransh 119
	public String create() {
120
		log.info("CartController.create");
555 chandransh 121
 
572 chandransh 122
		printParams();
123
 
124
		long userId = userinfo.getUserId();
125
		long cartId = userinfo.getCartId();
126
 
1614 rajveer 127
		log.info("user id is " + userId);
128
		log.info("cart id is " + cartId);
9301 kshitij.so 129
 
572 chandransh 130
		log.info("item id is " + this.reqparams.get("productid"));
9301 kshitij.so 131
 
637 rajveer 132
		String itemIds = "";
572 chandransh 133
		if (this.reqparams.get("productid") != null) {
134
			itemIds = this.reqparams.get("productid")[0];
637 rajveer 135
		}else{
136
			return "failure";
572 chandransh 137
		}
9301 kshitij.so 138
 
572 chandransh 139
		StringTokenizer tokenizer = new StringTokenizer(itemIds, "_");
140
		while (tokenizer.hasMoreTokens()) {
2810 rajveer 141
			itemId = Long.parseLong(tokenizer.nextToken());
572 chandransh 142
 
143
			try {
3126 rajveer 144
				UserClient userServiceClient = new UserClient();
572 chandransh 145
				UserContextService.Client userClient = userServiceClient.getClient();
762 rajveer 146
				if (cartId == 0){
5342 rajveer 147
					cartId = userClient.getUserById(userId).getActiveCartId();
762 rajveer 148
				}
3561 rajveer 149
				// If we add multiple items to cart and get some message from service, 
150
				// first message to be preserved and presented to the user.
2099 rajveer 151
				if(cartMsg.equals("")){
9301 kshitij.so 152
					cartMsg = userClient.addItemToCart(cartId, itemId, 1, sourceId);
153
				}else{
154
					userClient.addItemToCart(cartId, itemId, 1, sourceId);
155
				}
762 rajveer 156
				userinfo.setCartId(cartId);
157
				int totalItems = userClient.getCart(cartId).getLinesSize();
158
				userinfo.setTotalItems(totalItems);
572 chandransh 159
			} catch (TException e) {
9301 kshitij.so 160
				log.error("Unable to create or add to cart because of: ", e);
572 chandransh 161
			} catch (Exception e) {
9301 kshitij.so 162
				log.error("Unable to create or add to cart because of: ", e);
507 rajveer 163
			}
164
 
572 chandransh 165
		}
12616 anikendra 166
//		DataLogger.logData(EventType.ADD_TO_CART, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
167
//				Long.toString(cartId), itemIds);
572 chandransh 168
		return "success";
169
	}		
170
 
1614 rajveer 171
 
4217 varun.gupt 172
	// DELETE /entity
173
	public String destroy()	{
174
		log.info("CartController.destroy");
175
		printParams();
176
		log.info("item id is " + this.request.getParameter("productid"));
9301 kshitij.so 177
 
4217 varun.gupt 178
		String itemIdString = this.request.getParameter("productid");
179
		itemId = Long.parseLong(itemIdString);
180
 
181
		if(userinfo.getCartId() == -1)	{
182
			log.info("Cart does not exist. Nothing to delete.");
183
		} else	{
184
			if(deleteItemFromCart(userinfo.getCartId(), itemId, userinfo.getUserId(), userinfo.isSessionId()))	{
185
				updateUserSessionInfo(userinfo.getCartId());
12616 anikendra 186
//				DataLogger.logData(EventType.DELETE_FROM_CART, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
187
//						Long.toString(userinfo.getCartId()), itemIdString);
4217 varun.gupt 188
				return "redirect";
507 rajveer 189
			}
190
		}
4217 varun.gupt 191
		return "redirect";
192
	}
193
 
194
	// DELETE /entity
195
	public String update() {
196
		log.info("CartController.update");
197
		printParams();
198
		log.info("item id is " + this.request.getParameter("productid"));
199
		log.info("item quantity is " + this.request.getParameter("quantity"));
200
		String itemIdString = this.request.getParameter("productid");
201
		String quantityString = this.request.getParameter("quantity");
202
		long itemId = Long.parseLong(itemIdString);
203
		long quantity = Long.parseLong(quantityString);
204
 
205
		if(quantity <= 0)	{
206
			log.info("Not valid item quantity. Unable to change item quantity.");
207
		} else	{
208
			if(updateItemQuantityInCart(userinfo.getCartId(), itemId, quantity))	{
12616 anikendra 209
//				DataLogger.logData(EventType.UPDATE_CART_QUANTITY, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
210
//						Long.toString(userinfo.getCartId()), Long.toString(itemId), Long.toString(quantity));
4217 varun.gupt 211
				return "redirect";
507 rajveer 212
			}
4217 varun.gupt 213
		}
12616 anikendra 214
//		DataLogger.logData(EventType.UPDATE_CART_QUANTITY_FAILED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
215
//				Long.toString(userinfo.getCartId()), Long.toString(itemId), Long.toString(quantity));
4217 varun.gupt 216
		addActionError("Unable to update the quantity");
217
		return "redirect";
218
	}
507 rajveer 219
 
9301 kshitij.so 220
	public void printParams(){
221
		for(String param : reqparams.keySet()) {
222
			log.info("param name is " + param);
223
			log.info("param first is " + reqparams.get(param)[0]);
224
		}
225
		log.info(this.reqparams);
226
	}
227
 
762 rajveer 228
	private boolean updateItemQuantityInCart(long cartId, long itemId, long quantity){
229
		try {
3126 rajveer 230
			UserClient userContextServiceClient = new UserClient();
762 rajveer 231
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
232
 
3562 rajveer 233
			userClient.addItemToCart(cartId, itemId, quantity, sourceId);
762 rajveer 234
			return true;
235
		} catch (ShoppingCartException e) {
9301 kshitij.so 236
			log.error("Unable to update the item quantity in the cart: ", e);
762 rajveer 237
		} catch (TException e) {
9301 kshitij.so 238
			log.error("Unable to update the item quantity in the cart: ", e);
762 rajveer 239
		} catch (Exception e) {
9301 kshitij.so 240
			log.error("Unable to update the item quantity in the cart: ", e);
762 rajveer 241
		}
242
		return false;
243
	}
9301 kshitij.so 244
 
762 rajveer 245
	private boolean deleteItemFromCart(long cartId, long catalogItemId, long userId, boolean isSessionId){
246
		try {
3126 rajveer 247
			UserClient userContextServiceClient = new UserClient();
762 rajveer 248
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
9301 kshitij.so 249
 
762 rajveer 250
			userClient.deleteItemFromCart(cartId, catalogItemId);
4217 varun.gupt 251
			return true;
762 rajveer 252
		} catch (ShoppingCartException e) {
9301 kshitij.so 253
			log.error("Unable to delete item from cart: ", e);
762 rajveer 254
		} catch (TException e) {
9301 kshitij.so 255
			log.error("Unable to delete item from cart: ", e);
762 rajveer 256
		} catch (Exception e) {
9301 kshitij.so 257
			log.error("Unable to delete item from cart: ", e);
762 rajveer 258
		}
9301 kshitij.so 259
 
762 rajveer 260
		return false;
261
	}
262
 
3830 chandransh 263
	private void updateUserSessionInfo(long cartId) {
3126 rajveer 264
		UserClient userContextServiceClient = null;
762 rajveer 265
		try {
3126 rajveer 266
			userContextServiceClient = new UserClient();
762 rajveer 267
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
3830 chandransh 268
			Cart cart = userClient.getCart(cartId);
269
			userinfo.setTotalItems(cart.getLinesSize());
270
			userinfo.setTotalAmount(cart.getTotalPrice());
762 rajveer 271
		} catch (ShoppingCartException e) {
9301 kshitij.so 272
			log.error("Unable to get the cart from service: ", e);
762 rajveer 273
		} catch (TException e) {
9301 kshitij.so 274
			log.error("Unable to get the cart from service: ", e);
762 rajveer 275
		} catch (Exception e) {
9301 kshitij.so 276
			log.error("Unable to get the cart from service: ", e);
762 rajveer 277
		}
278
	}
9301 kshitij.so 279
 
1981 varun.gupt 280
	public List<Map<String,String>> getCartItems() {
9301 kshitij.so 281
		List<Map<String,String>> items = null;
762 rajveer 282
 
9301 kshitij.so 283
		UserClient userServiceClient = null;
284
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
285
		CatalogClient catalogServiceClient  = null;
286
		in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = null;
762 rajveer 287
 
9301 kshitij.so 288
		FormattingUtils formattingUtils = new FormattingUtils();
1981 varun.gupt 289
 
9301 kshitij.so 290
		try    {
291
			catalogServiceClient = new CatalogClient();
292
			catalogClient = catalogServiceClient.getClient();
293
			userServiceClient = new UserClient();
294
			userClient = userServiceClient.getClient();
295
 
296
			pincode = userClient.getDefaultPincode(userinfo.getUserId());
297
			Cart cart = userClient.getCart(userinfo.getCartId());
298
			List<Line> lineItems = cart.getLines();
299
			double totalInsuranceAmount = 0.0;
300
			boolean isAnyItemInsured = false;
301
			if(lineItems.size() != 0)  {
302
				items = new ArrayList<Map<String,String>>();
303
 
304
				for (Line line : lineItems)    {
305
					Map<String, String> itemdetail = new HashMap<String, String>();
306
 
307
					double insuranceAmount = 0;
308
					Item item = catalogClient.getItemForSource(line.getItemId(), sourceId);
309
					long prefferedInsurer  = catalogClient.getPrefferedInsurerForItem(line.getItemId(), InsurerType.DEVICE);
310
					long dataProtectionInsurer = catalogClient.getPrefferedInsurerForItem(line.getItemId(), InsurerType.DATA);
311
					Insurer insurer = null;
312
 
313
					if(line.getInsurer() != 0) {
314
						insuranceAmount = catalogClient.getInsuranceAmount(item.getId(), 
315
								(line.getDiscountedPrice() == 0 ? line.getActualPrice() : line.getDiscountedPrice()),
316
								prefferedInsurer, 
317
								(long)line.getQuantity());
318
						isAnyItemInsured = true;
319
					} else if (prefferedInsurer != 0) {
320
						insuranceAmount = catalogClient.getInsuranceAmount(item.getId(), 
321
								(line.getDiscountedPrice() == 0 ? line.getActualPrice() : line.getDiscountedPrice()),
322
								prefferedInsurer, 
323
								(long)line.getQuantity());
324
					} else {
325
						insuranceAmount = 0;
326
					}
327
 
328
					double oneAssistAmount = 0;
329
 
330
					if (line.getDataProtectionInsurer()!=0){
331
						/*
332
						 * We can call service to get amount for one assist.
333
                    	oneAssistAmount = catalogClient.getInsuranceAmount(item.getId(), 
334
								(line.getDiscountedPrice() == 0 ? line.getActualPrice() : line.getDiscountedPrice()),
335
								dataProtectionInsurer, 
336
								(long)line.getQuantity());*/
337
						oneAssistAmount =449.0 * line.getQuantity();
338
					}
339
					else if (dataProtectionInsurer != 0) {
340
						/*oneAssistAmount = catalogClient.getInsuranceAmount(item.getId(), 
341
								(line.getDiscountedPrice() == 0 ? line.getActualPrice() : line.getDiscountedPrice()),
342
								dataProtectionInsurer, 
343
								(long)line.getQuantity());
344
						 */
345
						oneAssistAmount =449.0 * line.getQuantity();
346
					} else {
347
						oneAssistAmount = 0;
348
					}
349
 
350
					String itemName = ((item.getBrand() != null) ? item.getBrand() + " " : "")
351
					+ ((item.getModelName() != null) ? item.getModelName() + " " : "") 
352
					+ (( item.getModelNumber() != null ) ? item.getModelNumber() + " " : "" );
353
 
354
					String itemColor = "";
355
					if(item.getColor() != null && !item.getColor().trim().equals("NA"))
356
						itemColor = "Color - " + item.getColor();
357
 
358
					itemdetail.put("ITEM_NAME", itemName);
359
					itemdetail.put("ITEM_COLOR", itemColor);
360
					itemdetail.put("ITEM_ID", line.getItemId() + "");
361
					itemdetail.put("CATALOG_ID", item.getCatalogItemId() + "");
362
					itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity()) + "");
363
					itemdetail.put("MRP", formattingUtils.formatPrice(item.getMrp()));
364
					itemdetail.put("SELLING_PRICE", formattingUtils.formatPrice(item.getSellingPrice()));
365
					itemdetail.put("TOTAL_PRICE", formattingUtils.formatPrice(((item.getSellingPrice() * line.getQuantity()))));
366
					itemdetail.put("SHIPPING_TIME", EstimateController.getDeliveryDateString(line.getEstimate(), DeliveryType.PREPAID));
367
					itemdetail.put("COD_SHIPPING_TIME", EstimateController.getDeliveryDateString(line.getEstimate(), DeliveryType.COD));
11653 amit.gupta 368
					itemdetail.put("BEST_DEAL_TEXT", line.isSetDealText()? line.getDealText() : item.getBestDealText());
9301 kshitij.so 369
					itemdetail.put("IS_INSURABLE", prefferedInsurer + "");
6903 anupam.sin 370
					itemdetail.put("IS_INSURED", (line.getInsurer() == 0 ? false : true) + "");
371
					itemdetail.put("INSURANCE_AMOUNT", insuranceAmount + "");
9301 kshitij.so 372
					itemdetail.put("DATA_PROTECTION_INSURER", dataProtectionInsurer + "");
373
					itemdetail.put("IS_DATA_PROTECTED", (line.getDataProtectionInsurer() == 0 ? false : true) + "");
374
					itemdetail.put("ONE_ASSIST_AMOUNT", oneAssistAmount + "");
1981 varun.gupt 375
 
6903 anupam.sin 376
					totalInsuranceAmount += insuranceAmount;
9301 kshitij.so 377
					items.add(itemdetail);
378
				}
379
			}
380
 
381
			//            if(isAnyItemInsured == false) {
382
			//                totalamount = formattingUtils.formatPrice(cart.getTotalPrice() + totalInsuranceAmount);
383
			//                discountedAmount = formattingUtils.formatPrice(cart.getDiscountedPrice() + totalInsuranceAmount);
384
			//            } else {
385
			totalamount = formattingUtils.formatPrice(cart.getTotalPrice());
386
			discountedAmount = formattingUtils.formatPrice(cart.getDiscountedPrice());
387
			//            }
388
 
389
			couponCode = cart.getCouponCode() == null ? "" : cart.getCouponCode();
390
		} catch (Exception e){
391
			log.error("Unable to get the cart details becasue of: ", e);
392
		}
393
		return items;
507 rajveer 394
	}
9301 kshitij.so 395
 
6903 anupam.sin 396
	public String insureItem() {
9301 kshitij.so 397
		//TODO : Call a method in userservice that insures the item.
398
		insuranceResult = "";
399
		try {
400
			UserContextService.Client usc = new UserClient().getClient();
401
			if(usc.insureItem(productId, userinfo.getCartId(), toInsure, insurerType)) {
402
				setInsuranceResult("SUCCESS");
403
			} else {
404
				setInsuranceResult("FAILURE");
405
			}
406
		} catch (Exception e) {
407
			log.error("Unable to insure item : " + productId + " for cart : " + userinfo.getCartId(), e);
408
			setInsuranceResult("FAILURE");
409
		}
410
		return "insurance-result";
6903 anupam.sin 411
	}
1981 varun.gupt 412
 
3080 rajveer 413
	public long getItemId(){
414
		return this.itemId;
415
	}
9301 kshitij.so 416
 
2137 chandransh 417
	public String getTotalAmount() {
9301 kshitij.so 418
		return totalamount;
1981 varun.gupt 419
	}
9301 kshitij.so 420
 
1981 varun.gupt 421
	public String getPinCode() {
9301 kshitij.so 422
		return pincode;
507 rajveer 423
	}
9301 kshitij.so 424
 
1981 varun.gupt 425
	public String getCouponCode()  {
9301 kshitij.so 426
		return couponCode;
1981 varun.gupt 427
	}
9301 kshitij.so 428
 
1981 varun.gupt 429
	public String getDiscountedAmount()   {
9301 kshitij.so 430
		return discountedAmount;
1981 varun.gupt 431
	}
9301 kshitij.so 432
 
1981 varun.gupt 433
	public String getErrorMsg()    {
9301 kshitij.so 434
		return errorMsg;
1981 varun.gupt 435
	}
9301 kshitij.so 436
 
507 rajveer 437
	public long getNumberOfItems(){
438
		return userinfo.getTotalItems();
439
	}
650 rajveer 440
 
2036 rajveer 441
	public String getCartMsg(){
9301 kshitij.so 442
		if(cartMsg.equals("")){
443
			return null;
444
		}
445
		return cartMsg;
2036 rajveer 446
	}
9301 kshitij.so 447
 
2810 rajveer 448
	public String getSnippets(){
9301 kshitij.so 449
		String snippets = "";
3126 rajveer 450
		CatalogClient csc;
2810 rajveer 451
		try {
3126 rajveer 452
			csc = new CatalogClient();
2810 rajveer 453
			List<Long> similarItems = csc.getClient().getSimilarItemsCatalogIds(0, 4, itemId);
454
			for(Long catalogId: similarItems){
3599 rajveer 455
				snippets = snippets + ContentServingService.getSnippet(SnippetType.WIDGET_SNIPPET, catalogId+"", sourceId);
2810 rajveer 456
			}
457
		} catch (Exception e) {
458
			log.error("Unable to initialise Catalogservice Client");
459
		}	    
9301 kshitij.so 460
		return snippets;
461
	}
462
 
650 rajveer 463
	@Override
464
	public void setParameters(Map<String, String[]> parameters) {
465
		this.reqparams = parameters;	
466
	}
9301 kshitij.so 467
 
3903 varun.gupt 468
	@Override
469
	public String getHeaderSnippet() {
470
		String url = request.getQueryString();
471
		if (url == null) {
472
			url = "";
473
		} else {
474
			url = "?" + url;
475
		}
476
		url = request.getRequestURI() + url;
11829 amit.gupta 477
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getEmail(), userinfo.getTotalItems(), url , 0, false, userinfo.isPrivateDealUser());
3903 varun.gupt 478
	}
9301 kshitij.so 479
 
4222 varun.gupt 480
	public boolean isUserLoggedIn()	{
481
		return userinfo.isLoggedIn();
482
	}
9301 kshitij.so 483
 
4046 varun.gupt 484
	public void setVariationId(String uri)	{
485
		if (uri.equals("/cart1"))	{
486
			this.variationId = 1;
487
		}
3970 varun.gupt 488
	}
9301 kshitij.so 489
 
4046 varun.gupt 490
	public int getVariationId()	{
491
		return this.variationId;
3970 varun.gupt 492
	}
9301 kshitij.so 493
 
5228 amit.gupta 494
	public String getActionMessage(){
495
		if(cartMsg.contains("out of stock")){
496
			return "Notify me when this product is in stock.";
497
		}else {
498
			return "Notify me when this product is available.";
499
		}
500
	}
9301 kshitij.so 501
 
5228 amit.gupta 502
	public String getOfferNote(){
503
		String note = null;
504
		if(cartMsg.contains("out of stock")){
505
			return note;
506
		}
507
		else {
508
			try {
9301 kshitij.so 509
				CatalogClient catalogServiceClient = new CatalogClient();
510
				Client catalogClient = catalogServiceClient.getClient();
511
				Item it = catalogClient.getItem(itemId);
512
				note = it.getBestDealText();
5228 amit.gupta 513
			} catch (Exception e)  {
514
				log.error("Unable to get the offertext because of: ", e);
515
			}
516
		}
517
		return note;
518
	}
6903 anupam.sin 519
 
9301 kshitij.so 520
	public String getInsuranceResult() {
521
		return insuranceResult;
522
	}
6903 anupam.sin 523
 
9301 kshitij.so 524
	public void setInsuranceResult(String insuranceResult) {
525
		this.insuranceResult = insuranceResult;
526
	}
6903 anupam.sin 527
 
9301 kshitij.so 528
	public void setToInsure(boolean toInsure) {
529
		this.toInsure = toInsure;
530
	}
6903 anupam.sin 531
 
9301 kshitij.so 532
	public boolean getToInsure() {
533
		return toInsure;
534
	}
6903 anupam.sin 535
 
9301 kshitij.so 536
	public long getProductId() {
537
		return productId;
538
	}
6903 anupam.sin 539
 
9301 kshitij.so 540
	public void setProductId(long productId) {
541
		this.productId = productId;
542
	}
543
 
544
	public void setInsurerType(int insurerType) {
545
		log.info("set insurerType"+insurerType);
546
		this.insurerType = insurerType;
547
	}
548
 
549
	public long getInsurerType() {
550
		return insurerType;
551
	}
5228 amit.gupta 552
}