Subversion Repositories SmartDukaan

Rev

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

Rev 9218 Rev 9280
Line 14... Line 14...
14
import in.shop2020.metamodel.util.CreationUtils;
14
import in.shop2020.metamodel.util.CreationUtils;
15
import in.shop2020.metamodel.util.ExpandedBullet;
15
import in.shop2020.metamodel.util.ExpandedBullet;
16
import in.shop2020.metamodel.util.ExpandedEntity;
16
import in.shop2020.metamodel.util.ExpandedEntity;
17
import in.shop2020.metamodel.util.ExpandedFeature;
17
import in.shop2020.metamodel.util.ExpandedFeature;
18
import in.shop2020.metamodel.util.ExpandedSlide;
18
import in.shop2020.metamodel.util.ExpandedSlide;
-
 
19
import in.shop2020.metamodel.util.RelatedAccessoriesPojo;
19
import in.shop2020.model.v1.catalog.CatalogService.Client;
20
import in.shop2020.model.v1.catalog.CatalogService.Client;
20
import in.shop2020.model.v1.catalog.Item;
21
import in.shop2020.model.v1.catalog.Item;
21
import in.shop2020.model.v1.catalog.status;
22
import in.shop2020.model.v1.catalog.status;
-
 
23
import in.shop2020.storage.mongo.StorageManager;
22
import in.shop2020.thrift.clients.CatalogClient;
24
import in.shop2020.thrift.clients.CatalogClient;
23
import in.shop2020.util.EntityUtils;
25
import in.shop2020.util.EntityUtils;
-
 
26
import in.shop2020.util.PojoCreator;
24
import in.shop2020.util.Utils;
27
import in.shop2020.util.Utils;
25
import in.shop2020.utils.Logger;
28
import in.shop2020.utils.Logger;
26
 
29
 
27
import java.io.BufferedWriter;
30
import java.io.BufferedWriter;
28
import java.io.File;
31
import java.io.File;
Line 65... Line 68...
65
    public static final String DEFAULT_JPG = "default.jpg";
68
    public static final String DEFAULT_JPG = "default.jpg";
66
    private static final String SPACE = " ";
69
    private static final String SPACE = " ";
67
    private static final String DOT = ".";
70
    private static final String DOT = ".";
68
    private static final String ESCAPED_DOT = "\\.";
71
    private static final String ESCAPED_DOT = "\\.";
69
    private static final String HYPHON = "-";
72
    private static final String HYPHON = "-";
-
 
73
 
-
 
74
    private Map<Long, Map<Long, List<Long>>> relatedAccessoriesMap;
-
 
75
    private PojoCreator pojoCreator;
-
 
76
    
70
    private static Log log = LogFactory.getLog(NewVUI.class);
77
    private static Log log = LogFactory.getLog(NewVUI.class);
71
    private String     contentVersion;
78
    private String     contentVersion;
72
 
79
 
73
    public NewVUI(Long contentVersion) throws Exception {
80
    public NewVUI(Long contentVersion) throws Exception {
74
        this.contentVersion = contentVersion.toString();
81
        this.contentVersion = contentVersion.toString();
-
 
82
        relatedAccessoriesMap =  CreationUtils.getRelatedAccessories();
-
 
83
        pojoCreator = new PojoCreator();
75
    }
84
    }
76
    
85
    
77
    static Client cl;
86
    static Client cl;
78
    
87
    
79
    static {
88
    static {
Line 512... Line 521...
512
     *
521
     *
513
     * @param expEntity
522
     * @param expEntity
514
     * @param exportPath
523
     * @param exportPath
515
     * @throws Exception
524
     * @throws Exception
516
     */
525
     */
517
    private void getRelatedAccessories(ExpandedEntity expEntity,
526
    private List<Long> getRelatedAccessories(ExpandedEntity expEntity,
518
            String exportPath) throws Exception {
527
            String exportPath) throws Exception {
519
        long catalogId = expEntity.getID();
528
        long catalogId = expEntity.getID();
520
 
-
 
521
        Map<Long, List<Long>> relatedAccessories = CreationUtils
529
        List<Long> relatedAccessoriesList = new ArrayList<Long>();
522
                .getRelatedAccessories().get(catalogId);
530
        Map<Long,List<Long>> relatedAccessories = relatedAccessoriesMap.get(catalogId);
523
        List<Long> priorityList = new ArrayList<Long>();
531
        List<Long> priorityList = new ArrayList<Long>();
524
        int individualLimit = 2;
532
        int individualLimit = 2;
525
        int totalLimit = 10;
533
        int totalLimit = 10;
526
        priorityList.add(Utils.CARRYING_CASE);
534
        priorityList.add(Utils.CARRYING_CASE);
527
        priorityList.add(Utils.SCREEN_GUARD);
535
        priorityList.add(Utils.SCREEN_GUARD);
528
        priorityList.add(Utils.BATTERY);
-
 
529
        priorityList.add(Utils.MEMORY_CARD);
536
        priorityList.add(Utils.MEMORY_CARD);
530
        priorityList.add(Utils.BLUETOOTH_HEADSET);
-
 
531
        priorityList.add(Utils.HEADSET);
537
        priorityList.add(Utils.HEADSET);
-
 
538
        priorityList.add(Utils.BLUETOOTH_HEADSET);
532
        priorityList.add(Utils.CHARGER);
539
        priorityList.add(Utils.CHARGER);
-
 
540
        priorityList.add(Utils.BATTERY);
533
 
541
 
534
        StringBuffer sb = new StringBuffer();
542
        StringBuffer sb = new StringBuffer();
535
        int totalCount = 0;
543
        int totalCount = 0;
536
        if (relatedAccessories != null) {
544
        if (relatedAccessories != null) {
537
            for (Long catID : priorityList) {
545
            for (Long catID : priorityList) {
Line 570... Line 578...
570
                    if (ents.size() > individualLimit) {
578
                    if (ents.size() > individualLimit) {
571
                        ents = ents.subList(0, individualLimit);
579
                        ents = ents.subList(0, individualLimit);
572
                    }
580
                    }
573
                    for (Long entID : ents) {
581
                    for (Long entID : ents) {
574
                        if (totalLimit > totalCount) {
582
                        if (totalLimit > totalCount) {
-
 
583
                        	relatedAccessoriesList.add(entID);
575
                            sb.append(entID + "\n");
584
                            sb.append(entID + "\n");
576
                            individualCount++;
585
                            individualCount++;
577
                            totalCount++;
586
                            totalCount++;
578
                        }
587
                        }
579
                    }
588
                    }
Line 592... Line 601...
592
                new FileOutputStream(exportFile)));
601
                new FileOutputStream(exportFile)));
593
 
602
 
594
        writer.write(sb.toString());
603
        writer.write(sb.toString());
595
        writer.flush();
604
        writer.flush();
596
        writer.close();
605
        writer.close();
-
 
606
        return relatedAccessoriesList;
597
 
607
 
598
    }
608
    }
599
 
609
 
600
    /**
610
    /**
601
     * Get most compared phones
611
     * Get most compared phones
Line 820... Line 830...
820
        context.put("mediaPrefix", mediaPrefix);
830
        context.put("mediaPrefix", mediaPrefix);
821
        context.put("expentity", expEntity);
831
        context.put("expentity", expEntity);
822
        context.put("contentVersion", this.contentVersion);
832
        context.put("contentVersion", this.contentVersion);
823
        context.put("defs", Catalog.getInstance().getDefinitionsContainer());
833
        context.put("defs", Catalog.getInstance().getDefinitionsContainer());
824
        context.put("helpdocs", CreationUtils.getHelpdocs());
834
        context.put("helpdocs", CreationUtils.getHelpdocs());
-
 
835
        Map<String, String > entityParams = getEntityParameters(expEntity);
825
        context.put("params", getEntityParameters(expEntity));
836
        context.put("params", entityParams);
826
        context.put("isComparable", isComparable);
837
        context.put("isComparable", isComparable);
-
 
838
        List<ExpertReview> expertReviews = getExpertReviews(catalogId);
827
        context.put("expertReviews", getExpertReviews(catalogId));
839
        context.put("expertReviews", expertReviews);
828
 
-
 
-
 
840
        pojoCreator.createAndStoreContentPojo(expEntity, expertReviews,entityParams.get("WARRANTY"));
829
        List<String> filenames = new ArrayList<String>();
841
        List<String> filenames = new ArrayList<String>();
830
        filenames.add("ProductDetail");
842
        filenames.add("ProductDetail");
831
        filenames.add("store/ProductDetail");
843
        filenames.add("store/ProductDetail");
832
        filenames.add("WidgetSnippet");
844
        filenames.add("WidgetSnippet");
833
        filenames.add("HomeSnippet");
845
        filenames.add("HomeSnippet");
Line 847... Line 859...
847
        	filenames.add("CompareProductSummarySnippet");
859
        	filenames.add("CompareProductSummarySnippet");
848
        	filenames.add("MostComparedSnippet");
860
        	filenames.add("MostComparedSnippet");
849
        	getMostComparedProducts(expEntity, exportPath);
861
        	getMostComparedProducts(expEntity, exportPath);
850
        }
862
        }
851
        if(parentCategory.isHasAccessories()){
863
        if(parentCategory.isHasAccessories()){
-
 
864
        	RelatedAccessoriesPojo rap =  new RelatedAccessoriesPojo();
852
        	getRelatedAccessories(expEntity, exportPath);
865
        	rap.setAccessories(getRelatedAccessories(expEntity, exportPath));
-
 
866
        	rap.setId(catalogId);
-
 
867
        	StorageManager.insertOrUpdateById(StorageManager.views.relatedAccessories, catalogId, rap);
-
 
868
        	
853
        }
869
        }
854
        if(parentCategory.getID()==Utils.MOBILE_PHONES_CATAGORY){
870
        if(parentCategory.getID()==Utils.MOBILE_PHONES_CATAGORY){
855
        	filenames.add("PhonesIOwnSnippet");
871
        	filenames.add("PhonesIOwnSnippet");
856
        }
872
        }
857
//        if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY) {
873
//        if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY) {