Subversion Repositories SmartDukaan

Rev

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

Rev 9313 Rev 10168
Line 1... Line 1...
1
package in.shop2020.ui.util;
1
package in.shop2020.ui.util;
2
 
2
 
3
import in.shop2020.metamodel.definitions.Catalog;
3
import in.shop2020.metamodel.definitions.Catalog;
4
import in.shop2020.metamodel.definitions.Category;
4
import in.shop2020.metamodel.definitions.Category;
-
 
5
import in.shop2020.metamodel.util.CreationUtils;
-
 
6
import in.shop2020.metamodel.util.ExpandedEntity;
5
import in.shop2020.metamodel.util.ItemPojo;
7
import in.shop2020.metamodel.util.ItemPojo;
6
import in.shop2020.model.v1.catalog.CatalogService.Client;
8
import in.shop2020.model.v1.catalog.CatalogService.Client;
7
import in.shop2020.model.v1.catalog.CatalogServiceException;
9
import in.shop2020.model.v1.catalog.CatalogServiceException;
8
import in.shop2020.model.v1.catalog.Item;
10
import in.shop2020.model.v1.catalog.Item;
9
import in.shop2020.model.v1.catalog.Source;
11
import in.shop2020.model.v1.catalog.Source;
Line 45... Line 47...
45
 * @author rajveer
47
 * @author rajveer
46
 *
48
 *
47
 */
49
 */
48
public class PriceInsertor {
50
public class PriceInsertor {
49
    static Map<Long, EmiScheme> EMI_SCHEMES = new TreeMap<Long, EmiScheme>();
51
    static Map<Long, EmiScheme> EMI_SCHEMES = new TreeMap<Long, EmiScheme>();
-
 
52
    private static Map<Long, Map<Long, Long>> comparisonStats;
50
    
53
    
51
    static {
54
    static {
52
        try {
55
        try {
-
 
56
        	comparisonStats = CreationUtils.getComparisonStats();
53
            TransactionClient transactionClient = new TransactionClient("support_transaction_service_server_host", "transaction_service_server_port");
57
            TransactionClient transactionClient = new TransactionClient("support_transaction_service_server_host", "transaction_service_server_port");
54
            in.shop2020.model.v1.order.TransactionService.Client trxClient = transactionClient.getClient();
58
            in.shop2020.model.v1.order.TransactionService.Client trxClient = transactionClient.getClient();
55
            List<EmiScheme> emiSchemes = trxClient.getAvailableEmiSchemes();
59
            List<EmiScheme> emiSchemes = trxClient.getAvailableEmiSchemes();
56
            System.out.println("EMIs:" + emiSchemes);
60
            System.out.println("EMIs:" + emiSchemes);
57
            for (EmiScheme emiScheme : emiSchemes){
61
            for (EmiScheme emiScheme : emiSchemes){
Line 185... Line 189...
185
				String bestDealsDetailsLink = item.getBestDealsDetailsLink();
189
				String bestDealsDetailsLink = item.getBestDealsDetailsLink();
186
				if( bestDealsDetailsLink != null && bestDealsDetailsLink.length() > 0){
190
				if( bestDealsDetailsLink != null && bestDealsDetailsLink.length() > 0){
187
					offerDetailLink = bestDealsDetailsLink;
191
					offerDetailLink = bestDealsDetailsLink;
188
				}
192
				}
189
			}
193
			}
-
 
194
        	//MostComparedProducts.vm should be generated as part of catalog generation
190
		}
195
		}
191
		
196
		
192
		
197
		
193
		
198
		
194
		
199
		
Line 253... Line 258...
253
            }
258
            }
254
            filenames.add("CompareProductSnippet");
259
            filenames.add("CompareProductSnippet");
255
            filenames.add("SlideNamesSnippet");
260
            filenames.add("SlideNamesSnippet");
256
            filenames.add("ComparisonSnippet");
261
            filenames.add("ComparisonSnippet");
257
            if(category.isComparable()) {
262
            if(category.isComparable()) {
258
                filenames.add("MostComparedProducts");
263
            	//Before adding we should populate 
-
 
264
            	try {
-
 
265
            		getMostComparedProducts(exportPath,catalogId);
-
 
266
            	}catch (Exception e){
-
 
267
            		e.printStackTrace();
-
 
268
            	}
259
                filenames.add("CompareProductSummarySnippet");
269
                filenames.add("CompareProductSummarySnippet");
260
                filenames.add("MostComparedSnippet");
270
                filenames.add("MostComparedSnippet");
261
            }
271
            }
262
        }
272
        }
263
        getHtmlFromVelocity(filenames,exportPath,context,catalogId);
273
        getHtmlFromVelocity(filenames,exportPath,context,catalogId);
264
        
-
 
265
        //Update catalogInfo to catalog
274
        //Update catalogInfo to catalog
266
        creator.updateCatalogInfo(catalogId, offerText, itemPojos);
275
        creator.updateCatalogInfo(catalogId, offerText, itemPojos);
267
        return minPriceItem.getSellingPrice();
276
        return minPriceItem.getSellingPrice();
268
    }
277
    }
269
    
278
    
Line 322... Line 331...
322
		} catch (Exception e) {
331
		} catch (Exception e) {
323
			// TODO Auto-generated catch block
332
			// TODO Auto-generated catch block
324
			e.printStackTrace();
333
			e.printStackTrace();
325
		}
334
		}
326
	}
335
	}
-
 
336
	
-
 
337
	/**
-
 
338
     * Get most compared phones
-
 
339
     *
-
 
340
     * @param expEntity
-
 
341
     * @param exportPath
-
 
342
     * @throws Exception
-
 
343
     */
-
 
344
    private void getMostComparedProducts(String exportPath, long catalogId) throws Exception {
-
 
345
 
-
 
346
        Map<Long, Long> comparedPhones = comparisonStats.get(catalogId);
-
 
347
 
-
 
348
        StringBuffer sb = new StringBuffer();
-
 
349
        int maxCount = 10;
-
 
350
        int count = 0;
-
 
351
        if (comparedPhones != null) {
-
 
352
            for (Long entityID : comparedPhones.keySet()) {
-
 
353
                if (count > maxCount) {
-
 
354
                    break;
-
 
355
                }
-
 
356
                sb.append(entityID + "\n");
-
 
357
                count++;
-
 
358
            }
-
 
359
        }
-
 
360
 
-
 
361
        String exportFileName = exportPath + File.separator + "MostComparedProducts.html";
-
 
362
        File exportFile = new File(exportFileName);
-
 
363
        exportFile.createNewFile();
-
 
364
 
-
 
365
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
-
 
366
                new FileOutputStream(exportFile)));
-
 
367
 
-
 
368
        writer.write(sb.toString());
-
 
369
        writer.flush();
-
 
370
        writer.close();
-
 
371
    }
327
}
372
}
328
 
373