Subversion Repositories SmartDukaan

Rev

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

Rev 5360 Rev 5404
Line 22... Line 22...
22
import java.text.SimpleDateFormat;
22
import java.text.SimpleDateFormat;
23
import java.util.ArrayList;
23
import java.util.ArrayList;
24
import java.util.Calendar;
24
import java.util.Calendar;
25
import java.util.Date;
25
import java.util.Date;
26
import java.util.HashMap;
26
import java.util.HashMap;
-
 
27
import java.util.HashSet;
27
import java.util.LinkedHashMap;
28
import java.util.LinkedHashMap;
28
import java.util.List;
29
import java.util.List;
29
import java.util.Map;
30
import java.util.Map;
30
 
31
 
31
import javax.mail.MessagingException;
32
import javax.mail.MessagingException;
Line 68... Line 69...
68
    private static String         ENTITY_ID                   = "ALL";
69
    private static String         ENTITY_ID                   = "ALL";
69
 
70
 
70
    private Date 				  timeStamp			  		  = null;
71
    private Date 				  timeStamp			  		  = null;
71
    private CommandLine           cmd                         = null;
72
    private CommandLine           cmd                         = null;
72
    private Map<Long, List<Item>> entityIdItemMap             = new LinkedHashMap<Long, List<Item>>();
73
    private Map<Long, List<Item>> entityIdItemMap             = new LinkedHashMap<Long, List<Item>>();
-
 
74
    private List<Long> 			  allValidEntityIds 			  = null;
73
    private Long                  lastGenerationTime          = 0l;
75
    private Long                  lastGenerationTime          = 0l;
74
    private Map<Long, Entity>     entities;
76
    private Map<Long, Entity>     entities;
75
    private List<Item>            items;
77
    private List<Item>            items;
76
    private List<Source>          sources;
78
    private List<Source>          sources;
77
    private CatalogClient         csc;
79
    private CatalogClient         csc;
Line 409... Line 411...
409
 
411
 
410
        //FIXME Avoiding the finding of accesories, as list of categories for which we need to find accessories is hardocoded in code. 
412
        //FIXME Avoiding the finding of accesories, as list of categories for which we need to find accessories is hardocoded in code. 
411
        // We need to make that configurable. Also creating ticket to improve it.
413
        // We need to make that configurable. Also creating ticket to improve it.
412
        try{
414
        try{
413
	        log.info("Finding accessories");
415
	        log.info("Finding accessories");
414
	        AccessoriesFinder af = new AccessoriesFinder(entityIdItemMap.keySet());
416
	        AccessoriesFinder af = new AccessoriesFinder(new HashSet<Long>(allValidEntityIds));
415
	        Map<Long, Map<Long, List<Long>>> relatedAccessories = af.findAccessories();
417
	        Map<Long, Map<Long, List<Long>>> relatedAccessories = af.findAccessories();
416
	        CreationUtils.storeRelatedAccessories(relatedAccessories);
418
	        CreationUtils.storeRelatedAccessories(relatedAccessories);
417
        }catch (Exception e) {
419
        }catch (Exception e) {
418
        	log.error("Error while generating accessories" + e);
420
        	log.error("Error while generating accessories" + e);
419
		}
421
		}
Line 441... Line 443...
441
        if (GENERATION_TYPE.equals(GENERATION_TYPE_ALL))	{
443
        if (GENERATION_TYPE.equals(GENERATION_TYPE_ALL))	{
442
        	allValidEntities = validEntities;
444
        	allValidEntities = validEntities;
443
            
445
            
444
        } else	{
446
        } else	{
445
        	allValidEntities = new ArrayList<Entity>();
447
        	allValidEntities = new ArrayList<Entity>();
446
			
-
 
447
			for (Entity entity:  new ArrayList<Entity>(CreationUtils.getEntities().values()))	{
-
 
448
				
-
 
449
				ExpandedEntity expEntity = new ExpandedEntity(entity);
448
			for (Long entityId : allValidEntityIds)	{
450
		        EntityState state = CreationUtils.getEntityState(entity.getID());
449
				allValidEntities.add(CreationUtils.getEntity(entityId));
451
		        long categoryID = expEntity.getCategoryID();
-
 
452
		        
-
 
453
		        if (state.getStatus() == EntityStatus.READY && categoryID != -1) {
-
 
454
					allValidEntities.add(entity);
-
 
455
		        }
-
 
456
			}
450
			}
457
        }
451
        }
458
        
452
        
459
        log.info("Generating HTML for Site Index");
453
        log.info("Generating HTML for Site Index");
460
        ProductIndexGenerator indexGenerator = new ProductIndexGenerator(allValidEntities);
454
        ProductIndexGenerator indexGenerator = new ProductIndexGenerator(allValidEntities);
Line 621... Line 615...
621
            }
615
            }
622
            if (!isValidEntity) {
616
            if (!isValidEntity) {
623
                removeEntities.add(entityId);
617
                removeEntities.add(entityId);
624
            }
618
            }
625
        }
619
        }
-
 
620
        //Simply assign allValidEntityIds to a class variable as these need to be used where all valid entites
-
 
621
        //are needed.
-
 
622
        allValidEntityIds = new ArrayList<Long>(entityIdItemMap.keySet());
626
        for (Long entityId : removeEntities) {
623
        for (Long entityId : removeEntities) {
627
            entityIdItemMap.remove(entityId);
624
            entityIdItemMap.remove(entityId);
628
        }
625
        }
629
 
626
 
630
        Utils.info("Final valid entities to be processed: " + entityIdItemMap.size());
627
        Utils.info("Final valid entities to be processed: " + entityIdItemMap.size());