]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/controller/PizzaBean.java
Continued with project:
[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.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;
30
31 /**
32  *
33  * @author Roland Haeder
34  */
35 public interface PizzaBean extends FrameworkBean {
36         /**
37          * Initializes this instance
38          * 
39          * @throws FacesException If something was wrong
40          */
41         public void init () throws FacesException;
42
43         /**
44          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
45          *
46          * @param product Product instance
47          * @param request Request instance
48          * @param session Session instance
49          * @return Whether the product is choosen
50          */
51         public String getCheckedHtmlFromProduct (final Product product, final ServletRequest request, final HttpSession session);
52
53         /**
54          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
55          *
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
60          */
61         public String getDisabledHtmlFromSession (final ServletRequest request, final HttpSession session) throws ServletException;
62
63         /**
64          * Somewhat setter in session
65          *
66          * @param session Session instance
67          * @param key Session key to set
68          * @param value Value to set
69          */
70         public void setValueInSession (final HttpSession session, final String key, final Object value);
71
72         /**
73          * Some "getter" for a an array of only available products
74          * 
75          * @return Only available products
76          * @throws javax.servlet.ServletException If anything went wrong
77          */
78         public Iterator<Product> getAvailableProducts () throws ServletException;
79
80         /**
81          * Some "getter" for a an array of all products
82          *
83          * @return All products
84          * @throws javax.servlet.ServletException If anything went wrong
85          */
86         public Iterator<Product> getAllProducts () throws ServletException;
87
88         /**
89          * Some "getter" for a an array of all categories
90          *
91          * @return All categories
92          * @throws javax.servlet.ServletException If anything went wrong
93          */
94         public Iterator<Category> getAllCategories () throws ServletException;
95
96         /**
97          * Checks if given Product instance is available and returns a printable
98          * (human-readable) string.
99          * 
100          * @param product Product instance to check
101          * @return Human-readable version of product availability
102          */
103         public String getPrintableProduktAvailability (final Product product);
104
105         /**
106          * Returns a printable (human-readable) string of product's category
107          * 
108          * @param product Product instance to check
109          * @return Human-readable version of product availability
110          * @throws javax.servlet.ServletException If something unexpected happened
111          */
112         public String getPrintableProduktCategory (final Product product) throws ServletException;
113
114         /**
115          * Adds given category data from request to database
116          *
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
120          */
121         public void doAdminAddCategory (final ServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
122
123         /**
124          * Adds given product data from request to database
125          *
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
129          */
130         public void doAdminAddProduct (final ServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
131
132         /**
133          * Generates link HTML code for given category's parent id, if set. This
134          * link then points to products.jsp?category_id=x
135          *
136          * @param category Category instance
137          * @return HTML code
138          */
139         public String generateLinkForParent (final Category category);
140
141         /**
142          * Handles admin product form requests
143          *
144          * @throws ServletException If something unexpected happened
145          */
146         public void doAdminHandleProductForms () throws ServletException;
147
148         /**
149          * Handles admin category form requests
150          * 
151          * @throws ServletException If something unexpected happened
152          */
153         public void doAdminHandleCategoryForms () throws ServletException;
154
155         /**
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
160          */
161         public Product getProduct (final AddableBasketItem item) throws ServletException;
162 }