Subversion Repositories SmartDukaan

Rev

Rev 21602 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
21545 ashik.ali 1
package com.spice.profitmandi.dao.util;
2
 
3
import org.apache.commons.lang.StringUtils;
4
 
5
import com.google.gson.Gson;
6
import com.spice.profitmandi.dao.model.ContentPojo;
7
import com.spice.profitmandi.dao.model.ProductPojo;
8
import com.spice.profitmandi.dao.repository.Mongo;
9
 
10
 
11
public class ContentPojoPopulator {
12
 
13
	private static final Gson gs = new Gson();
14
 
15
	public static ProductPojo getShortContent(long entityId) {
16
		ContentPojo cp=null;
17
		ProductPojo pp = null;
18
		try {
19
			cp = gs.fromJson(Mongo.getEntityById(entityId).toString(), ContentPojo.class);
20
		} catch (Exception e) {
21
			e.printStackTrace();
22
			return null;
23
		}
24
		try {
25
			pp = new ProductPojo();
26
			pp.setId(entityId);
27
			pp.setDefaultImgUrl(cp.getDefaultImageUrl());
28
			pp.setDescription(StringUtils.join(cp.getKeySpecs().subList(0, Math.min(cp.getKeySpecs().size(), 3)),", "));
29
			pp.setImageUrl(cp.getIconImageUrl());
30
			pp.setUrl(cp.getUrl());
31
			pp.setTitle(cp.getTitle());
32
		} catch (Exception e) {
33
			e.printStackTrace();
34
			pp = null;
35
		}
36
		return pp;
37
	}
38
 
39
}