]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaBean.java
Removed already no longer used methods and cleared some which you should really not...
[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          * Some "getter" for total price of position from request or session.
64          * Single price and amount is multiplyed.
65          *
66          * @param product Product instance
67          * @param request Request instance
68          * @param session Session instance
69          * @return Amount as string
70          */
71         public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
72
73         /**
74          * Initializes this instance
75          * 
76          * @throws FacesException If something was wrong
77          */
78         public void init () throws FacesException;
79
80         /**
81          * Checks whether the given product is choosen, request overules session.
82          *
83          * @param product Product instance
84          * @param request Request instance
85          * @param session Session instance
86          * @return Whether the product is choosen
87          * @deprecated Old lost code
88          */
89         @Deprecated
90         public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
91
92         /**
93          * Calculates total price of all choosen products
94          *
95          * @param request Request instance
96          * @param session Session instance
97          * @return Total price of all choosen products
98          * @throws javax.servlet.ServletException If something unexpected happened
99          */
100         public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) throws ServletException;
101
102         /**
103          * Calculates total amount of all choosen products
104          *
105          * @param request Request instance
106          * @param session Session instance
107          * @return Total amount of all choosen products
108          * @throws javax.servlet.ServletException If something unexpected happened
109          * @deprecated Old lost code
110          */
111         @Deprecated
112         public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) throws ServletException;
113
114         /**
115          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
116          *
117          * @param product Product instance
118          * @param request Request instance
119          * @param session Session instance
120          * @return Whether the product is choosen
121          */
122         public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
123
124         /**
125          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
126          *
127          * @param request Request instance
128          * @param session Session instance
129          * @return Whether the product is choosen
130          * @throws javax.servlet.ServletException If something unexpected happened
131          */
132         public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
133
134         /**
135          * Some getter for printable value from session or an empty string for null.
136          *
137          * @param session Session instance
138          * @param key Key to get
139          * @return Value from key, empty string for null
140          */
141         public Object getPrintableValeFromSession (final HttpSession session, final String key);
142
143         /**
144          * Somewhat setter in session
145          *
146          * @param session Session instance
147          * @param key Session key to set
148          * @param value Value to set
149          */
150         public void setValueInSession (final HttpSession session, final String key, final Object value);
151
152         /**
153          * Some "getter" for a an array of only available products
154          * 
155          * @return Only available products
156          * @throws javax.servlet.ServletException If anything went wrong
157          */
158         public Iterator<Product> getAvailableProducts () throws ServletException;
159
160         /**
161          * Some "getter" for a an array of all products
162          *
163          * @return All products
164          * @throws javax.servlet.ServletException If anything went wrong
165          */
166         public Iterator<Product> getAllProducts () throws ServletException;
167
168         /**
169          * Some "getter" for a an array of all categories
170          *
171          * @return All categories
172          * @throws javax.servlet.ServletException If anything went wrong
173          */
174         public Iterator<Category> getAllCategories () throws ServletException;
175
176         /**
177          * Checks if given Product instance is available and returns a printable
178          * (human-readable) string.
179          * 
180          * @param product Product instance to check
181          * @return Human-readable version of product availability
182          */
183         public String getPrintableProduktAvailability (final Product product);
184
185         /**
186          * Returns a printable (human-readable) string of product's category
187          * 
188          * @param product Product instance to check
189          * @return Human-readable version of product availability
190          * @throws javax.servlet.ServletException If something unexpected happened
191          */
192         public String getPrintableProduktCategory (final Product product) throws ServletException;
193
194         /**
195          * Adds given category data from request to database
196          *
197          * @param request Request instance
198          * @throws javax.servlet.ServletException If something unexpected happened
199          * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
200          */
201         public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
202
203         /**
204          * Adds given product data from request to database
205          *
206          * @param request Request instance
207          * @throws javax.servlet.ServletException If something unexpected happened
208          * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
209          */
210         public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
211
212         /**
213          * Generates link HTML code for given category's parent id, if set. This
214          * link then points to products.jsp?category_id=x
215          *
216          * @param category Category instance
217          * @return HTML code
218          */
219         public String generateLinkForParent (final Category category);
220
221         /**
222          * Handles admin product form requests
223          *
224          * @param request Request instance
225          * @param response Response instance
226          * @throws ServletException If something unexpected happened
227          */
228         public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
229
230         /**
231          * Handles admin category form requests
232          * 
233          * @param request Request instance
234          * @param response Response instance
235          * @throws ServletException If something unexpected happened
236          */
237         public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
238
239         /**
240          * Getter for logger
241          *
242          * @return Logger
243          */
244         public Logger getLogger ();
245
246         /**
247          * @return the basket
248          */
249         public BasketBean getBasket ();
250
251         /**
252          * @param basket the basket to set
253          */
254         public void setBasket (final BasketBean basket);
255
256         /**
257          * @return the application
258          */
259         public ServletContext getApplication ();
260
261         /**
262          * @param application the application to set
263          */
264         public void setApplication (final ServletContext application);
265
266         /**
267          * Some "getter" for a product from given item
268          * @param item Item instance
269          * @return A Product instance
270          * @throws javax.servlet.ServletException If something bad happens
271          */
272         public Product getProduct (final AddableBasketItem item) throws ServletException;
273 }