Subversion Repositories SmartDukaan

Rev

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

Rev 507 Rev 517
Line 5... Line 5...
5
import java.io.FileInputStream;
5
import java.io.FileInputStream;
6
import java.io.FileNotFoundException;
6
import java.io.FileNotFoundException;
7
import java.io.IOException;
7
import java.io.IOException;
8
import java.io.InputStreamReader;
8
import java.io.InputStreamReader;
9
import java.io.StringWriter;
9
import java.io.StringWriter;
-
 
10
import java.text.DateFormat;
-
 
11
import java.text.SimpleDateFormat;
10
import java.util.ArrayList;
12
import java.util.ArrayList;
-
 
13
import java.util.Calendar;
11
import java.util.Date;
14
import java.util.Date;
12
import java.util.HashMap;
15
import java.util.HashMap;
13
import java.util.List;
16
import java.util.List;
14
import java.util.Map;
17
import java.util.Map;
15
import java.util.Properties;
18
import java.util.Properties;
Line 276... Line 279...
276
			catalogServiceClient = new CatalogServiceClient();
279
			catalogServiceClient = new CatalogServiceClient();
277
			client = catalogServiceClient.getClient();
280
			client = catalogServiceClient.getClient();
278
			List<Long> items = client.getBestSellers();
281
			List<Long> items = client.getBestSellers();
279
			List<String> itemList = new ArrayList<String>();
282
			List<String> itemList = new ArrayList<String>();
280
			for(Long item: items){
283
			for(Long item: items){
281
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item+"_snippet.html"));
284
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
282
			}
285
			}
283
			context.put("itemList", itemList);
286
			context.put("itemList", itemList);
284
			
287
			
285
		} catch(Exception e){
288
		} catch(Exception e){
286
			
289
			
287
		}
290
		}
288
 
291
 
289
		
292
		
290
		htmlString = getHtmlFromVelocity(templateFile, context);
293
		htmlString = getHtmlFromVelocity(templateFile, context);
291
		return htmlString;	}
294
		return htmlString;	
-
 
295
	}
292
 
296
 
293
 
297
 
294
	private String getLatestArrivalsHtml() {
298
	private String getLatestArrivalsHtml() {
295
		String htmlString = "";
299
		String htmlString = "";
296
		VelocityContext context = new VelocityContext();
300
		VelocityContext context = new VelocityContext();
Line 303... Line 307...
303
			catalogServiceClient = new CatalogServiceClient();
307
			catalogServiceClient = new CatalogServiceClient();
304
			client = catalogServiceClient.getClient();
308
			client = catalogServiceClient.getClient();
305
			List<Long> items = client.getLatestArrivals();
309
			List<Long> items = client.getLatestArrivals();
306
			List<String> itemList = new ArrayList<String>();
310
			List<String> itemList = new ArrayList<String>();
307
			for(Long item: items){
311
			for(Long item: items){
308
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item+"_snippet.html"));
312
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
309
			}
313
			}
310
			context.put("itemList", itemList);
314
			context.put("itemList", itemList);
311
			
315
			
312
		} catch(Exception e){
316
		} catch(Exception e){
313
			
317
			
Line 331... Line 335...
331
			catalogServiceClient = new CatalogServiceClient();
335
			catalogServiceClient = new CatalogServiceClient();
332
			client = catalogServiceClient.getClient();
336
			client = catalogServiceClient.getClient();
333
			List<Long> items = client.getBestDeals();
337
			List<Long> items = client.getBestDeals();
334
			List<String> itemList = new ArrayList<String>();
338
			List<String> itemList = new ArrayList<String>();
335
			for(Long item: items){
339
			for(Long item: items){
336
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item+"_snippet.html"));
340
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
337
			}
341
			}
338
			context.put("itemList", itemList);
342
			context.put("itemList", itemList);
339
			
343
			
340
		} catch(Exception e){
344
		} catch(Exception e){
341
			
345
			
Line 344... Line 348...
344
		htmlString = getHtmlFromVelocity(templateFile, context);
348
		htmlString = getHtmlFromVelocity(templateFile, context);
345
		return htmlString;
349
		return htmlString;
346
	}
350
	}
347
 
351
 
348
 
352
 
349
	private String getFooterHtml() {
353
	public String getFooterHtml() {
350
		String htmlString = "";
354
		String htmlString = "";
351
		VelocityContext context = new VelocityContext();
355
		VelocityContext context = new VelocityContext();
352
		String templateFile = "templates/footer.vm";
356
		String templateFile = "templates/footer.vm";
353
		htmlString = getHtmlFromVelocity(templateFile, context);
357
		htmlString = getHtmlFromVelocity(templateFile, context);
354
		return htmlString;
358
		return htmlString;
Line 372... Line 376...
372
		return getWidgetDiv( "", WidgetType.RECOMMENDED_ITEMS, "recommendations.vm");
376
		return getWidgetDiv( "", WidgetType.RECOMMENDED_ITEMS, "recommendations.vm");
373
	}
377
	}
374
 
378
 
375
 
379
 
376
 
380
 
377
	private String getMyResearchHtml(long userId, boolean isSessionId) {
381
	public String getMyResearchHtml(long userId, boolean isSessionId) {
378
		return getWidgetDiv(userId+"", WidgetType.MY_RESEARCH, "myresearch.vm");
382
		return getWidgetDiv(userId+"", WidgetType.MY_RESEARCH, "myresearch.vm");
379
	}
383
	}
380
 
384
 
381
	private String getBrowseHistoryHtml(long userId, boolean isSessionId) {
385
	private String getBrowseHistoryHtml(long userId, boolean isSessionId) {
382
		return getWidgetDiv(userId+"", WidgetType.BROWSE_HISTORY, "browsehistory.vm");
386
		return getWidgetDiv(userId+"", WidgetType.BROWSE_HISTORY, "browsehistory.vm");
383
	}
387
	}
384
 
388
 
385
	private String getCustomerServiceHtml() {
389
	public String getCustomerServiceHtml() {
386
		String htmlString = "";
390
		String htmlString = "";
387
		VelocityContext context = new VelocityContext();
391
		VelocityContext context = new VelocityContext();
388
		String templateFile = "templates/customerservice.vm";
392
		String templateFile = "templates/customerservice.vm";
389
		htmlString = getHtmlFromVelocity(templateFile, context);
393
		htmlString = getHtmlFromVelocity(templateFile, context);
390
		return htmlString;
394
		return htmlString;
Line 432... Line 436...
432
//		return htmlString;
436
//		return htmlString;
433
//	}
437
//	}
434
 
438
 
435
	private String getSlideGuideHtml(long productId) {
439
	private String getSlideGuideHtml(long productId) {
436
		StringBuilder htmlString = new StringBuilder();
440
		StringBuilder htmlString = new StringBuilder();
437
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + ".html";
441
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "SlideGuide.html";
438
		File f = new File(filename);
442
		File f = new File(filename);
439
		
443
		
440
		
444
		
441
		FileInputStream fis = null;
445
		FileInputStream fis = null;
442
		try {
446
		try {
Line 465... Line 469...
465
		}
469
		}
466
		
470
		
467
		return htmlString.toString();
471
		return htmlString.toString();
468
	}
472
	}
469
 
473
 
470
	private String getProductSummaryHtml(long productId) {
474
	public String getProductSummaryHtml(long productId) {
471
		StringBuilder htmlString = new StringBuilder();
475
		StringBuilder htmlString = new StringBuilder();
472
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + "_mainsummary.html";
476
		String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "ProductDetail.html";
473
		File f = new File(filename);
477
		File f = new File(filename);
474
		
478
		
475
		
479
		
476
		FileInputStream fis = null;
480
		FileInputStream fis = null;
477
		try {
481
		try {
Line 572... Line 576...
572
		return htmlString;
576
		return htmlString;
573
	}
577
	}
574
 
578
 
575
 
579
 
576
 
580
 
577
	private String getMainMenuHtml() {
581
	public String getMainMenuHtml() {
578
		String htmlString = "";
582
		String htmlString = "";
579
		VelocityContext context = new VelocityContext();
583
		VelocityContext context = new VelocityContext();
580
		String templateFile = "templates/mainmenu.vm";
584
		String templateFile = "templates/mainmenu.vm";
581
		htmlString = getHtmlFromVelocity(templateFile, context);
585
		htmlString = getHtmlFromVelocity(templateFile, context);
582
		return htmlString;
586
		return htmlString;
583
	}
587
	}
584
 
588
 
585
	
589
	
586
	private String getSearchBarHtml(long itemCounts, long categoryId) {
590
	public String getSearchBarHtml(long itemCounts, long categoryId) {
587
		String htmlString = "";
591
		String htmlString = "";
588
		VelocityContext context = new VelocityContext();
592
		VelocityContext context = new VelocityContext();
589
		String templateFile = "templates/searchbar.vm";
593
		String templateFile = "templates/searchbar.vm";
590
		Map<String, String> params = new HashMap<String, String>();
594
		Map<String, String> params = new HashMap<String, String>();
591
		params.put("ITEM_COUNT", itemCounts+"");
595
		params.put("ITEM_COUNT", itemCounts+"");
Line 594... Line 598...
594
		return htmlString;
598
		return htmlString;
595
	}
599
	}
596
 
600
 
597
 
601
 
598
 
602
 
599
	private String getHeaderHtml(long userId, boolean isSessionId, String  userName) {
603
	public String getHeaderHtml(long userId, boolean isSessionId, String  userName) {
600
		String htmlString = "";
604
		String htmlString = "";
601
		Map<String,String> params = new HashMap<String, String>();
605
		Map<String,String> params = new HashMap<String, String>();
602
		if(isSessionId){
606
		if(isSessionId){
603
			params.put("LOGGED_IN", "FALSE");
607
			params.put("LOGGED_IN", "FALSE");
604
			params.put("WELCOME_MESSAGE", "Hi, Welcome to Shop2020");
608
			params.put("WELCOME_MESSAGE", "Hi, Welcome to Shop2020");
Line 859... Line 863...
859
		return "Widget";
863
		return "Widget";
860
	}
864
	}
861
	
865
	
862
	private String getItemSnippet(long productId){
866
	private String getItemSnippet(long productId){
863
			StringBuilder htmlString = new StringBuilder();
867
			StringBuilder htmlString = new StringBuilder();
864
			String filename = Utils.EXPORT_ENTITIES_PATH + productId + "_tinysnippet.html";
868
			String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "WidgetSnippet.html";
865
			try {
869
			try {
866
				return FileUtils.read(filename);
870
				return FileUtils.read(filename);
867
			} catch (Exception e) {
871
			} catch (Exception e) {
868
				// TODO Auto-generated catch block
872
				// TODO Auto-generated catch block
869
				e.printStackTrace();
873
				e.printStackTrace();
Line 902... Line 906...
902
			for(WidgetItem item: items){
906
			for(WidgetItem item: items){
903
				Map<String, String> itemDetail = new HashMap<String, String>();
907
				Map<String, String> itemDetail = new HashMap<String, String>();
904
				
908
				
905
				itemDetail.put("ITEM_ID", item.getItem_id()+"");
909
				itemDetail.put("ITEM_ID", item.getItem_id()+"");
906
				try {
910
				try {
907
					itemDetail.put("ITEM_SNIPPET", FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item.getItem_id()+"_tinysnippet.html"));
911
					itemDetail.put("ITEM_SNIPPET", FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item.getItem_id() + File.separator + "WidgetSnippet.html"));
908
				} catch (Exception e) {
912
				} catch (Exception e) {
909
					// TODO Auto-generated catch block
913
					// TODO Auto-generated catch block
910
					e.printStackTrace();
914
					e.printStackTrace();
911
				}
915
				}
912
				itemDetails.add(itemDetail);
916
				itemDetails.add(itemDetail);
Line 1176... Line 1180...
1176
		VelocityContext context = new VelocityContext();
1180
		VelocityContext context = new VelocityContext();
1177
		String templateFile = "templates/orderdetails.vm";
1181
		String templateFile = "templates/orderdetails.vm";
1178
		TransactionServiceClient transactionServiceClient = null;
1182
		TransactionServiceClient transactionServiceClient = null;
1179
		in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
1183
		in.shop2020.model.v1.order.TransactionService.Client orderClient = null;
1180
		Order order = null;
1184
		Order order = null;
-
 
1185
		Date orderedOn = null, deliveryEstimate = null;
1181
		try{
1186
		try{
1182
			transactionServiceClient = new TransactionServiceClient();
1187
			transactionServiceClient = new TransactionServiceClient();
1183
			orderClient = transactionServiceClient.getClient();
1188
			orderClient = transactionServiceClient.getClient();
1184
			order = orderClient.getOrder(orderId);
1189
			order = orderClient.getOrder(orderId);
1185
			
-
 
-
 
1190
			orderedOn = new Date(order.getCreated_timestamp());
-
 
1191
			deliveryEstimate = new Date(order.getExpected_delivery_time());
1186
		}catch (Exception e){
1192
		}catch (Exception e){
1187
			
1193
			
1188
		}
1194
		}
-
 
1195
		
-
 
1196
		SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
1189
		context.put("order", order);
1197
		context.put("order", order);
-
 
1198
		context.put("orderedOn", dateformat.format(orderedOn));
-
 
1199
		context.put("deliveryEstimate", dateformat.format(deliveryEstimate));
-
 
1200
		
-
 
1201
		
1190
		htmlString = getHtmlFromVelocity(templateFile, context);
1202
		htmlString = getHtmlFromVelocity(templateFile, context);
1191
		return htmlString;
1203
		return htmlString;
1192
	}
1204
	}
1193
	
1205
	
1194
	private String getMyaccountDetailsHtml(long userId) {
1206
	private String getMyaccountDetailsHtml(long userId) {
Line 1236... Line 1248...
1236
	private String getPersonalDetailsHtml(long userId) {
1248
	private String getPersonalDetailsHtml(long userId) {
1237
		String htmlString = "";
1249
		String htmlString = "";
1238
		VelocityContext context = new VelocityContext();
1250
		VelocityContext context = new VelocityContext();
1239
		String templateFile = "templates/personaldetails.vm";
1251
		String templateFile = "templates/personaldetails.vm";
1240
		String email = "";
1252
		String email = "";
-
 
1253
		String name = "";
-
 
1254
		int year = 0, month = 0, day = 0;
-
 
1255
		String sex = "";
-
 
1256
		String subscribe = "false";
1241
		UserContextServiceClient userContextServiceClient = null;
1257
		UserContextServiceClient userContextServiceClient = null;
1242
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
1258
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
1243
		UserPrimaryInfo primaryInfo = null;
1259
		UserPrimaryInfo primaryInfo = null;
1244
		try{
1260
		try{
1245
			userContextServiceClient = new UserContextServiceClient();
1261
			userContextServiceClient = new UserContextServiceClient();
1246
			userClient = userContextServiceClient.getClient();
1262
			userClient = userContextServiceClient.getClient();
1247
			primaryInfo = userClient.getPrimaryInfo(userId, false);
1263
			primaryInfo = userClient.getPrimaryInfo(userId, false);
1248
			
1264
			
-
 
1265
			email = primaryInfo.getCommunicationEmail();
-
 
1266
			name = primaryInfo.getFirstName();
-
 
1267
			
-
 
1268
			Calendar calendar = Calendar.getInstance();
-
 
1269
			calendar.setTimeInMillis(primaryInfo.getDateOfBirth());
-
 
1270
			month = calendar.get(Calendar.MONTH);
-
 
1271
			year = calendar.get(Calendar.YEAR);
-
 
1272
			day = calendar.get(Calendar.DAY_OF_MONTH);
-
 
1273
			
1249
		}catch (Exception e){
1274
		}catch (Exception e){
1250
			
1275
			
1251
		}
1276
		}
-
 
1277
		context.put("name", name);
1252
		context.put("primaryinfo", primaryInfo);
1278
		context.put("email", email);
-
 
1279
		context.put("month", month+"");
-
 
1280
		context.put("day", day+"");
-
 
1281
		context.put("year", year+"");
-
 
1282
		context.put("subscribe", subscribe);
-
 
1283
		context.put("sex", sex);
1253
		htmlString = getHtmlFromVelocity(templateFile, context);
1284
		htmlString = getHtmlFromVelocity(templateFile, context);
1254
		return htmlString;
1285
		return htmlString;
1255
	}
1286
	}
1256
	
1287
	
1257
	private String getCompletedOrdersHtml(long userId) {
1288
	private String getCompletedOrdersHtml(long userId) {
Line 1405... Line 1436...
1405
	private String getShippingAddressDetailsHtml(long userId){
1436
	private String getShippingAddressDetailsHtml(long userId){
1406
		String htmlString = "";
1437
		String htmlString = "";
1407
		VelocityContext context = new VelocityContext();
1438
		VelocityContext context = new VelocityContext();
1408
		String templateFile = "templates/shippingaddressdetails.vm";
1439
		String templateFile = "templates/shippingaddressdetails.vm";
1409
		long defaultAddressId = 0;
1440
		long defaultAddressId = 0;
1410
		Set<Address> addresses = null;
1441
		List<Address> addresses = null;
1411
		
1442
		
1412
		UserContextServiceClient userContextServiceClient = null;
1443
		UserContextServiceClient userContextServiceClient = null;
1413
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
1444
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
1414
		try {
1445
		try {
1415
			userContextServiceClient = new UserContextServiceClient();
1446
			userContextServiceClient = new UserContextServiceClient();
Line 1419... Line 1450...
1419
			defaultAddressId = primaryInfo.getDefaultAddressId();
1450
			defaultAddressId = primaryInfo.getDefaultAddressId();
1420
		} catch (Exception e) {
1451
		} catch (Exception e) {
1421
			// TODO Auto-generated catch block
1452
			// TODO Auto-generated catch block
1422
			e.printStackTrace();
1453
			e.printStackTrace();
1423
		}
1454
		}
1424
		context.put("dafaultAddressId", defaultAddressId+"");
1455
		context.put("defaultAddressId", defaultAddressId+"");
1425
		context.put("addresses", addresses);
1456
		context.put("addresses", addresses);
1426
		
1457
		
1427
		htmlString = getHtmlFromVelocity(templateFile, context);
1458
		htmlString = getHtmlFromVelocity(templateFile, context);
1428
		return htmlString;
1459
		return htmlString;
1429
	}
1460
	}
1430
 
1461
 
1431
	private String getShippingDetailsHtml(long cartId) {
1462
	private String getShippingDetailsHtml(long cartId) {
1432
		String htmlString = "";
1463
		String htmlString = "";
1433
		VelocityContext context = new VelocityContext();
1464
		VelocityContext context = new VelocityContext();
1434
		String templateFile = "templates/shippingdetails.vm";
1465
		String templateFile = "templates/shippingdetails.vm";
1435
		List<Map<String,String>> items = new ArrayList<Map<String,String>>();
1466
		List<Map<String,String>> items = null;
1436
		double totalamount= 0.0;
1467
		double totalamount= 0.0;
1437
		Set<Address> addresses = null;
1468
		List<Address> addresses = null;
1438
		
1469
		long defaultAddressId = 0;
1439
		ShoppingCartClient shoppingCartClient = null;
1470
		ShoppingCartClient shoppingCartClient = null;
1440
		in.shop2020.model.v1.shoppingcart.ShoppingCartService.Client cartClient = null;
1471
		in.shop2020.model.v1.shoppingcart.ShoppingCartService.Client cartClient = null;
1441
		CatalogServiceClient catalogServiceClient  = null;
1472
		CatalogServiceClient catalogServiceClient  = null;
1442
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
1473
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
1443
		UserContextServiceClient userContextServiceClient = null;
1474
		UserContextServiceClient userContextServiceClient = null;
Line 1453... Line 1484...
1453
			
1484
			
1454
			
1485
			
1455
			Cart cart = cartClient.getCart(cartId);
1486
			Cart cart = cartClient.getCart(cartId);
1456
			List<Line> lineItems = cart.getLines();
1487
			List<Line> lineItems = cart.getLines();
1457
			
1488
			
1458
			for (Line line : lineItems) {
1489
			if( ! lineItems.isEmpty())
-
 
1490
			{
1459
				Map<String, String> itemdetail = new HashMap<String, String>();
1491
				items = new ArrayList<Map<String,String>>();
1460
				Item item = catalogClient.getItemByCatalogId(line.getItemId());
-
 
1461
				
1492
				
-
 
1493
				for (Line line : lineItems) {
-
 
1494
					Map<String, String> itemdetail = new HashMap<String, String>();
-
 
1495
					Item item = catalogClient.getItemByCatalogId(line.getItemId());
1462
				itemdetail.put("ITEM_NAME", item.getManfucturerName()+" "+item.getModelName()+" "+item.getModelNumber());
1496
					String itemName = ((item.getManufacturerName() != null) ? item.getManufacturerName() + " " : "")
-
 
1497
										+ ((item.getModelName() != null) ? item.getModelName() + " " : "") 
-
 
1498
										+ (( item.getModelNumber() != null ) ? item.getModelNumber() : "" );
-
 
1499
					
-
 
1500
					itemdetail.put("ITEM_NAME", itemName);
1463
				itemdetail.put("ITEM_ID", line.getItemId()+"");
1501
					itemdetail.put("ITEM_ID", line.getItemId()+"");
1464
				itemdetail.put("ITEM_QUANTITY", line.getQuantity()+"");
1502
					itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
1465
				itemdetail.put("MRP", item.getMrp()+"");
1503
					itemdetail.put("MRP", ((int)item.getMrp())+"");
1466
				itemdetail.put("SELLING_PRICE", item.getSellingPrice()+"");
1504
					itemdetail.put("SELLING_PRICE", ((int)item.getSellingPrice())+"");
1467
				itemdetail.put("TOTAL_PRICE", (item.getSellingPrice()*line.getQuantity())+"");
1505
					itemdetail.put("TOTAL_PRICE", ((int)(item.getSellingPrice()*line.getQuantity()))+"");
1468
				itemdetail.put("SHIPPING_TIME", 48+"");
1506
					itemdetail.put("SHIPPING_TIME", 48+"");
1469
				totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
1507
					totalamount = totalamount + ((int)(line.getQuantity()*item.getSellingPrice()));
1470
				items.add(itemdetail);				
1508
					items.add(itemdetail);				
-
 
1509
				}
1471
			}
1510
			}
1472
			
1511
			
1473
			UserPrimaryInfo primaryInfo = userClient.getPrimaryInfo(cart.getUserId(), false);
1512
			UserPrimaryInfo primaryInfo = userClient.getPrimaryInfo(cart.getUserId(), false);
1474
			addresses = primaryInfo.getAddresses();
1513
			addresses = primaryInfo.getAddresses();
-
 
1514
			defaultAddressId = primaryInfo.getDefaultAddressId();
1475
			
1515
			
1476
		}catch (Exception e){
1516
		}catch (Exception e){
1477
			e.printStackTrace();
1517
			e.printStackTrace();
1478
		}
1518
		}
1479
		
1519
		
1480
		context.put("items", items);
1520
		context.put("items", items);
1481
		context.put("totalamount", totalamount+"");
1521
		context.put("totalamount", totalamount+"");
1482
		context.put("addresses", addresses);
1522
		context.put("addresses", addresses);
1483
		
-
 
-
 
1523
		context.put("defaultAddressId", defaultAddressId+"");
1484
		htmlString = getHtmlFromVelocity(templateFile, context);
1524
		htmlString = getHtmlFromVelocity(templateFile, context);
1485
		return htmlString;
1525
		return htmlString;
1486
	}
1526
	}
1487
 
1527
 
1488
	
1528
	
Line 1537... Line 1577...
1537
 
1577
 
1538
	private String getCartDetailsHtml(long cartId) {
1578
	private String getCartDetailsHtml(long cartId) {
1539
		String htmlString = "";
1579
		String htmlString = "";
1540
		VelocityContext context = new VelocityContext();
1580
		VelocityContext context = new VelocityContext();
1541
		String templateFile = "templates/cartdetails.vm";
1581
		String templateFile = "templates/cartdetails.vm";
1542
		List<Map<String,String>> items = new ArrayList<Map<String,String>>();
1582
		List<Map<String,String>> items = null;
1543
		
-
 
1544
		double totalamount= 0.0;
1583
		double totalamount= 0.0;
1545
		
1584
		
1546
		ShoppingCartClient shoppingCartClient = null;
1585
		ShoppingCartClient shoppingCartClient = null;
1547
		in.shop2020.model.v1.shoppingcart.ShoppingCartService.Client cartClient = null;
1586
		in.shop2020.model.v1.shoppingcart.ShoppingCartService.Client cartClient = null;
1548
		CatalogServiceClient catalogServiceClient  = null;
1587
		CatalogServiceClient catalogServiceClient  = null;
Line 1554... Line 1593...
1554
			catalogServiceClient = new CatalogServiceClient();
1593
			catalogServiceClient = new CatalogServiceClient();
1555
			catalogClient = catalogServiceClient.getClient();
1594
			catalogClient = catalogServiceClient.getClient();
1556
			
1595
			
1557
			Cart cart = cartClient.getCart(cartId);
1596
			Cart cart = cartClient.getCart(cartId);
1558
			List<Line> lineItems = cart.getLines();
1597
			List<Line> lineItems = cart.getLines();
-
 
1598
			if(lineItems.size() != 0){
-
 
1599
				items = new ArrayList<Map<String,String>>();
-
 
1600
				for (Line line : lineItems) {
1559
 
1601
	
-
 
1602
					Map<String, String> itemdetail = new HashMap<String, String>();
1560
			for (Line line : lineItems) {
1603
					Item item = catalogClient.getItemByCatalogId(line.getItemId());
-
 
1604
					
-
 
1605
					String itemName = ((item.getManufacturerName() != null) ? item.getManufacturerName() + " " : "")
1561
				if(line.getLineStatus() != LineStatus.LINE_ACTIVE){
1606
										+ ((item.getModelName() != null) ? item.getModelName() + " " : "") 
-
 
1607
										+ (( item.getModelNumber() != null ) ? item.getModelNumber() : "" );
1562
					continue;
1608
					
-
 
1609
					itemdetail.put("ITEM_NAME", itemName);
-
 
1610
					System.out.println(itemdetail.get("ITEM_NAME"));
-
 
1611
					itemdetail.put("ITEM_ID", line.getItemId()+"");
-
 
1612
					itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
-
 
1613
					itemdetail.put("MRP", ((int)item.getMrp())+"");
-
 
1614
					itemdetail.put("SELLING_PRICE", ((int)item.getSellingPrice())+"");
-
 
1615
					itemdetail.put("TOTAL_PRICE", ((int)((item.getSellingPrice()*line.getQuantity())))+"");
-
 
1616
					itemdetail.put("SHIPPING_TIME", 48+"");
-
 
1617
					totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
-
 
1618
					items.add(itemdetail);				
1563
				}
1619
				}
1564
				Map<String, String> itemdetail = new HashMap<String, String>();
-
 
1565
				Item item = catalogClient.getItemByCatalogId(line.getItemId());
-
 
1566
				
-
 
1567
				itemdetail.put("ITEM_NAME", item.getManfucturerName()+" "+item.getModelName()+" "+item.getModelNumber());
-
 
1568
				itemdetail.put("ITEM_ID", line.getItemId()+"");
-
 
1569
				itemdetail.put("ITEM_QUANTITY", line.getQuantity()+"");
-
 
1570
				itemdetail.put("MRP", item.getMrp()+"");
-
 
1571
				itemdetail.put("SELLING_PRICE", item.getSellingPrice()+"");
-
 
1572
				itemdetail.put("TOTAL_PRICE", (item.getSellingPrice()*line.getQuantity())+"");
-
 
1573
				itemdetail.put("SHIPPING_TIME", 48+"");
-
 
1574
				totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
-
 
1575
				items.add(itemdetail);				
-
 
1576
			}
1620
			}
1577
			
1621
			
1578
		}catch (Exception e){
1622
		}catch (Exception e){
1579
			e.printStackTrace();
1623
			e.printStackTrace();
1580
		}
1624
		}
1581
			
1625
			
1582
		context.put("items", items);
1626
		context.put("items", items);
1583
		context.put("totalamount", totalamount+"");
1627
		context.put("totalamount", ((int)totalamount)+"");
1584
		htmlString = getHtmlFromVelocity(templateFile, context);
1628
		htmlString = getHtmlFromVelocity(templateFile, context);
1585
		return htmlString;
1629
		return htmlString;
1586
	}
1630
	}
1587
 
1631
 
1588
 
1632
 
Line 1840... Line 1884...
1840
			e.printStackTrace();
1884
			e.printStackTrace();
1841
		}
1885
		}
1842
		return itemPrice;
1886
		return itemPrice;
1843
	}
1887
	}
1844
 
1888
 
-
 
1889
 
-
 
1890
	public String getCategoryHeaderSnippet() {
-
 
1891
		String htmlString = "";
-
 
1892
		VelocityContext context = new VelocityContext();
-
 
1893
		String templateFile = "templates/categoryheader.vm";
-
 
1894
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
1895
		return htmlString;
-
 
1896
	}
-
 
1897
 
1845
		
1898
		
1846
 
1899
 
1847
}
1900
}
1848
 
1901