Subversion Repositories SmartDukaan

Rev

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

Rev 4384 Rev 4802
Line 1... Line 1...
1
package in.shop2020.util;
1
package in.shop2020.util;
2
 
2
 
3
import in.shop2020.metamodel.core.Entity;
3
import in.shop2020.metamodel.core.Entity;
-
 
4
import in.shop2020.metamodel.definitions.Catalog;
-
 
5
import in.shop2020.metamodel.definitions.DefinitionsContainer;
4
import in.shop2020.metamodel.util.CreationUtils;
6
import in.shop2020.metamodel.util.CreationUtils;
5
import in.shop2020.model.v1.catalog.Category;
-
 
6
import in.shop2020.model.v1.catalog.Item;
7
import in.shop2020.model.v1.catalog.Item;
7
import in.shop2020.utils.CategoryManager;
-
 
8
import in.shop2020.model.v1.catalog.status;
8
import in.shop2020.model.v1.catalog.status;
9
import in.shop2020.model.v1.user.ItemCouponDiscount;
9
import in.shop2020.model.v1.user.ItemCouponDiscount;
10
 
-
 
11
import in.shop2020.thrift.clients.CatalogClient;
10
import in.shop2020.thrift.clients.CatalogClient;
12
import in.shop2020.thrift.clients.PromotionClient;
11
import in.shop2020.thrift.clients.PromotionClient;
13
 
12
 
14
import java.io.File;
13
import java.io.File;
15
import java.util.ArrayList;
14
import java.util.ArrayList;
Line 31... Line 30...
31
 */
30
 */
32
public class ProductListGenerator {
31
public class ProductListGenerator {
33
	
32
	
34
	private String[] xmlIndentation = {"", "    ", "        ", "            ","                "};
33
	private String[] xmlIndentation = {"", "    ", "        ", "            ","                "};
35
	public Map<Long, List<Item>> entityIdItemMap;
34
	public Map<Long, List<Item>> entityIdItemMap;
36
	CategoryManager catm = CategoryManager.getCategoryManager();
35
	DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
37
	
36
	
38
	public ProductListGenerator(Map<Long, List<Item>> entityIdItemMap) throws Exception {
37
	public ProductListGenerator(Map<Long, List<Item>> entityIdItemMap) throws Exception {
39
		this.entityIdItemMap = entityIdItemMap;
38
		this.entityIdItemMap = entityIdItemMap;
40
	}
39
	}
41
	
40
	
Line 44... Line 43...
44
	 * Get the url of the entity
43
	 * Get the url of the entity
45
	 * @param expEntity
44
	 * @param expEntity
46
	 * @return url
45
	 * @return url
47
	 */
46
	 */
48
	private String getProductURL(long entityId, Item item){
47
	private String getProductURL(long entityId, Item item){
49
		long rootCategoryId = catm.getCategory(item.getCategory()).getParent_category_id();
48
		//long rootCategoryId = catm.getCategory(item.getCategory()).getParent_category_id();
50
		if(rootCategoryId == Utils.ROOT_CATAGOEY){
-
 
51
			rootCategoryId = item.getCategory(); 	
49
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
52
		}
50
		
53
		String url = "http://www.saholic.com/" + catm.getCategoryLabel(rootCategoryId).toLowerCase().replace(' ', '-') + "/";
51
		String url = "http://www.saholic.com/" + parentCategory.getLabel().toLowerCase().replace(' ', '-') + "/";
54
		String productUrl = ((item.getBrand() != null) ? item.getBrand().trim() + " " : "").toLowerCase().replace(' ', '-')
52
		String productUrl = ((item.getBrand() != null) ? item.getBrand().trim() + " " : "").toLowerCase().replace(' ', '-')
55
        + "-" + ((item.getModelName() != null) ? item.getModelName().trim() + " " : "").toLowerCase().replace(' ', '-') 
53
        + "-" + ((item.getModelName() != null) ? item.getModelName().trim() + " " : "").toLowerCase().replace(' ', '-') 
56
	    + "-" + (( item.getModelNumber() != null ) ? item.getModelNumber().trim() + " ": "" ).toLowerCase().replace(' ', '-')
54
	    + "-" + (( item.getModelNumber() != null ) ? item.getModelNumber().trim() + " ": "" ).toLowerCase().replace(' ', '-')
57
        + "-" + entityId;
55
        + "-" + entityId;
58
		productUrl = productUrl.replaceAll("/", "-");
56
		productUrl = productUrl.replaceAll("/", "-");
Line 99... Line 97...
99
	 * Check whether product is mobile or not
97
	 * Check whether product is mobile or not
100
	 * @param item
98
	 * @param item
101
	 * @return
99
	 * @return
102
	 */
100
	 */
103
	private boolean isMobile(Item item){
101
	private boolean isMobile(Item item){
104
		Category category = CategoryManager.getCategoryManager().getCategory(item.getCategory());
102
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
105
        long parentCategoryId = category.getParent_category_id();
103
		return parentCategory.getID() == Utils.MOBILE_PHONES_CATAGORY;
106
		if(parentCategoryId == Utils.MOBILE_ACCESSORIES_CATEGORY || category.getId() == Utils.LAPTOPS_CATEGORY){
-
 
107
			return false;
-
 
108
		}
-
 
109
		return true;
-
 
110
	}
104
	}
111
	
105
	
112
	/**
106
	/**
113
	 * Checks whether a product is laptop or not
107
	 * Checks whether a product is laptop or not
114
	 */
108
	 */
115
	private boolean isLaptop(Item item) {
109
	private boolean isLaptop(Item item) {
116
		
-
 
117
		Category category = CategoryManager.getCategoryManager().getCategory(item.getCategory());
110
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
118
//        long parentCategoryId = category.getParent_category_id();
-
 
119
        
-
 
120
        return category.getId() == Utils.LAPTOPS_CATEGORY ? true : false;
111
		return parentCategory.getID() == Utils.LAPTOPS_CATEGORY;
121
	}
112
	}
122
	
113
	
123
	/**
114
	/**
124
	 * 
115
	 * 
125
	 * @param item
116
	 * @param item