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 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
50 * @param product Product instance
51 * @param request Request instance
52 * @param session Session instance
53 * @return Whether the product is choosen
55 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
58 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
60 * @param request Request instance
61 * @param session Session instance
62 * @return Whether the product is choosen
63 * @throws javax.servlet.ServletException If something unexpected happened
65 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
68 * Somewhat setter in session
70 * @param session Session instance
71 * @param key Session key to set
72 * @param value Value to set
74 public void setValueInSession (final HttpSession session, final String key, final Object value);
77 * Some "getter" for a an array of only available products
79 * @return Only available products
80 * @throws javax.servlet.ServletException If anything went wrong
82 public Iterator<Product> getAvailableProducts () throws ServletException;
85 * Some "getter" for a an array of all products
87 * @return All products
88 * @throws javax.servlet.ServletException If anything went wrong
90 public Iterator<Product> getAllProducts () throws ServletException;
93 * Some "getter" for a an array of all categories
95 * @return All categories
96 * @throws javax.servlet.ServletException If anything went wrong
98 public Iterator<Category> getAllCategories () throws ServletException;
101 * Checks if given Product instance is available and returns a printable
102 * (human-readable) string.
104 * @param product Product instance to check
105 * @return Human-readable version of product availability
107 public String getPrintableProduktAvailability (final Product product);
110 * Returns a printable (human-readable) string of product's category
112 * @param product Product instance to check
113 * @return Human-readable version of product availability
114 * @throws javax.servlet.ServletException If something unexpected happened
116 public String getPrintableProduktCategory (final Product product) throws ServletException;
119 * Adds given category data from request to database
121 * @param request Request instance
122 * @throws javax.servlet.ServletException If something unexpected happened
123 * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
125 public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
128 * Adds given product data from request to database
130 * @param request Request instance
131 * @throws javax.servlet.ServletException If something unexpected happened
132 * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
134 public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
137 * Generates link HTML code for given category's parent id, if set. This
138 * link then points to products.jsp?category_id=x
140 * @param category Category instance
143 public String generateLinkForParent (final Category category);
146 * Handles admin product form requests
148 * @param request Request instance
149 * @param response Response instance
150 * @throws ServletException If something unexpected happened
152 public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
155 * Handles admin category form requests
157 * @param request Request instance
158 * @param response Response instance
159 * @throws ServletException If something unexpected happened
161 public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
168 public Logger getLogger ();
173 public BasketBean getBasket ();
176 * @param basket the basket to set
178 public void setBasket (final BasketBean basket);
181 * @return the application
183 public ServletContext getApplication ();
186 * @param application the application to set
188 public void setApplication (final ServletContext application);
191 * Some "getter" for a product from given item
192 * @param item Item instance
193 * @return A Product instance
194 * @throws javax.servlet.ServletException If something bad happens
196 public Product getProduct (final AddableBasketItem item) throws ServletException;