Subversion Repositories SmartDukaan

Rev

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

Rev 5460 Rev 5504
Line 6... Line 6...
6
import in.shop2020.catalog.dashboard.shared.ItemStatus;
6
import in.shop2020.catalog.dashboard.shared.ItemStatus;
7
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
7
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
8
import in.shop2020.catalog.dashboard.shared.SourcePricings;
8
import in.shop2020.catalog.dashboard.shared.SourcePricings;
9
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
9
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
10
import in.shop2020.catalog.dashboard.shared.VendorPricings;
10
import in.shop2020.catalog.dashboard.shared.VendorPricings;
-
 
11
import in.shop2020.catalog.dashboard.shared.VoucherItemMapping;
11
import in.shop2020.config.ConfigException;
12
import in.shop2020.config.ConfigException;
12
import in.shop2020.content.ContentService;
13
import in.shop2020.content.ContentService;
13
import in.shop2020.content.ContentServiceException;
14
import in.shop2020.content.ContentServiceException;
14
import in.shop2020.model.v1.catalog.InventoryService;
15
import in.shop2020.model.v1.catalog.InventoryService;
15
import in.shop2020.model.v1.catalog.SourceItemPricing;
-
 
16
import in.shop2020.model.v1.catalog.status;
16
import in.shop2020.model.v1.catalog.status;
-
 
17
import in.shop2020.model.v1.user.VoucherType;
17
import in.shop2020.model.v1.catalog.ItemType;
18
import in.shop2020.model.v1.catalog.ItemType;
18
import in.shop2020.thrift.clients.CatalogClient;
19
import in.shop2020.thrift.clients.CatalogClient;
19
import in.shop2020.thrift.clients.ContentClient;
20
import in.shop2020.thrift.clients.ContentClient;
20
import in.shop2020.thrift.clients.config.ConfigClient;
21
import in.shop2020.thrift.clients.config.ConfigClient;
21
import in.shop2020.utils.CategoryManager;
22
import in.shop2020.utils.CategoryManager;
Line 93... Line 94...
93
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
94
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
94
 
95
 
95
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
96
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
96
 
97
 
97
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
98
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
98
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
99
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
99
            }
100
            }
100
        } catch (Exception e) {
101
        } catch (Exception e) {
101
            logger.error("Error while getting all items from the catalog service", e);
102
            logger.error("Error while getting all items from the catalog service", e);
102
        }
103
        }
103
        return itemList;
104
        return itemList;
Line 133... Line 134...
133
            CatalogClient catalogServiceClient = new CatalogClient();
134
            CatalogClient catalogServiceClient = new CatalogClient();
134
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
135
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
135
 
136
 
136
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
137
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
137
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
138
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
138
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
139
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
139
            }
140
            }
140
        } catch(Exception e){
141
        } catch(Exception e){
141
            logger.error("Error while getting the best deals from the catalog service", e);
142
            logger.error("Error while getting the best deals from the catalog service", e);
142
        }
143
        }
143
        //Collections.sort(itemList, new ItemsComparator());
144
        //Collections.sort(itemList, new ItemsComparator());
Line 151... Line 152...
151
            CatalogClient catalogServiceClient = new CatalogClient();
152
            CatalogClient catalogServiceClient = new CatalogClient();
152
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
153
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
153
 
154
 
154
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
155
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
155
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
156
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
156
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
157
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
157
            }
158
            }
158
        } catch(Exception e){
159
        } catch(Exception e){
159
            logger.error("Error while getting the risky items from the catalog service", e);
160
            logger.error("Error while getting the risky items from the catalog service", e);
160
        }
161
        }
161
        Collections.sort(itemList, new ItemsComparator());
162
        Collections.sort(itemList, new ItemsComparator());
Line 169... Line 170...
169
            CatalogClient catalogServiceClient = new CatalogClient();
170
            CatalogClient catalogServiceClient = new CatalogClient();
170
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
171
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
171
 
172
 
172
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
173
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
173
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
174
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
174
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
175
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
175
            }
176
            }
176
        } catch(Exception e){
177
        } catch(Exception e){
177
            logger.error("Error while getting the best sellers from the catalog service", e);
178
            logger.error("Error while getting the best sellers from the catalog service", e);
178
        }
179
        }
179
        return itemList;        
180
        return itemList;        
Line 188... Line 189...
188
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
189
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
189
 
190
 
190
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
191
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
191
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
192
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
192
                //List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
193
                //List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
193
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
194
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
194
            }
195
            }
195
        } catch(Exception e){
196
        } catch(Exception e){
196
            logger.error("Error while getting the latest arrivals from the catalog service", e);
197
            logger.error("Error while getting the latest arrivals from the catalog service", e);
197
        }
198
        }
198
        return itemList;
199
        return itemList;
Line 206... Line 207...
206
            CatalogClient catalogServiceClient = new CatalogClient();
207
            CatalogClient catalogServiceClient = new CatalogClient();
207
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
208
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
208
 
209
 
209
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
210
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
210
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
211
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
211
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
212
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
212
            }
213
            }
213
        } catch(Exception e){
214
        } catch(Exception e){
214
            logger.error("Error while getting the search results from the catalog service", e);
215
            logger.error("Error while getting the search results from the catalog service", e);
215
        }
216
        }
216
        return itemList;
217
        return itemList;
Line 250... Line 251...
250
            List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
251
            List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
251
            List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
252
            List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
252
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
253
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
253
            List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
254
            List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
254
            in.shop2020.model.v1.catalog.ItemInventory itemInventory = catalogClient.getItemInventoryByItemId(thriftItem.getId());
255
            in.shop2020.model.v1.catalog.ItemInventory itemInventory = catalogClient.getItemInventoryByItemId(thriftItem.getId());
-
 
256
            List<in.shop2020.model.v1.catalog.VoucherItemMapping> tvouchers = catalogClient.getAllItemVouchers(thriftItem.getId());
255
            Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory);
257
            Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory, tvouchers);
256
            it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
258
            it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
257
            return it;
259
            return it;
258
        }catch(Exception e){
260
        }catch(Exception e){
259
            logger.error("Error while getting the item from the catalog service", e);
261
            logger.error("Error while getting the item from the catalog service", e);
260
        }
262
        }
Line 643... Line 645...
643
            
645
            
644
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
646
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
645
                List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
647
                List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
646
                List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
648
                List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
647
                List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
649
                List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
648
                itemList.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null, null));
650
                itemList.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null, null, null));
649
            }
651
            }
650
        } catch (Exception e) {
652
        } catch (Exception e) {
651
            logger.error("Error while getting items by category: " + category, e);
653
            logger.error("Error while getting items by category: " + category, e);
652
        }
654
        }
653
        Collections.sort(itemList, new ItemsComparator());
655
        Collections.sort(itemList, new ItemsComparator());
Line 771... Line 773...
771
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
773
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
772
 
774
 
773
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
775
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
774
 
776
 
775
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
777
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
776
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
778
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null));
777
            }
779
            }
778
        } catch (Exception e) {
780
        } catch (Exception e) {
779
            logger.error("Error while getting items by status: " + st, e);
781
            logger.error("Error while getting items by status: " + st, e);
780
        }
782
        }
781
        return itemList;
783
        return itemList;
Line 788... Line 790...
788
     * @param thriftItem
790
     * @param thriftItem
789
     * @param tVendorPricings
791
     * @param tVendorPricings
790
     * @param tVendorMappings
792
     * @param tVendorMappings
791
     * @param tSourceMappings
793
     * @param tSourceMappings
792
     * @param tSimilarItems
794
     * @param tSimilarItems
-
 
795
     * @param tVoucherMappings
793
     * @return item object with attributes copied from thrift item object.
796
     * @return item object with attributes copied from thrift item object.
794
     */
797
     */
795
    private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem, 
798
    private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem, 
796
            List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings, 
799
            List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings, 
797
            List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings,
800
            List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings,
798
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
801
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
799
            List<in.shop2020.model.v1.catalog.Item> tSimilarItems, in.shop2020.model.v1.catalog.ItemInventory tItemInventory){
802
            List<in.shop2020.model.v1.catalog.Item> tSimilarItems, in.shop2020.model.v1.catalog.ItemInventory tItemInventory, List<in.shop2020.model.v1.catalog.VoucherItemMapping> tVoucherMappings){
800
 
803
 
801
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
804
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
802
        VendorItemMapping vItemMapping;
805
        VendorItemMapping vItemMapping;
803
        if(tVendorMappings != null) {
806
        if(tVendorMappings != null) {
804
            for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
807
            for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
Line 863... Line 866...
863
            }
866
            }
864
        }
867
        }
865
        else {
868
        else {
866
        	itemInventoryMap = null;
869
        	itemInventoryMap = null;
867
        }
870
        }
-
 
871
        
-
 
872
        Map<String, VoucherItemMapping> voucherMap = new HashMap<String, VoucherItemMapping>();
-
 
873
        VoucherItemMapping voucher;
-
 
874
        if(tVoucherMappings != null) {
-
 
875
            for(in.shop2020.model.v1.catalog.VoucherItemMapping tvoucher : tVoucherMappings) {
-
 
876
            	voucher = new VoucherItemMapping(tvoucher.getAmount(), tvoucher.getVoucherType());
-
 
877
            	voucherMap.put(tvoucher.getVoucherType(), voucher);
-
 
878
            }
-
 
879
        }
868
 
880
 
869
        Item item = new Item(thriftItem.getId(),
881
        Item item = new Item(thriftItem.getId(),
870
                thriftItem.getProductGroup(),
882
                thriftItem.getProductGroup(),
871
                thriftItem.getBrand(),
883
                thriftItem.getBrand(),
872
                thriftItem.getModelNumber(),
884
                thriftItem.getModelNumber(),
Line 903... Line 915...
903
                thriftItem.isSetPreferredVendor() ? thriftItem.getPreferredVendor() : null,
915
                thriftItem.isSetPreferredVendor() ? thriftItem.getPreferredVendor() : null,
904
                itemInventoryMap,
916
                itemInventoryMap,
905
                vendorPricingMap,
917
                vendorPricingMap,
906
                vItemMap,
918
                vItemMap,
907
                sourcePricingMap,
919
                sourcePricingMap,
908
                SimilarItemslist);
920
                SimilarItemslist,
-
 
921
                voucherMap);
909
        return item;
922
        return item;
910
    }
923
    }
911
    
924
    
912
    /**
925
    /**
913
     * 
926
     * 
Line 963... Line 976...
963
		try{
976
		try{
964
            CatalogClient catalogServiceClient = new CatalogClient();
977
            CatalogClient catalogServiceClient = new CatalogClient();
965
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
978
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
966
            in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.addSimilarItem(itemId, catalogItemId);;
979
            in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.addSimilarItem(itemId, catalogItemId);;
967
 
980
 
968
            return getItemFromThriftItem(thriftItem, null, null, null, null, null);
981
            return getItemFromThriftItem(thriftItem, null, null, null, null, null, null);
969
        }catch(Exception e){
982
        }catch(Exception e){
970
            logger.error("Error while adding the SimilarItems for: " + itemId, e);
983
            logger.error("Error while adding the SimilarItems for: " + itemId, e);
971
        }
984
        }
972
        return null;
985
        return null;
973
	}
986
	}
Line 1076... Line 1089...
1076
            logger.error("Error while getting all the categories: ", e);
1089
            logger.error("Error while getting all the categories: ", e);
1077
        }
1090
        }
1078
        return brandsList;
1091
        return brandsList;
1079
	}
1092
	}
1080
 
1093
 
-
 
1094
	@Override
-
 
1095
	public boolean deleteVoucher(Long catalogItemId, String voucherType) {
-
 
1096
		try{
-
 
1097
            CatalogClient catalogServiceClient = new CatalogClient();
-
 
1098
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
-
 
1099
 
-
 
1100
            return catalogClient.deleteVoucherForItem(catalogItemId, voucherType);
-
 
1101
 
-
 
1102
        }catch(Exception e){
-
 
1103
            logger.error("Error while deleting the Voucher for: " + catalogItemId, e);
-
 
1104
        }
-
 
1105
        return false;
-
 
1106
	}
-
 
1107
 
-
 
1108
	@Override
-
 
1109
	public boolean addVoucher(Long catalogItemId, String voucherType, long voucherAmount) {
-
 
1110
		try{
-
 
1111
            CatalogClient catalogServiceClient = new CatalogClient();
-
 
1112
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
-
 
1113
 
-
 
1114
            return catalogClient.addupdateVoucherForItem(catalogItemId, voucherType, voucherAmount);
-
 
1115
 
-
 
1116
        }catch(Exception e){
-
 
1117
            logger.error("Error while adding the Voucher for: " + catalogItemId, e);
-
 
1118
        }
-
 
1119
		return false;
-
 
1120
	}
-
 
1121
 
-
 
1122
	@Override
-
 
1123
	public List<String> getvoucherTypes() {
-
 
1124
		List<String> voucherType = new ArrayList<String>();
-
 
1125
		for(VoucherType voucher : VoucherType.values())
-
 
1126
		{
-
 
1127
			voucherType.add(voucher.name());
-
 
1128
		}
-
 
1129
		return voucherType;
-
 
1130
	}
-
 
1131
 
1081
}
1132
}
1082
1133