Subversion Repositories SmartDukaan

Rev

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

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