Subversion Repositories SmartDukaan

Rev

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

Rev 4413 Rev 4423
Line 88... Line 88...
88
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
88
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
89
 
89
 
90
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
90
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
91
 
91
 
92
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
92
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
93
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
93
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
94
            }
94
            }
95
        } catch (Exception e) {
95
        } catch (Exception e) {
96
            logger.error("Error while getting all items from the catalog service", e);
96
            logger.error("Error while getting all items from the catalog service", e);
97
        }
97
        }
98
        return itemList;
98
        return itemList;
Line 128... Line 128...
128
            CatalogClient catalogServiceClient = new CatalogClient();
128
            CatalogClient catalogServiceClient = new CatalogClient();
129
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
129
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
130
 
130
 
131
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
131
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
132
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
132
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
133
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
133
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
134
            }
134
            }
135
        } catch(Exception e){
135
        } catch(Exception e){
136
            logger.error("Error while getting the best deals from the catalog service", e);
136
            logger.error("Error while getting the best deals from the catalog service", e);
137
        }
137
        }
138
        //Collections.sort(itemList, new ItemsComparator());
138
        //Collections.sort(itemList, new ItemsComparator());
Line 146... Line 146...
146
            CatalogClient catalogServiceClient = new CatalogClient();
146
            CatalogClient catalogServiceClient = new CatalogClient();
147
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
147
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
148
 
148
 
149
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
149
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
150
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
150
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
151
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
151
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
152
            }
152
            }
153
        } catch(Exception e){
153
        } catch(Exception e){
154
            logger.error("Error while getting the risky items from the catalog service", e);
154
            logger.error("Error while getting the risky items from the catalog service", e);
155
        }
155
        }
156
        Collections.sort(itemList, new ItemsComparator());
156
        Collections.sort(itemList, new ItemsComparator());
Line 164... Line 164...
164
            CatalogClient catalogServiceClient = new CatalogClient();
164
            CatalogClient catalogServiceClient = new CatalogClient();
165
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
165
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
166
 
166
 
167
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
167
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
168
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
168
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
169
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
169
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
170
            }
170
            }
171
        } catch(Exception e){
171
        } catch(Exception e){
172
            logger.error("Error while getting the best sellers from the catalog service", e);
172
            logger.error("Error while getting the best sellers from the catalog service", e);
173
        }
173
        }
174
        return itemList;        
174
        return itemList;        
Line 183... Line 183...
183
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
183
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
184
 
184
 
185
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
185
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
186
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
186
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
187
                //List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
187
                //List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
188
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
188
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
189
            }
189
            }
190
        } catch(Exception e){
190
        } catch(Exception e){
191
            logger.error("Error while getting the latest arrivals from the catalog service", e);
191
            logger.error("Error while getting the latest arrivals from the catalog service", e);
192
        }
192
        }
193
        return itemList;
193
        return itemList;
Line 201... Line 201...
201
            CatalogClient catalogServiceClient = new CatalogClient();
201
            CatalogClient catalogServiceClient = new CatalogClient();
202
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
202
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
203
 
203
 
204
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
204
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
205
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
205
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
206
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
206
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
207
            }
207
            }
208
        } catch(Exception e){
208
        } catch(Exception e){
209
            logger.error("Error while getting the search results from the catalog service", e);
209
            logger.error("Error while getting the search results from the catalog service", e);
210
        }
210
        }
211
        return itemList;
211
        return itemList;
Line 233... Line 233...
233
            in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
233
            in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
234
 
234
 
235
            List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
235
            List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
236
            List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
236
            List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
237
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
237
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
-
 
238
            List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
238
            return getItemFromThriftItem(thriftItem, vip, vim, sip);
239
            return getItemFromThriftItem(thriftItem, vip, vim, sip, sit);
239
        }catch(Exception e){
240
        }catch(Exception e){
240
            logger.error("Error while getting the item from the catalog service", e);
241
            logger.error("Error while getting the item from the catalog service", e);
241
        }
242
        }
242
        return null;
243
        return null;
243
    }
244
    }
Line 581... Line 582...
581
            
582
            
582
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
583
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
583
                List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
584
                List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
584
                List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
585
                List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
585
                List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
586
                List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
586
                itemList.add(getItemFromThriftItem(thriftItem, vip, vim, sip));
587
                itemList.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null));
587
            }
588
            }
588
        } catch (Exception e) {
589
        } catch (Exception e) {
589
            logger.error("Error while getting items by vendor category: " + category, e);
590
            logger.error("Error while getting items by vendor category: " + category, e);
590
        }
591
        }
591
        Collections.sort(itemList, new ItemsComparator());
592
        Collections.sort(itemList, new ItemsComparator());
Line 695... Line 696...
695
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
696
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
696
 
697
 
697
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
698
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
698
 
699
 
699
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
700
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
700
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null));
701
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null));
701
            }
702
            }
702
        } catch (Exception e) {
703
        } catch (Exception e) {
703
            logger.error("Error while getting items by status: " + st, e);
704
            logger.error("Error while getting items by status: " + st, e);
704
        }
705
        }
705
        return itemList;
706
        return itemList;
706
    }
707
    }
707
    
708
    
708
    /**
709
    /**
709
     * Creates a new Item object and populates its attributes from thrift item passed as parameter.
710
     * Creates a new Item object and populates its attributes from thrift item passed as parameter.
710
     * Also creates a Map each for VendorItemPricing and VendorItemMapping and adds these maps to the
711
     * Also creates a Map each for VendorItemPricing, VendorItemMapping, SourceItemPricing and SimilarItems and adds these maps to the
711
     * new Item object.
712
     * new Item object.
712
     * @param thriftItem
713
     * @param thriftItem
713
     * @param tVendorPricings
714
     * @param tVendorPricings
714
     * @param tVendorMappings
715
     * @param tVendorMappings
-
 
716
     * @param tSourceMappings
-
 
717
     * @param tSimilarItems
715
     * @return item object with attributes copied from thrift item object.
718
     * @return item object with attributes copied from thrift item object.
716
     */
719
     */
717
    private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem, 
720
    private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem, 
718
            List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings, 
721
            List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings, 
719
            List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings,
722
            List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings,
720
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings){
723
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
-
 
724
            List<in.shop2020.model.v1.catalog.Item> tSimilarItems){
721
 
725
 
722
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
726
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
723
        VendorItemMapping vItemMapping;
727
        VendorItemMapping vItemMapping;
724
        if(tVendorMappings != null) {
728
        if(tVendorMappings != null) {
725
            for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
729
            for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
Line 752... Line 756...
752
                sPricings.setMrp(sip.getMrp());
756
                sPricings.setMrp(sip.getMrp());
753
                sPricings.setSellingPrice(sip.getSellingPrice());
757
                sPricings.setSellingPrice(sip.getSellingPrice());
754
                sourcePricingMap.put(sPricings.getSourceId(), sPricings);
758
                sourcePricingMap.put(sPricings.getSourceId(), sPricings);
755
            }
759
            }
756
        }
760
        }
-
 
761
        
-
 
762
        Map<Long, Item> SimilarItemslist = new HashMap<Long, Item>();
-
 
763
        Item sItems;
-
 
764
        if(tSimilarItems != null) {
-
 
765
            for(in.shop2020.model.v1.catalog.Item sit : tSimilarItems) {
-
 
766
            	sItems = new Item();
-
 
767
            	sItems.setCatalogItemId(sit.getCatalogItemId());
-
 
768
            	sItems.setProductGroup(sit.getProductGroup());
-
 
769
            	sItems.setBrand(sit.getBrand());
-
 
770
            	sItems.setModelNumber(sit.getModelNumber());
-
 
771
            	sItems.setModelName(sit.getModelName());
-
 
772
            	sItems.setContentCategory(CategoryManager.getCategoryManager().getCategoryLabel(sit.getCategory()));
-
 
773
            	SimilarItemslist.put(sit.getCatalogItemId(), sItems);
-
 
774
            }
-
 
775
        }
757
 
776
 
758
        Item item = new Item(thriftItem.getId(),
777
        Item item = new Item(thriftItem.getId(),
759
                thriftItem.getHotspotCategory(),
778
                thriftItem.getHotspotCategory(),
760
                thriftItem.getProductGroup(),
779
                thriftItem.getProductGroup(),
761
                thriftItem.getBrand(),
780
                thriftItem.getBrand(),
Line 789... Line 808...
789
                thriftItem.isSetDefaultWarehouse() ? thriftItem.getDefaultWarehouse() : null,
808
                thriftItem.isSetDefaultWarehouse() ? thriftItem.getDefaultWarehouse() : null,
790
                thriftItem.isIsWarehousePreferenceSticky(),        
809
                thriftItem.isIsWarehousePreferenceSticky(),        
791
                (thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
810
                (thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
792
                vendorPricingMap,
811
                vendorPricingMap,
793
                vItemMap,
812
                vItemMap,
794
                sourcePricingMap);
813
                sourcePricingMap,
-
 
814
                SimilarItemslist);
795
        return item;
815
        return item;
796
    }
816
    }
797
    
817
    
798
    /**
818
    /**
799
     * 
819
     * 
Line 827... Line 847...
827
        } catch (IOException e) {
847
        } catch (IOException e) {
828
            logger.error("Error while reading the log file", e);
848
            logger.error("Error while reading the log file", e);
829
        }
849
        }
830
        return lineCount;
850
        return lineCount;
831
    }
851
    }
-
 
852
 
-
 
853
	@Override
-
 
854
	public boolean deleteSimilarItem(long itemId, long catalogItemId) {
-
 
855
		try{
-
 
856
            CatalogClient catalogServiceClient = new CatalogClient();
-
 
857
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
-
 
858
 
-
 
859
            return catalogClient.deleteSimilarItem(itemId, catalogItemId);
-
 
860
 
-
 
861
        }catch(Exception e){
-
 
862
            logger.error("Error while deleting the SimilarItems for: " + itemId, e);
-
 
863
        }
-
 
864
        return false;
-
 
865
	}
-
 
866
 
-
 
867
	@Override
-
 
868
	public Item addSimilarItem(long itemId, long catalogItemId) {
-
 
869
		try{
-
 
870
            CatalogClient catalogServiceClient = new CatalogClient();
-
 
871
            InventoryService.Client catalogClient = catalogServiceClient.getClient();
-
 
872
            in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.addSimilarItem(itemId, catalogItemId);;
-
 
873
 
-
 
874
            return getItemFromThriftItem(thriftItem, null, null, null, null);
-
 
875
        }catch(Exception e){
-
 
876
            logger.error("Error while adding the SimilarItems for: " + itemId, e);
-
 
877
        }
-
 
878
        return null;
-
 
879
	}
832
}
880
}
833
881