Subversion Repositories SmartDukaan

Rev

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

Rev 3558 Rev 3850
Line 1... Line 1...
1
package in.shop2020.catalog.dashboard.server;
1
package in.shop2020.catalog.dashboard.server;
2
 
2
 
3
import in.shop2020.catalog.dashboard.client.CatalogService;
3
import in.shop2020.catalog.dashboard.client.CatalogService;
4
import in.shop2020.catalog.dashboard.shared.Item;
4
import in.shop2020.catalog.dashboard.shared.Item;
-
 
5
import in.shop2020.catalog.dashboard.shared.ItemStatus;
5
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
6
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
6
import in.shop2020.catalog.dashboard.shared.SourcePricings;
7
import in.shop2020.catalog.dashboard.shared.SourcePricings;
7
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
8
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
8
import in.shop2020.catalog.dashboard.shared.VendorPricings;
9
import in.shop2020.catalog.dashboard.shared.VendorPricings;
9
import in.shop2020.config.ConfigException;
10
import in.shop2020.config.ConfigException;
Line 37... Line 38...
37
 
38
 
38
    private static Logger logger = Logger.getLogger(CatalogServiceImpl.class);
39
    private static Logger logger = Logger.getLogger(CatalogServiceImpl.class);
39
    
40
    
40
    private static Date pushToProdDate;
41
    private static Date pushToProdDate;
41
    
42
    
-
 
43
    @Override
-
 
44
    public int getItemCountByStatus(boolean useStatus, ItemStatus itemStatus){
-
 
45
        int count = 0;
-
 
46
        try{
-
 
47
            CatalogClient catalogServiceClient = new CatalogClient();
-
 
48
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
-
 
49
            
-
 
50
            status stat = status.findByValue(itemStatus.getValue());
-
 
51
            count = catalogClient.getItemCountByStatus(useStatus, stat);
-
 
52
        }catch(Exception e){
-
 
53
            logger.error("Error while getting the count of items from the catalog service", e);
-
 
54
        }
-
 
55
        return count;
-
 
56
    }
-
 
57
    
-
 
58
    @Override
42
    public List<Item> getAllItems(){
59
    public List<Item> getAllItems(int start, int limit) {
43
        List<Item> itemList = new ArrayList<Item>();
60
        List<Item> itemList = new ArrayList<Item>();
44
 
61
 
45
        try {
62
        try {
46
            CatalogClient catalogServiceClient = new CatalogClient();
63
            CatalogClient catalogServiceClient = new CatalogClient();
47
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
64
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
48
 
65
 
49
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(false);
66
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
50
 
67
 
51
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
68
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
52
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
69
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
53
            }
70
            }
54
        } catch (Exception e) {
71
        } catch (Exception e) {
55
            logger.error("Error while getting all items from the catalog service", e);
72
            logger.error("Error while getting all items from the catalog service", e);
56
        }
73
        }
57
        Collections.sort(itemList, new ItemsComparator());
-
 
58
        return itemList;
74
        return itemList;
59
    }
75
    }
60
 
76
 
61
    public List<Item> getAllActiveItems(){
77
    public List<Item> getAllActiveItems(int start, int limit){
62
        return getItemsByStatus(status.ACTIVE);
78
        return getItemsByStatus(status.ACTIVE, start, limit);
63
    }
79
    }
64
 
80
 
65
    @Override
81
    @Override
66
    public List<Item> getAllPhasedOutItems(){
82
    public List<Item> getAllPhasedOutItems(int start, int limit){
67
        return getItemsByStatus(status.PHASED_OUT);
83
        return getItemsByStatus(status.PHASED_OUT, start, limit);
68
    }
84
    }
69
 
85
 
70
    @Override
86
    @Override
71
    public List<Item> getAllPausedItems(){
87
    public List<Item> getAllPausedItems(int start, int limit){
72
        return getItemsByStatus(status.PAUSED);
88
        return getItemsByStatus(status.PAUSED, start, limit);
73
    }
89
    }
74
 
90
 
75
    @Override
91
    @Override
76
    public List<Item> getAllInProcessItems() {
92
    public List<Item> getAllInProcessItems(int start, int limit) {
77
        return getItemsByStatus(status.IN_PROCESS);
93
        return getItemsByStatus(status.IN_PROCESS, start, limit);
78
    }
94
    }
79
 
95
 
80
    @Override
96
    @Override
81
    public List<Item> getAllContentCompleteItems() {
97
    public List<Item> getAllContentCompleteItems(int start, int limit) {
82
        return getItemsByStatus(status.CONTENT_COMPLETE);
98
        return getItemsByStatus(status.CONTENT_COMPLETE, start, limit);
83
    }
99
    }
84
 
100
 
85
    public List<Item> getBestDeals(){
101
    public List<Item> getBestDeals(){
86
        List<Item> itemList = new ArrayList<Item>();
102
        List<Item> itemList = new ArrayList<Item>();
87
        try {
103
        try {
Line 596... Line 612...
596
    /**
612
    /**
597
     * Returns list of items with a particular status.
613
     * Returns list of items with a particular status.
598
     * @param st
614
     * @param st
599
     * @return
615
     * @return
600
     */
616
     */
601
    private List<Item> getItemsByStatus(status st) {
617
    private List<Item> getItemsByStatus(status st, int start, int limit) {
602
        List<Item> itemList = new ArrayList<Item>();
618
        List<Item> itemList = new ArrayList<Item>();
603
        try {
619
        try {
604
            CatalogClient catalogServiceClient = new CatalogClient();
620
            CatalogClient catalogServiceClient = new CatalogClient();
605
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
621
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
606
 
622
 
607
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatus(st);
623
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
608
 
624
 
609
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
625
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
610
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
626
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
611
            }
627
            }
612
        } catch (Exception e) {
628
        } catch (Exception e) {
613
            logger.error("Error while getting items by status: " + st, e);
629
            logger.error("Error while getting items by status: " + st, e);
614
        }
630
        }
615
        Collections.sort(itemList, new ItemsComparator());
-
 
616
        return itemList;
631
        return itemList;
617
    }
632
    }
618
    
633
    
619
    /**
634
    /**
620
     * Creates a new Item object and populates its attributes from thrift item passed as parameter.
635
     * Creates a new Item object and populates its attributes from thrift item passed as parameter.