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