Subversion Repositories SmartDukaan

Rev

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

Rev 11154 Rev 11585
Line 5... Line 5...
5
import in.shop2020.metamodel.util.CreationUtils;
5
import in.shop2020.metamodel.util.CreationUtils;
6
import in.shop2020.metamodel.util.ItemPojo;
6
import in.shop2020.metamodel.util.ItemPojo;
7
import in.shop2020.model.v1.catalog.CatalogService.Client;
7
import in.shop2020.model.v1.catalog.CatalogService.Client;
8
import in.shop2020.model.v1.catalog.CatalogServiceException;
8
import in.shop2020.model.v1.catalog.CatalogServiceException;
9
import in.shop2020.model.v1.catalog.Item;
9
import in.shop2020.model.v1.catalog.Item;
-
 
10
import in.shop2020.model.v1.catalog.PrivateDeal;
10
import in.shop2020.model.v1.catalog.Source;
11
import in.shop2020.model.v1.catalog.Source;
11
import in.shop2020.model.v1.catalog.SourceItemPricing;
12
import in.shop2020.model.v1.catalog.SourceItemPricing;
12
import in.shop2020.model.v1.catalog.status;
13
import in.shop2020.model.v1.catalog.status;
13
import in.shop2020.model.v1.order.EmiScheme;
14
import in.shop2020.model.v1.order.EmiScheme;
14
import in.shop2020.thrift.clients.CatalogClient;
15
import in.shop2020.thrift.clients.CatalogClient;
Line 29... Line 30...
29
import java.util.Properties;
30
import java.util.Properties;
30
import java.util.TreeMap;
31
import java.util.TreeMap;
31
 
32
 
32
import org.apache.commons.io.FileUtils;
33
import org.apache.commons.io.FileUtils;
33
import org.apache.thrift.TException;
34
import org.apache.thrift.TException;
34
import org.apache.thrift.transport.TTransportException;
-
 
35
import org.apache.velocity.Template;
35
import org.apache.velocity.Template;
36
import org.apache.velocity.VelocityContext;
36
import org.apache.velocity.VelocityContext;
37
import org.apache.velocity.app.Velocity;
37
import org.apache.velocity.app.Velocity;
38
import org.apache.velocity.exception.ParseErrorException;
38
import org.apache.velocity.exception.ParseErrorException;
39
import org.apache.velocity.exception.ResourceNotFoundException;
39
import org.apache.velocity.exception.ResourceNotFoundException;
Line 77... Line 77...
77
        }
77
        }
78
    }
78
    }
79
    CatalogClient csc;
79
    CatalogClient csc;
80
    Client client;
80
    Client client;
81
    PojoCreator creator;
81
    PojoCreator creator;
-
 
82
    private Map<Long, PrivateDeal> privateDealsMap;
82
 
83
 
83
	public PriceInsertor() throws TTransportException{
84
	public PriceInsertor() throws Exception{
84
        creator = new PojoCreator();
85
        creator = new PojoCreator();
85
        csc = new CatalogClient();
86
        csc = new CatalogClient();
86
        client = csc.getClient();
87
        client = csc.getClient();
-
 
88
        privateDealsMap = client.getAllActivePrivateDeals();
87
	}
89
	}
88
	
90
	
89
	public void copySolrSchemaFiles() throws IOException{
91
	public void copySolrSchemaFiles() throws IOException{
90
		String source = Utils.EXPORT_PATH + "xml/final/irmetadata_solrschema.xml";
92
		String source = Utils.EXPORT_PATH + "xml/final/irmetadata_solrschema.xml";
91
		String destination = Utils.EXPORT_PATH + "solr/irmetadata_solrschema.xml";
93
		String destination = Utils.EXPORT_PATH + "solr/irmetadata_solrschema.xml";
Line 124... Line 126...
124
		String offerDetailText = null;
126
		String offerDetailText = null;
125
		String offerDetailLink = null;
127
		String offerDetailLink = null;
126
		String afterArrival = null;
128
		String afterArrival = null;
127
		String showPrice = "TRUE";
129
		String showPrice = "TRUE";
128
		Item minPriceItem = null;
130
		Item minPriceItem = null;
-
 
131
		boolean isPrivateDeal = false;
129
		for(Item item: items){
132
		for(Item item: items){
130
			Map<String, String> itemDetail = new HashMap<String, String>();
133
			Map<String, String> itemDetail = new HashMap<String, String>();
131
			ItemPojo itemPojo = new ItemPojo();
134
			ItemPojo itemPojo = new ItemPojo();
132
			boolean showmrp = true;
135
			boolean showmrp = true;
133
			double sellingPrice = item.getSellingPrice();
136
			double sellingPrice = item.getSellingPrice();
Line 181... Line 184...
181
					itemPojo.setMinEmi(Double.parseDouble(em));
184
					itemPojo.setMinEmi(Double.parseDouble(em));
182
				}
185
				}
183
				if(showmrp) {
186
				if(showmrp) {
184
					itemPojo.setMrp(mrp);
187
					itemPojo.setMrp(mrp);
185
				}
188
				}
-
 
189
				if(privateDealsMap.containsKey(item.getId())  && item.getItemStatus().equals(status.ACTIVE)){
-
 
190
					PrivateDeal pd = privateDealsMap.get(item.getId());
-
 
191
					isPrivateDeal = true;
-
 
192
					itemDetail.put("DEAL_PRICE", String.format(Locale.getDefault(),"%.0f",pd.getDealPrice()));
-
 
193
				}
186
			}
194
			}
187
			String bestDealsText = item.getBestDealText();
195
			String bestDealsText = item.getBestDealText();
188
			if( bestDealsText != null && bestDealsText.length() > 0 && offerText == null && status.ACTIVE.equals(item.getItemStatus())){
196
			if( bestDealsText != null && bestDealsText.length() > 0 && offerText == null && status.ACTIVE.equals(item.getItemStatus())){
189
				offerText = bestDealsText;
197
				offerText = bestDealsText;
190
				String bestDealsDetailsText = item.getBestDealsDetailsText();
198
				String bestDealsDetailsText = item.getBestDealsDetailsText();
Line 259... Line 267...
259
                filenames.add("PhonesIOwnSnippet");
267
                filenames.add("PhonesIOwnSnippet");
260
            }
268
            }
261
            if(parentCategory.isHasAccessories()){
269
            if(parentCategory.isHasAccessories()){
262
                filenames.add("RelatedAccessories");
270
                filenames.add("RelatedAccessories");
263
            }
271
            }
-
 
272
            if(isPrivateDeal){
-
 
273
            	filenames.add("DealSnippet");
-
 
274
            }
264
            filenames.add("CompareProductSnippet");
275
            filenames.add("CompareProductSnippet");
265
            filenames.add("SlideNamesSnippet");
276
            filenames.add("SlideNamesSnippet");
266
            filenames.add("ComparisonSnippet");
277
            filenames.add("ComparisonSnippet");
267
            if(category.isComparable()) {
278
            if(category.isComparable()) {
268
            	//Before adding we should populate 
279
            	//Before adding we should populate