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 * Somewhat setter in session
47 * @param session Session instance
48 * @param key Session key to set
49 * @param value Value to set
51 public void setValueInSession (final HttpSession session, final String key, final Object value);
54 * Some "getter" for an iterator of only available products
56 * @return Only available products
57 * @throws javax.servlet.ServletException If anything went wrong
59 public Iterator<Product> getAvailableProductsIterator () throws ServletException;
62 * Some "getter" for an iterator of all products
64 * @return All products
65 * @throws javax.servlet.ServletException If anything went wrong
67 public Iterator<Product> getAllProductsIterator () throws ServletException;
70 * Some "getter" for an iterator of all categories
72 * @return All categories
73 * @throws javax.servlet.ServletException If anything went wrong
75 public Iterator<Category> getAllCategoriesIterator () throws ServletException;
78 * Some "getter" for a linked list of only available products
80 * @return Only available products
81 * @throws javax.servlet.ServletException If anything went wrong
83 public Deque<Product> getAvailableProducts () throws ServletException;
86 * Some "getter" for a linked list of all products
88 * @return All products
89 * @throws javax.servlet.ServletException If anything went wrong
91 public Deque<Product> getAllProducts () throws ServletException;
94 * Some "getter" for a linked list of all categories
96 * @return All categories
97 * @throws javax.servlet.ServletException If anything went wrong
99 public Deque<Category> getAllCategories () throws ServletException;
102 * Checks if given Product instance is available and returns a printable
103 * (human-readable) string.
105 * @param product Product instance to check
106 * @return Human-readable version of product availability
108 public String getPrintableProduktAvailability (final Product product);
111 * Returns a printable (human-readable) string of product's category
113 * @param product Product instance to check
114 * @return Human-readable version of product availability
115 * @throws javax.servlet.ServletException If something unexpected happened
117 public String getPrintableProduktCategory (final Product product) throws ServletException;
120 * Adds given category data from request to database
122 * @param request Request instance
123 * @throws javax.servlet.ServletException If something unexpected happened
124 * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
126 public void doAdminAddCategory (final ServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
129 * Adds given product data from request to database
131 * @param request Request instance
132 * @throws javax.servlet.ServletException If something unexpected happened
133 * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
135 public void doAdminAddProduct (final ServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
138 * Generates link HTML code for given category's parent id, if set. This
139 * link then points to products.jsp?category_id=x
141 * @param category Category instance
144 public String generateLinkForParent (final Category category);
147 * Handles admin product form requests
149 * @throws ServletException If something unexpected happened
151 public void doAdminHandleProductForms () throws ServletException;
154 * Handles admin category form requests
156 * @throws ServletException If something unexpected happened
158 public void doAdminHandleCategoryForms () throws ServletException;
161 * Some "getter" for a product from given item
162 * @param item Item instance
163 * @return A Product instance
164 * @throws javax.servlet.ServletException If something bad happens
166 public Product getProduct (final AddableBasketItem item) throws ServletException;