Subversion Repositories SmartDukaan

Rev

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

Rev 6842 Rev 6871
Line 18... Line 18...
18
import in.shop2020.ui.util.SpecialPageJSONConvertor;
18
import in.shop2020.ui.util.SpecialPageJSONConvertor;
19
import in.shop2020.utils.ConfigClientKeys;
19
import in.shop2020.utils.ConfigClientKeys;
20
import in.shop2020.utils.GmailUtils;
20
import in.shop2020.utils.GmailUtils;
21
 
21
 
22
import java.io.File;
22
import java.io.File;
-
 
23
import java.io.FileNotFoundException;
-
 
24
import java.io.FileReader;
23
import java.io.IOException;
25
import java.io.IOException;
-
 
26
import java.io.Reader;
24
import java.text.SimpleDateFormat;
27
import java.text.SimpleDateFormat;
25
import java.util.ArrayList;
28
import java.util.ArrayList;
26
import java.util.Calendar;
29
import java.util.Calendar;
27
import java.util.Date;
30
import java.util.Date;
28
import java.util.HashMap;
31
import java.util.HashMap;
Line 44... Line 47...
44
import org.apache.commons.logging.Log;
47
import org.apache.commons.logging.Log;
45
import org.apache.commons.logging.LogFactory;
48
import org.apache.commons.logging.LogFactory;
46
import org.apache.thrift.transport.TTransportException;
49
import org.apache.thrift.transport.TTransportException;
47
 
50
 
48
import com.google.gson.Gson;
51
import com.google.gson.Gson;
-
 
52
import com.google.gson.reflect.TypeToken;
49
 
53
 
50
public class ContentGenerationUtility {
54
public class ContentGenerationUtility {
51
    private static final String   UPDATE_TYPE_CATALOG         = "CATALOG";
55
    private static final String   UPDATE_TYPE_CATALOG         = "CATALOG";
52
 
56
 
53
    private static final String   UPDATE_TYPE_CONTENT         = "CONTENT";
57
    private static final String   UPDATE_TYPE_CONTENT         = "CONTENT";
Line 317... Line 321...
317
        	
321
        	
318
        }
322
        }
319
        PriceInsertor priceInserter = new PriceInsertor();
323
        PriceInsertor priceInserter = new PriceInsertor();
320
 
324
 
321
        Map<Long,List<String>> entityTags = client.getAllEntityTags();
325
        Map<Long,List<String>> entityTags = client.getAllEntityTags();
-
 
326
        Map<Long, Integer> popularityMap = getPolularityMap();
322
        for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
327
        for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
323
            long entityId = entry.getKey();
328
            long entityId = entry.getKey();
324
            List<Item> items = entry.getValue();
329
            List<Item> items = entry.getValue();
325
	            // TODO Domain name and destination directory should be read from
330
	            // TODO Domain name and destination directory should be read from
326
	            // properties file
331
	            // properties file
Line 349... Line 354...
349
            			List<String> tags = entityTags.get(entityId);
354
            			List<String> tags = entityTags.get(entityId);
350
            			for(String tag: tags){
355
            			for(String tag: tags){
351
            				availabilityString.append("\n<field name=\"F_50029\">" + tag + "</field>");
356
            				availabilityString.append("\n<field name=\"F_50029\">" + tag + "</field>");
352
            			}
357
            			}
353
            		}
358
            		}
-
 
359
            		if(popularityMap.containsKey(entityId)) {
-
 
360
            			availabilityString.append("\n<field name=\"F_50030\">" + popularityMap.get(entityId) + "</field>");
-
 
361
            		}else {
-
 
362
            			availabilityString.append("\n<field name=\"F_50030\">" + "0" + "</field>");
-
 
363
            		}
354
            		domainOnce = false;
364
            		domainOnce = false;
355
            	}
365
            	}
356
            	if(sources != null){
366
            	if(sources != null){
357
            		for (Source source : sources) {
367
            		for (Source source : sources) {
358
                        minPrice = priceInserter.insertPriceInHtml(items, entityId,
368
                        minPrice = priceInserter.insertPriceInHtml(items, entityId,
Line 373... Line 383...
373
 
383
 
374
        priceInserter.copySolrSchemaFiles();
384
        priceInserter.copySolrSchemaFiles();
375
        synonymTitlesExporter();
385
        synonymTitlesExporter();
376
    }
386
    }
377
 
387
 
-
 
388
    private Map<Long, Integer> getPolularityMap() {
-
 
389
		try {
-
 
390
			Reader reader = new FileReader(Utils.EXPORT_PATH + Utils.POPULARITY_JSON);
-
 
391
			return new Gson().fromJson(reader, new TypeToken<Map<Long, Integer>>() {}.getType());
-
 
392
		} catch (FileNotFoundException e) {
-
 
393
			log.error("Could not read popularity file");
-
 
394
			e.printStackTrace();
-
 
395
			return new HashMap<Long, Integer>();
-
 
396
		}
-
 
397
    	
-
 
398
	}
-
 
399
 
378
    private String getAvaialability(List<Item> value) {
400
	private String getAvaialability(List<Item> value) {
379
    	boolean isActive = true;
401
    	boolean isActive = true;
380
    	try {
402
    	try {
381
			Client catalogClientProd = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(), ConfigClientKeys.catalog_service_server_port.toString()).getClient();
403
			Client catalogClientProd = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(), ConfigClientKeys.catalog_service_server_port.toString()).getClient();
382
			for (Item item : value ) {
404
			for (Item item : value ) {
383
				if (item.getItemStatus().equals(status.ACTIVE)) {
405
				if (item.getItemStatus().equals(status.ACTIVE)) {