]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
Continued with project:
[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.util.Iterator;
20 import javax.servlet.ServletException;
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpSession;
23 import org.mxchange.jcore.application.Application;
24 import org.mxchange.pizzaapplication.category.Category;
25 import org.mxchange.pizzaapplication.product.Product;
26
27 /**
28  *
29  * @author Roland Haeder
30  */
31 public interface PizzaApplication extends Application {
32         /**
33          * HTTP parameter "amount"
34          */
35         public static final String HTTP_PARAM_AMOUNT = "amount"; //NOI18N
36
37         /**
38          * HTTP parameter "choose"
39          */
40         public static final String HTTP_PARAM_CHOOSE = "choose"; //NOI18N
41
42         /**
43          * Session key "ordered"
44          */
45         public static final String SESSION_ORDERED = "ordered"; //NOI18N
46
47         /**
48          * Mask for all parameters
49          */
50         public static final String HTTP_PARAM_MASK = "%s[%s]"; //NOI18N
51
52         /**
53          * Some "getter" for amount from session
54          *
55          * @param product Product instance
56          * @param session Session instance
57          * @return Amount as string
58          */
59         public String getAmountFromSession (final Product product, final HttpSession session);
60
61         /**
62          * Some "getter" for choose from session
63          *
64          * @param product Product instance
65          * @param session Session instance
66          * @return Choose as string
67          */
68         public String getChooseFromSession (final Product product, final HttpSession session);
69
70         /**
71          * Handler for amount from session
72          *
73          * @param product Product instance
74          * @param request Request instance
75          * @param session Session instance
76          * @return Amount as string
77          */
78         public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
79
80         /**
81          * Some "getter" for printable choosen (checkbox) from request or session
82          *
83          * @param product Product instance
84          * @param request Request instance
85          * @param session Session instance
86          * @return Amount as string
87          */
88         public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
89
90         /**
91          * Some "getter" for total price of position from request or session.
92          * Single price and amount is multiplyed.
93          *
94          * @param product Product instance
95          * @param request Request instance
96          * @param session Session instance
97          * @return Amount as string
98          */
99         public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
100
101         /**
102          * Checks whether the given product is choosen, request overules session.
103          *
104          * @param product Product instance
105          * @param request Request instance
106          * @param session Session instance
107          * @return Whether the product is choosen
108          */
109         public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
110
111         /**
112          * Calculates total price of all choosen products
113          *
114          * @param request Request instance
115          * @param session Session instance
116          * @return Total price of all choosen products
117          * @throws javax.servlet.ServletException If something unexpected happened
118          */
119         public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session) throws ServletException;
120
121         /**
122          * Calculates total amount of all choosen products
123          *
124          * @param request Request instance
125          * @param session Session instance
126          * @return Total amount of all choosen products
127          * @throws javax.servlet.ServletException If something unexpected happened
128          */
129         public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session) throws ServletException;
130
131         /**
132          * Some "getter" for HTML code 'checked="checked"' if the product is choosen
133          *
134          * @param product Product instance
135          * @param request Request instance
136          * @param session Session instance
137          * @return Whether the product is choosen
138          */
139         public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
140
141         /**
142          * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
143          *
144          * @param request Request instance
145          * @param session Session instance
146          * @return Whether the product is choosen
147          * @throws javax.servlet.ServletException If something unexpected happened
148          */
149         public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session) throws ServletException;
150
151         /**
152          * Marks given product as ordered in session
153          *
154          * @param product Product to mark as ordered
155          * @param session Session instance
156          */
157         public void markProductAsOrdered(final Product product, final HttpSession session);
158
159         /**
160          * Marks given product as choosen in session
161          *
162          * @param product Product to mark as ordered
163          * @param session Session instance
164          */
165         public void markProductAsChoosen(final Product product, final HttpSession session);
166
167         /**
168          * Unmarks given product as ordered in session
169          *
170          * @param product Product to unmark as ordered
171          * @param session Session instance
172          */
173         public void unmarkProductAsOrdered(final Product product, final HttpSession session);
174
175         /**
176          * Unmarks given product as choosen in session
177          *
178          * @param product Product to unmark as choosen
179          * @param session Session instance
180          */
181         public void unmarkProductAsChoosen(final Product product, final HttpSession session);
182
183         /**
184          * Some getter for printable value from session or an empty string for null.
185          *
186          * @param session Session instance
187          * @param key Key to get
188          * @return Value from key, empty string for null
189          */
190         public Object getPrintableValeFromSession (final HttpSession session, final String key);
191
192         /**
193          * Somewhat setter in session
194          *
195          * @param session Session instance
196          * @param key Session key to set
197          * @param value Value to set
198          */
199         public void setValueInSession (final HttpSession session, final String key, final Object value);
200
201         /**
202          * Some "getter" for a an array of all products
203          * 
204          * @return All products
205          * @throws javax.servlet.ServletException If anything went wrong
206          */
207         public Iterator<Product> getProducts () throws ServletException;
208
209         /**
210          * Some "getter" for a an array of all categories
211          *
212          * @return All categories
213          * @throws javax.servlet.ServletException If anything went wrong
214          */
215         public Iterator<Category> getCategories () throws ServletException;
216
217         /**
218          * Checks if given Product instance is available and returns a printable
219          * (human-readable) string.
220          * 
221          * @param product Product instance to check
222          * @return Human-readable version of product availability
223          */
224         public String getPrintableProduktAvailability (final Product product);
225
226         /**
227          * Marks all choosen products as ordered
228          *
229          * @param request Request instance
230          * @param session Session instance
231          * @throws javax.servlet.ServletException If something unexpected happened
232          */
233         public void markAllChoosenProductsAsOrdered (final HttpServletRequest request, final HttpSession session) throws ServletException;
234
235         /**
236          * Adds given category data from request to database
237          *
238          * @param request Request instance
239          */
240         public void doAdminAddCategory (final HttpServletRequest request);
241
242         /**
243          * Adds given product data from request to database
244          *
245          * @param request Request instance
246          */
247         public void doAdminAddProduct (final HttpServletRequest request);
248 }