]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaBean.java
Removed more deprecated and no longer used methods + kept one for functionality
[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          * Checks whether the given product is choosen, request overules session.
49          *
50          * @param product Product instance
51          * @param request Request instance
52          * @param session Session instance
53          * @return Whether the product is choosen
54          * @deprecated Old lost code
55          */
56         @Deprecated
57         public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
58
59         /**
60          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
61          *
62          * @param product Product instance
63          * @param request Request instance
64          * @param session Session instance
65          * @return Whether the product is choosen
66          */
67         public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
68
69         /**
70          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
71          *
72          * @param request Request instance
73          * @param session Session instance
74          * @return Whether the product is choosen
75          * @throws javax.servlet.ServletException If something unexpected happened
76          */
77         public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
78
79         /**
80          * Somewhat setter in session
81          *
82          * @param session Session instance
83          * @param key Session key to set
84          * @param value Value to set
85          */
86         public void setValueInSession (final HttpSession session, final String key, final Object value);
87
88         /**
89          * Some "getter" for a an array of only available products
90          * 
91          * @return Only available products
92          * @throws javax.servlet.ServletException If anything went wrong
93          */
94         public Iterator<Product> getAvailableProducts () throws ServletException;
95
96         /**
97          * Some "getter" for a an array of all products
98          *
99          * @return All products
100          * @throws javax.servlet.ServletException If anything went wrong
101          */
102         public Iterator<Product> getAllProducts () throws ServletException;
103
104         /**
105          * Some "getter" for a an array of all categories
106          *
107          * @return All categories
108          * @throws javax.servlet.ServletException If anything went wrong
109          */
110         public Iterator<Category> getAllCategories () throws ServletException;
111
112         /**
113          * Checks if given Product instance is available and returns a printable
114          * (human-readable) string.
115          * 
116          * @param product Product instance to check
117          * @return Human-readable version of product availability
118          */
119         public String getPrintableProduktAvailability (final Product product);
120
121         /**
122          * Returns a printable (human-readable) string of product's category
123          * 
124          * @param product Product instance to check
125          * @return Human-readable version of product availability
126          * @throws javax.servlet.ServletException If something unexpected happened
127          */
128         public String getPrintableProduktCategory (final Product product) throws ServletException;
129
130         /**
131          * Adds given category data from request to database
132          *
133          * @param request Request instance
134          * @throws javax.servlet.ServletException If something unexpected happened
135          * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
136          */
137         public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
138
139         /**
140          * Adds given product data from request to database
141          *
142          * @param request Request instance
143          * @throws javax.servlet.ServletException If something unexpected happened
144          * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
145          */
146         public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
147
148         /**
149          * Generates link HTML code for given category's parent id, if set. This
150          * link then points to products.jsp?category_id=x
151          *
152          * @param category Category instance
153          * @return HTML code
154          */
155         public String generateLinkForParent (final Category category);
156
157         /**
158          * Handles admin product form requests
159          *
160          * @param request Request instance
161          * @param response Response instance
162          * @throws ServletException If something unexpected happened
163          */
164         public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
165
166         /**
167          * Handles admin category form requests
168          * 
169          * @param request Request instance
170          * @param response Response instance
171          * @throws ServletException If something unexpected happened
172          */
173         public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
174
175         /**
176          * Getter for logger
177          *
178          * @return Logger
179          */
180         public Logger getLogger ();
181
182         /**
183          * @return the basket
184          */
185         public BasketBean getBasket ();
186
187         /**
188          * @param basket the basket to set
189          */
190         public void setBasket (final BasketBean basket);
191
192         /**
193          * @return the application
194          */
195         public ServletContext getApplication ();
196
197         /**
198          * @param application the application to set
199          */
200         public void setApplication (final ServletContext application);
201
202         /**
203          * Some "getter" for a product from given item
204          * @param item Item instance
205          * @return A Product instance
206          * @throws javax.servlet.ServletException If something bad happens
207          */
208         public Product getProduct (final AddableBasketItem item) throws ServletException;
209 }