2 * Copyright (C) 2015 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.pizzaapplication.application;
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;
26 * @author Roland Haeder
28 public interface PizzaApplication extends Application {
30 * HTTP parameter "amount"
32 public static final String HTTP_PARAM_AMOUNT = "amount"; //NOI18N
35 * HTTP parameter "choose"
37 public static final String HTTP_PARAM_CHOOSE = "choose"; //NOI18N
40 * Session key "ordered"
42 public static final String SESSION_ORDERED = "ordered"; //NOI18N
45 * Mask for all parameters
47 public static final String HTTP_PARAM_MASK = "%s[%s]"; //NOI18N
50 * Some "getter" for amount from session
52 * @param product Product instance
53 * @param session Session instance
54 * @return Amount as string
56 public String getAmountFromSession (final Product product, final HttpSession session);
59 * Some "getter" for choose from session
61 * @param product Product instance
62 * @param session Session instance
63 * @return Choose as string
65 public String getChooseFromSession (final Product product, final HttpSession session);
68 * Handler for amount from session
70 * @param product Product instance
71 * @param request Request instance
72 * @param session Session instance
73 * @return Amount as string
75 public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
78 * Handler for choosen (checkbox) from request or session
80 * @param product Product instance
81 * @param request Request instance
82 * @param session Session instance
83 * @return Amount as string
85 public String handleChooseFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
88 * Some "getter" for printable choosen (checkbox) from request or session
90 * @param product Product instance
91 * @param request Request instance
92 * @param session Session instance
93 * @return Amount as string
95 public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
98 * Some "getter" for total price of position from request or session.
99 * Single price and amount is multiplyed.
101 * @param product Product instance
102 * @param request Request instance
103 * @param session Session instance
104 * @return Amount as string
106 public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
109 * Checks whether the given product is choosen, request overules session.
111 * @param product Product instance
112 * @param request Request instance
113 * @param session Session instance
114 * @return Whether the product is choosen
116 public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
119 * Calculates total price of all choosen products
121 * @param request Request instance
122 * @param session Session instance
123 * @return Total price of all choosen products
125 public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session);
128 * Calculates total amount of all choosen products
130 * @param request Request instance
131 * @param session Session instance
132 * @return Total amount of all choosen products
134 public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session);
137 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
139 * @param product Product instance
140 * @param request Request instance
141 * @param session Session instance
142 * @return Whether the product is choosen
144 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
147 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
149 * @param request Request instance
150 * @param session Session instance
151 * @return Whether the product is choosen
153 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session);
156 * Marks given product as ordered in session
158 * @param product Product to mark as ordered
159 * @param session Session instance
161 public void markProductAsOrdered(final Product product, final HttpSession session);
164 * Marks given product as choosen in session
166 * @param product Product to mark as ordered
167 * @param session Session instance
169 public void markProductAsChoosen(final Product product, final HttpSession session);
172 * Unmarks given product as ordered in session
174 * @param product Product to unmark as ordered
175 * @param session Session instance
177 public void unmarkProductAsOrdered(final Product product, final HttpSession session);
180 * Some getter for printable value from session or an empty string for null.
182 * @param session Session instance
183 * @param key Key to get
184 * @return Value from key, empty string for null
186 public Object getPrintableValeFromSession (final HttpSession session, final String key);
189 * Somewhat setter in session
191 * @param session Session instance
192 * @param key Session key to set
193 * @param value Value to set
195 public void setValueInSession (final HttpSession session, final String key, final Object value);
198 * Some "getter" for a an array of unmarked products
200 * @param session HttpSession instance
201 * @return Unmarked products
203 public Product[] getUnmarkedProducts (final HttpSession session);
206 * Some "getter" for a an array of all products
208 * @return Unmarked products
210 public Product[] getProducts ();