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 * Initializes this instance
43 * @throws FacesException If something was wrong
45 public void init () throws FacesException;
48 * Checks whether the given product is choosen, request overules session.
50 * @param product Product instance
51 * @param request Request instance
52 * @param session Session instance
53 * @return Whether the product is choosen
54 * @deprecated Old lost code
57 public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
60 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
62 * @param product Product instance
63 * @param request Request instance
64 * @param session Session instance
65 * @return Whether the product is choosen
67 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
70 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
72 * @param request Request instance
73 * @param session Session instance
74 * @return Whether the product is choosen
75 * @throws javax.servlet.ServletException If something unexpected happened
77 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
80 * Somewhat setter in session
82 * @param session Session instance
83 * @param key Session key to set
84 * @param value Value to set
86 public void setValueInSession (final HttpSession session, final String key, final Object value);
89 * Some "getter" for a an array of only available products
91 * @return Only available products
92 * @throws javax.servlet.ServletException If anything went wrong
94 public Iterator<Product> getAvailableProducts () throws ServletException;
97 * Some "getter" for a an array of all products
99 * @return All products
100 * @throws javax.servlet.ServletException If anything went wrong
102 public Iterator<Product> getAllProducts () throws ServletException;
105 * Some "getter" for a an array of all categories
107 * @return All categories
108 * @throws javax.servlet.ServletException If anything went wrong
110 public Iterator<Category> getAllCategories () throws ServletException;
113 * Checks if given Product instance is available and returns a printable
114 * (human-readable) string.
116 * @param product Product instance to check
117 * @return Human-readable version of product availability
119 public String getPrintableProduktAvailability (final Product product);
122 * Returns a printable (human-readable) string of product's category
124 * @param product Product instance to check
125 * @return Human-readable version of product availability
126 * @throws javax.servlet.ServletException If something unexpected happened
128 public String getPrintableProduktCategory (final Product product) throws ServletException;
131 * Adds given category data from request to database
133 * @param request Request instance
134 * @throws javax.servlet.ServletException If something unexpected happened
135 * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
137 public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
140 * Adds given product data from request to database
142 * @param request Request instance
143 * @throws javax.servlet.ServletException If something unexpected happened
144 * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
146 public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
149 * Generates link HTML code for given category's parent id, if set. This
150 * link then points to products.jsp?category_id=x
152 * @param category Category instance
155 public String generateLinkForParent (final Category category);
158 * Handles admin product form requests
160 * @param request Request instance
161 * @param response Response instance
162 * @throws ServletException If something unexpected happened
164 public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
167 * Handles admin category form requests
169 * @param request Request instance
170 * @param response Response instance
171 * @throws ServletException If something unexpected happened
173 public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
180 public Logger getLogger ();
185 public BasketBean getBasket ();
188 * @param basket the basket to set
190 public void setBasket (final BasketBean basket);
193 * @return the application
195 public ServletContext getApplication ();
198 * @param application the application to set
200 public void setApplication (final ServletContext application);
203 * Some "getter" for a product from given item
204 * @param item Item instance
205 * @return A Product instance
206 * @throws javax.servlet.ServletException If something bad happens
208 public Product getProduct (final AddableBasketItem item) throws ServletException;