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.ServletException;
22 import javax.servlet.ServletRequest;
23 import javax.servlet.http.HttpSession;
24 import org.mxchange.jshop.beans.FrameworkBean;
25 import org.mxchange.jshop.category.Category;
26 import org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException;
27 import org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException;
28 import org.mxchange.jshop.item.AddableBasketItem;
29 import org.mxchange.jshop.product.Product;
33 * @author Roland Haeder
35 public interface PizzaBean extends FrameworkBean {
37 * Initializes this instance
39 * @throws FacesException If something was wrong
41 public void init () throws FacesException;
44 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
46 * @param product Product instance
47 * @param request Request instance
48 * @param session Session instance
49 * @return Whether the product is choosen
51 public String getCheckedHtmlFromProduct (final Product product, final ServletRequest request, final HttpSession session);
54 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
56 * @param request Request instance
57 * @param session Session instance
58 * @return Whether the product is choosen
59 * @throws javax.servlet.ServletException If something unexpected happened
61 public String getDisabledHtmlFromSession (final ServletRequest request, final HttpSession session) throws ServletException;
64 * Somewhat setter in session
66 * @param session Session instance
67 * @param key Session key to set
68 * @param value Value to set
70 public void setValueInSession (final HttpSession session, final String key, final Object value);
73 * Some "getter" for a an array of only available products
75 * @return Only available products
76 * @throws javax.servlet.ServletException If anything went wrong
78 public Iterator<Product> getAvailableProducts () throws ServletException;
81 * Some "getter" for a an array of all products
83 * @return All products
84 * @throws javax.servlet.ServletException If anything went wrong
86 public Iterator<Product> getAllProducts () throws ServletException;
89 * Some "getter" for a an array of all categories
91 * @return All categories
92 * @throws javax.servlet.ServletException If anything went wrong
94 public Iterator<Category> getAllCategories () throws ServletException;
97 * Checks if given Product instance is available and returns a printable
98 * (human-readable) string.
100 * @param product Product instance to check
101 * @return Human-readable version of product availability
103 public String getPrintableProduktAvailability (final Product product);
106 * Returns a printable (human-readable) string of product's category
108 * @param product Product instance to check
109 * @return Human-readable version of product availability
110 * @throws javax.servlet.ServletException If something unexpected happened
112 public String getPrintableProduktCategory (final Product product) throws ServletException;
115 * Adds given category data from request to database
117 * @param request Request instance
118 * @throws javax.servlet.ServletException If something unexpected happened
119 * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
121 public void doAdminAddCategory (final ServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
124 * Adds given product data from request to database
126 * @param request Request instance
127 * @throws javax.servlet.ServletException If something unexpected happened
128 * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
130 public void doAdminAddProduct (final ServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
133 * Generates link HTML code for given category's parent id, if set. This
134 * link then points to products.jsp?category_id=x
136 * @param category Category instance
139 public String generateLinkForParent (final Category category);
142 * Handles admin product form requests
144 * @throws ServletException If something unexpected happened
146 public void doAdminHandleProductForms () throws ServletException;
149 * Handles admin category form requests
151 * @throws ServletException If something unexpected happened
153 public void doAdminHandleCategoryForms () throws ServletException;
156 * Some "getter" for a product from given item
157 * @param item Item instance
158 * @return A Product instance
159 * @throws javax.servlet.ServletException If something bad happens
161 public Product getProduct (final AddableBasketItem item) throws ServletException;