2 * Copyright (C) 2016 - 2024 Free Software Foundation
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.jproduct.model.product.Product;
23 import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
24 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
27 * An interface for a basket
29 * @author Roland Häder<roland@mxchange.org>
32 public interface PizzaBasketWebSessionController extends Serializable {
35 * Observes events being fired when a checkout is completed by user
37 * @param event Event being fired
39 void afterCheckoutCompleted (final ObservableCheckoutCompletedEvent event);
42 * Adds given product instance to basket by adding amount from form data to
45 * @param product Product instance to add
47 * @return Redirect target or null
49 String addItem (final Product product);
52 * Gets for all added items
54 * @return A list of all added items
56 List<AddableBasketItem> allItems ();
59 * Calculates total price (no tax added) of current item. If no current item
60 * is set and no amount, a NPE is thrown.
62 * @return Current item's total price
64 Float calculateCurrentItemPrice ();
67 * Calculates total price (no tax added) for given item.
69 * @param item Item instance to calculate total price for
73 Float calculateItemPrice (final AddableBasketItem item);
76 * Calculates total sum (no tax added) for all items
78 * @return Total price of all items
80 Float calculateTotalPrice ();
83 * Changes given item instance's amount in basket and redirects to proper
84 * page. If the item is not found, another "error" page is called.
86 * @param item Item instance to change
88 * @return Page redirection
90 String doChangeItem (final AddableBasketItem item);
93 * Getter for item amount property
95 * @return Item amount property
97 Long getOrderedAmount ();
100 * Setter for item amount property
102 * @param amount Item amount property
104 void setOrderedAmount (final Long amount);
107 * Getter for current item
109 * @return Current item
111 AddableBasketItem getCurrentItem ();
114 * Setter for current item
116 * @param currentItem Current item
118 void setCurrentItem (final AddableBasketItem currentItem);
121 * Some getter for item amount of given product. This method requires a full
122 * iteration over all items in the basket to look for proper product
125 * @param product Product instance
127 * @return Item amount of given product
129 Long getItemAmount (final Product product);
132 * Getter for last entry
134 * @return Last added item in basket
136 AddableBasketItem getLast ();
139 * Getter for last num rows
141 * @return Last num rows
143 int getLastNumRows ();
146 * Checks whether the basket has items in it. This method is wrapper to
149 * @return Whether the basket is empty
154 * Checks whether the basket is empty
156 * @return Whether the basket is empty
161 * Checks whether the currently set product is added in basked
163 * @param product Product instance
165 * @return Whether the product is added
167 boolean isProductAdded (final Product product);
170 * Outputs last added item in the basket.
172 * @return Last added item
174 String outputLastAddedItem ();