]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaBean.java
Refacturing:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / controller / PizzaBean.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (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 General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.pizzaapplication.beans.controller;
18
19 import java.util.Iterator;
20 import javax.faces.FacesException;
21 import javax.servlet.ServletContext;
22 import javax.servlet.ServletException;
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
25 import javax.servlet.http.HttpSession;
26 import org.apache.logging.log4j.Logger;
27 import org.mxchange.jshop.beans.FrameworkBean;
28 import org.mxchange.jshop.beans.basket.BasketBean;
29 import org.mxchange.jshop.category.Category;
30 import org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException;
31 import org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException;
32 import org.mxchange.jshop.item.AddableBasketItem;
33 import org.mxchange.jshop.product.Product;
34
35 /**
36  *
37  * @author Roland Haeder
38  */
39 public interface PizzaBean extends FrameworkBean {
40         /**
41          * Some "getter" for amount from session
42          *
43          * @param product Product instance
44          * @param session Session instance
45          * @return Amount as string
46          * @deprecated Old code
47          */
48         @Deprecated
49         public String getAmountFromSession (final Product product, final HttpSession session);
50
51         /**
52          * Some "getter" for choose from session
53          *
54          * @param product Product instance
55          * @param session Session instance
56          * @return Choose as string
57          * @deprecated Old code
58          */
59         @Deprecated
60         public String getChooseFromSession (final Product product, final HttpSession session);
61
62         /**
63          * Handler for amount from session
64          *
65          * @param product Product instance
66          * @param request Request instance
67          * @param session Session instance
68          * @return Amount as string
69          * @deprecated Old code
70          */
71         @Deprecated
72         public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
73
74         /**
75          * Some "getter" for printable choosen (checkbox) from request or session
76          *
77          * @param product Product instance
78          * @param request Request instance
79          * @param session Session instance
80          * @return Amount as string
81          * @deprecated Old code
82          */
83         @Deprecated
84         public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
85
86         /**
87          * Some "getter" for total price of position from request or session.
88          * Single price and amount is multiplyed.
89          *
90          * @param product Product instance
91          * @param request Request instance
92          * @param session Session instance
93          * @return Amount as string
94          */
95         public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
96
97         /**
98          * Initializes this instance
99          * 
100          * @throws FacesException If something was wrong
101          */
102         public void init () throws FacesException;
103
104         /**
105          * Checks whether the given product is choosen, request overules session.
106          *
107          * @param product Product instance
108          * @param request Request instance
109          * @param session Session instance
110          * @return Whether the product is choosen
111          * @deprecated Old lost code
112          */
113         @Deprecated
114         public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
115
116         /**
117          * Calculates total price of all choosen products
118          *
119          * @param request Request instance
120          * @param session Session instance
121          * @return Total price of all choosen products
122          * @throws javax.servlet.ServletException If something unexpected happened
123          */
124         public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) throws ServletException;
125
126         /**
127          * Calculates total amount of all choosen products
128          *
129          * @param request Request instance
130          * @param session Session instance
131          * @return Total amount of all choosen products
132          * @throws javax.servlet.ServletException If something unexpected happened
133          */
134         public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) throws ServletException;
135
136         /**
137          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
138          *
139          * @param product Product instance
140          * @param request Request instance
141          * @param session Session instance
142          * @return Whether the product is choosen
143          */
144         public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
145
146         /**
147          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
148          *
149          * @param request Request instance
150          * @param session Session instance
151          * @return Whether the product is choosen
152          * @throws javax.servlet.ServletException If something unexpected happened
153          */
154         public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
155
156         /**
157          * Marks given product as ordered in session
158          *
159          * @param product Product to mark as ordered
160          * @param session Session instance
161          * @deprecated Old code
162          */
163         @Deprecated
164         public void markProductAsOrdered(final Product product, final HttpSession session);
165
166         /**
167          * Marks given product as choosen in session
168          *
169          * @param product Product to mark as ordered
170          * @param session Session instance
171          * @deprecated Old code
172          */
173         @Deprecated
174         public void markProductAsChoosen(final Product product, final HttpSession session);
175
176         /**
177          * Unmarks given product as ordered in session
178          *
179          * @param product Product to unmark as ordered
180          * @param session Session instance
181          * @deprecated Old code
182          */
183         @Deprecated
184         public void unmarkProductAsOrdered(final Product product, final HttpSession session);
185
186         /**
187          * Unmarks given product as choosen in session
188          *
189          * @param product Product to unmark as choosen
190          * @param session Session instance
191          * @deprecated Old code
192          */
193         @Deprecated
194         public void unmarkProductAsChoosen(final Product product, final HttpSession session);
195
196         /**
197          * Some getter for printable value from session or an empty string for null.
198          *
199          * @param session Session instance
200          * @param key Key to get
201          * @return Value from key, empty string for null
202          */
203         public Object getPrintableValeFromSession (final HttpSession session, final String key);
204
205         /**
206          * Somewhat setter in session
207          *
208          * @param session Session instance
209          * @param key Session key to set
210          * @param value Value to set
211          */
212         public void setValueInSession (final HttpSession session, final String key, final Object value);
213
214         /**
215          * Some "getter" for a an array of only available products
216          * 
217          * @return Only available products
218          * @throws javax.servlet.ServletException If anything went wrong
219          */
220         public Iterator<Product> getAvailableProducts () throws ServletException;
221
222         /**
223          * Some "getter" for a an array of all products
224          *
225          * @return All products
226          * @throws javax.servlet.ServletException If anything went wrong
227          */
228         public Iterator<Product> getAllProducts () throws ServletException;
229
230         /**
231          * Some "getter" for a an array of all categories
232          *
233          * @return All categories
234          * @throws javax.servlet.ServletException If anything went wrong
235          */
236         public Iterator<Category> getAllCategories () throws ServletException;
237
238         /**
239          * Checks if given Product instance is available and returns a printable
240          * (human-readable) string.
241          * 
242          * @param product Product instance to check
243          * @return Human-readable version of product availability
244          */
245         public String getPrintableProduktAvailability (final Product product);
246
247         /**
248          * Returns a printable (human-readable) string of product's category
249          * 
250          * @param product Product instance to check
251          * @return Human-readable version of product availability
252          * @throws javax.servlet.ServletException If something unexpected happened
253          */
254         public String getPrintableProduktCategory (final Product product) throws ServletException;
255
256         /**
257          * Marks all choosen products as ordered
258          *
259          * @param request Request instance
260          * @param session Session instance
261          * @throws javax.servlet.ServletException If something unexpected happened
262          * @deprecated Old code
263          */
264         @Deprecated
265         public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException;
266
267         /**
268          * Adds given category data from request to database
269          *
270          * @param request Request instance
271          * @throws javax.servlet.ServletException If something unexpected happened
272          * @throws org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
273          */
274         public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
275
276         /**
277          * Adds given product data from request to database
278          *
279          * @param request Request instance
280          * @throws javax.servlet.ServletException If something unexpected happened
281          * @throws org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
282          */
283         public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
284
285         /**
286          * Generates link HTML code for given category's parent id, if set. This
287          * link then points to products.jsp?category_id=x
288          *
289          * @param category Category instance
290          * @return HTML code
291          */
292         public String generateLinkForParent (final Category category);
293
294         /**
295          * Handles admin product form requests
296          *
297          * @param request Request instance
298          * @param response Response instance
299          * @throws ServletException If something unexpected happened
300          */
301         public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
302
303         /**
304          * Handles admin category form requests
305          * 
306          * @param request Request instance
307          * @param response Response instance
308          * @throws ServletException If something unexpected happened
309          */
310         public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
311
312         /**
313          * Getter for logger
314          *
315          * @return Logger
316          */
317         public Logger getLogger ();
318
319         /**
320          * @return the basket
321          */
322         public BasketBean getBasket ();
323
324         /**
325          * @param basket the basket to set
326          */
327         public void setBasket (final BasketBean basket);
328
329         /**
330          * @return the application
331          */
332         public ServletContext getApplication ();
333
334         /**
335          * @param application the application to set
336          */
337         public void setApplication (final ServletContext application);
338
339         /**
340          * Some "getter" for a product from given item
341          * @param item Item instance
342          * @return A Product instance
343          * @throws javax.servlet.ServletException If something bad happens
344          */
345         public Product getProduct (final AddableBasketItem item) throws ServletException;
346 }