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.Deque;
20 import java.util.Iterator;
21 import javax.faces.FacesException;
22 import javax.servlet.ServletException;
23 import javax.servlet.ServletRequest;
24 import javax.servlet.http.HttpSession;
25 import org.mxchange.jshop.beans.FrameworkBean;
26 import org.mxchange.jshop.category.Category;
27 import org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException;
28 import org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException;
29 import org.mxchange.jshop.item.AddableBasketItem;
30 import org.mxchange.jshop.product.Product;
34 * @author Roland Haeder
36 public interface PizzaBean extends FrameworkBean {
38 * Initializes this instance
40 * @throws FacesException If something was wrong
42 public void init () throws FacesException;
45 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
47 * @param product Product instance
48 * @param request Request instance
49 * @param session Session instance
50 * @return Whether the product is choosen
52 public String getCheckedHtmlFromProduct (final Product product, final ServletRequest request, final HttpSession session);
55 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
57 * @param request Request instance
58 * @param session Session instance
59 * @return Whether the product is choosen
60 * @throws javax.servlet.ServletException If something unexpected happened
62 public String getDisabledHtmlFromSession (final ServletRequest request, final HttpSession session) throws ServletException;
65 * Somewhat setter in session
67 * @param session Session instance
68 * @param key Session key to set
69 * @param value Value to set
71 public void setValueInSession (final HttpSession session, final String key, final Object value);
74 * Some "getter" for an iterator of only available products
76 * @return Only available products
77 * @throws javax.servlet.ServletException If anything went wrong
79 public Iterator<Product> getAvailableProductsIterator () throws ServletException;
82 * Some "getter" for an iterator of all products
84 * @return All products
85 * @throws javax.servlet.ServletException If anything went wrong
87 public Iterator<Product> getAllProductsIterator () throws ServletException;
90 * Some "getter" for an iterator of all categories
92 * @return All categories
93 * @throws javax.servlet.ServletException If anything went wrong
95 public Iterator<Category> getAllCategoriesIterator () throws ServletException;
98 * Some "getter" for a linked list of only available products
100 * @return Only available products
101 * @throws javax.servlet.ServletException If anything went wrong
103 public Deque<Product> getAvailableProducts () throws ServletException;
106 * Some "getter" for a linked list of all products
108 * @return All products
109 * @throws javax.servlet.ServletException If anything went wrong
111 public Deque<Product> getAllProducts () throws ServletException;
114 * Some "getter" for a linked list of all categories
116 * @return All categories
117 * @throws javax.servlet.ServletException If anything went wrong
119 public Deque<Category> getAllCategories () throws ServletException;
122 * Checks if given Product instance is available and returns a printable
123 * (human-readable) string.
125 * @param product Product instance to check
126 * @return Human-readable version of product availability
128 public String getPrintableProduktAvailability (final Product product);
131 * Returns a printable (human-readable) string of product's category
133 * @param product Product instance to check
134 * @return Human-readable version of product availability
135 * @throws javax.servlet.ServletException If something unexpected happened
137 public String getPrintableProduktCategory (final Product product) throws ServletException;
140 * Adds given category 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.CategoryTitleAlreadyUsedException If the given title is already used
146 public void doAdminAddCategory (final ServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
149 * Adds given product data from request to database
151 * @param request Request instance
152 * @throws javax.servlet.ServletException If something unexpected happened
153 * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
155 public void doAdminAddProduct (final ServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
158 * Generates link HTML code for given category's parent id, if set. This
159 * link then points to products.jsp?category_id=x
161 * @param category Category instance
164 public String generateLinkForParent (final Category category);
167 * Handles admin product form requests
169 * @throws ServletException If something unexpected happened
171 public void doAdminHandleProductForms () throws ServletException;
174 * Handles admin category form requests
176 * @throws ServletException If something unexpected happened
178 public void doAdminHandleCategoryForms () throws ServletException;
181 * Some "getter" for a product from given item
182 * @param item Item instance
183 * @return A Product instance
184 * @throws javax.servlet.ServletException If something bad happens
186 public Product getProduct (final AddableBasketItem item) throws ServletException;