Subversion Repositories SmartDukaan

Rev

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