Subversion Repositories SmartDukaan

Rev

Rev 10003 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7506 amit.gupta 1
package in.shop2020.util;
2
 
3
import in.shop2020.metamodel.core.Entity;
4
import in.shop2020.metamodel.util.CreationUtils;
5
import in.shop2020.model.v1.catalog.CatalogService.Client;
6
import in.shop2020.model.v1.catalog.Item;
7
import in.shop2020.model.v1.catalog.status;
8
import in.shop2020.thrift.clients.CatalogClient;
9
import in.shop2020.ui.util.CatalogUploderToGAE;
10
 
11
import java.util.HashMap;
12
import java.util.HashSet;
13
import java.util.List;
14
import java.util.Map;
15
 
16
import org.apache.commons.logging.Log;
17
import org.apache.commons.logging.LogFactory;
18
 
19
public class WeeklyContentCreation {
20
 
21
	private static Log log = LogFactory.getLog(ContentGenerationUtility.class);
22
 
23
	private static List<Item> items = null;
24
	private static Map<Long,List<Item>> entityIdItemMap = new HashMap<Long, List<Item>>();
25
	private static List<Long> allValidEntityIds = null;
26
	private static List<Entity> allValidEntities = null;
27
 
28
	public static void main(String[] args) throws Exception {
29
		//Boolean.parseBoolean("true");
30
		Client client = new CatalogClient().getClient();
31
 
32
		items = client.getAllItemsByStatus(status.ACTIVE);
33
		items.addAll(client.getAllItemsByStatus(status.PAUSED));
34
		items.addAll(client.getAllItemsByStatus(status.COMING_SOON));
35
 
10007 amit.gupta 36
		/*populateEntityIdItemMap();
7506 amit.gupta 37
		Map<Long, Entity> allEntities = CreationUtils.getEntities();
38
		allValidEntities = new ArrayList<Entity>();
39
		allValidEntityIds = new ArrayList<Long>(entityIdItemMap.keySet());
40
 
41
		for(Long entityId : entityIdItemMap.keySet()) {
42
			if(allEntities.containsKey(entityId)){
43
				allValidEntities.add(allEntities.get(entityId));
44
			}
45
		}
7708 amit.gupta 46
		try {
47
		//Temporarily added
10007 amit.gupta 48
		AmazonSCDataGenerator asg = new AmazonSCDataGenerator(allValidEntities, "ALL");
49
		asg.generateSCProdData();
7708 amit.gupta 50
		}catch(Exception e){
51
			System.out.println("Could not generate Amazon feed.");
8131 amit.gupta 52
			e.printStackTrace();
10007 amit.gupta 53
		}*/
54
 
7506 amit.gupta 55
		// Upload catalog to Google App Engine.
7662 amit.gupta 56
		log.info("Uploading Catalog to Google app engine");
7506 amit.gupta 57
		CatalogUploderToGAE catalogUploaderToGAE = new CatalogUploderToGAE();
58
		catalogUploaderToGAE.uploadItems(items);
59
 
60
		// FIXME Avoiding the finding of accesories, as list of categories for
61
		// which we need to find accessories is hardocoded in code.
62
		// We need to make that configurable. Also creating ticket to improve
63
		// it.
64
		try {
65
			log.info("Finding accessories");
66
			AccessoriesFinder af = new AccessoriesFinder(new HashSet<Long>(
67
					allValidEntityIds));
68
			Map<Long, Map<Long, List<Long>>> relatedAccessories = af
69
					.findAccessories();
70
			CreationUtils.storeRelatedAccessories(relatedAccessories);
71
		} catch (Exception e) {
72
			log.error("Error while generating accessories" + e);
73
		}
74
 
75
        // Generate synonyms list. This will be used in PriceComparisonTool to
76
        // resolve the product names.
77
        log.info("Generating synonyms");
78
        SynonymExporter sx = new SynonymExporter();
79
        sx.storeSynonyms(allValidEntities);
80
 
81
        //Generation for website SEO      
82
        log.info("Generating HTML for Site Index");
83
        ProductIndexGenerator indexGenerator = new ProductIndexGenerator(allValidEntities);
84
        indexGenerator.generate();
85
 
86
        log.info("Generating HTML for Site for Product Documents");
87
        ProductDocumentsGenerator asGenerator = new ProductDocumentsGenerator(allValidEntities);
88
        asGenerator.generate();
89
 
90
        log.info("Generating HTML for Accessories Compatibility Index");	
91
        CompatibleAccessoriesIndexGenerator generator = new CompatibleAccessoriesIndexGenerator(allValidEntities);
92
        generator.generate();
93
 
94
        log.info("Generating HTML for Most Frequently searched keywords");
95
        MostFrequentlySearchedKeywords mfsk = new MostFrequentlySearchedKeywords();
96
        mfsk.generate();
97
 
98
        log.info("Generating HTML for Most Compared Index");
99
        MostComparedIndexGenerator mostCompGenerator = new MostComparedIndexGenerator(allValidEntityIds);
100
        mostCompGenerator.generate();
101
 
102
        log.info("Generating XML for Mobile Site XML feed");
103
        MobileSiteDataXMLGenerator mSiteXMLGenerator = new MobileSiteDataXMLGenerator(allValidEntities);
10007 amit.gupta 104
        mSiteXMLGenerator.generate();
7506 amit.gupta 105
	}
106
 
10007 amit.gupta 107
    /*
7506 amit.gupta 108
    private static void populateEntityIdItemMap() {
109
        Utils.info("Processing " + items.size() + " items");
110
        for (Item item : items) {
111
            Utils.info(item.getId() + " Item is adding");
112
            List<Item> itemList = entityIdItemMap.get(item.getCatalogItemId());
113
            if (itemList == null) {
114
                itemList = new ArrayList<Item>();
115
            } 
116
            itemList.add(item);
117
            entityIdItemMap.put(item.getCatalogItemId(), itemList);
118
        }
10007 amit.gupta 119
    }*/
7506 amit.gupta 120
}