Subversion Repositories SmartDukaan

Rev

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

Rev 5217 Rev 5309
Line 92... Line 92...
92
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
92
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
93
 
93
 
94
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
94
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
95
 
95
 
96
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
96
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
97
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
97
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
98
            }
98
            }
99
        } catch (Exception e) {
99
        } catch (Exception e) {
100
            logger.error("Error while getting all items from the catalog service", e);
100
            logger.error("Error while getting all items from the catalog service", e);
101
        }
101
        }
102
        return itemList;
102
        return itemList;
Line 132... Line 132...
132
            CatalogClient catalogServiceClient = new CatalogClient();
132
            CatalogClient catalogServiceClient = new CatalogClient();
133
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
133
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
134
 
134
 
135
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
135
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
136
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
136
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
137
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
137
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
138
            }
138
            }
139
        } catch(Exception e){
139
        } catch(Exception e){
140
            logger.error("Error while getting the best deals from the catalog service", e);
140
            logger.error("Error while getting the best deals from the catalog service", e);
141
        }
141
        }
142
        //Collections.sort(itemList, new ItemsComparator());
142
        //Collections.sort(itemList, new ItemsComparator());
Line 150... Line 150...
150
            CatalogClient catalogServiceClient = new CatalogClient();
150
            CatalogClient catalogServiceClient = new CatalogClient();
151
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
151
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
152
 
152
 
153
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
153
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
154
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
154
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
155
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
155
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
156
            }
156
            }
157
        } catch(Exception e){
157
        } catch(Exception e){
158
            logger.error("Error while getting the risky items from the catalog service", e);
158
            logger.error("Error while getting the risky items from the catalog service", e);
159
        }
159
        }
160
        Collections.sort(itemList, new ItemsComparator());
160
        Collections.sort(itemList, new ItemsComparator());
Line 168... Line 168...
168
            CatalogClient catalogServiceClient = new CatalogClient();
168
            CatalogClient catalogServiceClient = new CatalogClient();
169
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
169
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
170
 
170
 
171
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
171
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
172
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
172
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
173
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
173
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
174
            }
174
            }
175
        } catch(Exception e){
175
        } catch(Exception e){
176
            logger.error("Error while getting the best sellers from the catalog service", e);
176
            logger.error("Error while getting the best sellers from the catalog service", e);
177
        }
177
        }
178
        return itemList;        
178
        return itemList;        
Line 187... Line 187...
187
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
187
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
188
 
188
 
189
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
189
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
190
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
190
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
191
                //List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
191
                //List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
192
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
192
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
193
            }
193
            }
194
        } catch(Exception e){
194
        } catch(Exception e){
195
            logger.error("Error while getting the latest arrivals from the catalog service", e);
195
            logger.error("Error while getting the latest arrivals from the catalog service", e);
196
        }
196
        }
197
        return itemList;
197
        return itemList;
Line 205... Line 205...
205
            CatalogClient catalogServiceClient = new CatalogClient();
205
            CatalogClient catalogServiceClient = new CatalogClient();
206
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
206
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
207
 
207
 
208
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
208
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
209
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
209
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
210
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
210
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
211
            }
211
            }
212
        } catch(Exception e){
212
        } catch(Exception e){
213
            logger.error("Error while getting the search results from the catalog service", e);
213
            logger.error("Error while getting the search results from the catalog service", e);
214
        }
214
        }
215
        return itemList;
215
        return itemList;
Line 238... Line 238...
238
 
238
 
239
            List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
239
            List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
240
            List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
240
            List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
241
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
241
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
242
            List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
242
            List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
-
 
243
            in.shop2020.model.v1.catalog.ItemInventory itemInventory = catalogClient.getItemInventoryByItemId(thriftItem.getId());
243
            return getItemFromThriftItem(thriftItem, vip, vim, sip, sit);
244
            return getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory);
244
        }catch(Exception e){
245
        }catch(Exception e){
245
            logger.error("Error while getting the item from the catalog service", e);
246
            logger.error("Error while getting the item from the catalog service", e);
246
        }
247
        }
247
        return null;
248
        return null;
248
    }
249
    }
Line 628... Line 629...
628
            
629
            
629
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
630
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
630
                List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
631
                List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
631
                List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
632
                List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
632
                List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
633
                List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
633
                itemList.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null));
634
                itemList.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null, null));
634
            }
635
            }
635
        } catch (Exception e) {
636
        } catch (Exception e) {
636
            logger.error("Error while getting items by category: " + category, e);
637
            logger.error("Error while getting items by category: " + category, e);
637
        }
638
        }
638
        Collections.sort(itemList, new ItemsComparator());
639
        Collections.sort(itemList, new ItemsComparator());
Line 756... Line 757...
756
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
757
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
757
 
758
 
758
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
759
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
759
 
760
 
760
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
761
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
761
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
762
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null));
762
            }
763
            }
763
        } catch (Exception e) {
764
        } catch (Exception e) {
764
            logger.error("Error while getting items by status: " + st, e);
765
            logger.error("Error while getting items by status: " + st, e);
765
        }
766
        }
766
        return itemList;
767
        return itemList;
Line 779... Line 780...
779
     */
780
     */
780
    private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem, 
781
    private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem, 
781
            List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings, 
782
            List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings, 
782
            List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings,
783
            List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings,
783
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
784
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
784
            List<in.shop2020.model.v1.catalog.Item> tSimilarItems){
785
            List<in.shop2020.model.v1.catalog.Item> tSimilarItems, in.shop2020.model.v1.catalog.ItemInventory tItemInventory){
785
 
786
 
786
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
787
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
787
        VendorItemMapping vItemMapping;
788
        VendorItemMapping vItemMapping;
788
        if(tVendorMappings != null) {
789
        if(tVendorMappings != null) {
789
            for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
790
            for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
Line 834... Line 835...
834
            }
835
            }
835
        }
836
        }
836
 
837
 
837
        Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
838
        Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
838
        ItemInventory warehousedata;
839
        ItemInventory warehousedata;
839
        if(thriftItem.getItemInventory() != null) {
840
        if(tItemInventory != null) {
840
        	Map<Long, Long> availabilityMap = thriftItem.getItemInventory().getAvailability();
841
        	Map<Long, Long> availabilityMap = tItemInventory.getAvailability();
841
        	Map<Long, Long> reservedMap = thriftItem.getItemInventory().getReserved();
842
        	Map<Long, Long> reservedMap = tItemInventory.getReserved();
842
            for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
843
            for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
843
            	warehousedata = new ItemInventory();
844
            	warehousedata = new ItemInventory();
844
            	warehousedata.setWarehouseId(availability.getKey());
845
            	warehousedata.setWarehouseId(availability.getKey());
845
            	warehousedata.setAvailability(availability.getValue());
846
            	warehousedata.setAvailability(availability.getValue());
846
            	warehousedata.setReserved(reservedMap.get(availability.getKey()));
847
            	warehousedata.setReserved(reservedMap.get(availability.getKey()));
Line 873... Line 874...
873
                thriftItem.getRetireDate(),
874
                thriftItem.getRetireDate(),
874
                thriftItem.getUpdatedOn(),
875
                thriftItem.getUpdatedOn(),
875
                thriftItem.getItemStatus().name(),
876
                thriftItem.getItemStatus().name(),
876
                thriftItem.getItemStatus().getValue(),
877
                thriftItem.getItemStatus().getValue(),
877
                thriftItem.getStatus_description(),
878
                thriftItem.getStatus_description(),
878
                thriftItem.getOtherInfo(),
-
 
879
                thriftItem.getBestDealText(),
879
                thriftItem.getBestDealText(),
880
                thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
880
                thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
881
                thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
881
                thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
882
                thriftItem.isDefaultForEntity(),
882
                thriftItem.isDefaultForEntity(),
883
                thriftItem.isRisky(),
883
                thriftItem.isRisky(),
Line 948... Line 948...
948
		try{
948
		try{
949
            CatalogClient catalogServiceClient = new CatalogClient();
949
            CatalogClient catalogServiceClient = new CatalogClient();
950
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
950
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
951
            in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.addSimilarItem(itemId, catalogItemId);;
951
            in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.addSimilarItem(itemId, catalogItemId);;
952
 
952
 
953
            return getItemFromThriftItem(thriftItem, null, null, null, null);
953
            return getItemFromThriftItem(thriftItem, null, null, null, null, null);
954
        }catch(Exception e){
954
        }catch(Exception e){
955
            logger.error("Error while adding the SimilarItems for: " + itemId, e);
955
            logger.error("Error while adding the SimilarItems for: " + itemId, e);
956
        }
956
        }
957
        return null;
957
        return null;
958
	}
958
	}