private void removeWishListItem( final ShoppingCart shoppingCart, final ProductSku productSku, final long pk) { final List<CustomerWishList> wishList = customerWishListService.getWishListByCustomerEmail(shoppingCart.getCustomerEmail()); for (final CustomerWishList item : wishList) { if (item.getCustomerwishlistId() == pk) { customerWishListService.delete(item); return; } } }
/** * Construct page. * * @param params page parameters */ public WishListPage(final PageParameters params) { super(params); final String email; final Customer customer; final String publicKey; final String key = params.get("token").toString(); final String tag = params.get("tag").toString(); if (StringUtils.isBlank(key)) { // Trying to view own wish list final ShoppingCart cart = ApplicationDirector.getShoppingCart(); if (cart.getLogonState() == ShoppingCart.LOGGED_IN && ((AuthenticatedWebSession) getSession()).isSignedIn()) { email = cart.getCustomerEmail(); customer = customerServiceFacade.getCustomerByEmail(ApplicationDirector.getCurrentShop(), email); publicKey = customerServiceFacade.getCustomerPublicKey(customer); } else { email = ""; customer = null; publicKey = null; // Redirect away from profile! final PageParameters rparams = new PageParameters(); rparams.set(ShoppingCartCommand.CMD_LOGOUT, ShoppingCartCommand.CMD_LOGOUT); setResponsePage(Application.get().getHomePage(), rparams); } } else { publicKey = null; customer = customerServiceFacade.getCustomerByPublicKey(key); if (customer == null) { info(getLocalizer().getString("wishListNotFound", this)); email = ""; } else { email = customer.getEmail(); } } add(new FeedbackPanel(FEEDBACK)); add( new WishListView( WISHLIST_PANEL, new Model<String>(email), new Model<String>(CustomerWishList.SIMPLE_WISH_ITEM), new Model<String>(tag)) .setVisible(customer != null) .add(new AttributeModifier("data-publickey", publicKey))); add(new StandardFooter(FOOTER)); add(new StandardHeader(HEADER)); add(new ServerSideJs("serverSideJs")); add(new HeaderMetaInclude("headerInclude")); if (StringUtils.isNotBlank(publicKey)) { String content = contentServiceFacade.getContentBody( "profile_wishlist_owner_include", ShopCodeContext.getShopId(), getLocale().getLanguage()); add(new Label("wishListOwnerInfo", content).setEscapeModelStrings(false)); add(new Label("wishListViewerInfo", "")); } else { String content = contentServiceFacade.getContentBody( "profile_wishlist_viewer_include", ShopCodeContext.getShopId(), getLocale().getLanguage()); add(new Label("wishListOwnerInfo", "")); add(new Label("wishListViewerInfo", content).setEscapeModelStrings(false)); } }