]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/basket/PizzaBasketWebSessionController.java
Updated copyright year
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / basket / PizzaBasketWebSessionController.java
1 /*
2  * Copyright (C) 2016 - 2024 Free Software Foundation
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.pizzaapplication.beans.basket;
18
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;
25
26 /**
27  * An interface for a basket
28  * <p>
29  * @author Roland Häder<roland@mxchange.org>
30  */
31 @Local
32 public interface PizzaBasketWebSessionController extends Serializable {
33
34         /**
35          * Observes events being fired when a checkout is completed by user
36          * <p>
37          * @param event Event being fired
38          */
39         void afterCheckoutCompleted (final ObservableCheckoutCompletedEvent event);
40
41         /**
42          * Adds given product instance to basket by adding amount from form data to
43          * it.
44          * <p>
45          * @param product Product instance to add
46          * <p>
47          * @return Redirect target or null
48          */
49         String addItem (final Product product);
50
51         /**
52          * Gets for all added items
53          * <p>
54          * @return A list of all added items
55          */
56         List<AddableBasketItem> allItems ();
57
58         /**
59          * Calculates total price (no tax added) of current item. If no current item
60          * is set and no amount, a NPE is thrown.
61          * <p>
62          * @return Current item's total price
63          */
64         Float calculateCurrentItemPrice ();
65
66         /**
67          * Calculates total price (no tax added) for given item.
68          * <p>
69          * @param item Item instance to calculate total price for
70          * <p>
71          * @return Total price
72          */
73         Float calculateItemPrice (final AddableBasketItem item);
74
75         /**
76          * Calculates total sum (no tax added) for all items
77          * <p>
78          * @return Total price of all items
79          */
80         Float calculateTotalPrice ();
81
82         /**
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.
85          * <p>
86          * @param item Item instance to change
87          * <p>
88          * @return Page redirection
89          */
90         String doChangeItem (final AddableBasketItem item);
91
92         /**
93          * Getter for item amount property
94          * <p>
95          * @return Item amount property
96          */
97         Long getOrderedAmount ();
98
99         /**
100          * Setter for item amount property
101          * <p>
102          * @param amount Item amount property
103          */
104         void setOrderedAmount (final Long amount);
105
106         /**
107          * Getter for current item
108          * <p>
109          * @return Current item
110          */
111         AddableBasketItem getCurrentItem ();
112
113         /**
114          * Setter for current item
115          * <p>
116          * @param currentItem Current item
117          */
118         void setCurrentItem (final AddableBasketItem currentItem);
119
120         /**
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
123          * instance.
124          * <p>
125          * @param product Product instance
126          * <p>
127          * @return Item amount of given product
128          */
129         Long getItemAmount (final Product product);
130
131         /**
132          * Getter for last entry
133          * <p>
134          * @return Last added item in basket
135          */
136         AddableBasketItem getLast ();
137
138         /**
139          * Getter for last num rows
140          * <p>
141          * @return Last num rows
142          */
143         int getLastNumRows ();
144
145         /**
146          * Checks whether the basket has items in it. This method is wrapper to
147          * isEmpty()
148          * <p>
149          * @return Whether the basket is empty
150          */
151         boolean hasItems ();
152
153         /**
154          * Checks whether the basket is empty
155          * <p>
156          * @return Whether the basket is empty
157          */
158         boolean isEmpty ();
159
160         /**
161          * Checks whether the currently set product is added in basked
162          * <p>
163          * @param product Product instance
164          * <p>
165          * @return Whether the product is added
166          */
167         boolean isProductAdded (final Product product);
168
169         /**
170          * Outputs last added item in the basket.
171          * <p>
172          * @return Last added item
173          */
174         String outputLastAddedItem ();
175
176 }