Subversion Repositories SmartDukaan

Rev

Rev 21727 | Rev 22162 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.util;

import com.google.gson.Gson;
import com.spice.profitmandi.dao.model.ContentPojo;
import com.spice.profitmandi.dao.model.ProductPojo;
import com.spice.profitmandi.dao.repository.dtr.Mongo;


public class ContentPojoPopulator {

        private static final Gson gs = new Gson();

        public static ProductPojo getShortContent(long entityId) {
                ContentPojo cp=null;
                ProductPojo pp = null;
                try {
                        cp = gs.fromJson(Mongo.getEntityById(entityId).toString(), ContentPojo.class);
                } catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
                try {
                        pp = new ProductPojo();
                        pp.setId(entityId);
                        pp.setDefaultImgUrl(cp.getDefaultImageUrl());
                        pp.setDescription(String.join(", ", cp.getKeySpecs().subList(0, Math.min(cp.getKeySpecs().size(), 3))));
                        pp.setImageUrl(cp.getIconImageUrl());
                        pp.setUrl(cp.getUrl());
                        pp.setTitle(cp.getTitle());
                } catch (Exception e) {
                        e.printStackTrace();
                        pp = null;
                }
                return pp;
        }

}