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