Subversion Repositories SmartDukaan

Rev

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

Rev 5642 Rev 5664
Line 66... Line 66...
66
 
66
 
67
    // Default values of cmdline options
67
    // Default values of cmdline options
68
    private static String         UPDATE_TYPE                 = UPDATE_TYPE_CONTENT;
68
    private static String         UPDATE_TYPE                 = UPDATE_TYPE_CONTENT;
69
    private static String         GENERATION_TYPE             = GENERATION_TYPE_INCREMENTAL;
69
    private static String         GENERATION_TYPE             = GENERATION_TYPE_INCREMENTAL;
70
    private static String         ENTITY_ID                   = "ALL";
70
    private static String         ENTITY_ID                   = "ALL";
-
 
71
    private static String [] 	  DOMAINPATHS 			      = Utils.DOMAIN_NAMES_FOR_CONTENT_GENERATION.split(";");
71
 
72
 
72
    private Date 				  timeStamp			  		  = null;
73
    private Date 				  timeStamp			  		  = null;
73
    private CommandLine           cmd                         = null;
74
    private CommandLine           cmd                         = null;
74
    private Map<Long, List<Item>> entityIdItemMap             = new LinkedHashMap<Long, List<Item>>();
75
    private Map<Long, List<Item>> entityIdItemMap             = new LinkedHashMap<Long, List<Item>>();
75
    private List<Long> 			  allValidEntityIds 			  = null;
76
    private List<Long> 			  allValidEntityIds 			  = null;
Line 231... Line 232...
231
    private void removeOldResources() throws IOException {
232
    private void removeOldResources() throws IOException {
232
        File f = new File(Utils.EXPORT_SOLR_PATH);
233
        File f = new File(Utils.EXPORT_SOLR_PATH);
233
        if (f.exists()) {
234
        if (f.exists()) {
234
            cleanDir(f, false);
235
            cleanDir(f, false);
235
        }
236
        }
236
 
237
        
237
        File f1 = new File(Utils.EXPORT_ENTITIES_PATH_LOCALHOST);
238
        for(String domainPath : DOMAINPATHS){
238
        if (f1.exists()) {
-
 
239
            cleanDir(f1, false);
239
        	String pathName = domainPath.split("\\.")[0].split(":")[0];
240
        }
-
 
241
 
-
 
242
        File f2 = new File(Utils.EXPORT_ENTITIES_PATH_SAHOLIC);
240
        	File f1 = new File(Utils.EXPORT_PATH + "html/entities-" +  pathName);
243
        if (f2.exists()) {
241
        	if (f1.exists()) {
244
            cleanDir(f2, false);
242
        		cleanDir(f1, false);
245
        }
243
        	}else {
246
 
-
 
247
        File f3 = new File(Utils.EXPORT_ENTITIES_PATH_SHOP2020);
-
 
248
        if (f3.exists()) {
244
        		f1.mkdir();
249
            cleanDir(f3, false);
245
        	}
250
        }
246
        }
251
    }
247
    }
252
 
248
 
253
    /**
249
    /**
254
     * Update the prices in the generated content
250
     * Update the prices in the generated content
Line 292... Line 288...
292
        PriceInsertor priceInserter = new PriceInsertor();
288
        PriceInsertor priceInserter = new PriceInsertor();
293
 
289
 
294
        for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
290
        for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
295
            long entityId = entry.getKey();
291
            long entityId = entry.getKey();
296
            List<Item> items = entry.getValue();
292
            List<Item> items = entry.getValue();
297
            // TODO Domain name and destination directory should be read from
293
	            // TODO Domain name and destination directory should be read from
298
            // properties file
294
	            // properties file
-
 
295
            double minPrice = 0d;
299
            double minPrice = priceInserter.insertPriceInHtml(items, entityId,
296
            StringBuilder priceString = new StringBuilder();
-
 
297
            boolean domainOnce = true;
300
                    "saholic.com", Utils.EXPORT_ENTITIES_PATH_SAHOLIC, null);
298
            for(String domainPath : DOMAINPATHS){
301
            priceInserter.insertPriceInHtml(items, entityId, "shop2020.in",
299
            	String domainName = domainPath;
302
                    Utils.EXPORT_ENTITIES_PATH_SHOP2020, null);
300
            	String pathName = domainPath.split("\\.")[0].split(":")[0];
303
            priceInserter.insertPriceInHtml(items, entityId, "localhost:8090",
301
            	minPrice = priceInserter.insertPriceInHtml(items, entityId,
304
                    Utils.EXPORT_ENTITIES_PATH_LOCALHOST, null);
302
            			domainName, Utils.EXPORT_PATH + "html/entities-" +  pathName + "/", null);
-
 
303
            	if(domainOnce){
305
            StringBuilder priceString = new StringBuilder(
304
            		priceString.append(
306
                    "<field name=\"F_50002\">" + minPrice + "</field>");
305
            				"<field name=\"F_50002\">" + minPrice + "</field>");
-
 
306
            		domainOnce = false;
307
 
307
            	}
308
            if (sources != null) {
308
            	if(sources != null){
-
 
309
            		boolean sourceOnce = true;
309
                for (Source source : sources) {
310
            		for (Source source : sources) {
310
                    minPrice = priceInserter.insertPriceInHtml(items, entityId,
311
                        minPrice = priceInserter.insertPriceInHtml(items, entityId,
311
                            "saholic.com", Utils.EXPORT_ENTITIES_PATH_SAHOLIC,
312
                                domainName, Utils.EXPORT_PATH + "html/entities-" + pathName + "/",
312
                            source);
313
                                source);
313
                    priceInserter.insertPriceInHtml(items, entityId,
-
 
314
                            "shop2020.in", Utils.EXPORT_ENTITIES_PATH_SHOP2020,
-
 
315
                            source);
314
                        if(sourceOnce){
316
                    priceInserter.insertPriceInHtml(items, entityId,
315
                        	priceString.append("<field name=\"F_50002_"
317
                            "localhost:8090",
316
                                + source.getId() + "\">" + minPrice + "</field>");
318
                            Utils.EXPORT_ENTITIES_PATH_LOCALHOST, source);
317
                        	sourceOnce = false;
319
                    priceString.append("<field name=\"F_50002_"
318
                        }
320
                            + source.getId() + "\">" + minPrice + "</field>");
319
            		}
321
                }
320
            	}
322
            }
321
            }
323
 
322
 
324
            priceInserter.insertPriceInSolrData(entityId,
323
            priceInserter.insertPriceInSolrData(entityId,
325
                    priceString.toString());
324
                    priceString.toString());
326
        }
325
        }