]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaBean.java
Removed more deprecated stuff + marked more as deprecated
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / controller / PizzaBean.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.pizzaapplication.beans.controller;
18
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;
34
35 /**
36  *
37  * @author Roland Haeder
38  */
39 public interface PizzaBean extends FrameworkBean {
40         /**
41          * Initializes this instance
42          * 
43          * @throws FacesException If something was wrong
44          */
45         public void init () throws FacesException;
46
47         /**
48          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
49          *
50          * @param product Product instance
51          * @param request Request instance
52          * @param session Session instance
53          * @return Whether the product is choosen
54          */
55         public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
56
57         /**
58          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
59          *
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
64          */
65         public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
66
67         /**
68          * Somewhat setter in session
69          *
70          * @param session Session instance
71          * @param key Session key to set
72          * @param value Value to set
73          */
74         public void setValueInSession (final HttpSession session, final String key, final Object value);
75
76         /**
77          * Some "getter" for a an array of only available products
78          * 
79          * @return Only available products
80          * @throws javax.servlet.ServletException If anything went wrong
81          */
82         public Iterator<Product> getAvailableProducts () throws ServletException;
83
84         /**
85          * Some "getter" for a an array of all products
86          *
87          * @return All products
88          * @throws javax.servlet.ServletException If anything went wrong
89          */
90         public Iterator<Product> getAllProducts () throws ServletException;
91
92         /**
93          * Some "getter" for a an array of all categories
94          *
95          * @return All categories
96          * @throws javax.servlet.ServletException If anything went wrong
97          */
98         public Iterator<Category> getAllCategories () throws ServletException;
99
100         /**
101          * Checks if given Product instance is available and returns a printable
102          * (human-readable) string.
103          * 
104          * @param product Product instance to check
105          * @return Human-readable version of product availability
106          */
107         public String getPrintableProduktAvailability (final Product product);
108
109         /**
110          * Returns a printable (human-readable) string of product's category
111          * 
112          * @param product Product instance to check
113          * @return Human-readable version of product availability
114          * @throws javax.servlet.ServletException If something unexpected happened
115          */
116         public String getPrintableProduktCategory (final Product product) throws ServletException;
117
118         /**
119          * Adds given category data from request to database
120          *
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
124          */
125         public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
126
127         /**
128          * Adds given product data from request to database
129          *
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
133          */
134         public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
135
136         /**
137          * Generates link HTML code for given category's parent id, if set. This
138          * link then points to products.jsp?category_id=x
139          *
140          * @param category Category instance
141          * @return HTML code
142          */
143         public String generateLinkForParent (final Category category);
144
145         /**
146          * Handles admin product form requests
147          *
148          * @param request Request instance
149          * @param response Response instance
150          * @throws ServletException If something unexpected happened
151          */
152         public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
153
154         /**
155          * Handles admin category form requests
156          * 
157          * @param request Request instance
158          * @param response Response instance
159          * @throws ServletException If something unexpected happened
160          */
161         public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
162
163         /**
164          * Getter for logger
165          *
166          * @return Logger
167          */
168         public Logger getLogger ();
169
170         /**
171          * @return the basket
172          */
173         public BasketBean getBasket ();
174
175         /**
176          * @param basket the basket to set
177          */
178         public void setBasket (final BasketBean basket);
179
180         /**
181          * @return the application
182          */
183         public ServletContext getApplication ();
184
185         /**
186          * @param application the application to set
187          */
188         public void setApplication (final ServletContext application);
189
190         /**
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
195          */
196         public Product getProduct (final AddableBasketItem item) throws ServletException;
197 }