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 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
95 * @param product Product instance
96 * @param request Request instance
97 * @param session Session instance
98 * @return Whether the product is choosen
100 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
103 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
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
110 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
113 * Some getter for printable value from session or an empty string for null.
115 * @param session Session instance
116 * @param key Key to get
117 * @return Value from key, empty string for null
119 public Object getPrintableValeFromSession (final HttpSession session, final String key);
122 * Somewhat setter in session
124 * @param session Session instance
125 * @param key Session key to set
126 * @param value Value to set
128 public void setValueInSession (final HttpSession session, final String key, final Object value);
131 * Some "getter" for a an array of only available products
133 * @return Only available products
134 * @throws javax.servlet.ServletException If anything went wrong
136 public Iterator<Product> getAvailableProducts () throws ServletException;
139 * Some "getter" for a an array of all products
141 * @return All products
142 * @throws javax.servlet.ServletException If anything went wrong
144 public Iterator<Product> getAllProducts () throws ServletException;
147 * Some "getter" for a an array of all categories
149 * @return All categories
150 * @throws javax.servlet.ServletException If anything went wrong
152 public Iterator<Category> getAllCategories () throws ServletException;
155 * Checks if given Product instance is available and returns a printable
156 * (human-readable) string.
158 * @param product Product instance to check
159 * @return Human-readable version of product availability
161 public String getPrintableProduktAvailability (final Product product);
164 * Returns a printable (human-readable) string of product's category
166 * @param product Product instance to check
167 * @return Human-readable version of product availability
168 * @throws javax.servlet.ServletException If something unexpected happened
170 public String getPrintableProduktCategory (final Product product) throws ServletException;
173 * Adds given category data from request to database
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
179 public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
182 * Adds given product data from request to database
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
188 public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
191 * Generates link HTML code for given category's parent id, if set. This
192 * link then points to products.jsp?category_id=x
194 * @param category Category instance
197 public String generateLinkForParent (final Category category);
200 * Handles admin product form requests
202 * @param request Request instance
203 * @param response Response instance
204 * @throws ServletException If something unexpected happened
206 public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
209 * Handles admin category form requests
211 * @param request Request instance
212 * @param response Response instance
213 * @throws ServletException If something unexpected happened
215 public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
222 public Logger getLogger ();
227 public BasketBean getBasket ();
230 * @param basket the basket to set
232 public void setBasket (final BasketBean basket);
235 * @return the application
237 public ServletContext getApplication ();
240 * @param application the application to set
242 public void setApplication (final ServletContext application);
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
250 public Product getProduct (final AddableBasketItem item) throws ServletException;