Subversion Repositories SmartDukaan

Rev

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

Rev 9344 Rev 9388
Line 1... Line 1...
1
package in.shop2020.mobileapi.serving.utils;
1
package in.shop2020.mobileapi.serving.utils;
2
 
2
 
3
import in.shop2020.metamodel.util.ContentPojo;
3
import in.shop2020.metamodel.util.ContentPojo;
4
import in.shop2020.storage.mongo.StorageManager;
4
import in.shop2020.storage.mongo.StorageManager;
5
import in.shop2020.metamodel.util.ProductPojo;
5
import in.shop2020.metamodel.util.ProductPojo;
-
 
6
import in.shop2020.mobileapi.serving.controllers.CategoryController;
6
import in.shop2020.mobileapi.serving.pojos.MenuPojo;
7
import in.shop2020.mobileapi.serving.pojos.MenuPojo;
7
 
8
 
8
import java.util.ArrayList;
9
import java.util.ArrayList;
9
import java.util.List;
10
import java.util.List;
10
 
11
 
11
import org.apache.commons.lang.StringUtils;
12
import org.apache.commons.lang.StringUtils;
-
 
13
import org.apache.log4j.Logger;
12
 
14
 
13
import com.google.gson.Gson;
15
import com.google.gson.Gson;
14
 
16
 
15
public class PojoPopulator {
17
public class PojoPopulator {
16
	
18
	
17
	public static Gson gson = new Gson();
19
	public static Gson gson = new Gson();
-
 
20
	private static Logger log = Logger.getLogger(PojoPopulator.class);
18
 
21
 
19
    public static List<MenuPojo> getCurrentMenu() {
22
    public static List<MenuPojo> getCurrentMenu() {
20
        List<MenuPojo> finalList = new ArrayList<MenuPojo>();
23
        List<MenuPojo> finalList = new ArrayList<MenuPojo>();
21
        List<MenuPojo> children = new ArrayList<MenuPojo>();
24
        List<MenuPojo> children = new ArrayList<MenuPojo>();
22
 
25
 
Line 24... Line 27...
24
        children.clear();
27
        children.clear();
25
        children.add(getMenuPojoObject("Android Phones", "android", "", null));
28
        children.add(getMenuPojoObject("Android Phones", "android", "", null));
26
        children.add(getMenuPojoObject("Business Phones", "business", "", null));
29
        children.add(getMenuPojoObject("Business Phones", "business", "", null));
27
        children.add(getMenuPojoObject("Windows Phones", "windows", "", null));
30
        children.add(getMenuPojoObject("Windows Phones", "windows", "", null));
28
        children.add(getMenuPojoObject("Samsung Phones", "samsung", "", null));
31
        children.add(getMenuPojoObject("Samsung Phones", "samsung", "", null));
29
        finalList.add(getMenuPojoObject("Mobiles", "mobile", "images/menu/mobile.PNG", children));
32
        finalList.add(getMenuPojoObject("Mobiles", "all-mobiles/10006", "images/menu/mobile.PNG", children));
30
        //  Mobile Menu end
33
        //  Mobile Menu end
31
        
34
        
32
        //  Tablet Menu start
35
        //  Tablet Menu start
33
        children.clear();
36
        children.clear();
34
        children.add(getMenuPojoObject("With call facility", "tablets-with-calling", "", null));
37
        children.add(getMenuPojoObject("With call facility", "tablets-with-calling", "", null));
Line 97... Line 100...
97
        menuObject.setChildren(children);
100
        menuObject.setChildren(children);
98
        return menuObject;
101
        return menuObject;
99
    }
102
    }
100
    
103
    
101
	
104
	
102
	public static ProductPojo getShortContent(long entityId){
105
	public static ProductPojo getShortContent(long entityId) throws Exception{
103
		ContentPojo cp = StorageManager.getById(StorageManager.views.siteContent, entityId, ContentPojo.class);
106
		ContentPojo cp = StorageManager.getById(StorageManager.views.siteContent, entityId, ContentPojo.class);
104
		ProductPojo pp = null;
107
		ProductPojo pp = null;
105
		if(cp!=null){
108
		if(cp!=null){
-
 
109
			try {
106
			pp = new ProductPojo();
110
			pp = new ProductPojo();
107
			pp.setOfferText(cp.getOfferText());
111
			pp.setOfferText(cp.getOfferText());
108
			pp.setDescription(StringUtils.join(cp.getKeySpecs().subList(0, 3),", "));
112
			pp.setDescription(StringUtils.join(cp.getKeySpecs().subList(0, 3),", "));
109
			pp.setImageUrl(cp.getThumbnailImageUrl());
113
			pp.setImageUrl(cp.getThumbnailImageUrl());
110
			pp.setUrl(cp.getUrl());
114
			pp.setUrl(cp.getUrl());
111
			
115
			
112
			pp.setMrp(cp.getItems().get(0).getMrp());
116
			pp.setMrp(cp.getItems().get(0).getMrp());
113
			pp.setPrice(cp.getItems().get(0).getSellingPrice());
117
			pp.setPrice(cp.getItems().get(0).getSellingPrice());
114
			pp.setTitle(cp.getTitle());
118
			pp.setTitle(cp.getTitle());
-
 
119
			} catch (Exception e) {
-
 
120
				log.error("Error" + e.getMessage());
-
 
121
				pp = null;
-
 
122
			}
115
		}
123
		}
116
		return pp;
124
		return pp;
117
	}
125
	}
118
    
126
    
119
}
127
}