2626import org .woehlke .greenshop .catalog .model .ProductAttributes ;
2727import org .woehlke .greenshop .catalog .model .SpecialProduct ;
2828import org .woehlke .greenshop .catalog .service .LanguageService ;
29+ import org .woehlke .greenshop .catalog .service .ManufacturerService ;
30+ import org .woehlke .greenshop .catalog .service .ReviewService ;
31+ import org .woehlke .greenshop .catalog .service .SpecialService ;
2932
3033@ Controller
3134@ SessionAttributes ({"transientBasket" })
@@ -38,6 +41,15 @@ public class CartController extends AbstractController {
3841
3942 @ Inject
4043 private LanguageService languageService ;
44+
45+ @ Inject
46+ private ManufacturerService manufacturerService ;
47+
48+ @ Inject
49+ private ReviewService reviewService ;
50+
51+ @ Inject
52+ private SpecialService specialService ;
4153
4254 @ RequestMapping (value = "/shoppingCart" , method = RequestMethod .GET )
4355 public String shoppingCart (
@@ -55,19 +67,19 @@ public String addToBasket(
5567 HttpServletResponse response ,
5668 @ PathVariable long productId , Model model ){
5769 Language language = languageService .findLanguageByCode ("en" );
58- ReviewDescription randomReview = catalogService .getRandomReview (language );
70+ ReviewDescription randomReview = reviewService .getRandomReview (language );
5971 model .addAttribute ("randomReview" , randomReview );
60- SpecialProduct randomSpecialProduct = catalogService .getRandomSpecial (language );
72+ SpecialProduct randomSpecialProduct = specialService .getRandomSpecial (language );
6173 model .addAttribute ("randomSpecialProduct" , randomSpecialProduct );
62- SpecialProduct thisProduct = catalogService .findSpecialProductById (productId , language );
74+ SpecialProduct thisProduct = specialService .findSpecialProductById (productId , language );
6375 model .addAttribute ("product" , thisProduct );
6476 logger .info (thisProduct .toString ());
65- Manufacturers manufacturers =catalogService .findManufacturers ();
77+ Manufacturers manufacturers =manufacturerService .findManufacturers ();
6678 model .addAttribute ("manufacturers" , manufacturers );
6779 ProductAttributes productAttributes = catalogService .findProductOptionsByProduct (thisProduct .getProductDescription ());
6880 logger .info (productAttributes .toString ());
6981 model .addAttribute ("productAttributes" , productAttributes );
70- CategoryTree categoryTree = catalogService .getCategoriesTree (thisProduct .getProductDescription ().getProduct ().getCategories ().iterator ().next ().getId (), language );
82+ CategoryTree categoryTree = categoryService .getCategoriesTree (thisProduct .getProductDescription ().getProduct ().getCategories ().iterator ().next ().getId (), language );
7183 model .addAttribute ("categoryTree" , categoryTree );
7284 Map <Long ,Long > optionsAndValues = getOptionsAndValuesFromRequest (request );
7385 transientBasket = cartService .addProductToCart (transientBasket ,productId ,optionsAndValues ,language );
@@ -82,19 +94,19 @@ public String removeFromBasket(
8294 HttpServletResponse response ,
8395 @ PathVariable long productId , Model model ){
8496 Language language = languageService .findLanguageByCode ("en" );
85- ReviewDescription randomReview = catalogService .getRandomReview (language );
97+ ReviewDescription randomReview = reviewService .getRandomReview (language );
8698 model .addAttribute ("randomReview" , randomReview );
87- SpecialProduct randomSpecialProduct = catalogService .getRandomSpecial (language );
99+ SpecialProduct randomSpecialProduct = specialService .getRandomSpecial (language );
88100 model .addAttribute ("randomSpecialProduct" , randomSpecialProduct );
89- SpecialProduct thisProduct = catalogService .findSpecialProductById (productId , language );
101+ SpecialProduct thisProduct = specialService .findSpecialProductById (productId , language );
90102 model .addAttribute ("product" , thisProduct );
91103 logger .info (thisProduct .toString ());
92- Manufacturers manufacturers =catalogService .findManufacturers ();
104+ Manufacturers manufacturers =manufacturerService .findManufacturers ();
93105 model .addAttribute ("manufacturers" , manufacturers );
94106 ProductAttributes productAttributes = catalogService .findProductOptionsByProduct (thisProduct .getProductDescription ());
95107 logger .info (productAttributes .toString ());
96108 model .addAttribute ("productAttributes" , productAttributes );
97- CategoryTree categoryTree = catalogService .getCategoriesTree (thisProduct .getProductDescription ().getProduct ().getCategories ().iterator ().next ().getId (), language );
109+ CategoryTree categoryTree = categoryService .getCategoriesTree (thisProduct .getProductDescription ().getProduct ().getCategories ().iterator ().next ().getId (), language );
98110 model .addAttribute ("categoryTree" , categoryTree );
99111 Map <Long ,Long > optionsAndValues = getOptionsAndValuesFromRequest (request );
100112 transientBasket = cartService .removeProductFromCart (transientBasket ,productId ,optionsAndValues ,language );
0 commit comments