Subversion Repositories SmartDukaan

Rev

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

Rev 2227 Rev 2305
Line 1... Line 1...
1
package in.shop2020.ui.util;
1
package in.shop2020.ui.util;
2
 
2
 
3
import in.shop2020.metamodel.core.Bullet;
3
import in.shop2020.metamodel.core.Bullet;
4
import in.shop2020.metamodel.core.Entity;
4
import in.shop2020.metamodel.core.Entity;
5
import in.shop2020.metamodel.core.EntityState;
-
 
6
import in.shop2020.metamodel.core.EntityStatus;
-
 
7
import in.shop2020.metamodel.core.Feature;
5
import in.shop2020.metamodel.core.Feature;
8
import in.shop2020.metamodel.core.PrimitiveDataObject;
6
import in.shop2020.metamodel.core.PrimitiveDataObject;
9
import in.shop2020.metamodel.definitions.CMPBucketDefinition;
-
 
10
import in.shop2020.metamodel.definitions.Catalog;
7
import in.shop2020.metamodel.definitions.Catalog;
11
import in.shop2020.metamodel.definitions.DefinitionsContainer;
-
 
12
 
-
 
13
import in.shop2020.metamodel.definitions.SlideDefinition;
-
 
14
import in.shop2020.metamodel.util.CreationUtils;
8
import in.shop2020.metamodel.util.CreationUtils;
15
import in.shop2020.metamodel.util.ExpandedBullet;
9
import in.shop2020.metamodel.util.ExpandedBullet;
16
import in.shop2020.metamodel.util.ExpandedEntity;
10
import in.shop2020.metamodel.util.ExpandedEntity;
17
import in.shop2020.metamodel.util.ExpandedFeature;
11
import in.shop2020.metamodel.util.ExpandedFeature;
18
import in.shop2020.metamodel.util.ExpandedSlide;
12
import in.shop2020.metamodel.util.ExpandedSlide;
19
import in.shop2020.model.v1.catalog.InventoryService.Client;
13
import in.shop2020.model.v1.catalog.InventoryService.Client;
20
import in.shop2020.model.v1.catalog.Item;
14
import in.shop2020.model.v1.catalog.Item;
21
import in.shop2020.model.v1.catalog.status;
-
 
22
import in.shop2020.thrift.clients.CatalogServiceClient;
15
import in.shop2020.thrift.clients.CatalogServiceClient;
23
import in.shop2020.util.Utils;
16
import in.shop2020.util.Utils;
24
 
17
 
25
import java.awt.Graphics2D;
-
 
26
import java.awt.geom.AffineTransform;
-
 
27
import java.awt.image.BufferedImage;
-
 
28
import java.io.BufferedReader;
-
 
29
import java.io.BufferedWriter;
18
import java.io.BufferedWriter;
30
import java.io.DataInputStream;
-
 
31
import java.io.DataOutputStream;
-
 
32
import java.io.File;
19
import java.io.File;
33
import java.io.FileInputStream;
20
import java.io.FileInputStream;
34
import java.io.FileNotFoundException;
-
 
35
import java.io.FileOutputStream;
21
import java.io.FileOutputStream;
36
import java.io.FileReader;
-
 
37
import java.io.FileWriter;
-
 
38
import java.io.IOException;
22
import java.io.IOException;
39
import java.io.InputStream;
23
import java.io.InputStream;
40
import java.io.InputStreamReader;
-
 
41
import java.io.OutputStream;
24
import java.io.OutputStream;
42
import java.io.OutputStreamWriter;
25
import java.io.OutputStreamWriter;
43
import java.io.StringWriter;
26
import java.io.StringWriter;
44
import java.net.URLEncoder;
27
import java.net.URLEncoder;
45
import java.text.DecimalFormat;
28
import java.text.DecimalFormat;
46
import java.util.ArrayList;
29
import java.util.ArrayList;
47
import java.util.Collection;
-
 
48
import java.util.Date;
30
import java.util.Date;
49
import java.util.HashMap;
31
import java.util.HashMap;
50
import java.util.LinkedHashMap;
-
 
51
import java.util.List;
32
import java.util.List;
52
import java.util.Map;
33
import java.util.Map;
53
 
34
 
54
import javax.imageio.ImageIO;
-
 
55
 
-
 
56
import org.apache.commons.lang.StringUtils;
-
 
57
import org.apache.velocity.Template;
35
import org.apache.velocity.Template;
58
import org.apache.velocity.VelocityContext;
36
import org.apache.velocity.VelocityContext;
59
import org.apache.velocity.app.Velocity;
37
import org.apache.velocity.app.Velocity;
60
import org.apache.velocity.exception.MethodInvocationException;
38
import org.apache.velocity.exception.MethodInvocationException;
61
import org.apache.velocity.exception.ParseErrorException;
39
import org.apache.velocity.exception.ParseErrorException;
62
import org.apache.velocity.exception.ResourceNotFoundException;
40
import org.apache.velocity.exception.ResourceNotFoundException;
-
 
41
import org.json.JSONObject;
63
 
42
 
64
/**
43
/**
65
 * utility class to generated all html stuff from java objects
44
 * utility class to generated all html stuff from java objects
66
 * Driver class to merge Java data objects with VTL script. 
45
 * Driver class to merge Java data objects with VTL script. 
67
 * 
46
 * 
Line 81... Line 60...
81
		client = catalogServiceClient.getClient();
60
		client = catalogServiceClient.getClient();
82
		this.lastContentVersion = contentVersion.toString();
61
		this.lastContentVersion = contentVersion.toString();
83
		this.contentVersion =  (new Date()).getTime() +"" ;
62
		this.contentVersion =  (new Date()).getTime() +"" ;
84
	}
63
	}
85
 
64
 
86
	
-
 
87
	/**
-
 
88
	 * Usage: VUI [entities | entity] [Entity ID] {Template file name}
-
 
89
	 * 
-
 
90
	 * @param args
-
 
91
	 */
-
 
92
	public static void main(String[] args) throws Exception {
-
 
93
		
-
 
94
		String[] commands = new String[] {"entity", "entities", "entitiesall"};
-
 
95
		String[] datatypes = new String[] {"Entity ID"};
-
 
96
 
-
 
97
		String usage = "Usage: VUI ["+ StringUtils.join(commands, "|") +"] ["+ StringUtils.join(datatypes, "|") + "] ";
-
 
98
		
-
 
99
		if(args.length < 1) {
-
 
100
			System.out.println(usage);
-
 
101
			System.exit(-1);
-
 
102
		}
-
 
103
		String inputCommand = args[0];
-
 
104
		String inputID = null;
-
 
105
		if(args.length == 2){
-
 
106
			inputID = args[1];
-
 
107
		}
-
 
108
		
-
 
109
	    Long lastGenerationTime = CreationUtils.getLastContentGenerationTime();
-
 
110
	    if(lastGenerationTime==null){
-
 
111
	    	lastGenerationTime = new Long(0);
-
 
112
	    }
-
 
113
	    
-
 
114
	    //If non incremental content needs to be generated
-
 
115
	    if(inputCommand.equals("entitiesall") || inputCommand.equals("entity")) {
-
 
116
	    	lastGenerationTime = new Long(0);
-
 
117
	    }
-
 
118
	    
-
 
119
		NewVUI vui = new NewVUI(lastGenerationTime);
-
 
120
		
-
 
121
		long catalogId = 0;
-
 
122
		if(inputCommand.equals("entity")) {
-
 
123
			try {
-
 
124
				catalogId = Long.parseLong(inputID);
-
 
125
//				vui.generateHtmlForOneEntity(CreationUtils.getEntity(catalogId), "saholic.com", Utils.EXPORT_ENTITIES_PATH_SAHOLIC);
-
 
126
//				vui.generateHtmlForOneEntity(CreationUtils.getEntity(catalogId), "shop2020.in", Utils.EXPORT_ENTITIES_PATH_SHOP2020);
-
 
127
//				vui.generateHtmlForOneEntity(CreationUtils.getEntity(catalogId), "localhost:8090", Utils.EXPORT_ENTITIES_PATH_LOCALHOST);
-
 
128
			}
-
 
129
			catch (NumberFormatException nfe) {
-
 
130
				System.out.println("Invalid ID - " + inputID);
-
 
131
				System.exit(-1);
-
 
132
			}
-
 
133
		}
-
 
134
 
-
 
135
		if(inputCommand.equals("entities") || inputCommand.equals("entitiesall")) {
-
 
136
			vui.generateHtmlForAllEntities("saholic.com", Utils.EXPORT_ENTITIES_PATH_SAHOLIC);
-
 
137
			vui.generateHtmlForAllEntities("shop2020.in", Utils.EXPORT_ENTITIES_PATH_SHOP2020);
-
 
138
			vui.generateHtmlForAllEntities("localhost:8090", Utils.EXPORT_ENTITIES_PATH_LOCALHOST);
-
 
139
		}
-
 
140
		
-
 
141
		
-
 
142
		Velocity.init("src/main/java/in/shop2020/ui/util/velocity.properties");
-
 
143
		
-
 
144
		CreationUtils.storeLastContentGenerationTime((new Date()).getTime());
-
 
145
 
-
 
146
	}
-
 
147
 
-
 
148
	/**
65
	/**
149
	 * Generates content for the specified entity embedding links to the
66
	 * Generates content for the specified entity embedding links to the
150
	 * specified domain name.
67
	 * specified domain name.
151
	 * 
68
	 * 
152
	 * The method updates the member variable problems in any of the following
69
	 * The method updates the member variable problems in any of the following
Line 211... Line 128...
211
		getEntityCategorySnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
128
		getEntityCategorySnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
212
		
129
		
213
		templateFile= Utils.VTL_SRC_PATH + "slideguide_img_video.vm";
130
		templateFile= Utils.VTL_SRC_PATH + "slideguide_img_video.vm";
214
		getEntitySlideGuideHtml(expEntity, templateFile, domain, exportPath);
131
		getEntitySlideGuideHtml(expEntity, templateFile, domain, exportPath);
215
 
132
 
216
	    
-
 
217
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_phones_i_own.vm";
133
		templateFile= Utils.VTL_SRC_PATH + "entity_snippet_for_phones_i_own.vm";
218
		getEntityPhonesIOwnSnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
134
		getEntityPhonesIOwnSnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
219
		
135
		
220
		if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
136
		if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
221
		    
137
		    
Line 229... Line 145...
229
            getEntityCompareSummarySnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
145
            getEntityCompareSummarySnippetHtml(expEntity, items, templateFile, staticurl, exportPath);
230
 
146
 
231
            getSlidenamesSnippet(expEntity, exportPath);
147
            getSlidenamesSnippet(expEntity, exportPath);
232
		}
148
		}
233
		
149
		
234
		getEntityTitleSnippetHtml(expEntity, exportPath);
150
		getProductPropertiesSnippet(expEntity, exportPath);
235
		
-
 
236
		getEntityMetaDescriptionSnippetHtml(expEntity, exportPath);
-
 
237
		
-
 
238
		getEntityMetaKeywordSnippetHtml(expEntity, exportPath);
-
 
239
		
151
		
240
		generateImages(expEntity.getID(), getImagePrefix(expEntity));
152
		generateImages(expEntity.getID(), getImagePrefix(expEntity));
241
		
153
		
242
		return true;
154
		return true;
243
	}
155
	}
244
	
156
	
245
	private boolean generateHtmlForAllEntities(String domain, String exportPath) throws Exception{
-
 
246
		Map<Long, Entity> entities =  CreationUtils.getEntities();
-
 
247
		for(Entity entity: entities.values()){
-
 
248
	//		generateHtmlForOneEntity(entity, domain, exportPath);
-
 
249
		}
-
 
250
		System.out.println(problems);
-
 
251
		return true;
-
 
252
	}
-
 
253
 
-
 
254
		
-
 
255
		
-
 
256
	public boolean deleteDir(File dir) {
157
	public boolean deleteDir(File dir) {
257
	    if (dir.isDirectory()) {
158
	    if (dir.isDirectory()) {
258
	        String[] children = dir.list();
159
	        String[] children = dir.list();
259
	        for (int i=0; i<children.length; i++) {
160
	        for (int i=0; i<children.length; i++) {
260
	            boolean success = deleteDir(new File(dir, children[i]));
161
	            boolean success = deleteDir(new File(dir, children[i]));
Line 338... Line 239...
338
 
239
 
339
		if (!destinationFile.exists())
240
		if (!destinationFile.exists())
340
			destinationFile.createNewFile();
241
			destinationFile.createNewFile();
341
 
242
 
342
		InputStream in = new FileInputStream(sourceFile);
243
		InputStream in = new FileInputStream(sourceFile);
343
		OutputStream out = new FileOutputStream(destinationFile);
244
	    OutputStream out = new FileOutputStream(destinationFile);
344
		// Copy the bits from instream to outstream
245
		// Copy the bits from instream to outstream
345
		byte[] buf = new byte[1024];
246
		byte[] buf = new byte[1024];
346
		int len;
247
		int len;
347
		while ((len = in.read(buf)) > 0) {
248
		while ((len = in.read(buf)) > 0) {
348
			out.write(buf, 0, len);
249
			out.write(buf, 0, len);
Line 383... Line 284...
383
	        in.close();
284
	        in.close();
384
	        out.close();
285
	        out.close();
385
	    }
286
	    }
386
	}
287
	}
387
	 
288
	 
-
 
289
	private  void getProductPropertiesSnippet(ExpandedEntity expEntity, String exportPath) {
-
 
290
        long catalogId = expEntity.getID();
-
 
291
        try {
-
 
292
            expEntity = CreationUtils.getExpandedEntity(catalogId);
-
 
293
        } catch (Exception e) {
-
 
294
            e.printStackTrace();
-
 
295
        }
-
 
296
        
-
 
297
        String metaDescription = "";
-
 
298
        String metaKeywords = "";
-
 
299
        String entityUrl = getEntityURL(expEntity);
-
 
300
        String title = "";
-
 
301
        
-
 
302
        List<Feature>  features = expEntity.getSlide(130054).getFeatures();
-
 
303
        for(Feature feature: features){
-
 
304
            if(feature.getFeatureDefinitionID() == 120132){
-
 
305
                PrimitiveDataObject dataObject= (PrimitiveDataObject)feature.getBullets().get(0).getDataObject();
-
 
306
                title = dataObject.getValue(); 
-
 
307
            }
-
 
308
            if(feature.getFeatureDefinitionID() == 120133){
-
 
309
                PrimitiveDataObject dataObject= (PrimitiveDataObject)feature.getBullets().get(0).getDataObject();
-
 
310
                metaDescription = dataObject.getValue();
-
 
311
            }
-
 
312
            if(feature.getFeatureDefinitionID() == 120134){
-
 
313
                PrimitiveDataObject dataObject= (PrimitiveDataObject)feature.getBullets().get(0).getDataObject();
-
 
314
                metaKeywords = dataObject.getValue();
-
 
315
            }
-
 
316
        }
388
 
317
 
389
	private  void getEntityMetaDescriptionSnippetHtml(ExpandedEntity expEntity, String exportPath) {
-
 
390
		long catalogId = expEntity.getID();
-
 
391
		try {
318
        try {
392
			expEntity = CreationUtils.getExpandedEntity(catalogId);
-
 
393
			String description = "Best Price " + expEntity.getBrand() + " " + expEntity.getModelName() 
-
 
394
				+ " " + expEntity.getModelNumber() + " ";
-
 
395
			
-
 
396
			if(expEntity.getCategory().getParentCategory().getID() == 10011) {
-
 
397
				description += expEntity.getCategory().getLabel() + " in India.";
-
 
398
			}
-
 
399
			else {
-
 
400
				description += ".";
-
 
401
			}
-
 
402
			description += " Experience n' buy online. FREE Next Day delivery."
-
 
403
				+ " Original product - Full manufacturer warranty. Comprehensive reviews.";
-
 
404
			
-
 
405
			description = description.replaceAll("--", "-");
-
 
406
			String exportFileName = exportPath + catalogId + File.separator + "MetaDescriptionSnippet.html";
-
 
407
			File exportFile = new File(exportFileName);
-
 
408
			if(!exportFile.exists()) {
-
 
409
				exportFile.createNewFile();
-
 
410
			}
-
 
411
			
-
 
412
			BufferedWriter writer = new BufferedWriter(
-
 
413
			    new OutputStreamWriter(new FileOutputStream(exportFile)));
-
 
414
 
319
 
-
 
320
            JSONObject props = new JSONObject();
-
 
321
            props.put("metaDescription", metaDescription);
-
 
322
            props.put("metaKeywords", metaKeywords);
-
 
323
            props.put("entityUrl", entityUrl);
-
 
324
            props.put("title", title);
-
 
325
 
-
 
326
            String exportFileName = exportPath + catalogId + File.separator
-
 
327
                    + "ProductPropertiesSnippet.html";
-
 
328
            File exportFile = new File(exportFileName);
-
 
329
            if (!exportFile.exists()) {
-
 
330
                exportFile.createNewFile();
-
 
331
            }
-
 
332
 
-
 
333
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
-
 
334
                    new FileOutputStream(exportFile)));
-
 
335
 
415
			writer.write(description);
336
            writer.write(props.toString());
416
			
337
 
417
			writer.flush();
338
            writer.flush();
418
			writer.close();
339
            writer.close();
419
		} catch (Exception e) {
340
        } catch (Exception e) {
420
			e.printStackTrace();
341
            e.printStackTrace();
421
		}
342
        }
422
	}
343
	}
423
 
344
 
424
	private  void getEntityMetaKeywordSnippetHtml(ExpandedEntity expEntity, String exportPath) {
-
 
425
		long catalogId = expEntity.getID();
-
 
426
		try {
-
 
427
			expEntity = CreationUtils.getExpandedEntity(catalogId);
-
 
428
			String keywords;
-
 
429
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
-
 
430
				keywords = expEntity.getBrand() + " " + expEntity.getModelName() + ", ";
-
 
431
				if (expEntity.getCategory().getParentCategory().getID() == 10001) {
-
 
432
					keywords += expEntity.getBrand() + " mobile phones, ";
-
 
433
				}
-
 
434
				if (expEntity.getCategory().getParentCategory().getID() == 10011) {
-
 
435
					keywords += "phone accessories, ";
-
 
436
				}
-
 
437
				keywords += expEntity.getBrand() + " " + expEntity.getModelName() + " Price, ";
-
 
438
				keywords += expEntity.getBrand() + " " + expEntity.getModelName() + " India, ";
-
 
439
				if (expEntity.getCategory().getParentCategory().getID() == 10001) {
-
 
440
					keywords += expEntity.getBrand() + " " + expEntity.getModelName() + " Review, ";
-
 
441
				}	
-
 
442
	 		}
-
 
443
			else {
-
 
444
				keywords = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber() + ", ";
-
 
445
				if(expEntity.getCategory().getParentCategory().getID() == 10001) {
-
 
446
					keywords += expEntity.getBrand() + " mobile phones, ";
-
 
447
				}
-
 
448
				if(expEntity.getCategory().getParentCategory().getID() == 10011) {
-
 
449
					keywords += "phone accessories, ";
-
 
450
				}
-
 
451
				keywords += expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber() + " Price, ";
-
 
452
				keywords += expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber() + " India, ";
-
 
453
				if(expEntity.getCategory().getParentCategory().getID() == 10001) {
-
 
454
					keywords += expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber() + " Review, ";
-
 
455
				}
-
 
456
			}
-
 
457
			
-
 
458
			
-
 
459
			String exportFileName = exportPath + catalogId + File.separator + "MetaKeywordsSnippet.html";
-
 
460
			File exportFile = new File(exportFileName);
-
 
461
			if(!exportFile.exists()) {
-
 
462
				exportFile.createNewFile();
-
 
463
			}
-
 
464
			
-
 
465
			BufferedWriter writer = new BufferedWriter(
-
 
466
			    new OutputStreamWriter(new FileOutputStream(exportFile)));
-
 
467
 
-
 
468
			writer.write(keywords);
-
 
469
			
-
 
470
			writer.flush();
-
 
471
			writer.close();
-
 
472
		} catch (Exception e) {
-
 
473
			e.printStackTrace();
-
 
474
		}
-
 
475
	}
-
 
476
	
-
 
477
	
-
 
478
	private void getSlidenamesSnippet(ExpandedEntity expEntity, String exportPath) throws ResourceNotFoundException, ParseErrorException, Exception{
345
    private void getSlidenamesSnippet(ExpandedEntity expEntity, String exportPath) throws ResourceNotFoundException, ParseErrorException, Exception{
479
	    long catalogId = expEntity.getID();
346
	    long catalogId = expEntity.getID();
480
        
347
        
481
	    StringBuilder slideNames = new StringBuilder();
348
	    StringBuilder slideNames = new StringBuilder();
482
	    
349
	    
483
	    slideNames.append(expEntity.getBrand() + " " + expEntity.getModelNumber() + " " + expEntity.getModelName() + "\n");
350
	    slideNames.append(expEntity.getBrand() + " " + expEntity.getModelNumber() + " " + expEntity.getModelName() + "\n");
Line 610... Line 477...
610
				itemDetail.put("IS_SELECTED", item.isDefaultForEntity() ? "SELECTED" : "");
477
				itemDetail.put("IS_SELECTED", item.isDefaultForEntity() ? "SELECTED" : "");
611
				itemDetails.add(itemDetail);
478
				itemDetails.add(itemDetail);
612
			}
479
			}
613
			
480
			
614
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
481
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
-
 
482
			String brandName = expEntity.getBrand();
-
 
483
			String productName = expEntity.getModelName() + " " + expEntity.getModelNumber();
615
			String categoryName = expEntity.getCategory().getLabel();
484
			String categoryName = expEntity.getCategory().getLabel();
616
			String tagline = "";
485
			String tagline = "";
617
			String warranty = "";
486
			String warranty = "";
618
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
487
			List<Feature>  features = expEntity.getSlide(130054).getFeatures();
619
			for(Feature feature: features){
488
			for(Feature feature: features){
Line 633... Line 502...
633
			
502
			
634
			
503
			
635
			long categoryId = expEntity.getCategory().getID();
504
			long categoryId = expEntity.getCategory().getID();
636
			Map<String,String> params = new HashMap<String, String>();
505
			Map<String,String> params = new HashMap<String, String>();
637
			params.put("TITLE", title);
506
			params.put("TITLE", title);
-
 
507
			params.put("BRAND_NAME", brandName);
-
 
508
			params.put("PRODUCT_NAME", productName);
638
			params.put("CATEGORY_ID", ((int)categoryId)+"");
509
			params.put("CATEGORY_ID", ((int)categoryId)+"");
639
			params.put("CATEGORY_NAME", categoryName);
510
			params.put("CATEGORY_NAME", categoryName);
640
			params.put("CATEGORY_URL", categoryName.replaceAll(" ", "-").toLowerCase() + "/" + categoryId);
511
			params.put("CATEGORY_URL", categoryName.replaceAll(" ", "-").toLowerCase() + "/" + categoryId);
641
			params.put("PRODUCT_URL", URLEncoder.encode("http://www."+ domain + this.getEntityURL(expEntity), "UTF-8"));
512
			params.put("PRODUCT_URL", URLEncoder.encode("http://www."+ domain + this.getEntityURL(expEntity), "UTF-8"));
642
			if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
513
			if(expEntity.getCategory().getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGOEY){
Line 681... Line 552...
681
        + "-" + expEntity.getModelName().toLowerCase().replace(' ', '-') 
552
        + "-" + expEntity.getModelName().toLowerCase().replace(' ', '-') 
682
	    + "-" + expEntity.getModelNumber().toLowerCase().replace(' ', '-')
553
	    + "-" + expEntity.getModelNumber().toLowerCase().replace(' ', '-')
683
        + "-" + expEntity.getID();
554
        + "-" + expEntity.getID();
684
		productUrl = productUrl.replaceAll("/", "-");
555
		productUrl = productUrl.replaceAll("/", "-");
685
		url = url + productUrl;
556
		url = url + productUrl;
686
		url = url.replaceAll("--", "-");
557
		url = url.replaceAll("-+", "-");
687
		return url;
558
		return url;
688
	}
559
	}
689
	
560
	
690
	private String getImagePrefix(ExpandedEntity expEntity){
561
	private String getImagePrefix(ExpandedEntity expEntity){
691
		String imagePrefix = expEntity.getBrand().toLowerCase().replace(' ', '-')
562
		String imagePrefix = expEntity.getBrand().toLowerCase().replace(' ', '-')
Line 967... Line 838...
967
		} catch (Exception e) {
838
		} catch (Exception e) {
968
			e.printStackTrace();
839
			e.printStackTrace();
969
		}
840
		}
970
	}
841
	}
971
 
842
 
972
	private  void getEntityTitleSnippetHtml(ExpandedEntity expEntity, String exportPath) {
-
 
973
		long catalogId = expEntity.getID();
-
 
974
		
-
 
975
		try {
-
 
976
			expEntity = CreationUtils.getExpandedEntity(catalogId);
-
 
977
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
-
 
978
			if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
-
 
979
			title = expEntity.getBrand() + " " + expEntity.getModelName();
-
 
980
			}
-
 
981
			if(expEntity.getCategory().getParentCategory().getID() == 10001) {
-
 
982
				title +=  " | " + expEntity.getBrand() + " Mobile Phones";
-
 
983
			}
-
 
984
			if(expEntity.getCategory().getParentCategory().getID() == 10011) {
-
 
985
				title += " " + expEntity.getCategory().getLabel()
-
 
986
		            + " | " + expEntity.getBrand() + " Mobile Phone Accessories";
-
 
987
			}
-
 
988
			title += " | Saholic.com";
-
 
989
			
-
 
990
			String exportFileName = exportPath + catalogId + File.separator + "TitleSnippet.html";
-
 
991
			File exportFile = new File(exportFileName);
-
 
992
			if(!exportFile.exists()) {
-
 
993
				exportFile.createNewFile();
-
 
994
			}
-
 
995
			
-
 
996
			BufferedWriter writer = new BufferedWriter(
-
 
997
			    new OutputStreamWriter(new FileOutputStream(exportFile)));
-
 
998
 
-
 
999
			writer.write(title);
-
 
1000
			
-
 
1001
			writer.flush();
-
 
1002
			writer.close();
-
 
1003
		} catch (Exception e) {
-
 
1004
			e.printStackTrace();
-
 
1005
		}
-
 
1006
	}
-
 
1007
 
-
 
1008
	
-
 
1009
	private void getEntitySearchSnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
843
    private void getEntitySearchSnippetHtml(ExpandedEntity expEntity, List<Item> items, String templateFile, String staticurl, String exportPath) {
1010
		long catalogId = expEntity.getID();
844
		long catalogId = expEntity.getID();
1011
		Map<String,String> params = new HashMap<String, String>();
845
		Map<String,String> params = new HashMap<String, String>();
1012
		
846
		
1013
		try {
847
		try {
1014
			expEntity = CreationUtils.getExpandedEntity(catalogId);
848
			expEntity = CreationUtils.getExpandedEntity(catalogId);