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 * Some "getter" for total price of position from request or session.
64 * Single price and amount is multiplyed.
66 * @param product Product instance
67 * @param request Request instance
68 * @param session Session instance
69 * @return Amount as string
71 public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
74 * Initializes this instance
76 * @throws FacesException If something was wrong
78 public void init () throws FacesException;
81 * Checks whether the given product is choosen, request overules session.
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
90 public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
93 * Calculates total price of all choosen products
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
100 public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) throws ServletException;
103 * Calculates total amount of all choosen products
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
112 public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) throws ServletException;
115 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
117 * @param product Product instance
118 * @param request Request instance
119 * @param session Session instance
120 * @return Whether the product is choosen
122 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
125 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
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
132 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
135 * Some getter for printable value from session or an empty string for null.
137 * @param session Session instance
138 * @param key Key to get
139 * @return Value from key, empty string for null
141 public Object getPrintableValeFromSession (final HttpSession session, final String key);
144 * Somewhat setter in session
146 * @param session Session instance
147 * @param key Session key to set
148 * @param value Value to set
150 public void setValueInSession (final HttpSession session, final String key, final Object value);
153 * Some "getter" for a an array of only available products
155 * @return Only available products
156 * @throws javax.servlet.ServletException If anything went wrong
158 public Iterator<Product> getAvailableProducts () throws ServletException;
161 * Some "getter" for a an array of all products
163 * @return All products
164 * @throws javax.servlet.ServletException If anything went wrong
166 public Iterator<Product> getAllProducts () throws ServletException;
169 * Some "getter" for a an array of all categories
171 * @return All categories
172 * @throws javax.servlet.ServletException If anything went wrong
174 public Iterator<Category> getAllCategories () throws ServletException;
177 * Checks if given Product instance is available and returns a printable
178 * (human-readable) string.
180 * @param product Product instance to check
181 * @return Human-readable version of product availability
183 public String getPrintableProduktAvailability (final Product product);
186 * Returns a printable (human-readable) string of product's category
188 * @param product Product instance to check
189 * @return Human-readable version of product availability
190 * @throws javax.servlet.ServletException If something unexpected happened
192 public String getPrintableProduktCategory (final Product product) throws ServletException;
195 * Adds given category data from request to database
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
201 public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
204 * Adds given product data from request to database
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
210 public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
213 * Generates link HTML code for given category's parent id, if set. This
214 * link then points to products.jsp?category_id=x
216 * @param category Category instance
219 public String generateLinkForParent (final Category category);
222 * Handles admin product form requests
224 * @param request Request instance
225 * @param response Response instance
226 * @throws ServletException If something unexpected happened
228 public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
231 * Handles admin category form requests
233 * @param request Request instance
234 * @param response Response instance
235 * @throws ServletException If something unexpected happened
237 public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
244 public Logger getLogger ();
249 public BasketBean getBasket ();
252 * @param basket the basket to set
254 public void setBasket (final BasketBean basket);
257 * @return the application
259 public ServletContext getApplication ();
262 * @param application the application to set
264 public void setApplication (final ServletContext application);
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
272 public Product getProduct (final AddableBasketItem item) throws ServletException;