2 * Copyright (C) 2015 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.pizzaapplication.beans.controller;
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;
37 * @author Roland Haeder
39 public interface PizzaBean extends FrameworkBean {
41 * Some "getter" for amount from session
43 * @param product Product instance
44 * @param session Session instance
45 * @return Amount as string
46 * @deprecated Old code
49 public String getAmountFromSession (final Product product, final HttpSession session);
52 * Some "getter" for choose from session
54 * @param product Product instance
55 * @param session Session instance
56 * @return Choose as string
57 * @deprecated Old code
60 public String getChooseFromSession (final Product product, final HttpSession session);
63 * Handler for amount from session
65 * @param product Product instance
66 * @param request Request instance
67 * @param session Session instance
68 * @return Amount as string
69 * @deprecated Old code
72 public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
75 * Some "getter" for printable choosen (checkbox) from request or session
77 * @param product Product instance
78 * @param request Request instance
79 * @param session Session instance
80 * @return Amount as string
81 * @deprecated Old code
84 public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
87 * Some "getter" for total price of position from request or session.
88 * Single price and amount is multiplyed.
90 * @param product Product instance
91 * @param request Request instance
92 * @param session Session instance
93 * @return Amount as string
95 public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
98 * Initializes this instance
100 * @throws FacesException If something was wrong
102 public void init () throws FacesException;
105 * Checks whether the given product is choosen, request overules session.
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
114 public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
117 * Calculates total price of all choosen products
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
124 public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) throws ServletException;
127 * Calculates total amount of all choosen products
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
134 public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) throws ServletException;
137 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
139 * @param product Product instance
140 * @param request Request instance
141 * @param session Session instance
142 * @return Whether the product is choosen
144 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
147 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
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
154 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
157 * Marks given product as ordered in session
159 * @param product Product to mark as ordered
160 * @param session Session instance
161 * @deprecated Old code
164 public void markProductAsOrdered(final Product product, final HttpSession session);
167 * Marks given product as choosen in session
169 * @param product Product to mark as ordered
170 * @param session Session instance
171 * @deprecated Old code
174 public void markProductAsChoosen(final Product product, final HttpSession session);
177 * Unmarks given product as ordered in session
179 * @param product Product to unmark as ordered
180 * @param session Session instance
181 * @deprecated Old code
184 public void unmarkProductAsOrdered(final Product product, final HttpSession session);
187 * Unmarks given product as choosen in session
189 * @param product Product to unmark as choosen
190 * @param session Session instance
191 * @deprecated Old code
194 public void unmarkProductAsChoosen(final Product product, final HttpSession session);
197 * Some getter for printable value from session or an empty string for null.
199 * @param session Session instance
200 * @param key Key to get
201 * @return Value from key, empty string for null
203 public Object getPrintableValeFromSession (final HttpSession session, final String key);
206 * Somewhat setter in session
208 * @param session Session instance
209 * @param key Session key to set
210 * @param value Value to set
212 public void setValueInSession (final HttpSession session, final String key, final Object value);
215 * Some "getter" for a an array of only available products
217 * @return Only available products
218 * @throws javax.servlet.ServletException If anything went wrong
220 public Iterator<Product> getAvailableProducts () throws ServletException;
223 * Some "getter" for a an array of all products
225 * @return All products
226 * @throws javax.servlet.ServletException If anything went wrong
228 public Iterator<Product> getAllProducts () throws ServletException;
231 * Some "getter" for a an array of all categories
233 * @return All categories
234 * @throws javax.servlet.ServletException If anything went wrong
236 public Iterator<Category> getAllCategories () throws ServletException;
239 * Checks if given Product instance is available and returns a printable
240 * (human-readable) string.
242 * @param product Product instance to check
243 * @return Human-readable version of product availability
245 public String getPrintableProduktAvailability (final Product product);
248 * Returns a printable (human-readable) string of product's category
250 * @param product Product instance to check
251 * @return Human-readable version of product availability
252 * @throws javax.servlet.ServletException If something unexpected happened
254 public String getPrintableProduktCategory (final Product product) throws ServletException;
257 * Marks all choosen products as ordered
259 * @param request Request instance
260 * @param session Session instance
261 * @throws javax.servlet.ServletException If something unexpected happened
262 * @deprecated Old code
265 public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException;
268 * Adds given category data from request to database
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
274 public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
277 * Adds given product data from request to database
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
283 public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
286 * Generates link HTML code for given category's parent id, if set. This
287 * link then points to products.jsp?category_id=x
289 * @param category Category instance
292 public String generateLinkForParent (final Category category);
295 * Handles admin product form requests
297 * @param request Request instance
298 * @param response Response instance
299 * @throws ServletException If something unexpected happened
301 public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
304 * Handles admin category form requests
306 * @param request Request instance
307 * @param response Response instance
308 * @throws ServletException If something unexpected happened
310 public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
317 public Logger getLogger ();
322 public BasketBean getBasket ();
325 * @param basket the basket to set
327 public void setBasket (final BasketBean basket);
330 * @return the application
332 public ServletContext getApplication ();
335 * @param application the application to set
337 public void setApplication (final ServletContext application);
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
345 public Product getProduct (final AddableBasketItem item) throws ServletException;