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