]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaBean.java
Removed more deprecated and no longer used methods + kept one for functionality
[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          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
94          *
95          * @param product Product instance
96          * @param request Request instance
97          * @param session Session instance
98          * @return Whether the product is choosen
99          */
100         public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
101
102         /**
103          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
104          *
105          * @param request Request instance
106          * @param session Session instance
107          * @return Whether the product is choosen
108          * @throws javax.servlet.ServletException If something unexpected happened
109          */
110         public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
111
112         /**
113          * Some getter for printable value from session or an empty string for null.
114          *
115          * @param session Session instance
116          * @param key Key to get
117          * @return Value from key, empty string for null
118          */
119         public Object getPrintableValeFromSession (final HttpSession session, final String key);
120
121         /**
122          * Somewhat setter in session
123          *
124          * @param session Session instance
125          * @param key Session key to set
126          * @param value Value to set
127          */
128         public void setValueInSession (final HttpSession session, final String key, final Object value);
129
130         /**
131          * Some "getter" for a an array of only available products
132          * 
133          * @return Only available products
134          * @throws javax.servlet.ServletException If anything went wrong
135          */
136         public Iterator<Product> getAvailableProducts () throws ServletException;
137
138         /**
139          * Some "getter" for a an array of all products
140          *
141          * @return All products
142          * @throws javax.servlet.ServletException If anything went wrong
143          */
144         public Iterator<Product> getAllProducts () throws ServletException;
145
146         /**
147          * Some "getter" for a an array of all categories
148          *
149          * @return All categories
150          * @throws javax.servlet.ServletException If anything went wrong
151          */
152         public Iterator<Category> getAllCategories () throws ServletException;
153
154         /**
155          * Checks if given Product instance is available and returns a printable
156          * (human-readable) string.
157          * 
158          * @param product Product instance to check
159          * @return Human-readable version of product availability
160          */
161         public String getPrintableProduktAvailability (final Product product);
162
163         /**
164          * Returns a printable (human-readable) string of product's category
165          * 
166          * @param product Product instance to check
167          * @return Human-readable version of product availability
168          * @throws javax.servlet.ServletException If something unexpected happened
169          */
170         public String getPrintableProduktCategory (final Product product) throws ServletException;
171
172         /**
173          * Adds given category data from request to database
174          *
175          * @param request Request instance
176          * @throws javax.servlet.ServletException If something unexpected happened
177          * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
178          */
179         public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
180
181         /**
182          * Adds given product data from request to database
183          *
184          * @param request Request instance
185          * @throws javax.servlet.ServletException If something unexpected happened
186          * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
187          */
188         public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
189
190         /**
191          * Generates link HTML code for given category's parent id, if set. This
192          * link then points to products.jsp?category_id=x
193          *
194          * @param category Category instance
195          * @return HTML code
196          */
197         public String generateLinkForParent (final Category category);
198
199         /**
200          * Handles admin product form requests
201          *
202          * @param request Request instance
203          * @param response Response instance
204          * @throws ServletException If something unexpected happened
205          */
206         public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
207
208         /**
209          * Handles admin category form requests
210          * 
211          * @param request Request instance
212          * @param response Response instance
213          * @throws ServletException If something unexpected happened
214          */
215         public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
216
217         /**
218          * Getter for logger
219          *
220          * @return Logger
221          */
222         public Logger getLogger ();
223
224         /**
225          * @return the basket
226          */
227         public BasketBean getBasket ();
228
229         /**
230          * @param basket the basket to set
231          */
232         public void setBasket (final BasketBean basket);
233
234         /**
235          * @return the application
236          */
237         public ServletContext getApplication ();
238
239         /**
240          * @param application the application to set
241          */
242         public void setApplication (final ServletContext application);
243
244         /**
245          * Some "getter" for a product from given item
246          * @param item Item instance
247          * @return A Product instance
248          * @throws javax.servlet.ServletException If something bad happens
249          */
250         public Product getProduct (final AddableBasketItem item) throws ServletException;
251 }