Subversion Repositories SmartDukaan

Rev

Rev 2319 | Rev 2375 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2319 Rev 2367
Line 8... Line 8...
8
import in.shop2020.metamodel.util.CreationUtils;
8
import in.shop2020.metamodel.util.CreationUtils;
9
import in.shop2020.metamodel.util.ExpandedBullet;
9
import in.shop2020.metamodel.util.ExpandedBullet;
10
import in.shop2020.metamodel.util.ExpandedEntity;
10
import in.shop2020.metamodel.util.ExpandedEntity;
11
import in.shop2020.metamodel.util.ExpandedFeature;
11
import in.shop2020.metamodel.util.ExpandedFeature;
12
import in.shop2020.metamodel.util.ExpandedSlide;
12
import in.shop2020.metamodel.util.ExpandedSlide;
13
import in.shop2020.model.v1.catalog.InventoryService.Client;
-
 
14
import in.shop2020.model.v1.catalog.Item;
-
 
15
import in.shop2020.thrift.clients.CatalogServiceClient;
-
 
16
import in.shop2020.util.Utils;
13
import in.shop2020.util.Utils;
17
 
14
 
18
import java.io.BufferedWriter;
15
import java.io.BufferedWriter;
19
import java.io.File;
16
import java.io.File;
20
import java.io.FileInputStream;
17
import java.io.FileInputStream;
Line 24... Line 21...
24
import java.io.OutputStream;
21
import java.io.OutputStream;
25
import java.io.OutputStreamWriter;
22
import java.io.OutputStreamWriter;
26
import java.io.StringWriter;
23
import java.io.StringWriter;
27
import java.net.URLEncoder;
24
import java.net.URLEncoder;
28
import java.text.DecimalFormat;
25
import java.text.DecimalFormat;
29
import java.util.ArrayList;
-
 
30
import java.util.Date;
-
 
31
import java.util.HashMap;
26
import java.util.HashMap;
32
import java.util.List;
27
import java.util.List;
33
import java.util.Map;
28
import java.util.Map;
34
 
29
 
35
import org.apache.velocity.Template;
30
import org.apache.velocity.Template;
Line 46... Line 41...
46
 * 
41
 * 
47
 * @author rajveer
42
 * @author rajveer
48
 *
43
 *
49
 */
44
 */
50
public class NewVUI {
45
public class NewVUI {
51
	CatalogServiceClient catalogServiceClient = null;
-
 
52
	Client client = null;
-
 
53
	String lastContentVersion;
-
 
54
	String contentVersion;  
46
	String contentVersion;  
55
 
47
 
56
	StringBuffer problems = new StringBuffer();
-
 
57
 
-
 
58
	public NewVUI(Long contentVersion) throws Exception {
48
	public NewVUI(Long contentVersion) throws Exception {
59
		catalogServiceClient = new CatalogServiceClient();
-
 
60
		client = catalogServiceClient.getClient();
-
 
61
		this.lastContentVersion = contentVersion.toString();
49
		this.contentVersion = contentVersion.toString();
62
		this.contentVersion =  (new Date()).getTime() +"" ;
-
 
63
	}
50
	}
64
 
51
 
65
	/**
52
	/**
66
	 * Generates content for the specified entity embedding links to the
53
	 * Generates content for the specified entity embedding links to the
67
	 * specified domain name.
54
	 * specified domain name.
Line 84... Line 71...
84
	 * @param exportPath
71
	 * @param exportPath
85
	 *            - Local file system path where content has to be generated.
72
	 *            - Local file system path where content has to be generated.
86
	 * @return -True if content is generated successfully, False otherwise.
73
	 * @return -True if content is generated successfully, False otherwise.
87
	 * @throws Exception
74
	 * @throws Exception
88
	 */
75
	 */
89
	public boolean generateHtmlForOneEntity(Entity entity, String domain, String exportPath, List<Item> items) throws Exception{
76
	public boolean generateHtmlForOneEntity(Entity entity, String exportPath) throws Exception{
90
		String mediaPath = Utils.EXPORT_MEDIA_PATH + entity.getID();
77
		String mediaPath = Utils.EXPORT_MEDIA_PATH + entity.getID();
91
		
78
		
92
        deleteOldResources(mediaPath, exportPath + entity.getID());
79
		deleteOldResources(mediaPath, exportPath + entity.getID());
93
        
80
        
94
		ExpandedEntity expEntity = new ExpandedEntity(entity);
81
		ExpandedEntity expEntity = new ExpandedEntity(entity);
95
				
82
				
96
		long catalogId = expEntity.getID();
83
		long catalogId = expEntity.getID();
97
		String templateFile;
84
		String templateFile;
Line 100... Line 87...
100
		//Create new directory
87
		//Create new directory
101
		File exportDir = new File(exportPath + catalogId);
88
		File exportDir = new File(exportPath + catalogId);
102
		if(!exportDir.exists()) {
89
		if(!exportDir.exists()) {
103
			exportDir.mkdir();
90
			exportDir.mkdir();
104
		}
91
		}
105
 
-
 
106
		/*
-
 
107
		 * To delete 
-
 
108
		 */
-
 
109
		
-
 
110
		
-
 
111
		// This URL is used to ensure that images such as icon and thumbnail for
-
 
112
		// a particular entity are always downloaded from the same location.
-
 
113
		String staticurl = "http://static" + entity.getID()%3 + "." + domain;
-
 
114
		
92
		
115
		templateFile= Utils.VTL_SRC_PATH + "product_summary.vm";
93
		templateFile= Utils.VTL_SRC_PATH + "product_summary.vm";
116
		getProductSummaryHtml(expEntity, items, templateFile, exportPath, domain);
94
		getProductSummaryHtml(expEntity, templateFile, exportPath);
117
		
95
		
118
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_widget.vm";
96
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_widget.vm";
119
		getEntityWidgetSnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
97
		getEntityWidgetSnippetHtml(expEntity, templateFile, exportPath);
120
		
98
		
121
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_homepage.vm";
99
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_homepage.vm";
122
		getEntityHomeSnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
100
		getEntityHomeSnippetHtml(expEntity, templateFile, exportPath);
123
		
101
		
124
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_searchpage.vm";
102
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_searchpage.vm";
125
		getEntitySearchSnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
103
		getEntitySearchSnippetHtml(expEntity, templateFile, exportPath);
126
		
104
		
127
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_categorypage.vm";
105
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_categorypage.vm";
128
		getEntityCategorySnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
106
		getEntityCategorySnippetHtml(expEntity, templateFile, exportPath);
129
		
107
		
130
		templateFile= Utils.VTL_SRC_PATH + "slideguide_img_video.vm";
108
		templateFile= Utils.VTL_SRC_PATH + "slideguide_img_video.vm";
131
		getEntitySlideGuideHtml(expEntity, templateFile, domain, exportPath);
109
		getEntitySlideGuideHtml(expEntity, templateFile, exportPath);
132
 
110
 
133
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_phones_i_own.vm";
111
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_phones_i_own.vm";
134
		getEntityPhonesIOwnSnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
112
		getEntityPhonesIOwnSnippetHtml(expEntity, templateFile, exportPath);
135
		
113
		
136
		if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
114
		if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
137
		    
115
		    
138
		    templateFile= Utils.VTL_SRC_PATH + "slideguide_for_comparison.vm";
116
		    templateFile= Utils.VTL_SRC_PATH + "slideguide_for_comparison.vm";
139
	        getEntitySnippetForComparison(expEntity, templateFile, domain, exportPath);
117
	        getEntitySnippetForComparison(expEntity, templateFile, exportPath);
140
	        
118
	        
141
	        templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_comparisonpage.vm";
119
	        templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_comparisonpage.vm";
142
	        getEntityCompareSnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
120
	        getEntityCompareSnippetHtml(expEntity, templateFile, exportPath);
143
	            
121
	            
144
            templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_comparisonpage_summary.vm";
122
            templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_comparisonpage_summary.vm";
145
            getEntityCompareSummarySnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
123
            getEntityCompareSummarySnippetHtml(expEntity, templateFile, exportPath);
146
 
124
 
147
            getSlidenamesSnippet(expEntity, exportPath);
125
            getSlidenamesSnippet(expEntity, exportPath);
148
		}
126
		}
149
		
127
		
150
		getProductPropertiesSnippet(expEntity, exportPath);
128
		getProductPropertiesSnippet(expEntity, exportPath);
Line 322... Line 300...
322
            props.put("metaKeywords", metaKeywords);
300
            props.put("metaKeywords", metaKeywords);
323
            props.put("entityUrl", entityUrl);
301
            props.put("entityUrl", entityUrl);
324
            props.put("title", title);
302
            props.put("title", title);
325
 
303
 
326
            String exportFileName = exportPath + catalogId + File.separator
304
            String exportFileName = exportPath + catalogId + File.separator
327
                    + "ProductPropertiesSnippet.html";
305
                    + "ProductPropertiesSnippet.vm";
328
            File exportFile = new File(exportFileName);
306
            File exportFile = new File(exportFileName);
329
            if (!exportFile.exists()) {
307
            if (!exportFile.exists()) {
330
                exportFile.createNewFile();
308
                exportFile.createNewFile();
331
            }
309
            }
332
 
310
 
Line 372... Line 350...
372
	        score = Double.valueOf(oneDForm.format(score));
350
	        score = Double.valueOf(oneDForm.format(score));
373
	
351
	
374
	        slideNames.append(score + "\n");
352
	        slideNames.append(score + "\n");
375
	    }
353
	    }
376
 
354
 
377
        String exportFileName = exportPath + catalogId + File.separator + "SlideNamesSnippet.html";
355
        String exportFileName = exportPath + catalogId + File.separator + "SlideNamesSnippet.vm";
378
        File exportFile = new File(exportFileName);
356
        File exportFile = new File(exportFileName);
379
        if(!exportFile.exists()) {
357
        if(!exportFile.exists()) {
380
            exportFile.createNewFile();
358
            exportFile.createNewFile();
381
        }
359
        }
382
        
360
        
Line 388... Line 366...
388
        writer.close();
366
        writer.close();
389
	    
367
	    
390
	}
368
	}
391
	
369
	
392
	
370
	
393
	private  void getEntitySnippetForComparison(ExpandedEntity expEntity, String templateFile, String domain, String exportPath) throws Exception {
371
	private  void getEntitySnippetForComparison(ExpandedEntity expEntity, String templateFile,String exportPath) throws Exception {
394
		long catalogId = expEntity.getID();
372
		long catalogId = expEntity.getID();
395
		VelocityContext context = new VelocityContext();
373
		VelocityContext context = new VelocityContext();
396
		
374
		
397
		context.put("imagePrefix", getImagePrefix(expEntity));
375
		context.put("imagePrefix", getImagePrefix(expEntity));
398
		context.put("expentity", expEntity);
376
		context.put("expentity", expEntity);
399
		context.put("domain", domain);
-
 
400
		context.put("contentVersion", this.contentVersion);
377
		context.put("contentVersion", this.contentVersion);
401
		
378
		
402
		String exportFileName = null;
379
		String exportFileName = null;
403
 
380
 
404
		Template template = Velocity.getTemplate(templateFile);
381
		Template template = Velocity.getTemplate(templateFile);
405
		exportFileName = exportPath + catalogId + File.separator + "ComparisonSnippet.html";
382
		exportFileName = exportPath + catalogId + File.separator + "ComparisonSnippet.vm";
406
 
383
 
407
		File exportFile = new File(exportFileName);
384
		File exportFile = new File(exportFileName);
408
		if(!exportFile.exists()) {
385
		if(!exportFile.exists()) {
409
			exportFile.createNewFile();
386
			exportFile.createNewFile();
410
		}
387
		}
Line 419... Line 396...
419
		writer.close();
396
		writer.close();
420
		Utils.info("Export Complete!");
397
		Utils.info("Export Complete!");
421
 
398
 
422
	}
399
	}
423
 
400
 
424
	private  void getEntitySlideGuideHtml(ExpandedEntity expEntity, String templateFile, String domain, String exportPath) throws Exception {
401
	private  void getEntitySlideGuideHtml(ExpandedEntity expEntity, String templateFile, String exportPath) throws Exception {
425
        long catalogId = expEntity.getID();
402
        long catalogId = expEntity.getID();
426
        VelocityContext context = new VelocityContext();
403
        VelocityContext context = new VelocityContext();
427
        
404
        
428
        context.put("imagePrefix", getImagePrefix(expEntity));
405
        context.put("imagePrefix", getImagePrefix(expEntity));
429
        context.put("expentity", expEntity);
406
        context.put("expentity", expEntity);
430
        context.put("domain", domain);
-
 
431
        context.put("contentVersion", this.contentVersion);
407
        context.put("contentVersion", this.contentVersion);
432
        context.put("defs", Catalog.getInstance().getDefinitionsContainer());
408
        context.put("defs", Catalog.getInstance().getDefinitionsContainer());
433
        context.put("helpdocs", CreationUtils.getHelpdocs());
409
        context.put("helpdocs", CreationUtils.getHelpdocs());
434
        
410
        
435
        String exportFileName = null;
411
        String exportFileName = null;
436
 
412
 
437
        Template template = Velocity.getTemplate(templateFile);
413
        Template template = Velocity.getTemplate(templateFile);
438
        exportFileName = exportPath + catalogId + File.separator + "SlideGuide.html";
414
        exportFileName = exportPath + catalogId + File.separator + "SlideGuide.vm";
439
 
415
 
440
        File exportFile = new File(exportFileName);
416
        File exportFile = new File(exportFileName);
441
        if(!exportFile.exists()) {
417
        if(!exportFile.exists()) {
442
            exportFile.createNewFile();
418
            exportFile.createNewFile();
443
        }
419
        }
Line 452... Line 428...
452
        writer.close();
428
        writer.close();
453
        Utils.info("Export Complete!");
429
        Utils.info("Export Complete!");
454
 
430
 
455
    }
431
    }
456
 
432
 
457
	public void getProductSummaryHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String exportPath, String domain) {
433
	public void getProductSummaryHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
458
		long catalogId = expEntity.getID();
434
		long catalogId = expEntity.getID();
459
		try {
435
		try {
460
			List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
461
			for(Item item: items){
-
 
462
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
463
				double sellingPrice = item.getSellingPrice();
-
 
464
				double mrp = item.getMrp();
-
 
465
				boolean showmrp = true;
-
 
466
				if (mrp <= sellingPrice) {
-
 
467
					showmrp = false;
-
 
468
				}
-
 
469
 
-
 
470
				double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
471
				itemDetail.put("ITEM_ID", ((int)item.getId())+"");
-
 
472
				itemDetail.put("CATALOG_ID", ((int)item.getCatalogItemId())+"");
-
 
473
				itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
474
				itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
475
				itemDetail.put("SAVING", ((int)saving)+"");
-
 
476
				itemDetail.put("COLOR", item.getColor());
-
 
477
				itemDetail.put("SHOWMRP", showmrp +"");
-
 
478
				itemDetail.put("IS_SELECTED", item.isDefaultForEntity() ? "SELECTED" : "");
-
 
479
				itemDetails.add(itemDetail);
-
 
480
			}
-
 
481
			
-
 
482
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
436
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
483
			String brandName = expEntity.getBrand().trim();
437
			String brandName = expEntity.getBrand().trim();
484
			String productName = expEntity.getModelName() + " " + expEntity.getModelNumber();
438
			String productName = expEntity.getModelName() + " " + expEntity.getModelNumber();
485
			String categoryName = expEntity.getCategory().getLabel();
439
			String categoryName = expEntity.getCategory().getLabel();
486
			String tagline = "";
440
			String tagline = "";
Line 498... Line 452...
498
						warranty = expBullet.getValue() + " "+ expBullet.getUnit().getShortForm();
452
						warranty = expBullet.getValue() + " "+ expBullet.getUnit().getShortForm();
499
					}
453
					}
500
				}
454
				}
501
			}
455
			}
502
			
456
			
503
			
-
 
504
			
-
 
505
			long categoryId = expEntity.getCategory().getID();
457
			long categoryId = expEntity.getCategory().getID();
506
			Map<String,String> params = new HashMap<String, String>();
458
			Map<String,String> params = new HashMap<String, String>();
507
			params.put("TITLE", title);
459
			params.put("TITLE", title);
508
			params.put("BRAND_NAME", brandName);
460
			params.put("BRAND_NAME", brandName);
509
			params.put("PRODUCT_NAME", productName);
461
			params.put("PRODUCT_NAME", productName);
510
			params.put("CATEGORY_ID", ((int)categoryId)+"");
462
			params.put("CATEGORY_ID", ((int)categoryId)+"");
511
			params.put("CATEGORY_NAME", categoryName);
463
			params.put("CATEGORY_NAME", categoryName);
512
			params.put("CATEGORY_URL", categoryName.replaceAll(" ", "-").toLowerCase() + "/" + categoryId);
464
			params.put("CATEGORY_URL", categoryName.replaceAll(" ", "-").toLowerCase() + "/" + categoryId);
513
			params.put("PRODUCT_URL", URLEncoder.encode("http://www."+ domain + this.getEntityURL(expEntity), "UTF-8"));
465
			params.put("PRODUCT_URL", URLEncoder.encode(this.getEntityURL(expEntity), "UTF-8"));
514
			if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
466
			if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
515
				params.put("IS_MOBILE", "TRUE" );	
467
				params.put("IS_MOBILE", "TRUE" );	
516
			}else{
468
			}else{
517
				params.put("IS_MOBILE", "FALSE" );
469
				params.put("IS_MOBILE", "FALSE" );
518
			}
470
			}
519
			params.put("CATALOG_ID", ((int)catalogId)+"");
471
			params.put("CATALOG_ID", ((int)catalogId)+"");
520
			params.put("TAGLINE", tagline);
472
			params.put("TAGLINE", tagline);
521
			params.put("WARRANTY", warranty);
473
			params.put("WARRANTY", warranty);
522
			
474
			
523
			VelocityContext context = new VelocityContext();
475
			VelocityContext context = new VelocityContext();
524
			
-
 
525
			context.put("itemDetails", itemDetails);
-
 
526
			
-
 
527
			context.put("params", params);
476
			context.put("params", params);
528
			
477
			
529
			String exportFileName = exportPath + catalogId + File.separator + "ProductDetail.html";
478
			String exportFileName = exportPath + catalogId + File.separator + "ProductDetail.vm";
530
	
479
	
531
			File exportFile = new File(exportFileName);
480
			File exportFile = new File(exportFileName);
532
			if(!exportFile.exists()) {
481
			if(!exportFile.exists()) {
533
				exportFile.createNewFile();
482
				exportFile.createNewFile();
534
			}
483
			}
Line 547... Line 496...
547
		}
496
		}
548
	}
497
	}
549
 
498
 
550
	private String getEntityURL(ExpandedEntity expEntity){
499
	private String getEntityURL(ExpandedEntity expEntity){
551
		String url = "/" + expEntity.getCategory().getParentCategory().getLabel().toLowerCase().replace(' ', '-') + "/";
500
		String url = "/" + expEntity.getCategory().getParentCategory().getLabel().toLowerCase().replace(' ', '-') + "/";
552
		String productUrl = expEntity.getBrand().toLowerCase().replace(' ', '-')
501
		String productUrl = ((expEntity.getBrand() != null) ? expEntity.getBrand().trim() + " " : "").toLowerCase().replace(' ', '-')
553
        + "-" + expEntity.getModelName().toLowerCase().replace(' ', '-') 
502
        + "-" + ((expEntity.getModelName() != null) ? expEntity.getModelName().trim() + " " : "").toLowerCase().replace(' ', '-') 
554
	    + "-" + expEntity.getModelNumber().toLowerCase().replace(' ', '-')
503
	    + "-" + (( expEntity.getModelNumber() != null ) ? expEntity.getModelNumber().trim() + " " : "" ).toLowerCase().replace(' ', '-')
555
        + "-" + expEntity.getID();
504
        + "-" + expEntity.getID();
556
		productUrl = productUrl.replaceAll("/", "-");
505
		productUrl = productUrl.replaceAll("/", "-");
557
		url = url + productUrl;
506
		url = url + productUrl;
558
		url = url.replaceAll("-+", "-");
507
		url = url.replaceAll("-+", "-");
559
		return url;
508
		return url;
560
	}
509
	}
561
	
510
	
562
	private String getImagePrefix(ExpandedEntity expEntity){
511
	private String getImagePrefix(ExpandedEntity expEntity){
563
		String imagePrefix = expEntity.getBrand().toLowerCase().replace(' ', '-')
512
		String imagePrefix = ((expEntity.getBrand() != null) ? expEntity.getBrand().trim() + " " : "").toLowerCase().replace(' ', '-')
564
        + "-" + expEntity.getModelName().toLowerCase().replace(' ', '-') 
513
        + "-" + ((expEntity.getModelName() != null) ? expEntity.getModelName().trim() + " " : "").toLowerCase().replace(' ', '-') 
565
	    + "-" + expEntity.getModelNumber().toLowerCase().replace(' ', '-');
514
	    + "-" + (( expEntity.getModelNumber() != null ) ? expEntity.getModelNumber().trim() + " " : "" ).toLowerCase().replace(' ', '-');
566
		imagePrefix = imagePrefix.replaceAll("/", "-");
515
		imagePrefix = imagePrefix.replaceAll("/", "-");
567
		imagePrefix = imagePrefix.replaceAll("--", "-");
516
		imagePrefix = imagePrefix.replaceAll("-+", "-");
568
		return imagePrefix;
517
		return imagePrefix;
569
	}
518
	}
570
	
519
	
571
	private void getEntityWidgetSnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
520
	private void getEntityWidgetSnippetHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
572
		long catalogId = expEntity.getID();
521
		long catalogId = expEntity.getID();
573
		try {
522
		try {
574
			expEntity = CreationUtils.getExpandedEntity(catalogId);
523
			expEntity = CreationUtils.getExpandedEntity(catalogId);
575
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
524
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
576
			String prodName = title;
525
			String prodName = title;
Line 587... Line 536...
587
					PrimitiveDataObject dataObject= (PrimitiveDataObject)feature.getBullets().get(0).getDataObject();
536
					PrimitiveDataObject dataObject= (PrimitiveDataObject)feature.getBullets().get(0).getDataObject();
588
					tinySnippet = dataObject.getValue(); 
537
					tinySnippet = dataObject.getValue(); 
589
				}
538
				}
590
			}
539
			}
591
			
540
			
592
			List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
593
			
-
 
594
			Item minPriceItem = null; 
-
 
595
			for(Item item: items){
-
 
596
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
597
				if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
-
 
598
					minPriceItem = item;
-
 
599
				}
-
 
600
				double sellingPrice = item.getSellingPrice();
-
 
601
				double mrp = item.getMrp();
-
 
602
				double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
603
				itemDetail.put("ITEM_ID", ((int)item.getId())+"");	
-
 
604
				itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
605
				itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
606
				itemDetail.put("SAVING", ((int)saving)+"");
-
 
607
				itemDetail.put("COLOR", item.getColor());
-
 
608
				itemDetails.add(itemDetail);
-
 
609
			}
-
 
610
			
-
 
611
			boolean showmrp = true;
-
 
612
			if (minPriceItem.getMrp() <= minPriceItem.getSellingPrice()) {
-
 
613
				showmrp = false;
-
 
614
			}
-
 
615
			Map<String,String> params = new HashMap<String, String>();
541
			Map<String,String> params = new HashMap<String, String>();
616
			params.put("TITLE", title);
542
			params.put("TITLE", title);
617
			params.put("PROD_NAME", prodName);
543
			params.put("PROD_NAME", prodName);
618
			params.put("URL", url);
544
			params.put("URL", url);
619
			params.put("IMAGE_PREFIX", imagePrefix);
545
			params.put("IMAGE_PREFIX", imagePrefix);
620
			params.put("SELLING_PRICE", ((int)minPriceItem.getSellingPrice())+"");
-
 
621
			params.put("MRP", ((int)minPriceItem.getMrp())+"");
-
 
622
			params.put("SHOWMRP", showmrp +"");
-
 
623
			params.put("CATALOG_ID", ((int)catalogId)+"");
546
			params.put("CATALOG_ID", ((int)catalogId)+"");
624
			params.put("ITEM_ID", minPriceItem.getId()+"");
-
 
625
			params.put("TINY_SNIPPET", tinySnippet);
547
			params.put("TINY_SNIPPET", tinySnippet);
626
			params.put("staticurl", staticurl);
-
 
627
			params.put("contentVersion", contentVersion);
548
			params.put("contentVersion", contentVersion);
628
			VelocityContext context = new VelocityContext();
549
			VelocityContext context = new VelocityContext();
629
			context.put("itemDetails", itemDetails);
-
 
630
			context.put("params", params);
-
 
631
 
550
 
-
 
551
			context.put("params", params);
-
 
552
			
-
 
553
			
632
			String exportFileName = exportPath + catalogId + File.separator + "WidgetSnippet.html";
554
			String exportFileName = exportPath + catalogId + File.separator + "WidgetSnippet.vm";
633
			File exportFile = new File(exportFileName);
555
			File exportFile = new File(exportFileName);
634
			if(!exportFile.exists()) {
556
			if(!exportFile.exists()) {
635
				exportFile.createNewFile();
557
				exportFile.createNewFile();
636
			}
558
			}
637
			
559
			
Line 650... Line 572...
650
			e.printStackTrace();
572
			e.printStackTrace();
651
		}
573
		}
652
	}
574
	}
653
 
575
 
654
	
576
	
655
	private  void getEntityHomeSnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
577
	private  void getEntityHomeSnippetHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
656
		long catalogId = expEntity.getID();
578
		long catalogId = expEntity.getID();
657
		
-
 
658
		Map<String,String> params = new HashMap<String, String>();
579
		Map<String,String> params = new HashMap<String, String>();
659
		
-
 
660
		try {
580
		try {
661
			expEntity = CreationUtils.getExpandedEntity(catalogId);
581
			expEntity = CreationUtils.getExpandedEntity(catalogId);
662
			String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
582
			String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
663
			String prodName = title;
583
			String prodName = title;
664
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
584
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
665
				prodName = expEntity.getBrand() + " " + expEntity.getModelName();
585
				prodName = expEntity.getBrand() + " " + expEntity.getModelName();
666
			}
586
			}
667
			String url = getEntityURL(expEntity);
587
			String url = getEntityURL(expEntity);
668
			String imagePrefix = getImagePrefix(expEntity);
588
			String imagePrefix = getImagePrefix(expEntity);
669
			
-
 
670
			catalogServiceClient = new CatalogServiceClient();
-
 
671
			client = catalogServiceClient.getClient();
-
 
672
 
-
 
673
			String tinySnippet = "";
589
			String tinySnippet = "";
674
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
590
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
675
			for(Feature feature: features){
591
			for(Feature feature: features){
676
				if(feature.getFeatureDefinitionID() == 120081){
592
				if(feature.getFeatureDefinitionID() == 120081){
677
					List<Bullet> bullets = feature.getBullets();
593
					List<Bullet> bullets = feature.getBullets();
Line 683... Line 599...
683
						System.out.println("Tiny Snippets is " + dataObject.getValue());
599
						System.out.println("Tiny Snippets is " + dataObject.getValue());
684
					}
600
					}
685
 				}
601
 				}
686
			}
602
			}
687
 
603
 
688
 
-
 
689
			
-
 
690
			List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
691
			
-
 
692
			Item minPriceItem = null;
-
 
693
			
-
 
694
			for(Item item: items){
-
 
695
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
696
				if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
-
 
697
					minPriceItem = item;
-
 
698
				}
-
 
699
				double sellingPrice = item.getSellingPrice();
-
 
700
				double mrp = item.getMrp();
-
 
701
				double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
702
				itemDetail.put("ITEM_ID", ((int)item.getId())+"");	
-
 
703
				itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
704
				itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
705
				itemDetail.put("SAVING", ((int)saving)+"");
-
 
706
				itemDetail.put("COLOR", item.getColor());
-
 
707
				itemDetails.add(itemDetail);
-
 
708
			}
-
 
709
			boolean showmrp = true;
-
 
710
			if (minPriceItem.getMrp() <= minPriceItem.getSellingPrice()) {
-
 
711
				showmrp = false;
-
 
712
			}
-
 
713
			
-
 
714
			params.put("TITLE", title);
604
			params.put("TITLE", title);
715
			params.put("PROD_NAME", prodName);
605
			params.put("PROD_NAME", prodName);
716
			params.put("URL", url);
606
			params.put("URL", url);
717
			params.put("IMAGE_PREFIX", imagePrefix);
607
			params.put("IMAGE_PREFIX", imagePrefix);
718
			params.put("SELLING_PRICE", ((int)minPriceItem.getSellingPrice())+"");
-
 
719
			params.put("MRP", ((int)minPriceItem.getMrp())+"");
-
 
720
			params.put("SHOWMRP", showmrp +"");
-
 
721
			params.put("CATALOG_ID", ((int)catalogId)+"");
608
			params.put("CATALOG_ID", ((int)catalogId)+"");
722
			params.put("ITEM_ID", minPriceItem.getId()+"");
-
 
723
			params.put("staticurl", staticurl);
-
 
724
			params.put("contentVersion", contentVersion);
609
			params.put("contentVersion", contentVersion);
725
			
-
 
726
			VelocityContext context = new VelocityContext();
610
			VelocityContext context = new VelocityContext();
727
			context.put("itemDetails", itemDetails);
-
 
728
			context.put("params", params);
611
			context.put("params", params);
729
 
612
 
730
			
-
 
731
			String exportFileName = exportPath + catalogId + File.separator + "HomeSnippet.html";
613
			String exportFileName = exportPath + catalogId + File.separator + "HomeSnippet.vm";
732
			File exportFile = new File(exportFileName);
614
			File exportFile = new File(exportFileName);
733
			if(!exportFile.exists()) {
615
			if(!exportFile.exists()) {
734
				exportFile.createNewFile();
616
				exportFile.createNewFile();
735
			}
617
			}
736
			
618
			
Line 747... Line 629...
747
		} catch (Exception e) {
629
		} catch (Exception e) {
748
			e.printStackTrace();
630
			e.printStackTrace();
749
		}
631
		}
750
	}
632
	}
751
	
633
	
752
	private  void getEntityCategorySnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
634
	private  void getEntityCategorySnippetHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
753
		Map<String,String> params = new HashMap<String, String>();
635
		Map<String,String> params = new HashMap<String, String>();
754
		long catalogId = expEntity.getID();
636
		long catalogId = expEntity.getID();
755
		
637
		
756
		try {
638
		try {
757
			expEntity = CreationUtils.getExpandedEntity(catalogId);
639
			expEntity = CreationUtils.getExpandedEntity(catalogId);
758
			String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
640
			String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
759
			String prodName = title;
641
			String prodName = title;
760
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
642
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
761
				prodName = expEntity.getBrand() + " " + expEntity.getModelName();
643
				prodName = expEntity.getBrand() + " " + expEntity.getModelName();
762
			}
644
			}
763
			catalogServiceClient = new CatalogServiceClient();
-
 
764
			client = catalogServiceClient.getClient();
-
 
765
			String url = getEntityURL(expEntity);
645
			String url = getEntityURL(expEntity);
766
			String imagePrefix = getImagePrefix(expEntity);
646
			String imagePrefix = getImagePrefix(expEntity);
767
			
647
			
768
			String tinySnippet = "";
648
			String tinySnippet = "";
769
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
649
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
Line 777... Line 657...
777
						params.put("SNIPPET_"+count++, tinySnippet);
657
						params.put("SNIPPET_"+count++, tinySnippet);
778
						System.out.println("Tiny Snippets is " + dataObject.getValue());
658
						System.out.println("Tiny Snippets is " + dataObject.getValue());
779
					}
659
					}
780
 				}
660
 				}
781
			}
661
			}
782
 
-
 
783
			List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
784
			
-
 
785
			Item minPriceItem = null;
-
 
786
			for(Item item: items){
-
 
787
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
788
				if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
-
 
789
					minPriceItem = item;
-
 
790
				}
-
 
791
				double sellingPrice = item.getSellingPrice();
-
 
792
				double mrp = item.getMrp();
-
 
793
				double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
794
				itemDetail.put("ITEM_ID", ((int)item.getId())+"");	
-
 
795
				itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
796
				itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
797
				itemDetail.put("SAVING", ((int)saving)+"");
-
 
798
				itemDetail.put("COLOR", item.getColor());
-
 
799
				itemDetails.add(itemDetail);
-
 
800
			}
-
 
801
			
-
 
802
			boolean showmrp = true;
-
 
803
			if (minPriceItem.getMrp() <= minPriceItem.getSellingPrice()) {
-
 
804
				showmrp = false;
-
 
805
			}
-
 
806
			params.put("TITLE", title);
662
			params.put("TITLE", title);
807
			params.put("PROD_NAME", prodName);
663
			params.put("PROD_NAME", prodName);
808
			params.put("URL", url);
664
			params.put("URL", url);
809
			params.put("IMAGE_PREFIX", imagePrefix);
665
			params.put("IMAGE_PREFIX", imagePrefix);
810
			params.put("SELLING_PRICE", ((int)minPriceItem.getSellingPrice())+"");
-
 
811
			params.put("MRP", ((int)minPriceItem.getMrp())+"");
-
 
812
			params.put("SHOWMRP", showmrp +"");
-
 
813
			params.put("CATALOG_ID", ((int)catalogId)+"");
666
			params.put("CATALOG_ID", ((int)catalogId)+"");
814
			params.put("ITEM_ID", minPriceItem.getId()+"");
-
 
815
			params.put("staticurl", staticurl);
-
 
816
			params.put("contentVersion", contentVersion);
667
			params.put("contentVersion", contentVersion);
817
			
668
			
818
			VelocityContext context = new VelocityContext();
669
			VelocityContext context = new VelocityContext();
819
			context.put("itemDetails", itemDetails);
-
 
820
			context.put("params", params);
670
			context.put("params", params);
821
			
671
			
822
			String exportFileName = exportPath + catalogId + File.separator + "CategorySnippet.html";
672
			String exportFileName = exportPath + catalogId + File.separator + "CategorySnippet.vm";
823
			File exportFile = new File(exportFileName);
673
			File exportFile = new File(exportFileName);
824
			if(!exportFile.exists()) {
674
			if(!exportFile.exists()) {
825
				exportFile.createNewFile();
675
				exportFile.createNewFile();
826
			}
676
			}
827
			
677
			
Line 839... Line 689...
839
		} catch (Exception e) {
689
		} catch (Exception e) {
840
			e.printStackTrace();
690
			e.printStackTrace();
841
		}
691
		}
842
	}
692
	}
843
 
693
 
844
    private void getEntitySearchSnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
694
    private void getEntitySearchSnippetHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
845
		long catalogId = expEntity.getID();
695
		long catalogId = expEntity.getID();
846
		Map<String,String> params = new HashMap<String, String>();
696
		Map<String,String> params = new HashMap<String, String>();
847
		
-
 
848
		try {
697
		try {
849
			expEntity = CreationUtils.getExpandedEntity(catalogId);
698
			expEntity = CreationUtils.getExpandedEntity(catalogId);
850
			String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
699
			String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
851
			String prodName = title;
700
			String prodName = title;
852
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
701
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
Line 854... Line 703...
854
			}
703
			}
855
			
704
			
856
			String url = getEntityURL(expEntity);
705
			String url = getEntityURL(expEntity);
857
			String imagePrefix = getImagePrefix(expEntity);
706
			String imagePrefix = getImagePrefix(expEntity);
858
			
707
			
859
			catalogServiceClient = new CatalogServiceClient();
-
 
860
			client = catalogServiceClient.getClient();
-
 
861
			
-
 
862
			String tinySnippet = "";
708
			String tinySnippet = "";
863
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
709
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
864
			for(Feature feature: features){
710
			for(Feature feature: features){
865
				if(feature.getFeatureDefinitionID() == 120081){
711
				if(feature.getFeatureDefinitionID() == 120081){
866
					List<Bullet> bullets = feature.getBullets();
712
					List<Bullet> bullets = feature.getBullets();
Line 873... Line 719...
873
					}
719
					}
874
 				}
720
 				}
875
			}
721
			}
876
 
722
 
877
 
723
 
878
			List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
879
			
-
 
880
			Item minPriceItem = null;
-
 
881
			for(Item item: items){
-
 
882
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
883
				if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
-
 
884
					minPriceItem = item;
-
 
885
				}
-
 
886
				double sellingPrice = item.getSellingPrice();
-
 
887
				double mrp = item.getMrp();
-
 
888
				double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
889
				itemDetail.put("ITEM_ID", ((int)item.getId())+"");	
-
 
890
				itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
891
				itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
892
				itemDetail.put("SAVING", ((int)saving)+"");
-
 
893
				itemDetail.put("COLOR", item.getColor());
-
 
894
				itemDetails.add(itemDetail);
-
 
895
			}
-
 
896
			
-
 
897
			boolean showmrp = true;
-
 
898
			if (minPriceItem.getMrp() <= minPriceItem.getSellingPrice()) {
-
 
899
				showmrp = false;
-
 
900
			}
-
 
901
			params.put("TITLE", title);
724
			params.put("TITLE", title);
902
			params.put("PROD_NAME", prodName);
725
			params.put("PROD_NAME", prodName);
903
			params.put("URL", url);
726
			params.put("URL", url);
904
			params.put("IMAGE_PREFIX", imagePrefix);
727
			params.put("IMAGE_PREFIX", imagePrefix);
905
			params.put("SELLING_PRICE", ((int)minPriceItem.getSellingPrice())+"");
-
 
906
			params.put("MRP", ((int)minPriceItem.getMrp())+"");
-
 
907
			params.put("SHOWMRP", showmrp +"");
-
 
908
			params.put("CATALOG_ID", ((int)catalogId)+"");
728
			params.put("CATALOG_ID", ((int)catalogId)+"");
909
			params.put("ITEM_ID", minPriceItem.getId()+"");
-
 
910
			params.put("staticurl", staticurl);
-
 
911
			params.put("contentVersion", contentVersion);
729
			params.put("contentVersion", contentVersion);
912
			
-
 
913
			VelocityContext context = new VelocityContext();
730
			VelocityContext context = new VelocityContext();
914
			context.put("itemDetails", itemDetails);
-
 
915
			context.put("params", params);
731
			context.put("params", params);
916
			
-
 
917
			String exportFileName = exportPath + catalogId + File.separator + "SearchSnippet.html";
732
			String exportFileName = exportPath + catalogId + File.separator + "SearchSnippet.vm";
918
			File exportFile = new File(exportFileName);
733
			File exportFile = new File(exportFileName);
919
			if(!exportFile.exists()) {
734
			if(!exportFile.exists()) {
920
				exportFile.createNewFile();
735
				exportFile.createNewFile();
921
			}
736
			}
922
			
737
			
Line 935... Line 750...
935
			e.printStackTrace();
750
			e.printStackTrace();
936
		}
751
		}
937
	}
752
	}
938
 
753
 
939
	
754
	
940
    private void getEntityCompareSnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
755
    private void getEntityCompareSnippetHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
941
        long catalogId = expEntity.getID();
756
        long catalogId = expEntity.getID();
942
        Map<String,String> params = new HashMap<String, String>();
757
        Map<String,String> params = new HashMap<String, String>();
943
        
758
        
944
        try {
759
        try {
945
            expEntity = CreationUtils.getExpandedEntity(catalogId);
760
            expEntity = CreationUtils.getExpandedEntity(catalogId);
Line 949... Line 764...
949
            prodName = expEntity.getBrand() + " " + expEntity.getModelName();
764
            prodName = expEntity.getBrand() + " " + expEntity.getModelName();
950
            }
765
            }
951
            String url = getEntityURL(expEntity);
766
            String url = getEntityURL(expEntity);
952
            String imagePrefix = getImagePrefix(expEntity);
767
            String imagePrefix = getImagePrefix(expEntity);
953
            
768
            
954
            catalogServiceClient = new CatalogServiceClient();
-
 
955
            client = catalogServiceClient.getClient();
-
 
956
            
-
 
957
            String tinySnippet = "";
769
            String tinySnippet = "";
958
            List<Feature>  features = expEntity.getSlide(130054).getFeatures();
770
            List<Feature>  features = expEntity.getSlide(130054).getFeatures();
959
            for(Feature feature: features){
771
            for(Feature feature: features){
960
                if(feature.getFeatureDefinitionID() == 120081){
772
                if(feature.getFeatureDefinitionID() == 120081){
961
                    List<Bullet> bullets = feature.getBullets();
773
                    List<Bullet> bullets = feature.getBullets();
Line 967... Line 779...
967
                        System.out.println("Tiny Snippets is " + dataObject.getValue());
779
                        System.out.println("Tiny Snippets is " + dataObject.getValue());
968
                    }
780
                    }
969
                }
781
                }
970
            }
782
            }
971
 
783
 
972
 
-
 
973
            List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
974
            
784
            
975
            Item minPriceItem = null;
-
 
976
            for(Item item: items){
-
 
977
                Map<String, String> itemDetail = new HashMap<String, String>();
-
 
978
                if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
-
 
979
                    minPriceItem = item;
-
 
980
                }
-
 
981
                double sellingPrice = item.getSellingPrice();
-
 
982
                double mrp = item.getMrp();
-
 
983
                double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
984
                itemDetail.put("ITEM_ID", ((int)item.getId())+"");  
-
 
985
                itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
986
                itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
987
                itemDetail.put("SAVING", ((int)saving)+"");
-
 
988
                itemDetail.put("COLOR", item.getColor());
-
 
989
                itemDetails.add(itemDetail);
-
 
990
            }
-
 
991
            
-
 
992
            boolean showmrp = true;
-
 
993
            if (minPriceItem.getMrp() <= minPriceItem.getSellingPrice()) {
-
 
994
                showmrp = false;
-
 
995
            }
-
 
996
            params.put("TITLE", title);
785
            params.put("TITLE", title);
997
            params.put("PROD_NAME", prodName);
786
            params.put("PROD_NAME", prodName);
998
            params.put("URL", url);
787
            params.put("URL", url);
999
            params.put("IMAGE_PREFIX", imagePrefix);
788
            params.put("IMAGE_PREFIX", imagePrefix);
1000
            params.put("SELLING_PRICE", ((int)minPriceItem.getSellingPrice())+"");
-
 
1001
            params.put("MRP", ((int)minPriceItem.getMrp())+"");
-
 
1002
            params.put("SHOWMRP", showmrp +"");
-
 
1003
            params.put("CATALOG_ID", ((int)catalogId)+"");
789
            params.put("CATALOG_ID", ((int)catalogId)+"");
1004
            params.put("ITEM_ID", minPriceItem.getId()+"");
-
 
1005
            params.put("staticurl", staticurl);
-
 
1006
            params.put("contentVersion", contentVersion);
790
            params.put("contentVersion", contentVersion);
1007
            
791
            
1008
            VelocityContext context = new VelocityContext();
792
            VelocityContext context = new VelocityContext();
1009
            context.put("itemDetails", itemDetails);
-
 
1010
            context.put("params", params);
793
            context.put("params", params);
1011
            
794
            
1012
            String exportFileName = exportPath + catalogId + File.separator + "CompareProductSnippet.html";
795
            String exportFileName = exportPath + catalogId + File.separator + "CompareProductSnippet.vm";
1013
            File exportFile = new File(exportFileName);
796
            File exportFile = new File(exportFileName);
1014
            if(!exportFile.exists()) {
797
            if(!exportFile.exists()) {
1015
                exportFile.createNewFile();
798
                exportFile.createNewFile();
1016
            }
799
            }
1017
            
800
            
Line 1030... Line 813...
1030
            e.printStackTrace();
813
            e.printStackTrace();
1031
        }
814
        }
1032
    }
815
    }
1033
 
816
 
1034
    
817
    
1035
    private void getEntityCompareSummarySnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
818
    private void getEntityCompareSummarySnippetHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
1036
        long catalogId = expEntity.getID();
819
        long catalogId = expEntity.getID();
1037
        Map<String,String> params = new HashMap<String, String>();
820
        Map<String,String> params = new HashMap<String, String>();
1038
        
-
 
1039
        try {
821
        try {
1040
            expEntity = CreationUtils.getExpandedEntity(catalogId);
822
            expEntity = CreationUtils.getExpandedEntity(catalogId);
1041
            String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
823
            String title = expEntity.getBrand() + " " + expEntity.getModelName()+ " " + expEntity.getModelNumber();
1042
            String prodName = title;
824
            String prodName = title;
1043
            if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
825
            if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
1044
            prodName = expEntity.getBrand() + " " + expEntity.getModelName();
826
            prodName = expEntity.getBrand() + " " + expEntity.getModelName();
1045
            }
827
            }
1046
            String url = getEntityURL(expEntity);
828
            String url = getEntityURL(expEntity);
1047
            String imagePrefix = getImagePrefix(expEntity);
829
            String imagePrefix = getImagePrefix(expEntity);
1048
            
830
            
1049
            catalogServiceClient = new CatalogServiceClient();
-
 
1050
            client = catalogServiceClient.getClient();
-
 
1051
            
-
 
1052
            String tinySnippet = "";
831
            String tinySnippet = "";
1053
            List<Feature>  features = expEntity.getSlide(130054).getFeatures();
832
            List<Feature>  features = expEntity.getSlide(130054).getFeatures();
1054
            for(Feature feature: features){
833
            for(Feature feature: features){
1055
                if(feature.getFeatureDefinitionID() == 120081){
834
                if(feature.getFeatureDefinitionID() == 120081){
1056
                    List<Bullet> bullets = feature.getBullets();
835
                    List<Bullet> bullets = feature.getBullets();
Line 1063... Line 842...
1063
                    }
842
                    }
1064
                }
843
                }
1065
            }
844
            }
1066
 
845
 
1067
 
846
 
1068
            List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
1069
            
-
 
1070
            Item minPriceItem = null;
-
 
1071
            for(Item item: items){
-
 
1072
                Map<String, String> itemDetail = new HashMap<String, String>();
-
 
1073
                if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
-
 
1074
                    minPriceItem = item;
-
 
1075
                }
-
 
1076
                double sellingPrice = item.getSellingPrice();
-
 
1077
                double mrp = item.getMrp();
-
 
1078
                double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
1079
                itemDetail.put("ITEM_ID", ((int)item.getId())+"");  
-
 
1080
                itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
1081
                itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
1082
                itemDetail.put("SAVING", ((int)saving)+"");
-
 
1083
                itemDetail.put("COLOR", item.getColor());
-
 
1084
                itemDetails.add(itemDetail);
-
 
1085
            }
-
 
1086
            
-
 
1087
            boolean showmrp = true;
-
 
1088
            if (minPriceItem.getMrp() <= minPriceItem.getSellingPrice()) {
-
 
1089
                showmrp = false;
-
 
1090
            }
-
 
1091
            params.put("TITLE", title);
847
            params.put("TITLE", title);
1092
            params.put("PROD_NAME", prodName);
848
            params.put("PROD_NAME", prodName);
1093
            params.put("URL", url);
849
            params.put("URL", url);
1094
            params.put("IMAGE_PREFIX", imagePrefix);
850
            params.put("IMAGE_PREFIX", imagePrefix);
1095
            params.put("SELLING_PRICE", ((int)minPriceItem.getSellingPrice())+"");
-
 
1096
            params.put("MRP", ((int)minPriceItem.getMrp())+"");
-
 
1097
            params.put("SHOWMRP", showmrp +"");
-
 
1098
            params.put("CATALOG_ID", ((int)catalogId)+"");
851
            params.put("CATALOG_ID", ((int)catalogId)+"");
1099
            params.put("ITEM_ID", minPriceItem.getId()+"");
-
 
1100
            params.put("staticurl", staticurl);
-
 
1101
            params.put("contentVersion", contentVersion);
852
            params.put("contentVersion", contentVersion);
1102
            
853
            
1103
            VelocityContext context = new VelocityContext();
854
            VelocityContext context = new VelocityContext();
1104
            context.put("itemDetails", itemDetails);
-
 
1105
            context.put("params", params);
855
            context.put("params", params);
1106
            
856
            
1107
            String exportFileName = exportPath + catalogId + File.separator + "CompareProductSummarySnippet.html";
857
            String exportFileName = exportPath + catalogId + File.separator + "CompareProductSummarySnippet.vm";
1108
            File exportFile = new File(exportFileName);
858
            File exportFile = new File(exportFileName);
1109
            if(!exportFile.exists()) {
859
            if(!exportFile.exists()) {
1110
                exportFile.createNewFile();
860
                exportFile.createNewFile();
1111
            }
861
            }
1112
            
862
            
Line 1124... Line 874...
1124
        } catch (Exception e) {
874
        } catch (Exception e) {
1125
            e.printStackTrace();
875
            e.printStackTrace();
1126
        }
876
        }
1127
    }
877
    }
1128
 
878
 
1129
	private void getEntityPhonesIOwnSnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
879
	private void getEntityPhonesIOwnSnippetHtml(ExpandedEntity expEntity, String templateFile, String exportPath) {
1130
		long catalogId = expEntity.getID();
880
		long catalogId = expEntity.getID();
1131
		Map<String,String> params = new HashMap<String, String>();
881
		Map<String,String> params = new HashMap<String, String>();
1132
		
882
		
1133
		try {
883
		try {
1134
			expEntity = CreationUtils.getExpandedEntity(catalogId);
884
			expEntity = CreationUtils.getExpandedEntity(catalogId);
Line 1139... Line 889...
1139
			}
889
			}
1140
			String url = getEntityURL(expEntity);
890
			String url = getEntityURL(expEntity);
1141
			 
891
			 
1142
			String imagePrefix = getImagePrefix(expEntity);
892
			String imagePrefix = getImagePrefix(expEntity);
1143
			
893
			
1144
			catalogServiceClient = new CatalogServiceClient();
-
 
1145
			client = catalogServiceClient.getClient();
-
 
1146
			
-
 
1147
			String tinySnippet = "";
894
			String tinySnippet = "";
1148
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
895
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
1149
			for(Feature feature: features){
896
			for(Feature feature: features){
1150
				if(feature.getFeatureDefinitionID() == 120081){
897
				if(feature.getFeatureDefinitionID() == 120081){
1151
					List<Bullet> bullets = feature.getBullets();
898
					List<Bullet> bullets = feature.getBullets();
Line 1157... Line 904...
1157
						System.out.println("Tiny Snippets is " + dataObject.getValue());
904
						System.out.println("Tiny Snippets is " + dataObject.getValue());
1158
					}
905
					}
1159
 				}
906
 				}
1160
			}
907
			}
1161
 
908
 
1162
 
-
 
1163
			List<Map<String, String>> itemDetails = new ArrayList<Map<String,String>>(); 
-
 
1164
			
-
 
1165
			Item minPriceItem = null;
-
 
1166
			for(Item item: items){
-
 
1167
				Map<String, String> itemDetail = new HashMap<String, String>();
-
 
1168
				if(minPriceItem == null || minPriceItem.getSellingPrice() > item.getSellingPrice()){
-
 
1169
					minPriceItem = item;
-
 
1170
				}
-
 
1171
				double sellingPrice = item.getSellingPrice();
-
 
1172
				double mrp = item.getMrp();
-
 
1173
				double saving = Math.round((mrp-sellingPrice)/mrp*100);
-
 
1174
				itemDetail.put("ITEM_ID", ((int)item.getId())+"");	
-
 
1175
				itemDetail.put("SP", ((int)item.getSellingPrice())+"");
-
 
1176
				itemDetail.put("MRP", ((int)item.getMrp())+"");
-
 
1177
				itemDetail.put("SAVING", ((int)saving)+"");
-
 
1178
				itemDetail.put("COLOR", item.getColor());
-
 
1179
				itemDetails.add(itemDetail);
-
 
1180
			}
-
 
1181
			
-
 
1182
			boolean showmrp = true;
-
 
1183
			if (minPriceItem.getMrp() <= minPriceItem.getSellingPrice()) {
-
 
1184
				showmrp = false;
-
 
1185
			}
-
 
1186
			params.put("TITLE", title);
909
			params.put("TITLE", title);
1187
			params.put("PROD_NAME", prodName);
910
			params.put("PROD_NAME", prodName);
1188
			params.put("URL", url);
911
			params.put("URL", url);
1189
			params.put("IMAGE_PREFIX", imagePrefix);
912
			params.put("IMAGE_PREFIX", imagePrefix);
1190
			params.put("SELLING_PRICE", ((int)minPriceItem.getSellingPrice())+"");
-
 
1191
			params.put("MRP", ((int)minPriceItem.getMrp())+"");
-
 
1192
			params.put("SHOWMRP", showmrp +"");
-
 
1193
			params.put("CATALOG_ID", ((int)catalogId)+"");
913
			params.put("CATALOG_ID", ((int)catalogId)+"");
1194
			params.put("ITEM_ID", minPriceItem.getId()+"");
-
 
1195
			params.put("staticurl", staticurl);
-
 
1196
			params.put("contentVersion", contentVersion);
914
			params.put("contentVersion", contentVersion);
1197
			
915
			
1198
			VelocityContext context = new VelocityContext();
916
			VelocityContext context = new VelocityContext();
1199
			context.put("itemDetails", itemDetails);
-
 
1200
			context.put("params", params);
917
			context.put("params", params);
1201
			
918
			
1202
			String exportFileName = exportPath + catalogId + File.separator + "PhonesIOwnSnippet.html";
919
			String exportFileName = exportPath + catalogId + File.separator + "PhonesIOwnSnippet.vm";
1203
			File exportFile = new File(exportFileName);
920
			File exportFile = new File(exportFileName);
1204
			if(!exportFile.exists()) {
921
			if(!exportFile.exists()) {
1205
				exportFile.createNewFile();
922
				exportFile.createNewFile();
1206
			}
923
			}
1207
			
924