]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
Removed more deprecated and no longer used methods + kept one for functionality
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / application / PizzaApplication.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.application;
18
19 import java.io.IOException;
20 import java.sql.SQLException;
21 import java.util.Iterator;
22 import javax.servlet.ServletContext;
23 import javax.servlet.ServletException;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26 import javax.servlet.http.HttpSession;
27 import org.mxchange.jcore.application.Application;
28 import org.mxchange.jcore.exceptions.BadTokenException;
29 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
30 import org.mxchange.jshop.category.Category;
31 import org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException;
32 import org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException;
33 import org.mxchange.jshop.item.AddableBasketItem;
34 import org.mxchange.jshop.product.Product;
35
36 /**
37  *
38  * @author Roland Haeder
39  */
40 public interface PizzaApplication extends Application {
41         /**
42          * HTTP parameter "amount"
43          */
44         public static final String HTTP_PARAM_AMOUNT = "amount"; //NOI18N
45
46         /**
47          * HTTP parameter "item_id"
48          */
49         public static final String HTTP_PARAM_ITEM_ID = "itemId"; //NOI18N
50
51         /**
52          * HTTP parameter "type"
53          */
54         public static final String HTTP_PARAM_ITEM_TYPE = "itemType"; //NOI18N
55
56         /**
57          * Session key "ordered"
58          */
59         public static final String SESSION_ORDERED = "ordered"; //NOI18N
60
61         /**
62          * Mask for all parameters
63          * @deprecated Please refacture!
64          */
65         @Deprecated
66         static final String HTTP_PARAM_MASK = "%s[%s]"; //NOI18N
67
68         /**
69          * Initializes this instance with given ServletContext
70          *
71          * @param context Servlet context
72          * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the backend is unsupported
73          * @throws java.sql.SQLException If an SQL error occurs
74          * @throws java.io.IOException If an IO error occurs
75          * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
76          */
77         public void init (final ServletContext context) throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException;
78
79         /**
80          * Checks whether the given product is choosen, request overules session.
81          *
82          * @param product Product instance
83          * @param request Request instance
84          * @param session Session instance
85          * @return Whether the product is choosen
86          * @deprecated Old lost code
87          */
88         @Deprecated
89         public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
90
91         /**
92          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
93          *
94          * @param product Product instance
95          * @param request Request instance
96          * @param session Session instance
97          * @return Whether the product is choosen
98          */
99         public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
100
101         /**
102          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
103          *
104          * @param request Request instance
105          * @param session Session instance
106          * @return Whether the product is choosen
107          * @throws javax.servlet.ServletException If something unexpected happened
108          */
109         public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
110
111         /**
112          * Somewhat setter in session
113          *
114          * @param session Session instance
115          * @param key Session key to set
116          * @param value Value to set
117          */
118         public void setValueInSession (final HttpSession session, final String key, final Object value);
119
120         /**
121          * Some "getter" for a an array of only available products
122          * 
123          * @return Only available products
124          * @throws javax.servlet.ServletException If anything went wrong
125          */
126         public Iterator<Product> getAvailableProducts () throws ServletException;
127
128         /**
129          * Some "getter" for a an array of all products
130          *
131          * @return All products
132          * @throws javax.servlet.ServletException If anything went wrong
133          */
134         public Iterator<Product> getAllProducts () throws ServletException;
135
136         /**
137          * Some "getter" for a an array of all categories
138          *
139          * @return All categories
140          * @throws javax.servlet.ServletException If anything went wrong
141          */
142         public Iterator<Category> getAllCategories () throws ServletException;
143
144         /**
145          * Checks if given Product instance is available and returns a printable
146          * (human-readable) string.
147          * 
148          * @param product Product instance to check
149          * @return Human-readable version of product availability
150          */
151         public String getPrintableProduktAvailability (final Product product);
152
153         /**
154          * Returns a printable (human-readable) string of product's category
155          * 
156          * @param product Product instance to check
157          * @return Human-readable version of product availability
158          * @throws javax.servlet.ServletException If something unexpected happened
159          */
160         public String getPrintableProduktCategory (final Product product) throws ServletException;
161
162         /**
163          * Adds given category data from request to database
164          *
165          * @param request Request instance
166          * @throws javax.servlet.ServletException If something unexpected happened
167          * @throws org.mxchange.jshop.exceptions.CategoryTitleAlreadyUsedException If the given title is already used
168          */
169         public void doAdminAddCategory (final HttpServletRequest request) throws ServletException, CategoryTitleAlreadyUsedException;
170
171         /**
172          * Adds given product data from request to database
173          *
174          * @param request Request instance
175          * @throws javax.servlet.ServletException If something unexpected happened
176          * @throws org.mxchange.jshop.exceptions.ProductTitleAlreadyUsedException If the given product title is already used
177          */
178         public void doAdminAddProduct (final HttpServletRequest request) throws ServletException, ProductTitleAlreadyUsedException;
179
180         /**
181          * Generates link HTML code for given category's parent id, if set. This
182          * link then points to products.jsp?category_id=x
183          *
184          * @param category Category instance
185          * @return HTML code
186          */
187         public String generateLinkForParent (final Category category);
188
189         /**
190          * Handles admin product form requests
191          *
192          * @param request Request instance
193          * @param response Response instance
194          * @throws ServletException If something unexpected happened
195          */
196         public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
197
198         /**
199          * Handles admin category form requests
200          * 
201          * @param request Request instance
202          * @param response Response instance
203          * @throws ServletException If something unexpected happened
204          */
205         public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException;
206
207         /**
208          * Some "getter" for a Product instance from given item
209          * @param item Item instance
210          * @return A Product instance
211          * @throws ServletException If something unexpected happened
212          */
213         public Product getProduct (final AddableBasketItem item) throws ServletException;
214 }