2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.pizzaapplication.beans.basket;
19 import java.io.Serializable;
20 import java.util.List;
21 import javax.ejb.Local;
22 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
23 import org.mxchange.jshopcore.model.product.Product;
26 * An interface for a basket
28 * @author Roland Haeder<roland@mxchange.org>
31 public interface PizzaBasketWebSessionController extends Serializable {
34 * Adds given product instance to basket by adding amount from form data to
37 * @param product Product instance to add
39 * @return Redirect target or null
41 String addItem (final Product product);
44 * Gets for all added items
46 * @return A list of all added items
48 List<AddableBasketItem> allItems ();
51 * Calculates total price (no tax added) of current item. If no current item
52 * is set and no amount, a NPE is thrown.
54 * @return Current item's total price
56 Float calculateCurrentItemPrice ();
59 * Calculates total price (no tax added) for given item.
61 * @param item Item instance to calculate total price for
65 Float calculateItemPrice (final AddableBasketItem item);
68 * Calculates total sum (no tax added) for all items
70 * @return Total price of all items
72 Float calculateTotalPrice ();
75 * Changes given item instance's amount in basket and redirects to proper
76 * page. If the item is not found, another "error" page is called.
78 * @param item Item instance to change
80 * @return Page redirection
82 String doChangeItem (final AddableBasketItem item);
85 * Clears this basket instance
90 * Getter for item amount property
92 * @return Item amount property
94 Long getOrderedAmount ();
97 * Setter for item amount property
99 * @param amount Item amount property
101 void setOrderedAmount (final Long amount);
104 * Getter for current item
106 * @return Current item
108 AddableBasketItem getCurrentItem ();
111 * Setter for current item
113 * @param currentItem Current item
115 void setCurrentItem (final AddableBasketItem currentItem);
118 * Some getter for item amount of given product. This method requires a full
119 * iteration over all items in the basket to look for proper product
122 * @param product Product instance
124 * @return Item amount of given product
126 Long getItemAmount (final Product product);
129 * Getter for last entry
131 * @return Last added item in basket
133 AddableBasketItem getLast ();
136 * Getter for last num rows
138 * @return Last num rows
140 int getLastNumRows ();
143 * Checks whether the basket has items in it. This method is wrapper to
146 * @return Whether the basket is empty
151 * Checks whether the basket is empty
153 * @return Whether the basket is empty
158 * Checks whether the currently set product is added in basked
160 * @param product Product instance
162 * @return Whether the product is added
164 boolean isProductAdded (final Product product);
167 * Outputs last added item in the basket.
169 * @return Last added item
171 String outputLastAddedItem ();